فهرست منبع

采购页面决策辅助功能

cz 1 سال پیش
والد
کامیت
ec98b4046c

+ 153 - 170
src/components/process/SendPurchase.vue

@@ -103,7 +103,7 @@
                 <el-input-number
                   onmousewheel="return false;"
                   v-model="row.count"
-                  :precision="4"
+                  :precision="2"
                   :controls="false"
                   :min="0"
                   @change="handleChangeAmount"
@@ -121,7 +121,7 @@
                 <el-input-number
                   onmousewheel="return false;"
                   v-model="row.price"
-                  :precision="4"
+                  :precision="2"
                   :controls="false"
                   :min="0"
                   @change="handleChangeAmount"
@@ -188,7 +188,7 @@
               >
                 <el-input-number
                   v-model="row.price"
-                  :precision="4"
+                  :precision="2"
                   :controls="false"
                   @change="handleChangeAmount"
                 />
@@ -349,6 +349,10 @@ const pushGoods = (goods) => {
     formData.data.purchaseDetailList =
       formData.data.purchaseDetailList.concat(arr);
     openProduct.value = false;
+    const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
+    if (formData.data.supplyId && ids.length > 0) {
+      handleChangeSupplier(formData.data.supplyId);
+    }
     return ElMessage({
       message: "添加成功!",
       type: "success",
@@ -411,35 +415,6 @@ const handleSubmit = async () => {
 
   return false;
 };
-// 获取用户信息并赋默认值
-const userInfo = useUserStore().user;
-onMounted(() => {
-  formData.data.purchaseTime = proxy.parseTime(new Date());
-  formData.data.deptName = userInfo.dept.deptName;
-  formData.data.purchaseName = userInfo.nickName;
-  getSupplierList();
-  if (props.queryData.ids) {
-    ids.value = props.queryData.ids.split(",") || [];
-    getDetails();
-  }
-});
-
-// onActivated(() => {
-//   formData.data = {
-//     purchaseTime: "",
-//     purchaseDetailList: [],
-//     otherFeeList: [],
-//   };
-//   formData.data.purchaseTime = proxy.parseTime(new Date());
-//   formData.data.deptName = userInfo.dept.deptName;
-//   formData.data.purchaseName = userInfo.nickName;
-//   getSupplierList();
-//   if (props.queryData.ids) {
-//     ids.value = props.queryData.ids.split(",") || [];
-//     getDetails();
-//   }
-// });
-
 const ids = ref([]);
 const getDetails = () => {
   if (props.queryData.type && props.queryData.type === "handoverSlip") {
@@ -493,87 +468,54 @@ let auxiliaryData = ref([
       [
         {
           label: "合同编号",
-          value: "12312312312456",
-          fn: () => {
-            console.log(formData.data);
-          },
-          style: {
-            color: "red",
-          },
+          value: "",
+          fn: () => {},
           num: 1,
         },
         {
           label: "下单日期",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
+          value: "",
           num: 1,
         },
         {
           label: "合同金额",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
+          value: "",
           num: 1,
         },
       ],
       [
         {
           label: "合同编号",
-          value: "12312312312456",
-          fn: () => {
-            console.log(formData.data);
-          },
-          style: {
-            color: "red",
-          },
+          value: "",
+          fn: () => {},
           num: 1,
         },
         {
           label: "下单日期",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
+          value: "",
           num: 1,
         },
         {
           label: "合同金额",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
+          value: "",
           num: 1,
         },
       ],
       [
         {
           label: "合同编号",
-          value: "12312312312456",
-          fn: () => {
-            console.log(formData.data);
-          },
-          style: {
-            color: "red",
-          },
+          value: "",
+          fn: () => {},
           num: 1,
         },
         {
           label: "下单日期",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
+          value: "",
           num: 1,
         },
         {
           label: "合同金额",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
+          value: "",
           num: 1,
         },
       ],
@@ -581,45 +523,7 @@ let auxiliaryData = ref([
   },
   {
     label: "产品价格",
-    data: [
-      [
-        {
-          label: "产品名称",
-          value: "12312312312456",
-          fn: () => {
-            console.log(formData.data);
-          },
-          style: {
-            color: "red",
-          },
-          num: 1,
-        },
-        {
-          label: "最近价格",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
-          num: 1,
-        },
-        {
-          label: "历史最高",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
-          num: 1,
-        },
-        {
-          label: "历史最低",
-          value: "123456",
-          fn: () => {
-            alert("点击事件");
-          },
-          num: 1,
-        },
-      ],
-    ],
+    data: [],
   },
 ]);
 const auxiliaryChange = (data) => {
@@ -627,92 +531,150 @@ const auxiliaryChange = (data) => {
 };
 
 const getAuxiliaryData = (supplyId, productIdList) => {
-  if (supplyId && productIdList) {
+  if (supplyId && productIdList.length > 0) {
     proxy
       .post("/subscribe/decisionAid", {
         supplyId: supplyId,
         productIdList: productIdList,
       })
       .then((res) => {
-        auxiliaryData.value[0].data = auxiliaryData.value[0].data.map(
+        // 获取数组长度
+        let dataLength = auxiliaryData.value.length;
+        // 供应商最近采购
+        auxiliaryData.value[dataLength - 2].data = auxiliaryData.value[
+          dataLength - 2
+        ].data.map((x, index) => {
+          return x.map((y, sonIndex) => {
+            let obj = { ...y };
+            let value = "";
+            if (sonIndex === 0) {
+              value = res.purchaseList[index].code;
+            } else if (sonIndex === 1) {
+              value = res.purchaseList[index].createTime;
+            } else {
+              value =
+                res.purchaseList[index].currency +
+                " " +
+                proxy.moneyFormat(res.purchaseList[index].amount, 2);
+            }
+            obj.value = value;
+            return obj;
+          });
+        });
+        // 产品价格
+        const arrConfig = [
+          {
+            label: "产品名称",
+            value: "",
+            num: 1,
+          },
+          {
+            label: "最近价格",
+            value: "",
+            num: 1,
+          },
+          {
+            label: "历史最高",
+            value: "",
+            num: 1,
+          },
+          {
+            label: "历史最低",
+            value: "",
+            num: 1,
+          },
+        ];
+        auxiliaryData.value[dataLength - 1].data = res.productPriceList.map(
           (x, index) => {
-            return x.map((y, sonIndex) => {
+            return arrConfig.map((y, sonIndex) => {
               let obj = { ...y };
               let value = "";
               if (sonIndex === 0) {
-                value = res.purchaseList[index].code;
+                value = x.name;
               } else if (sonIndex === 1) {
-                value = res.purchaseList[index].createTime;
+                value = x.lastPrice;
+              } else if (sonIndex === 2) {
+                value = x.maxPrice;
               } else {
-                value =
-                  res.purchaseList[index].currency +
-                  " " +
-                  proxy.moneyFormat(res.purchaseList[index].amount, 2);
+                value = x.minPrice;
               }
               obj.value = value;
               return obj;
             });
           }
         );
-        const arr = auxiliaryData.value[1].data[0];
-        auxiliaryData.value[1].data = res.productPriceList.map((x, index) => {
-          return arr.map((y, sonIndex) => {
-            let obj = { ...y };
-            let value = "";
-            if (sonIndex === 0) {
-              value = x.name;
-            } else if (sonIndex === 1) {
-              value = x.lastPrice;
-            } else if (sonIndex === 2) {
-              value = x.maxPrice;
-            } else {
-              value = x.minPrice;
-            }
-            obj.value = value;
-            return obj;
-          });
-        });
-        console.log(auxiliaryData.value, "aaa");
         auxiliaryChange(auxiliaryData.value);
       });
+  } else {
+    if (props.queryData.type === "handoverSlip" && props.queryData.arr) {
+      let arrConfig = [
+        {
+          label: "合同编号",
+          value: "",
+          fn: () => {},
+          num: 1,
+        },
+        {
+          label: "下单日期",
+          value: "",
+          num: 1,
+        },
+      ];
+      auxiliaryData.value[0].data = contractData.value.map((x, index) => {
+        return arrConfig.map((y, sonIndex) => {
+          let obj = { ...y };
+          let value = "";
+          if (sonIndex === 0) {
+            value = contractData.value[index].contractCode;
+          } else if (sonIndex === 1) {
+            value = contractData.value[index].claimTime;
+          }
+          obj.value = value;
+          return obj;
+        });
+      });
+      auxiliaryChange(auxiliaryData.value);
+    }
   }
 };
 // 供应商改变逻辑
 const handleChangeSupplier = (val) => {
   const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
-  getAuxiliaryData(val, ids);
-  proxy
-    .post("/supplierPrice/getSupplierPriceByProductIds", {
-      supplierInfoId: val,
-      productIdList: ids,
-    })
-    .then((res) => {
-      if (res && Object.keys(res).length > 0) {
-        for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
-          const e = formData.data.purchaseDetailList[i];
-          for (const key in res) {
-            if (e.bussinessId === key) {
-              e.price = Number(res[key]);
+  if (val && ids.length > 0) {
+    getAuxiliaryData(val, ids);
+    proxy
+      .post("/supplierPrice/getSupplierPriceByProductIds", {
+        supplierInfoId: val,
+        productIdList: ids,
+      })
+      .then((res) => {
+        if (res && Object.keys(res).length > 0) {
+          for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
+            const e = formData.data.purchaseDetailList[i];
+            for (const key in res) {
+              if (e.bussinessId === key) {
+                e.price = Number(res[key]);
+              }
             }
           }
+        } else {
+          for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
+            const e = formData.data.purchaseDetailList[i];
+            e.price = 0;
+          }
         }
-      } else {
-        for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
-          const e = formData.data.purchaseDetailList[i];
-          e.price = 0;
-        }
-      }
-      handleChangeAmount();
-    });
+        handleChangeAmount();
+      });
+  }
 };
 const handleChangeProductAmount = () => {
   let sum = 0;
   for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
     const e = formData.data.purchaseDetailList[i];
-    e.amount = parseFloat(e.count * e.price).toFixed(4);
+    e.amount = parseFloat(e.count * e.price).toFixed(2);
     sum += Number(e.amount);
   }
-  formData.data.productAmount = parseFloat(sum).toFixed(4);
+  formData.data.productAmount = parseFloat(sum).toFixed(2);
 };
 
 const handleChangeOtherAmount = () => {
@@ -721,7 +683,7 @@ const handleChangeOtherAmount = () => {
     const e = formData.data.otherFeeList[i];
     sum += Number(e.price);
   }
-  formData.data.otherAmount = parseFloat(sum).toFixed(4);
+  formData.data.otherAmount = parseFloat(sum).toFixed(2);
 };
 
 // 计算采购总金额
@@ -731,14 +693,14 @@ const handleChangeAmount = () => {
   let sum = 0;
   for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
     const e = formData.data.purchaseDetailList[i];
-    e.amount = parseFloat(e.count * e.price).toFixed(4);
+    e.amount = parseFloat(e.count * e.price).toFixed(2);
     sum += Number(e.amount);
   }
   for (let i = 0; i < formData.data.otherFeeList.length; i++) {
     const e = formData.data.otherFeeList[i];
     sum += Number(e.price);
   }
-  formData.data.amount = parseFloat(sum).toFixed(4);
+  formData.data.amount = parseFloat(sum).toFixed(2);
 };
 
 const productUnit = ref([]);
@@ -803,6 +765,27 @@ const judgeStatus = () => {
   }
   return false;
 };
+// 获取用户信息并赋默认值
+const userInfo = useUserStore().user;
+const contractData = ref([]);
+onMounted(() => {
+  formData.data.purchaseTime = proxy.parseTime(new Date());
+  formData.data.deptName = userInfo.dept.deptName;
+  formData.data.purchaseName = userInfo.nickName;
+  getSupplierList();
+  if (props.queryData.ids) {
+    ids.value = props.queryData.ids.split(",") || [];
+    getDetails();
+  }
+  if (props.queryData.type === "handoverSlip" && props.queryData.arr) {
+    contractData.value = JSON.parse(props.queryData.arr);
+    auxiliaryData.value.unshift({
+      label: "关联销售合同",
+      data: [],
+    });
+    getAuxiliaryData();
+  }
+});
 
 const getFormData = () => {
   return formData.data;

+ 14 - 0
src/views/purchaseManage/purchaseManage/handoverSlip/index.vue

@@ -364,6 +364,19 @@ const start = (type, row) => {
   }
   if (selectData.value.length > 0) {
     let ids = selectData.value.map((x) => x.id).join();
+    let arr = selectData.value.map((x) => ({
+      contractId: x.contractId,
+      contractCode: x.contractCode,
+      claimTime: x.claimTime,
+    }));
+    let newArr = [];
+    for (let i = 0; i < arr.length; i++) {
+      const e = arr[i];
+      let flag = newArr.some((x) => x.contractId === e.contractId);
+      if (!flag) {
+        newArr.push(e);
+      }
+    }
     proxy.$router.replace({
       path: "/platform_manage/process/processApproval",
       query: {
@@ -371,6 +384,7 @@ const start = (type, row) => {
         type: "handoverSlip",
         random: proxy.random(),
         ids,
+        arr: JSON.stringify(newArr),
       },
     });
   } else {

+ 12 - 4
src/views/purchaseSales/outAndInWarehouse/manualDelivery/index.vue

@@ -55,7 +55,14 @@
                 label="规格型号"
                 width="160"
               />
-              <el-table-column prop="productUnit" label="单位" width="100" :formatter="(row) => dictValueLabel(row.productUnit, productUnit)" />
+              <el-table-column
+                prop="productUnit"
+                label="单位"
+                width="100"
+                :formatter="
+                  (row) => dictValueLabel(row.productUnit, productUnit)
+                "
+              />
               <el-table-column
                 prop="productQuantity"
                 label="库存数量"
@@ -75,7 +82,8 @@
                         style="width: 100%"
                         :precision="0"
                         :controls="false"
-                        :min="0"
+                        :min="1"
+                        onmousewheel="return false;"
                       />
                     </el-form-item>
                   </div>
@@ -190,7 +198,7 @@ const config = computed(() => {
         prop: "productUnit",
         width: 120,
       },
-        render(unit) {
+      render(unit) {
         return proxy.dictValueLabel(unit, productUnit.value);
       },
     },
@@ -228,7 +236,7 @@ const getDict = () => {
       });
     }
   });
-     proxy.getDictOne(['unit']).then((res) => {
+  proxy.getDictOne(["unit"]).then((res) => {
     productUnit.value = res["unit"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,

+ 98 - 27
src/views/purchaseSales/outAndInWarehouse/manualWarehousing/index.vue

@@ -14,32 +14,88 @@
             action: () => openModal(),
           },
         ]"
-        @get-list="getList">
+        @get-list="getList"
+      >
       </byTable>
     </div>
 
-    <el-dialog title="手动入库" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
-      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+    <el-dialog
+      title="手动入库"
+      v-if="dialogVisible"
+      v-model="dialogVisible"
+      width="1000"
+      v-loading="loadingDialog"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="submit"
+      >
         <template #details>
           <div style="width: 100%">
-            <el-button type="primary" @click="openProduct = true">添加明细</el-button>
-            <el-table :data="formData.data.list" style="width: 100%; margin-top: 16px">
-              <el-table-column prop="productCode" label="产品编码" width="140" />
-              <el-table-column prop="productName" label="产品名称" min-width="220" />
-              <el-table-column prop="productSpec" label="规格型号" min-width="220" />
-              <el-table-column prop="productUnit" label="单位" width="100" :formatter="(row) => dictValueLabel(row.productUnit, productUnit)" />
+            <el-button type="primary" @click="openProduct = true"
+              >添加明细</el-button
+            >
+            <el-table
+              :data="formData.data.list"
+              style="width: 100%; margin-top: 16px"
+            >
+              <el-table-column
+                prop="productCode"
+                label="产品编码"
+                width="140"
+              />
+              <el-table-column
+                prop="productName"
+                label="产品名称"
+                min-width="220"
+              />
+              <el-table-column
+                prop="productSpec"
+                label="规格型号"
+                min-width="220"
+              />
+              <el-table-column
+                prop="productUnit"
+                label="单位"
+                width="100"
+                :formatter="
+                  (row) => dictValueLabel(row.productUnit, productUnit)
+                "
+              />
               <el-table-column label="入库数量" width="160">
                 <template #default="{ row, $index }">
                   <div style="width: 100%">
-                    <el-form-item :prop="'list.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
-                      <el-input-number v-model="row.quantity" placeholder="请输入数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
+                    <el-form-item
+                      :prop="'list.' + $index + '.quantity'"
+                      :rules="rules.quantity"
+                      :inline-message="true"
+                    >
+                      <el-input-number
+                        v-model="row.quantity"
+                        placeholder="请输入数量"
+                        style="width: 100%"
+                        :precision="0"
+                        :controls="false"
+                        :min="1"
+                        onmousewheel="return false;"
+                      />
                     </el-form-item>
                   </div>
                 </template>
               </el-table-column>
-              <el-table-column align="center" label="操作" width="80" fixed="right">
+              <el-table-column
+                align="center"
+                label="操作"
+                width="80"
+                fixed="right"
+              >
                 <template #default="{ row, $index }">
-                  <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
+                  <el-button type="primary" link @click="handleDelete($index)"
+                    >删除</el-button
+                  >
                 </template>
               </el-table-column>
             </el-table>
@@ -48,12 +104,24 @@
       </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
+        <el-button type="primary" @click="submitForm()" size="large"
+          >确 定</el-button
+        >
       </template>
     </el-dialog>
 
-    <el-dialog v-if="openProduct" v-model="openProduct" title="选择商品" width="70%" append-to-body>
-      <SelectGoods :selectList="acquireSelectList()" @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
+    <el-dialog
+      v-if="openProduct"
+      v-model="openProduct"
+      title="选择商品"
+      width="70%"
+      append-to-body
+    >
+      <SelectGoods
+        :selectList="acquireSelectList()"
+        @cancel="openProduct = false"
+        @pushGoods="pushGoods"
+      ></SelectGoods>
     </el-dialog>
   </div>
 </template>
@@ -69,7 +137,6 @@ const { proxy } = getCurrentInstance();
 const warehouseList = ref([]);
 const productUnit = ref([]);
 
-
 const sourceList = ref({
   data: [],
   pagination: {
@@ -127,7 +194,7 @@ const config = computed(() => {
         prop: "productUnit",
         width: 120,
       },
-       render(unit) {
+      render(unit) {
         return proxy.dictValueLabel(unit, productUnit.value);
       },
     },
@@ -165,7 +232,7 @@ const getDict = () => {
       });
     }
   });
-   proxy.getDictOne(['unit']).then((res) => {
+  proxy.getDictOne(["unit"]).then((res) => {
     productUnit.value = res["unit"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,
@@ -175,13 +242,15 @@ const getDict = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy.post("/stockJournalDetails/page", sourceList.value.pagination).then((res) => {
-    sourceList.value.data = res.rows;
-    sourceList.value.pagination.total = res.total;
-    setTimeout(() => {
-      loading.value = false;
-    }, 200);
-  });
+  proxy
+    .post("/stockJournalDetails/page", sourceList.value.pagination)
+    .then((res) => {
+      sourceList.value.data = res.rows;
+      sourceList.value.pagination.total = res.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
 };
 getDict();
 getList();
@@ -233,7 +302,9 @@ const pushGoods = (goods) => {
     let afterFiltering = [];
     if (formData.data.list && formData.data.list.length > 0) {
       afterFiltering = goods.filter((item) => {
-        let data = formData.data.list.filter((itemProduct) => itemProduct.productId === item.id);
+        let data = formData.data.list.filter(
+          (itemProduct) => itemProduct.productId === item.id
+        );
         if (data && data.length > 0) {
           return false;
         }

+ 9 - 3
src/views/purchaseSales/outAndInWarehouse/waitingForDelivery/index.vue

@@ -169,7 +169,7 @@ const config = computed(() => {
         prop: "productUnit",
         width: 120,
       },
-         render(unit) {
+      render(unit) {
         return proxy.dictValueLabel(unit, productUnit.value);
       },
     },
@@ -227,7 +227,7 @@ const getDict = () => {
       });
     }
   });
-  proxy.getDictOne(["product_type",'unit']).then((res) => {
+  proxy.getDictOne(["product_type", "unit"]).then((res) => {
     productType.value = res["product_type"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,
@@ -313,7 +313,7 @@ const formConfig = computed(() => {
       prop: "warehousingQuantity",
       label: "出库数量",
       precision: 0,
-      min: 0,
+      min: 1,
       controls: false,
     },
   ];
@@ -327,6 +327,12 @@ const rules = ref({
 const submitForm = () => {
   submit.value.handleSubmit(() => {
     loadingDialog.value = true;
+    if (formData.data.warehousingQuantity > Number(formData.data.quantity)) {
+      return ElMessage({
+        message: "出库数量不可大于待出库数量",
+        type: "info",
+      });
+    }
     proxy
       .post("/stockWait/add", {
         id: formData.data.id,

+ 42 - 16
src/views/purchaseSales/outAndInWarehouse/waitingForStorage/index.vue

@@ -8,15 +8,31 @@
         :loading="loading"
         :selectConfig="selectConfig"
         highlight-current-row
-        @get-list="getList">
+        @get-list="getList"
+      >
       </byTable>
     </div>
 
-    <el-dialog title="入库" v-if="dialogVisible" v-model="dialogVisible" width="400" v-loading="loadingDialog">
-      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"> </byForm>
+    <el-dialog
+      title="入库"
+      v-if="dialogVisible"
+      v-model="dialogVisible"
+      width="400"
+      v-loading="loadingDialog"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="submit"
+      >
+      </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
+        <el-button type="primary" @click="submitForm()" size="large"
+          >确 定</el-button
+        >
       </template>
     </el-dialog>
   </div>
@@ -149,7 +165,7 @@ const config = computed(() => {
         prop: "productUnit",
         width: 120,
       },
-        render(unit) {
+      render(unit) {
         return proxy.dictValueLabel(unit, productUnit.value);
       },
     },
@@ -207,12 +223,12 @@ const getDict = () => {
       });
     }
   });
-  proxy.getDictOne(["product_type",'unit']).then((res) => {
+  proxy.getDictOne(["product_type", "unit"]).then((res) => {
     productType.value = res["product_type"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,
     }));
-      productUnit.value = res["unit"].map((x) => ({
+    productUnit.value = res["unit"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,
     }));
@@ -221,13 +237,15 @@ const getDict = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy.post("/stockWaitDetails/page", sourceList.value.pagination).then((res) => {
-    sourceList.value.data = res.rows;
-    sourceList.value.pagination.total = res.total;
-    setTimeout(() => {
-      loading.value = false;
-    }, 200);
-  });
+  proxy
+    .post("/stockWaitDetails/page", sourceList.value.pagination)
+    .then((res) => {
+      sourceList.value.data = res.rows;
+      sourceList.value.pagination.total = res.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
 };
 getDict();
 getList();
@@ -291,18 +309,26 @@ const formConfig = computed(() => {
       prop: "warehousingQuantity",
       label: "入库数量",
       precision: 0,
-      min: 0,
+      min: 1,
       controls: false,
     },
   ];
 });
 const rules = ref({
   warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
-  warehousingQuantity: [{ required: true, message: "请输入入库数量", trigger: "blur" }],
+  warehousingQuantity: [
+    { required: true, message: "请输入入库数量", trigger: "blur" },
+  ],
 });
 const submitForm = () => {
   submit.value.handleSubmit(() => {
     loadingDialog.value = true;
+    if (formData.data.warehousingQuantity > Number(formData.data.quantity)) {
+      return ElMessage({
+        message: "入库数量不可大于待入库数量",
+        type: "info",
+      });
+    }
     proxy
       .post("/stockWait/add", {
         id: formData.data.id,

+ 120 - 42
src/views/purchaseSales/outAndInWarehouse/warehouseAdjustment/index.vue

@@ -14,32 +14,83 @@
             action: () => openModal(),
           },
         ]"
-        @get-list="getList">
+        @get-list="getList"
+      >
       </byTable>
     </div>
 
-    <el-dialog title="新增调仓" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
-      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+    <el-dialog
+      title="新增调仓"
+      v-if="dialogVisible"
+      v-model="dialogVisible"
+      width="1000"
+      v-loading="loadingDialog"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="submit"
+      >
         <template #details>
           <div style="width: 100%">
-            <el-button type="primary" @click="openProduct = true">添加明细</el-button>
-            <el-table :data="formData.data.stockTransferDetailsList" style="width: 100%; margin-top: 16px">
-              <el-table-column prop="productCode" label="物品编码" width="140" />
-              <el-table-column prop="productName" label="物品名称" min-width="220" />
-              <el-table-column prop="productSpec" label="规格型号" min-width="220" />
+            <el-button type="primary" @click="openProduct = true"
+              >添加明细</el-button
+            >
+            <el-table
+              :data="formData.data.stockTransferDetailsList"
+              style="width: 100%; margin-top: 16px"
+            >
+              <el-table-column
+                prop="productCode"
+                label="物品编码"
+                width="140"
+              />
+              <el-table-column
+                prop="productName"
+                label="物品名称"
+                min-width="220"
+              />
+              <el-table-column
+                prop="productSpec"
+                label="规格型号"
+                min-width="220"
+              />
               <!-- <el-table-column prop="productUnit" label="单位" width="100" /> -->
               <el-table-column label="调仓数量" width="160">
                 <template #default="{ row, $index }">
                   <div style="width: 100%">
-                    <el-form-item :prop="'stockTransferDetailsList.' + $index + '.outQuantity'" :rules="rules.outQuantity" :inline-message="true">
-                      <el-input-number v-model="row.outQuantity" placeholder="请输入数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
+                    <el-form-item
+                      :prop="
+                        'stockTransferDetailsList.' + $index + '.outQuantity'
+                      "
+                      :rules="rules.outQuantity"
+                      :inline-message="true"
+                    >
+                      <el-input-number
+                        v-model="row.outQuantity"
+                        placeholder="请输入数量"
+                        style="width: 100%"
+                        :precision="0"
+                        :controls="false"
+                        :min="1"
+                        onmousewheel="return false;"
+                      />
                     </el-form-item>
                   </div>
                 </template>
               </el-table-column>
-              <el-table-column align="center" label="操作" width="80" fixed="right">
+              <el-table-column
+                align="center"
+                label="操作"
+                width="80"
+                fixed="right"
+              >
                 <template #default="{ row, $index }">
-                  <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
+                  <el-button type="primary" link @click="handleDelete($index)"
+                    >删除</el-button
+                  >
                 </template>
               </el-table-column>
             </el-table>
@@ -48,12 +99,24 @@
       </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
+        <el-button type="primary" @click="submitForm()" size="large"
+          >确 定</el-button
+        >
       </template>
     </el-dialog>
 
-    <el-dialog v-if="openProduct" v-model="openProduct" title="选择商品" width="70%" append-to-body>
-      <SelectGoods :selectList="acquireSelectList()" @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
+    <el-dialog
+      v-if="openProduct"
+      v-model="openProduct"
+      title="选择商品"
+      width="70%"
+      append-to-body
+    >
+      <SelectGoods
+        :selectList="acquireSelectList()"
+        @cancel="openProduct = false"
+        @pushGoods="pushGoods"
+      ></SelectGoods>
     </el-dialog>
   </div>
 </template>
@@ -151,7 +214,7 @@ const config = computed(() => {
         prop: "productUnit",
         width: 120,
       },
-        render(unit) {
+      render(unit) {
         return proxy.dictValueLabel(unit, productUnit.value);
       },
     },
@@ -165,7 +228,7 @@ const config = computed(() => {
     {
       attrs: {
         label: "操作人",
-        prop: "opUserName",
+        prop: "operatorName",
         width: 140,
       },
     },
@@ -189,7 +252,7 @@ const getDict = () => {
       });
     }
   });
-      proxy.getDictOne(['unit']).then((res) => {
+  proxy.getDictOne(["unit"]).then((res) => {
     productUnit.value = res["unit"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,
@@ -199,13 +262,15 @@ const getDict = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy.post("stockTransferDetails/page", sourceList.value.pagination).then((res) => {
-    sourceList.value.data = res.rows;
-    sourceList.value.pagination.total = res.total;
-    setTimeout(() => {
-      loading.value = false;
-    }, 200);
-  });
+  proxy
+    .post("stockTransferDetails/page", sourceList.value.pagination)
+    .then((res) => {
+      sourceList.value.data = res.rows;
+      sourceList.value.pagination.total = res.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
 };
 getDict();
 getList();
@@ -257,8 +322,12 @@ const formConfig = computed(() => {
   ];
 });
 const rules = ref({
-  outWarehouseId: [{ required: true, message: "请选择调出仓库", trigger: "change" }],
-  inWarehouseId: [{ required: true, message: "请选择调入仓库", trigger: "change" }],
+  outWarehouseId: [
+    { required: true, message: "请选择调出仓库", trigger: "change" },
+  ],
+  inWarehouseId: [
+    { required: true, message: "请选择调入仓库", trigger: "change" },
+  ],
   outQuantity: [{ required: true, message: "请输入调仓数量", trigger: "blur" }],
 });
 const openModal = () => {
@@ -272,9 +341,14 @@ const openModal = () => {
 const pushGoods = (goods) => {
   if (goods && goods.length > 0) {
     let afterFiltering = [];
-    if (formData.data.stockTransferDetailsList && formData.data.stockTransferDetailsList.length > 0) {
+    if (
+      formData.data.stockTransferDetailsList &&
+      formData.data.stockTransferDetailsList.length > 0
+    ) {
       afterFiltering = goods.filter((item) => {
-        let data = formData.data.stockTransferDetailsList.filter((itemProduct) => itemProduct.productId === item.id);
+        let data = formData.data.stockTransferDetailsList.filter(
+          (itemProduct) => itemProduct.productId === item.id
+        );
         if (data && data.length > 0) {
           return false;
         }
@@ -283,18 +357,19 @@ const pushGoods = (goods) => {
     } else {
       afterFiltering = goods;
     }
-    formData.data.stockTransferDetailsList = formData.data.stockTransferDetailsList.concat(
-      afterFiltering.map((item) => {
-        return {
-          productCode: item.code,
-          productId: item.id,
-          productName: item.name,
-          productSpec: item.spec,
-          productUnit: item.unit,
-          outQuantity: undefined,
-        };
-      })
-    );
+    formData.data.stockTransferDetailsList =
+      formData.data.stockTransferDetailsList.concat(
+        afterFiltering.map((item) => {
+          return {
+            productCode: item.code,
+            productId: item.id,
+            productName: item.name,
+            productSpec: item.spec,
+            productUnit: item.unit,
+            outQuantity: undefined,
+          };
+        })
+      );
     ElMessage({
       message: "添加成功!",
       type: "success",
@@ -339,7 +414,10 @@ const handleDelete = (index) => {
 };
 const acquireSelectList = () => {
   let data = [];
-  if (formData.data.stockTransferDetailsList && formData.data.stockTransferDetailsList.length > 0) {
+  if (
+    formData.data.stockTransferDetailsList &&
+    formData.data.stockTransferDetailsList.length > 0
+  ) {
     data = formData.data.stockTransferDetailsList.map((item) => {
       return {
         id: item.productId,

+ 127 - 39
src/views/purchaseSales/stockManage/inventory/index.vue

@@ -19,37 +19,88 @@
             action: () => openModal('add'),
           },
         ]"
-        @get-list="getList">
+        @get-list="getList"
+      >
         <template #code="{ item }">
-          <div style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
+          <div
+            style="cursor: pointer; color: #409eff"
+            @click="handleClickCode(item)"
+          >
             {{ item.code }}
           </div>
         </template>
       </byTable>
     </div>
-    <el-dialog :title="modalType == 'add' ? '发起盘点' : '盘点详情'" v-model="dialogVisible" width="800" v-loading="loading" destroy-on-close>
-      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
+    <el-dialog
+      :title="modalType == 'add' ? '发起盘点' : '盘点详情'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+      destroy-on-close
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
         <template #products>
           <div style="width: 100%">
-            <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px" v-if="modalType == 'add'" :disabled="!formData.data.warehouseId">
+            <el-button
+              type="primary"
+              @click="openProduct = true"
+              style="margin-bottom: 10px"
+              v-if="modalType == 'add'"
+              :disabled="!formData.data.warehouseId"
+            >
               添加物品
             </el-button>
             <el-table :data="formData.data.list" :row-class-name="changeClass">
               <el-table-column prop="productCode" label="物品编码" />
               <el-table-column prop="productName" label="物品名称" />
-              <el-table-column prop="productUnit" label="单位" :formatter="(row) => dictValueLabel(row.productUnit, productUnit)" />
+              <el-table-column
+                prop="productUnit"
+                label="单位"
+                :formatter="
+                  (row) => dictValueLabel(row.productUnit, productUnit)
+                "
+              />
               <el-table-column prop="quantity" label="库存数量" />
-              <el-table-column prop="checkQuantity" label="盘点数量" min-width="150">
+              <el-table-column
+                prop="checkQuantity"
+                label="盘点数量"
+                min-width="150"
+              >
                 <template #default="{ row, $index }">
-                  <el-form-item :prop="'list.' + $index + '.checkQuantity'" :rules="rules.checkQuantity" :inline-message="true">
-                    <el-input-number v-model="row.checkQuantity" :precision="4" :controls="false" :min="0" @change="() => handleChange($index)" />
+                  <el-form-item
+                    :prop="'list.' + $index + '.checkQuantity'"
+                    :rules="rules.checkQuantity"
+                    :inline-message="true"
+                  >
+                    <el-input-number
+                      v-model="row.checkQuantity"
+                      :precision="0"
+                      :controls="false"
+                      :min="0"
+                      :disabled="modalType == 'edit'"
+                      @change="() => handleChange($index)"
+                      onmousewheel="return false;"
+                    />
                   </el-form-item>
                 </template>
               </el-table-column>
               <el-table-column prop="result" label="盘点结果" />
-              <el-table-column prop="zip" label="操作" width="100" v-if="modalType == 'add'">
+              <el-table-column
+                prop="zip"
+                label="操作"
+                width="100"
+                v-if="modalType == 'add'"
+              >
                 <template #default="{ $index }">
-                  <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
+                  <el-button type="primary" link @click="handleRemove($index)"
+                    >删除</el-button
+                  >
                 </template>
               </el-table-column>
             </el-table>
@@ -58,11 +109,28 @@
       </byForm>
       <template #footer v-if="modalType == 'add'">
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading"> 确 定 </el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
       </template>
     </el-dialog>
-    <el-dialog v-if="openProduct" v-model="openProduct" title="选择物品" width="70%" append-to-body>
-      <SelectGoods :selectList="acquireSelectList()" @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
+    <el-dialog
+      v-if="openProduct"
+      v-model="openProduct"
+      title="选择物品"
+      width="70%"
+      append-to-body
+    >
+      <SelectGoods
+        :selectList="acquireSelectList()"
+        @cancel="openProduct = false"
+        @pushGoods="pushGoods"
+      ></SelectGoods>
     </el-dialog>
   </div>
 </template>
@@ -92,8 +160,12 @@ let openProduct = ref(false);
 let roomDialogVisible = ref(false);
 let modalType = ref("add");
 let rules = ref({
-  checkQuantity: [{ required: true, message: "请输入盘点数量", trigger: "blur" }],
-  warehouseId: [{ required: true, message: "请选择盘点仓库", trigger: "change" }],
+  checkQuantity: [
+    { required: true, message: "请输入盘点数量", trigger: "blur" },
+  ],
+  warehouseId: [
+    { required: true, message: "请选择盘点仓库", trigger: "change" },
+  ],
 });
 const { proxy } = getCurrentInstance();
 const selectConfig = reactive([
@@ -248,14 +320,16 @@ const formConfig = reactive([
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy.post("/stockCheck/page", sourceList.value.pagination).then((message) => {
-    console.log(message);
-    sourceList.value.data = message.rows;
-    sourceList.value.pagination.total = message.total;
-    setTimeout(() => {
-      loading.value = false;
-    }, 200);
-  });
+  proxy
+    .post("/stockCheck/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows;
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
 };
 const openModal = () => {
   dialogVisible.value = true;
@@ -340,7 +414,9 @@ const pushGoods = (goods) => {
     let afterFiltering = [];
     if (formData.data.list && formData.data.list.length > 0) {
       afterFiltering = goods.filter((item) => {
-        let data = formData.data.list.filter((itemProduct) => itemProduct.productId === item.id);
+        let data = formData.data.list.filter(
+          (itemProduct) => itemProduct.productId === item.id
+        );
         if (data && data.length > 0) {
           return false;
         }
@@ -366,22 +442,27 @@ const pushGoods = (goods) => {
         })
         .then((res) => {
           const productList = res.rows;
-          for (let i = 0; i < productList.length; i++) {
-            const e = productList[i];
-            for (let j = 0; j < arr.length; j++) {
-              const jele = arr[j];
-              if (e.productId === jele.productId) {
-                formData.data.list.push({ ...jele, quantity: e.quantity });
+          if (productList.length > 0) {
+            for (let i = 0; i < arr.length; i++) {
+              const e = arr[i];
+              const current = productList.find(
+                (x) => x.productId === e.productId
+              );
+              if (current) {
+                formData.data.list.push({ ...e, quantity: current.quantity });
+              } else {
+                formData.data.list.push({ ...e, quantity: 0 });
               }
             }
+          } else {
+            for (let i = 0; i < arr.length; i++) {
+              const e = arr[i];
+              formData.data.list.push({ ...e, quantity: 0 });
+            }
           }
         });
     }
     openProduct.value = false;
-    return ElMessage({
-      message: "添加成功,已为你自动过滤库存数量为0的数据 !",
-      type: "success",
-    });
   } else {
     ElMessage("请选择至少一件物品");
   }
@@ -424,14 +505,21 @@ const handleRemove = (index) => {
 // });
 
 const handleChange = (index) => {
-  if (!formData.data.list[index].quantity) return;
-  if (formData.data.list[index].quantity > formData.data.list[index].checkQuantity) {
+  // if (!formData.data.list[index].quantity) return;
+  if (
+    formData.data.list[index].quantity > formData.data.list[index].checkQuantity
+  ) {
     formData.data.list[index].result = "盘亏";
   }
-  if (formData.data.list[index].quantity == formData.data.list[index].checkQuantity) {
+  if (
+    formData.data.list[index].quantity ==
+    formData.data.list[index].checkQuantity
+  ) {
     formData.data.list[index].result = "正常";
   }
-  if (formData.data.list[index].quantity < formData.data.list[index].checkQuantity) {
+  if (
+    formData.data.list[index].quantity < formData.data.list[index].checkQuantity
+  ) {
     formData.data.list[index].result = "盘盈";
   }
 };