Browse Source

wdly产品维护修改问题

cz 1 năm trước cách đây
mục cha
commit
ff6940a5e0
1 tập tin đã thay đổi với 242 bổ sung82 xóa
  1. 242 82
      src/views/WDLY/basic/product/index.vue

+ 242 - 82
src/views/WDLY/basic/product/index.vue

@@ -7,7 +7,8 @@
         :data="treeListData"
         v-model="sourceList.pagination.productClassifyId"
         @change="treeChange"
-        @changeTreeList="getTreeList">
+        @changeTreeList="getTreeList"
+      >
       </treeList>
     </div>
     <div class="content">
@@ -35,18 +36,35 @@
             disabled: false,
           },
         ]"
-        @get-list="getList">
+        @get-list="getList"
+      >
         <template #pic="{ item }">
           <div v-if="item.fileList.length > 0">
-            <img :src="item.fileList[0].fileUrl" class="pic" @click="handleClickFile(item.fileList[0])" />
+            <img
+              :src="item.fileList[0].fileUrl"
+              class="pic"
+              @click="handleClickFile(item.fileList[0])"
+            />
           </div>
           <div v-else></div>
         </template>
       </byTable>
     </div>
-    <el-dialog :title="modalType == 'add' ? '添加' : '编辑'" v-model="dialogVisible" width="800" v-loading="loadingOne" destroy-on-close>
+    <el-dialog
+      :title="modalType == 'add' ? '添加' : '编辑'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loadingOne"
+      destroy-on-close
+    >
       <div class="public_height_dialog">
-        <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
+        <byForm
+          :formConfig="formConfig"
+          :formOption="formOption"
+          v-model="formData.data"
+          :rules="rules"
+          ref="byform"
+        >
           <template #productPic>
             <div>
               <el-upload
@@ -57,7 +75,8 @@
                 :on-remove="handleRemove"
                 :on-success="handleSuccess"
                 :before-upload="handleBeforeUpload"
-                accept=".gif, .jpeg, .jpg, .png">
+                accept=".gif, .jpeg, .jpg, .png"
+              >
                 <el-icon><Plus /></el-icon>
               </el-upload>
             </div>
@@ -65,21 +84,62 @@
 
           <template #combination>
             <div style="width: 100%">
-              <div style="font-size: 14px; font-weight: bold; margin-bottom: 10px; color: #333333" v-show="formData.data.combination == 1">组合明细</div>
-              <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px" v-show="formData.data.combination == 1"> 添加 </el-button>
-              <el-table :data="formData.data.productCombinationList" v-show="formData.data.combination == 1">
+              <div
+                style="
+                  font-size: 14px;
+                  font-weight: bold;
+                  margin-bottom: 10px;
+                  color: #333333;
+                "
+                v-show="formData.data.combination == 1"
+              >
+                组合明细
+              </div>
+              <el-button
+                type="primary"
+                @click="openProduct = true"
+                style="margin-bottom: 10px"
+                v-show="formData.data.combination == 1"
+              >
+                添加
+              </el-button>
+              <el-table
+                :data="formData.data.productCombinationList"
+                v-show="formData.data.combination == 1"
+              >
                 <el-table-column prop="code" label="产品编码" />
                 <el-table-column prop="name" label="产品名称" />
-                <el-table-column prop="linkQuantity" label="组合数量" min-width="150">
+                <el-table-column
+                  prop="linkQuantity"
+                  label="组合数量"
+                  min-width="150"
+                >
                   <template #default="{ row, $index }">
-                    <el-form-item :prop="'productCombinationList.' + $index + '.linkQuantity'" :rules="rules.linkQuantity" :inline-message="true">
-                      <el-input-number v-model="row.linkQuantity" placeholder="请输入" :min="1" :controls="false" :precision="0" />
+                    <el-form-item
+                      :prop="
+                        'productCombinationList.' + $index + '.linkQuantity'
+                      "
+                      :rules="rules.linkQuantity"
+                      :inline-message="true"
+                    >
+                      <el-input-number
+                        v-model="row.linkQuantity"
+                        placeholder="请输入"
+                        :min="1"
+                        :controls="false"
+                        :precision="0"
+                      />
                     </el-form-item>
                   </template>
                 </el-table-column>
                 <el-table-column prop="zip" label="操作" width="100">
                   <template #default="{ $index }">
-                    <el-button type="primary" link @click="handleRemoveProduct($index)">删除</el-button>
+                    <el-button
+                      type="primary"
+                      link
+                      @click="handleRemoveProduct($index)"
+                      >删除</el-button
+                    >
                   </template>
                 </el-table-column>
               </el-table>
@@ -89,7 +149,11 @@
             <div style="width: 100%">
               <el-row>
                 <el-col :span="4">
-                  <el-input v-model="formData.data.victoriatouristJson.newProductsDay1" placeholder="请输入" disabled />
+                  <el-input
+                    v-model="formData.data.victoriatouristJson.newProductsDay1"
+                    placeholder="请输入"
+                    disabled
+                  />
                 </el-col>
                 <el-col :span="1" style="text-align: center"> ~ </el-col>
                 <el-col :span="4">
@@ -100,18 +164,22 @@
                     :controls="false"
                     :precision="0"
                     style="width: 100%"
-                    @change="changeDay(10)">
+                    @change="changeDay(10)"
+                  >
                   </el-input-number>
                 </el-col>
                 <el-col :span="1" style="text-align: center"> : </el-col>
                 <el-col :span="6">
                   <el-input-number
-                    v-model="formData.data.victoriatouristJson.newProductsExpectedSales"
+                    v-model="
+                      formData.data.victoriatouristJson.newProductsExpectedSales
+                    "
                     placeholder="预期销量"
                     :min="0"
                     :controls="false"
                     :precision="0"
-                    style="width: 100%" />
+                    style="width: 100%"
+                  />
                 </el-col>
               </el-row>
             </div>
@@ -120,7 +188,11 @@
             <div style="width: 100%">
               <el-row>
                 <el-col :span="4">
-                  <el-input v-model="formData.data.victoriatouristJson.growUpDay1" placeholder="请输入" disabled />
+                  <el-input
+                    v-model="formData.data.victoriatouristJson.growUpDay1"
+                    placeholder="请输入"
+                    disabled
+                  />
                 </el-col>
                 <el-col :span="1" style="text-align: center"> ~ </el-col>
                 <el-col :span="4">
@@ -131,33 +203,42 @@
                     :controls="false"
                     :precision="0"
                     style="width: 100%"
-                    @change="changeDay(20)">
+                    @change="changeDay(20)"
+                  >
                   </el-input-number>
                 </el-col>
                 <el-col :span="1" style="text-align: center"> : </el-col>
                 <el-col :span="6">
                   <el-input-number
-                    v-model="formData.data.victoriatouristJson.growUpExpectedSales"
+                    v-model="
+                      formData.data.victoriatouristJson.growUpExpectedSales
+                    "
                     placeholder="预期销量"
                     :min="0"
                     :controls="false"
                     :precision="0"
-                    style="width: 100%" />
+                    style="width: 100%"
+                  />
                 </el-col>
               </el-row>
             </div>
           </template>
           <template #three>
             <el-row style="width: 100%">
-              <el-col :span="5"> 大于{{ formData.data.victoriatouristJson.attDay }}天: </el-col>
+              <el-col :span="5">
+                大于{{ formData.data.victoriatouristJson.attDay }}天:
+              </el-col>
               <el-col :span="6">
                 <el-input-number
-                  v-model="formData.data.victoriatouristJson.matureExpectedSales"
+                  v-model="
+                    formData.data.victoriatouristJson.matureExpectedSales
+                  "
                   placeholder="预期销量"
                   :min="0"
                   :controls="false"
                   :precision="0"
-                  style="width: 100%" />
+                  style="width: 100%"
+                />
               </el-col>
             </el-row>
           </template>
@@ -165,25 +246,64 @@
       </div>
       <template #footer>
         <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 title="Excel导入" v-model="openExcelDialog" width="400" v-loading="loading">
+    <el-dialog
+      title="Excel导入"
+      v-model="openExcelDialog"
+      width="400"
+      v-loading="loading"
+    >
       <template #footer>
-        <el-button @click="openExcelDialog = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitExcel()" size="large" :loading="submitLoading"> 确 定 </el-button>
+        <el-button @click="openExcelDialog = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitExcel()"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
       </template>
     </el-dialog>
 
     <el-dialog title="移交" v-model="moveDept" width="400" v-loading="loading">
       <div style="margin-bottom: 15px">请选择部门</div>
-      <el-tree-select v-model="moveForm.deptId" :data="deptList" :render-after-expand="false" check-strictly :node-key="'deptId'" :props="defaultProps" />
+      <el-tree-select
+        v-model="moveForm.deptId"
+        :data="deptList"
+        :render-after-expand="false"
+        check-strictly
+        :node-key="'deptId'"
+        :props="defaultProps"
+      />
       <template #footer>
         <el-button @click="moveDept = false">取 消</el-button>
-        <el-button type="primary" @click="submitMove()" :loading="submitLoading"> 确 定 </el-button>
+        <el-button
+          type="primary"
+          @click="submitMove()"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
       </template>
     </el-dialog>
-    <el-dialog v-model="openProduct" title="选择产品" width="70%" append-to-body>
+    <el-dialog
+      v-model="openProduct"
+      title="选择产品"
+      width="70%"
+      append-to-body
+    >
       <SelectProduct @handleSelect="handleSelect"></SelectProduct>
       <template #footer>
         <span class="dialog-footer">
@@ -228,11 +348,15 @@ let moveDept = ref(false);
 const deptIdCopy = ref("");
 let modalType = ref("add");
 let rules = ref({
-  productClassifyId: [{ required: true, message: "请选择产品分类", trigger: "change" }],
+  productClassifyId: [
+    { required: true, message: "请选择产品分类", trigger: "change" },
+  ],
   type: [{ required: true, message: "请选择产品类型", trigger: "change" }],
   name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
   unit: [{ required: true, message: "请选择单位", trigger: "change" }],
-  linkQuantity: [{ required: true, message: "请输入组合数量", trigger: "blur" }],
+  linkQuantity: [
+    { required: true, message: "请输入组合数量", trigger: "blur" },
+  ],
 });
 const { proxy } = getCurrentInstance();
 const productUnit = ref([]);
@@ -394,11 +518,15 @@ const config = computed(() => {
             el: "button",
             click() {
               // 弹窗提示是否删除
-              ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
-                confirmButtonText: "确定",
-                cancelButtonText: "取消",
-                type: "warning",
-              }).then(() => {
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
                 // 删除
                 proxy
                   .post("/productInfo/delete", {
@@ -617,33 +745,37 @@ const generatePassword = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy.post("/productInfo/pageByWdly", sourceList.value.pagination).then((message) => {
-    console.log(message);
-    sourceList.value.data = message.rows.map((x) => ({
-      ...x,
-      fileList: [],
-      ...JSON.parse(x.victoriatouristJson),
-    }));
-    sourceList.value.pagination.total = message.total;
-    setTimeout(() => {
-      loading.value = false;
-    }, 200);
+  proxy
+    .post("/productInfo/pageByWdly", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows.map((x) => ({
+        ...x,
+        fileList: [],
+        ...JSON.parse(x.victoriatouristJson),
+      }));
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
 
-    const productIdList = message.rows.map((x) => x.id);
-    // 请求文件数据并回显
-    if (productIdList.length > 0) {
-      proxy.post("/fileInfo/getList", { businessIdList: productIdList }).then((fileObj) => {
-        for (let i = 0; i < sourceList.value.data.length; i++) {
-          const e = sourceList.value.data[i];
-          for (const key in fileObj) {
-            if (e.id === key) {
-              e.fileList = fileObj[key];
+      const productIdList = message.rows.map((x) => x.id);
+      // 请求文件数据并回显
+      if (productIdList.length > 0) {
+        proxy
+          .post("/fileInfo/getList", { businessIdList: productIdList })
+          .then((fileObj) => {
+            for (let i = 0; i < sourceList.value.data.length; i++) {
+              const e = sourceList.value.data[i];
+              for (const key in fileObj) {
+                if (e.id === key) {
+                  e.fileList = fileObj[key];
+                }
+              }
             }
-          }
-        }
-      });
-    }
-  });
+          });
+      }
+    });
 };
 
 const treeChange = (e) => {
@@ -726,7 +858,8 @@ const submitForm = () => {
       fileName: x.fileName,
     }));
     submitLoading.value = true;
-    let url = modalType.value == "add" ? "/productInfo/addByWdly" : "/productInfo/edit";
+    let url =
+      modalType.value == "add" ? "/productInfo/addByWdly" : "/productInfo/edit";
     proxy.post(url, formData.data).then(
       (res) => {
         ElMessage({
@@ -741,7 +874,9 @@ const submitForm = () => {
       },
       (err) => {
         formData.data = { ...submitProductData.value };
-        formData.data.victoriatouristJson = JSON.parse(submitProductData.value.victoriatouristJson);
+        formData.data.victoriatouristJson = JSON.parse(
+          submitProductData.value.victoriatouristJson
+        );
         loadingOne.value = false;
         submitLoading.value = false;
       }
@@ -750,9 +885,11 @@ const submitForm = () => {
 };
 
 const getTreeList = () => {
-  proxy.post("/productClassify/tree", { parentId: "", name: "", definition: "1" }).then((message) => {
-    treeListData.value = message;
-  });
+  proxy
+    .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
+    .then((message) => {
+      treeListData.value = message;
+    });
 };
 
 const deptList = ref([]);
@@ -785,14 +922,26 @@ const getDtl = (row) => {
     fileListCopy.value = [...fileList.value];
     res.type = res.type + ""; //type回显
     res.definition = "1"; //产品
-    res.victoriatouristJson = res.victoriatouristJson ? JSON.parse(res.victoriatouristJson) : {};
-    res.combination = res.victoriatouristJson.combination ? res.victoriatouristJson.combination + "" : "0";
-    res.productCombinationList = res.victoriatouristJson.productCombinationList.map((item) => {
-      return {
-        ...item,
-        code: item.customCode,
-      };
-    });
+    res.victoriatouristJson = res.victoriatouristJson
+      ? JSON.parse(res.victoriatouristJson)
+      : {};
+    res.combination = res.victoriatouristJson.combination
+      ? res.victoriatouristJson.combination + ""
+      : "0";
+    if (
+      res.victoriatouristJson.productCombinationList &&
+      res.victoriatouristJson.productCombinationList.length > 0
+    ) {
+      res.productCombinationList =
+        res.victoriatouristJson.productCombinationList.map((item) => {
+          return {
+            ...item,
+            code: item.customCode,
+          };
+        });
+    } else {
+      res.productCombinationList = [];
+    }
     formData.data = res;
     dialogVisible.value = true;
   });
@@ -821,7 +970,9 @@ const handleSuccess = (res, file, files) => {
 };
 
 const handleRemove = (file) => {
-  const index = fileListCopy.value.findIndex((x) => x.uid === file.uid || x.id === file.id);
+  const index = fileListCopy.value.findIndex(
+    (x) => x.uid === file.uid || x.id === file.id
+  );
   fileListCopy.value.splice(index, 1);
 };
 
@@ -844,7 +995,8 @@ const pushGoods = (goods) => {
     name: x.name,
     code: x.code,
   }));
-  formData.data.productCombinationList = formData.data.productCombinationList.concat(arr);
+  formData.data.productCombinationList =
+    formData.data.productCombinationList.concat(arr);
   return ElMessage({
     message: "添加成功!",
     type: "success",
@@ -853,15 +1005,23 @@ const pushGoods = (goods) => {
 
 const changeDay = (type) => {
   if (type == 10) {
-    formData.data.victoriatouristJson.growUpDay1 = Number(formData.data.victoriatouristJson.newProductsDay) + 1;
+    formData.data.victoriatouristJson.growUpDay1 =
+      Number(formData.data.victoriatouristJson.newProductsDay) + 1;
   } else if (type == 20) {
-    formData.data.victoriatouristJson.attDay = Number(formData.data.victoriatouristJson.growUpDay);
+    formData.data.victoriatouristJson.attDay = Number(
+      formData.data.victoriatouristJson.growUpDay
+    );
   }
 };
 
 const handleSelect = (row) => {
-  if (formData.data.productCombinationList && formData.data.productCombinationList.length > 0) {
-    const flag = formData.data.productCombinationList.some((x) => x.linkProductId === row.id);
+  if (
+    formData.data.productCombinationList &&
+    formData.data.productCombinationList.length > 0
+  ) {
+    const flag = formData.data.productCombinationList.some(
+      (x) => x.linkProductId === row.id
+    );
     if (flag)
       return ElMessage({
         message: "该产品已选择",