Procházet zdrojové kódy

产品库字典替换

cz před 2 roky
rodič
revize
3e22f50a00

+ 1 - 1
src/components/WDLY/process/SendSubscribeWDLY.vue

@@ -92,7 +92,7 @@ let formData = reactive({
 });
 let rules = ref({
   receiptWarehouseId: [
-    { required: true, message: "请选择收仓库", trigger: "change" },
+    { required: true, message: "请选择收仓库", trigger: "change" },
   ],
   planArrivalTime: [
     { required: true, message: "请选择要求到货时间", trigger: "change" },

+ 12 - 1
src/main.js

@@ -44,7 +44,17 @@ import {
   selectDictLabels
 } from '@/utils/ruoyi'
 
-import { dictDataEcho, dictValueLabel, moneyFormat, calculationWeek, getDict, getPdf, translateIntoEnglish, random } from '@/utils/util'
+import {
+  dictDataEcho,
+  dictValueLabel,
+  moneyFormat,
+  calculationWeek,
+  getDict,
+  getDictOne,
+  getPdf,
+  translateIntoEnglish,
+  random
+} from '@/utils/util'
 
 // 分页组件
 import Pagination from '@/components/Pagination'
@@ -80,6 +90,7 @@ app.config.globalProperties.dictValueLabel = dictValueLabel
 app.config.globalProperties.moneyFormat = moneyFormat
 app.config.globalProperties.calculationWeek = calculationWeek
 app.config.globalProperties.getDict = getDict
+app.config.globalProperties.getDictOne = getDictOne
 app.config.globalProperties.getPdf = getPdf
 app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
 app.config.globalProperties.random = random

+ 30 - 0
src/utils/util.js

@@ -72,6 +72,36 @@ export function getDict(key) {
   });
 }
 
+export function getDictOne(key) {
+  return new Promise((resolve, reject) => {
+    let dictObj = {};
+    let arr = {};
+    let num = 0;
+    for (let i = 0; i < key.length; i++) {
+      const element = key[i];
+      if (dictObj[element]) {
+        arr[element] = dictObj[element];
+        num++;
+        if (num === key.length) {
+          resolve(arr);
+        }
+      } else {
+        post("/tenantDict/getDict", {
+
+          dictCode: element,
+        }).then((res) => {
+          dictObj[element] = res;
+          arr[element] = res;
+          num++;
+          if (num === key.length) {
+            resolve(arr);
+          }
+        });
+      }
+    }
+  });
+}
+
 // 金额千分符
 export function moneyFormat(s, n) {
   if (s) {

+ 7 - 4
src/views/WDLY/basic/product/index.vue

@@ -792,7 +792,9 @@ const submitForm = () => {
       });
     }
     loadingOne.value = true;
-    jsonObj.deptId = deptIdCopy.value;
+    if (deptIdCopy.value) {
+      jsonObj.deptId = deptIdCopy.value;
+    }
     formData.data.victoriatouristJson = jsonObj;
     jsonObj.productCombinationList = list;
     jsonObj.combination = formData.data.combination;
@@ -859,8 +861,9 @@ const getDtl = (row) => {
   modalType.value = "edit";
   proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
     if (res.victoriatouristJson) {
-      if (res.victoriatouristJson.deptId) {
-        deptIdCopy.value = parse(res.victoriatouristJson).deptId.value;
+      const jsonObj = parse(res.victoriatouristJson);
+      if (jsonObj && jsonObj.deptId) {
+        deptIdCopy.value = jsonObj.deptId.value;
       }
     }
     fileList.value = row.fileList.map((x) => ({ ...x, url: x.fileUrl }));
@@ -1001,7 +1004,7 @@ const productUnit = ref([]);
 const productType = ref([]);
 
 const getDict = () => {
-  proxy.getDict(["unit", "product_type"]).then((res) => {
+  proxy.getDictOne(["unit", "product_type"]).then((res) => {
     productUnit.value = res["unit"];
     productType.value = res["product_type"];
     formConfig.value[1].data = productType.value.map((x) => ({

+ 22 - 21
src/views/WDLY/outInBound/transfer/index.vue

@@ -163,7 +163,7 @@
         :selectStatus="true"
         :warehouseId="formData.data.outWarehouseId"
         @cancel="openProduct = false"
-        @select="select"
+        @select="pushGoods"
         :key="formData.data.outWarehouseId"
       ></InventoryInquiry>
 
@@ -533,26 +533,6 @@ const handleSelect = (row) => {
   });
 };
 
-const pushGoods = (goods) => {
-  const arr = goods.map((x) => ({
-    goodType: x.goodType,
-    productCode: x.code,
-    productName: x.name,
-    productSpec: x.spec,
-    productUnit: x.unit,
-    count: 0,
-    price: 0,
-    bussinessId: x.id,
-    amount: 0,
-  }));
-  formData.data.stockTransferDetailsList =
-    formData.data.stockTransferDetailsList.concat(arr);
-  return ElMessage({
-    message: "添加成功!",
-    type: "success",
-  });
-};
-
 const handleRemove = (index) => {
   formData.data.stockTransferDetailsList.splice(index, 1);
   return ElMessage({
@@ -569,6 +549,27 @@ const clickAdd = () => {
   }
 };
 
+const pushGoods = (goods) => {
+  const arr = goods.map((item) => ({
+    goodType: item.goodType,
+    productCode: item.productCode,
+    productName: item.productName,
+    productSpec: item.productSpec,
+    productUnit: item.productUnit,
+    bussinessId: item.productId,
+    count: 0,
+    price: 0,
+    amount: 0,
+  }));
+  formData.data.stockTransferDetailsList =
+    formData.data.stockTransferDetailsList.concat(arr);
+  openProduct.value = false;
+  return ElMessage({
+    message: "添加成功!",
+    type: "success",
+  });
+};
+
 const select = (x) => {
   if (
     formData.data.stockTransferDetailsList &&

+ 94 - 103
src/views/WDLY/outInBound/waitOutBound/index.vue

@@ -24,8 +24,9 @@
     <el-dialog
       title="出库"
       v-model="dialogVisible"
-      width="500"
-      v-loading="loading"
+      width="800"
+      v-loading="submitLoading"
+      destroy-on-close
     >
       <byForm
         :formConfig="formConfig"
@@ -36,50 +37,28 @@
       >
         <template #products>
           <div style="width: 100%">
-            <el-button
+            <!-- <el-button
               type="primary"
               @click="clickAdd()"
               style="margin-bottom: 10px"
               v-if="modalType == 'add'"
             >
               添加物品
-            </el-button>
-            <el-table :data="formData.data.stockTransferDetailsList">
+            </el-button> -->
+            <el-table :data="formData.data.jdOrderDetailsList">
               <el-table-column prop="productCode" label="物品编码" />
               <el-table-column prop="productName" label="物品名称" />
               <el-table-column prop="productSpec" label="规格型号" />
-              <el-table-column
-                prop="outQuantity"
-                label="调仓数量"
-                v-if="modalType == 'detail'"
-              />
-              <el-table-column
-                prop="inQuantity"
-                label="接收数量"
-                v-if="modalType == 'detail'"
-              />
-
-              <el-table-column
-                prop="outQuantity"
-                label="调仓数量"
-                v-if="modalType == 'edit'"
-              />
-              <el-table-column
-                prop="outQuantity"
-                label="调仓数量"
-                min-width="150"
-                v-if="modalType == 'add'"
-              >
+              <el-table-column prop="waitQuantity" label="待出库数量" />
+              <el-table-column prop="quantity" label="调仓数量" min-width="150">
                 <template #default="{ row, $index }">
                   <el-form-item
-                    :prop="
-                      'stockTransferDetailsList.' + $index + '.outQuantity'
-                    "
-                    :rules="rules.outQuantity"
+                    :prop="'jdOrderDetailsList.' + $index + '.quantity'"
+                    :rules="rules.quantity"
                     :inline-message="true"
                   >
                     <el-input-number
-                      v-model="row.outQuantity"
+                      v-model="row.quantity"
                       :precision="2"
                       :controls="false"
                       :min="0"
@@ -95,7 +74,7 @@
               >
                 <template #default="{ row, $index }">
                   <el-form-item
-                    :prop="'stockTransferDetailsList.' + $index + '.inQuantity'"
+                    :prop="'jdOrderDetailsList.' + $index + '.inQuantity'"
                     :rules="rules.inQuantity"
                     :inline-message="true"
                   >
@@ -187,18 +166,24 @@ let rules = ref({
   warehouseId: [
     { required: true, message: "请选择仓库名称", trigger: "change" },
   ],
-  quantity: [{ required: true, message: "请输入入库数量", trigger: "blur" }],
+  outWarehouseId: [
+    { required: true, message: "请选择调出仓库", trigger: "change" },
+  ],
+  inWarehouseId: [
+    { required: true, message: "请选择调入仓库", trigger: "change" },
+  ],
+  quantity: [{ required: true, message: "请输入调仓数量", trigger: "blur" }],
 });
 const { proxy } = getCurrentInstance();
 const selectConfig = reactive([
   {
-    label: "数据来源",
-    prop: "type",
+    label: "type",
+    prop: "businessType",
     data: [],
   },
   {
     label: "出库状态",
-    prop: "type",
+    prop: "status",
     data: [],
   },
 ]);
@@ -282,7 +267,7 @@ const config = computed(() => {
         prop: "status",
       },
       render(status) {
-        return status == 0 ? "未出库" : status == 1 ? "部分出库" : "";
+        return status == 0 ? "未出库" : status == 1 ? "部分出库" : "入库完成";
       },
     },
     {
@@ -294,18 +279,20 @@ const config = computed(() => {
       // 渲染 el-button,一般用在最后一列。
       renderHTML(row) {
         return [
-          {
-            attrs: {
-              label: "出库",
-              type: "primary",
-              text: true,
-              disabled: row.status > 1,
-            },
-            el: "button",
-            click() {
-              outBound(row);
-            },
-          },
+          row.status < 2
+            ? {
+                attrs: {
+                  label: "出库",
+                  type: "primary",
+                  text: true,
+                  disabled: row.status > 1,
+                },
+                el: "button",
+                click() {
+                  outBound(row);
+                },
+              }
+            : {},
         ];
       },
     },
@@ -453,62 +440,66 @@ const openModal = () => {
 
 const submitForm = () => {
   byform.value.handleSubmit((valid) => {
-    const list = formData.data.stockWaitDetailsList;
-    const total = list.reduce((total, x) => (total += Number(x.quantity)), 0);
-    if (!(total > 0)) {
-      return ElMessage({
-        message: `本次入库不能为0!`,
-        type: "info",
-      });
-    }
-    for (let i = 0; i < list.length; i++) {
-      const e = list[i];
-      if (Number(e.receiptQuantity) + e.quantity > Number(e.arrivalQuantity)) {
-        return ElMessage({
-          message: "本次入库加已入库数量不可大于发货数量!",
-          type: "info",
-        });
+    if (modalType.value === "add") {
+      const list = formData.data.jdOrderDetailsList;
+      for (let i = 0; i < list.length; i++) {
+        const e = list[i];
+        if (!(e.quantity > 0)) {
+          return ElMessage({
+            message: "调仓数量不能为0!",
+            type: "info",
+          });
+        }
+        if (e.quantity > e.waitQuantity) {
+          return ElMessage({
+            message: "调仓数量不能大于待出库数量!",
+            type: "info",
+          });
+        }
       }
+      submitLoading.value = true;
+      proxy.post("/jdOrder/outbound", formData.data).then(
+        (res) => {
+          ElMessage({
+            message: "操作成功",
+            type: "success",
+          });
+          dialogVisible.value = false;
+          submitLoading.value = false;
+          getList();
+        },
+        (err) => (submitLoading.value = false)
+      );
     }
-    submitLoading.value = true;
-    proxy.post("/stockWait/addByWdly", formData.data).then(
-      (res) => {
-        ElMessage({
-          message: "操作成功",
-          type: "success",
-        });
-        dialogVisible.value = false;
-        submitLoading.value = false;
-        getList();
-      },
-      (err) => (submitLoading.value = false)
-    );
   });
 };
 
 const outBound = (row) => {
-  const index = row.$index;
-  modalType.value = "add";
-  if (index % 2 == 0) {
-    formConfig.value = configData[0];
-  } else {
+  if (row.businessType == 5) {
+    modalType.value = "add";
     formConfig.value = configData[1];
+    proxy.post("/jdOrder/detail", { id: row.businessId }).then((res) => {
+      formData.data = {
+        id: row.businessId,
+        outWarehouseId: "",
+        inWarehouseId: "",
+        jdOrderDetailsList: res.jdOrderDetailsList.map((x) => ({
+          waitQuantity: row.quantity,
+          quantity: row.quantity,
+          productId: x.productId,
+          id: x.id,
+          productCode: x.productCode,
+          productName: x.productName,
+          productSpec: x.productSpec,
+        })),
+      };
+      dialogVisible.value = true;
+    });
+  } else {
+    modalType.value = "edit";
+    formConfig.value = configData[0];
   }
-  // proxy.post("/stockWait/detailByWdly", { id: row.id }).then((res) => {
-  //   const json = JSON.parse(res.victoriatouristJson);
-  //   formData.data = {
-  //     type: "1",
-  //     businessType: res.businessType,
-  //     warehouseId: "",
-  //     code: json.code,
-  //     stockWaitDetailsList: res.stockWaitDetailsList.map((x) => ({
-  //       ...x,
-  //       arrivalQuantity: x.quantity,
-  //       quantity: 0,
-  //     })),
-  //   };
-  //   dialogVisible.value = true;
-  // });
+
   dialogVisible.value = true;
 };
 const warehouseType = ref([]);
@@ -519,7 +510,7 @@ const businessType = [
 ];
 
 const handleRemove = (index) => {
-  formData.data.stockTransferDetailsList.splice(index, 1);
+  formData.data.jdOrderDetailsList.splice(index, 1);
   return ElMessage({
     message: "删除成功",
     type: "success",
@@ -536,17 +527,17 @@ const clickAdd = () => {
 
 const select = (x) => {
   if (
-    formData.data.stockTransferDetailsList &&
-    formData.data.stockTransferDetailsList.length > 0
+    formData.data.jdOrderDetailsList &&
+    formData.data.jdOrderDetailsList.length > 0
   ) {
-    let data = formData.data.stockTransferDetailsList.filter(
+    let data = formData.data.jdOrderDetailsList.filter(
       (row) => row.bussinessId === x.productId
     );
     if (data && data.length > 0) {
       return ElMessage("请勿重复添加");
     }
   }
-  formData.data.stockTransferDetailsList.push({
+  formData.data.jdOrderDetailsList.push({
     goodType: x.goodType,
     productCode: x.productCode,
     productName: x.productName,

+ 1 - 1
src/views/product/material/index.vue

@@ -487,7 +487,7 @@ const handleClickFile = (file) => {
 const materialUnit = ref([]);
 const materialType = ref([]);
 const getDict = () => {
-  proxy.getDict(["material_unit", "material_type"]).then((res) => {
+  proxy.getDictOne(["material_unit", "material_type"]).then((res) => {
     materialUnit.value = res["material_unit"];
     materialType.value = res["material_type"];
     formConfig.value[4].data = materialUnit.value.map((x) => ({

+ 1 - 1
src/views/product/product/index.vue

@@ -524,7 +524,7 @@ const handleClickFile = (file) => {
 };
 const productType = ref([]);
 const getDict = () => {
-  proxy.getDict(["product_type"]).then((res) => {
+  proxy.getDictOne(["product_type"]).then((res) => {
     productType.value = res["product_type"];
     formConfig.value[1].data = productType.value.map((x) => ({
       label: x.dictValue,

+ 1 - 1
src/views/product/product/index2.vue

@@ -500,7 +500,7 @@ const handleClickFile = (file) => {
 
 const productType = ref([]);
 const getDict = () => {
-  proxy.getDict(["product_type"]).then((res) => {
+  proxy.getDictOne(["product_type"]).then((res) => {
     productType.value = res["product_type"];
     formConfig.value[1].data = productType.value.map((x) => ({
       label: x.dictValue,