Parcourir la source

wdly产品维护调整

lxf il y a 1 an
Parent
commit
8c11c83568
1 fichiers modifiés avec 88 ajouts et 232 suppressions
  1. 88 232
      src/views/WDLY/basic/product/index.vue

+ 88 - 232
src/views/WDLY/basic/product/index.vue

@@ -7,8 +7,7 @@
         :data="treeListData"
         v-model="sourceList.pagination.productClassifyId"
         @change="treeChange"
-        @changeTreeList="getTreeList"
-      >
+        @changeTreeList="getTreeList">
       </treeList>
     </div>
     <div class="content">
@@ -36,35 +35,18 @@
             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
@@ -75,71 +57,29 @@
                 :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>
           </template>
 
           <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="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">
                 <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>
@@ -149,11 +89,7 @@
             <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">
@@ -164,22 +100,18 @@
                     :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>
@@ -188,11 +120,7 @@
             <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">
@@ -203,42 +131,33 @@
                     :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>
@@ -246,64 +165,25 @@
       </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">
@@ -313,7 +193,7 @@
     </el-dialog>
   </div>
 </template>
-  
+
 <script setup>
 /* eslint-disable vue/no-unused-components */
 import { ElMessage, ElMessageBox } from "element-plus";
@@ -348,15 +228,11 @@ 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([]);
@@ -518,15 +394,11 @@ const config = computed(() => {
             el: "button",
             click() {
               // 弹窗提示是否删除
-              ElMessageBox.confirm(
-                "此操作将永久删除该数据, 是否继续?",
-                "提示",
-                {
-                  confirmButtonText: "确定",
-                  cancelButtonText: "取消",
-                  type: "warning",
-                }
-              ).then(() => {
+              ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+              }).then(() => {
                 // 删除
                 proxy
                   .post("/productInfo/delete", {
@@ -612,7 +484,7 @@ const formConfig = computed(() => {
       label: "备注",
       itemType: "textarea",
     },
-    
+
     {
       type: "json",
       prop: "victoriatouristJson",
@@ -745,37 +617,33 @@ 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) => {
@@ -858,8 +726,7 @@ 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({
@@ -874,9 +741,7 @@ 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;
       }
@@ -885,11 +750,9 @@ 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([]);
@@ -911,7 +774,7 @@ const getDept = () => {
 
 const getDtl = (row) => {
   modalType.value = "edit";
-  proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
+  proxy.post("/productInfo/detailByWdly", { id: row.id }).then((res) => {
     if (res.victoriatouristJson) {
       const jsonObj = parse(res.victoriatouristJson);
       if (jsonObj && jsonObj.deptId) {
@@ -922,13 +785,14 @@ 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;
+    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,
+      };
+    });
     formData.data = res;
     dialogVisible.value = true;
   });
@@ -957,9 +821,7 @@ 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);
 };
 
@@ -982,8 +844,7 @@ 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",
@@ -992,20 +853,15 @@ 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
-    );
+    const flag = formData.data.productCombinationList.some((x) => x.linkProductId === row.id);
     if (flag)
       return ElMessage({
         message: "该产品已选择",
@@ -1055,7 +911,7 @@ const submitMove = () => {
 };
 
 const getDict = () => {
-  proxy.getDictOne(["unit", "product_type",'sales_status']).then((res) => {
+  proxy.getDictOne(["unit", "product_type", "sales_status"]).then((res) => {
     productUnit.value = res["unit"].map((x) => ({
       label: x.dictValue,
       value: x.dictKey,
@@ -1072,7 +928,7 @@ const getDict = () => {
 };
 getDict();
 </script>
-  
+
 <style lang="scss" scoped>
 .user {
   padding: 20px;
@@ -1113,4 +969,4 @@ getDict();
 :deep(.el-date-picker__header .el-date-picker__header-label) {
   display: none;
 }
-</style>
+</style>