Selaa lähdekoodia

出库信息下发添加联动

ydf 1 vuosi sitten
vanhempi
commit
d7156b5fbd

+ 19 - 0
src/api/inAndOut/formationFilling/out.ts

@@ -114,3 +114,22 @@ export function lookOutDataNew(id: string) {
114 114
     method: "get"
115 115
   });
116 116
 }
117
+
118
+//获取仓库下的物资信息
119
+export function materialsTree(data: any) {
120
+  return request({
121
+    url: `/admin/in/materials-tree`,
122
+    method: "get",
123
+    params: data
124
+  });
125
+}
126
+
127
+// 获取入库日期与单价
128
+export function getTimeAndUnitPriceForOutbound(data: any) {
129
+  return request({
130
+    url: "/admin/maintenance/getTimeAndUnitPriceForOutbound",
131
+    method: "post",
132
+    data
133
+  });
134
+}
135
+

+ 135 - 25
src/views/InformationFilling/outIssue/detail.vue

@@ -65,6 +65,7 @@
65 65
                 size="small"
66 66
                 @change="(val:any) => getDeptName(val, scope.$index)"
67 67
                 :disabled="props.type == 'look'"
68
+                filterable
68 69
                 clearable
69 70
               >
70 71
                 <el-option
@@ -95,7 +96,7 @@
95 96
         <el-table-column prop="materialTree" label="物资名称" align="center" width="360">
96 97
           <template #default="scope">
97 98
             <el-form-item :prop="'tableData.' + scope.$index + '.materialTree'" :rules="rules.materialTree">
98
-              <el-cascader
99
+              <!-- <el-cascader
99 100
                 :disabled="props.type == 'look'"
100 101
                 clearable
101 102
                 filterable
@@ -105,7 +106,19 @@
105 106
                 :options="wzOptions"
106 107
                 :props="{ value: 'id', label: 'name' }"
107 108
                 style="width: 100%"
108
-                @change="handleChange"
109
+                @change="(val:any) => handleChange(val, scope.$index)"
110
+              ></el-cascader> -->
111
+              <el-cascader
112
+                :disabled="props.type == 'look'"
113
+                clearable
114
+                filterable
115
+                size="small"
116
+                v-model="scope.row.materialTree"
117
+                placeholder="请选择物资"
118
+                :options="scope.row.wzOptions"
119
+                :props="{ value: 'id', label: 'name' }"
120
+                style="width: 100%"
121
+                @change="(val:any) => handleChange(val, scope.$index)"
109 122
               ></el-cascader>
110 123
             </el-form-item>
111 124
           </template>
@@ -170,7 +183,21 @@
170 183
         <el-table-column prop="inboundTime" label="入库日期" align="center" width="140">
171 184
           <template #default="scope">
172 185
             <el-form-item :prop="'tableData.' + scope.$index + '.inboundTime'" :rules="rules.inboundTime">
173
-              <el-date-picker
186
+              <el-select
187
+                v-model="scope.row.inboundTime"
188
+                :disabled="props.type == 'look'"
189
+                size="small"
190
+                style="width: 100%"
191
+                clearable
192
+              >
193
+                <el-option
194
+                  v-for="(item, index) in scope.row.rkrqAndDjOption"
195
+                  :key="index"
196
+                  :label="item.inboundTime"
197
+                  :value="item.inboundTime"
198
+                />
199
+              </el-select>
200
+              <!-- <el-date-picker
174 201
                 :disabled="props.type == 'look'"
175 202
                 clearable
176 203
                 size="small"
@@ -181,19 +208,33 @@
181 208
                 format="YYYY-MM-DD"
182 209
                 value-format="YYYY-MM-DD"
183 210
               >
184
-              </el-date-picker>
211
+              </el-date-picker> -->
185 212
             </el-form-item>
186 213
           </template>
187 214
         </el-table-column>
188 215
         <el-table-column prop="unitPrice" label="单价(元)" align="center" width="114">
189 216
           <template #default="scope">
190 217
             <el-form-item :prop="'tableData.' + scope.$index + '.unitPrice'" :rules="rules.unitPrice">
191
-              <el-input
218
+              <el-select
219
+                v-model="scope.row.unitPrice"
220
+                :disabled="props.type == 'look'"
221
+                size="small"
222
+                style="width: 100%"
223
+                clearable
224
+              >
225
+                <el-option
226
+                  v-for="(item, index) in scope.row.rkrqAndDjOption"
227
+                  :key="index"
228
+                  :label="item.unitPrice"
229
+                  :value="item.unitPrice"
230
+                />
231
+              </el-select>
232
+              <!-- <el-input
192 233
                 v-model="scope.row.unitPrice"
193 234
                 size="small"
194 235
                 placeholder="请输入"
195 236
                 :disabled="props.type == 'look'"
196
-              ></el-input>
237
+              ></el-input> -->
197 238
             </el-form-item>
198 239
           </template>
199 240
         </el-table-column>
@@ -212,13 +253,27 @@
212 253
             <el-form-item :prop="'tableData.' + scope.$index + '.isAvailable'" :rules="rules.isAvailable">
213 254
               <el-select
214 255
                 v-model="scope.row.isAvailable"
256
+                :disabled="props.type == 'look'"
257
+                size="small"
258
+                style="width: 100%"
259
+                clearable
260
+              >
261
+                <el-option
262
+                  v-for="(item, index) in scope.row.rkrqAndDjOption"
263
+                  :key="index"
264
+                  :label="isAvailableLabel[Number(item.isAvailable)]"
265
+                  :value="item.isAvailable"
266
+                />
267
+              </el-select>
268
+              <!-- <el-select
269
+                v-model="scope.row.isAvailable"
215 270
                 style="width: 90px"
216 271
                 size="small"
217 272
                 :disabled="props.type == 'look'"
218 273
                 clearable
219 274
               >
220 275
                 <el-option v-for="item in is_available" :key="item.value" :label="item.label" :value="item.value" />
221
-              </el-select>
276
+              </el-select> -->
222 277
             </el-form-item>
223 278
           </template>
224 279
         </el-table-column>
@@ -290,6 +345,8 @@ import {
290 345
   updateOutData,
291 346
   lookOutDataNew,
292 347
   dictTree,
348
+  materialsTree,
349
+  getTimeAndUnitPriceForOutbound,
293 350
   getDeptTypeList
294 351
 } from "@/api/inAndOut/formationFilling/out";
295 352
 import { sysFile } from "@/api/inAndOut/formationFilling/in";
@@ -300,7 +357,7 @@ import store from "@/store";
300 357
 import { useGetters } from "@/hooks/storeHooks";
301 358
 const { access_token } = useGetters(["access_token"]);
302 359
 import { decimalMul, decimalDev } from "@/global/decimalCompute";
303
-import type { TableColumnCtx } from 'element-plus'
360
+import type { TableColumnCtx } from "element-plus";
304 361
 
305 362
 const { outdound_type, is_available, province_ch } = useDict("outdound_type", "is_available", "province_ch");
306 363
 
@@ -309,6 +366,9 @@ const props = getQuery("/InformationFilling/outIssueDetail");
309 366
 // 价值计算带万
310 367
 const wanJson = ["118", "122", "124", "132", "182", "184"];
311 368
 
369
+// 是否可用Label
370
+const isAvailableLabel = ["是", "否"];
371
+
312 372
 // const tableData = ref([{}]);
313 373
 const wzOptions = ref([]);
314 374
 const dcckOptions = ref([]);
@@ -401,17 +461,36 @@ const getSelect = () => {
401 461
     }
402 462
   });
403 463
 };
404
-const handleChange = (value) => {
405
-  console.log(JSON.stringify(value));
464
+const handleChange = (value, index) => {
465
+  const postData = {
466
+    materialGroup: value[0],
467
+    materialType: value[1],
468
+    materialName: value[2],
469
+    materialUnit: value[3],
470
+    warehouseId: formData.tableData[index].deptId
471
+  };
472
+
473
+  getTimeAndUnitPriceForOutbound(postData).then((res: any) => {
474
+    if (res.code === 0) {
475
+      formData.tableData[index].rkrqAndDjOption = res.data;
476
+    }
477
+  });
406 478
 };
407 479
 
408 480
 const getDeptName = (value: any, index: number) => {
409 481
   if (value) {
410 482
     const filterItem = dcckOptions.value.filter((item) => item.deptId == value);
411 483
     formData.tableData[index].warehouse = filterItem[0].abbreviationName;
484
+
485
+    materialsTree({warehouseId:value}).then((res: any) => {
486
+      if (res.code === 0) {
487
+        formData.tableData[index].wzOptions = res.data;
488
+      }
489
+    });
412 490
   }
413 491
 };
414 492
 
493
+
415 494
 interface Product {
416 495
   id: string
417 496
   quantity: string
@@ -424,34 +503,32 @@ interface SummaryMethodProps<T = Product> {
424 503
 }
425 504
 const summaryJson = ["quantity","unitPrice","totalPrice"]
426 505
 const getSummaries = (param: SummaryMethodProps) => {
427
-  const { columns, data } = param
428
-  const sums: (string | VNode)[] = []
506
+  const { columns, data } = param;
507
+  const sums: (string | VNode)[] = [];
429 508
   columns.forEach((column, index) => {
430 509
     if (index === 0) {
431
-      sums[index] = h('div', [
432
-        '合计',
433
-      ])
434
-      return
510
+      sums[index] = h("div", ["合计"]);
511
+      return;
435 512
     }
436 513
     if(summaryJson.indexOf(column.property)!=-1){
437
-      const values = data.map((item) => Number(item[column.property]))
514
+      const values = data.map((item) => Number(item[column.property]));
438 515
       if (!values.every((value) => Number.isNaN(value))) {
439 516
         sums[index] = `${values.reduce((prev, curr) => {
440
-          const value = Number(curr)
517
+          const value = Number(curr);
441 518
           if (!Number.isNaN(value)) {
442
-            return prev + curr
519
+            return prev + curr;
443 520
           } else {
444
-            return prev
521
+            return prev;
445 522
           }
446
-        }, 0)}`
523
+        }, 0)}`;
447 524
       } else {
448
-        sums[index] = 'N/A'
525
+        sums[index] = "N/A";
449 526
       }
450 527
     }
451
-  })
528
+  });
452 529
 
453
-  return sums
454
-}
530
+  return sums;
531
+};
455 532
 // 计算总价
456 533
 const totalPrice = (row: any) => {
457 534
   if (row.unitPrice && row.quantity) {
@@ -475,6 +552,33 @@ const deleteTableData = (rowIndex) => {
475 552
     });
476 553
   }
477 554
 };
555
+// 获取物资下拉数据
556
+const getWzOptions = (value: any, index, itemName) => {
557
+  if (value) {
558
+    materialsTree({warehouseId:value}).then((res: any) => {
559
+      if (res.code === 0) {
560
+        formData.tableData[index].wzOptions = res.data;
561
+        formData.tableData[index].materialTree = itemName;
562
+      }
563
+    });
564
+  }
565
+};
566
+// 获取入库日期等下拉数据
567
+const getRkrqAndDjOption = (value, deptId, index) => {
568
+  const postData = {
569
+    materialGroup: value[0],
570
+    materialType: value[1],
571
+    materialName: value[2],
572
+    materialUnit: value[3],
573
+    warehouseId: deptId
574
+  };
575
+
576
+  getTimeAndUnitPriceForOutbound(postData).then((res: any) => {
577
+    if (res.code === 0) {
578
+      formData.tableData[index].rkrqAndDjOption = res.data;
579
+    }
580
+  });
581
+};
478 582
 // 详情获取数据
479 583
 const lookData = () => {
480 584
   lookOutDataNew(props.id).then((res: any) => {
@@ -484,6 +588,12 @@ const lookData = () => {
484 588
         ...item,
485 589
         filePartList: [{ name: item.fileName, filePart: item.filePart }]
486 590
       }));
591
+      formData.tableData = getData.map((item: any, index) => ({
592
+        ...item,
593
+        filePartList: [{ name: item.fileName, filePart: item.filePart }],
594
+        wzOptions: getWzOptions(item.deptId, index, item.materialTree),
595
+        rkrqAndDjOption: getRkrqAndDjOption(item.materialTree, item.deptId, index)
596
+      }));
487 597
       formData.orderNo = res.data.orderNo;
488 598
       formData.filePartList = res.data.filePartList;
489 599
       formData.orderName = res.data.orderName;