Browse Source

wdly申购采购回退

cz 1 year ago
parent
commit
3d7ea9c713

+ 26 - 61
src/components/WDLY/process/SendPurchaseWDLY.vue

@@ -5,7 +5,7 @@
       :rules="rules"
       ref="formDom"
       label-position="top"
-      :disabled="judgeStatus()"
+      :disabled="props.queryData.purchaseDetailList ? true : false"
     >
       <div class="_t">基础信息</div>
       <el-row :gutter="10">
@@ -264,7 +264,6 @@ import SelectGoods from "@/components/product/SelectGoods";
 import { ElMessage, ElMessageBox } from "element-plus";
 import useUserStore from "@/store/modules/user";
 import { useRouter, useRoute } from "vue-router";
-import { watch } from "vue";
 const { proxy } = getCurrentInstance();
 const route = useRoute();
 let formData = reactive({
@@ -401,6 +400,28 @@ onMounted(() => {
     ids.value = props.queryData.ids.split(",") || [];
     getDetails();
   }
+  setTimeout(() => {
+    if (!props.queryData.purchaseDetailList) return;
+    formData.data = props.queryData;
+    proxy
+      .post("/subscribeDetail/detail", {
+        ids: props.queryData.purchaseDetailList.map((item) => {
+          return item.subscribeDetailId;
+        }),
+      })
+      .then((res) => {
+        console.log(formData.data.purchaseDetailList);
+        formData.data.purchaseDetailList =
+          props.queryData.purchaseDetailList.map((x, index) => ({
+            ...res[index],
+            subscribeCount: x.count,
+            count: x.count,
+            price: x.price,
+            amount: x.amount,
+          }));
+        console.log(formData.data.purchaseDetailList);
+      });
+  }, 2000);
 });
 
 // 接收父组件的传值
@@ -411,16 +432,10 @@ const props = defineProps({
 const ids = ref([]);
 const getDetails = () => {
   proxy.post("/subscribeDetail/detail", { ids: ids.value }).then((res) => {
+    console.log(res, "123123123123123123123123");
     formData.data.purchaseDetailList = res.map((x) => ({
-      subscribeDetailId: x.id,
-      productCustomCode: x.productCustomCode,
-      productDefinition: x.productDefinition,
-      productName: x.productName,
-      productSpec: x.productSpec,
-      productUnit: x.productUnit,
-      bussinessId: x.bussinessId,
+      ...x,
       subscribeCount: x.count,
-      purchaseCount: x.purchaseCount,
       count: Number(x.count) - Number(x.purchaseCount),
       price: null,
       amount: null,
@@ -503,59 +518,9 @@ const getDict = () => {
   });
 };
 getDict();
-
-const judgeStatus = () => {
-  if (route.query.processType == 20) {
-    return true;
-  }
-  if (props.queryData.recordList && props.queryData.recordList.length > 0) {
-    let data = props.queryData.recordList.filter(
-      (item) => item.status === 2 && item.nodeType !== 1
-    );
-    if (data && data.length > 0) {
-      return true;
-    }
-  }
-  return false;
-};
-
-watch(
-  () => props.queryData,
-  () => {
-    if (
-      props.queryData &&
-      (route.query.processType == 10 || route.query.processType == 20)
-    ) {
-      formData.data = props.queryData;
-      // proxy
-      //   .post("/subscribeDetail/detail", {
-      //     ids: props.queryData.purchaseDetailList.map((item) => {
-      //       return item.subscribeDetailId;
-      //     }),
-      //   })
-      //   .then((res) => {
-      //     formData.data.purchaseDetailList =
-      //       props.queryData.purchaseDetailList.map((x, index) => ({
-      //         ...res[index],
-      //         subscribeCount: x.count,
-      //         count: x.count,
-      //         price: x.price,
-      //         amount: x.amount,
-      //       }));
-      //   });
-    }
-  },
-  {
-    deep: true,
-  }
-);
-
-const getFormData = () => {
-  return formData.data;
-};
 // 向父组件暴露
 defineExpose({
-  getFormData,
+  submitData: formData.data,
   handleSubmit,
 });
 </script>

+ 30 - 44
src/components/WDLY/process/SendSubscribeWDLY.vue

@@ -90,6 +90,7 @@ import useUserStore from "@/store/modules/user";
 import { computed } from "vue";
 const { proxy } = getCurrentInstance();
 const route = useRoute();
+
 let formData = reactive({
   data: {
     subscribeDetailList: [],
@@ -105,12 +106,12 @@ let rules = ref({
   count: [{ required: true, message: "请输入申购数量", trigger: "blur" }],
   // remark: [{ required: true, message: "请输入申购备注", trigger: "blur" }],
 });
-const formOption = reactive({
+const formOption = computed(() => ({
   disabled: false,
   inline: true,
   labelWidth: 100,
   itemWidth: 100,
-});
+}));
 const formConfig = computed(() => {
   return [
     {
@@ -183,7 +184,6 @@ const formConfig = computed(() => {
     },
   ];
 });
-
 const formDom = ref(null);
 const handleSubmit = async () => {
   const vaild = await formDom.value.handleSubmit(() => {}); //拿到内部表单是否验证通过
@@ -241,7 +241,6 @@ const pushGoods = (goods) => {
 const props = defineProps({
   queryData: String,
 });
-
 const productUnit = ref([]);
 const getDict = () => {
   proxy.getDictOne(["unit"]).then((res) => {
@@ -256,50 +255,37 @@ getDict();
 // 获取用户信息并赋默认值
 const userInfo = useUserStore().user;
 onMounted(() => {
-  formData.data.subcribeTime = proxy.parseTime(new Date());
-  formData.data.deptName = userInfo.dept.deptName;
-  formData.data.subcribeName = userInfo.nickName;
-});
-
-const judgeStatus = () => {
-  if (route.query.processType == 20) {
-    return true;
-  }
-  if (props.queryData.recordList && props.queryData.recordList.length > 0) {
-    let data = props.queryData.recordList.filter(
-      (item) => item.status === 2 && item.nodeType !== 1
-    );
-    if (data && data.length > 0) {
-      return true;
-    }
-  }
-  return false;
-};
-
-watch(
-  () => props.queryData,
-  () => {
-    formOption.disabled = judgeStatus();
-    if (
-      props.queryData &&
-      (route.query.processType == 10 || route.query.processType == 20)
-    ) {
-      for (const key in props.queryData) {
-        formData.data[key] = props.queryData[key];
+  if (
+    route.query.id &&
+    (route.query.processType == 20 || route.query.processType == 10)
+  ) {
+    formOption.value.disabled = true;
+    setTimeout(() => {
+      formData.data = {
+        ...props.queryData,
+      };
+      if (formData.data && route.query.subscribeId) {
+        // const ids = formData.data.subscribeDetailList.map((x) => x.bussinessId);
+        proxy
+          .post("/subscribe/detail", {
+            id: route.query.subscribeId,
+          })
+          .then((res) => {
+            formData.data.subscribeDetailList = res.subscribeDetailList.map(
+              (x) => ({ ...x, goodType: x.productDefinition })
+            );
+          });
       }
-    }
-  },
-  {
-    deep: true,
+    }, 2000);
+  } else {
+    formData.data.subcribeTime = proxy.parseTime(new Date());
+    formData.data.deptName = userInfo.dept.deptName;
+    formData.data.subcribeName = userInfo.nickName;
   }
-);
-const getFormData = () => {
-  return formData.data;
-};
-
+});
 // 向父组件暴露
 defineExpose({
-  getFormData,
+  submitData: formData.data,
   handleSubmit,
 });
 </script>

+ 34 - 34
src/views/WDLY/basic/product/index.vue

@@ -529,7 +529,7 @@ const config = computed(() => {
     {
       attrs: {
         label: "操作",
-        width: "160",
+        width: "120",
         align: "center",
         fixed: "right",
       },
@@ -558,39 +558,39 @@ const config = computed(() => {
               getDtlOne(row);
             },
           },
-          {
-            attrs: {
-              label: "删除",
-              type: "danger",
-              text: true,
-            },
-            el: "button",
-            click() {
-              // 弹窗提示是否删除
-              ElMessageBox.confirm(
-                "此操作将永久删除该数据, 是否继续?",
-                "提示",
-                {
-                  confirmButtonText: "确定",
-                  cancelButtonText: "取消",
-                  type: "warning",
-                }
-              ).then(() => {
-                // 删除
-                proxy
-                  .post("/productInfo/delete", {
-                    id: row.id,
-                  })
-                  .then((res) => {
-                    ElMessage({
-                      message: "删除成功",
-                      type: "success",
-                    });
-                    getList();
-                  });
-              });
-            },
-          },
+          // {
+          //   attrs: {
+          //     label: "删除",
+          //     type: "danger",
+          //     text: true,
+          //   },
+          //   el: "button",
+          //   click() {
+          //     // 弹窗提示是否删除
+          //     ElMessageBox.confirm(
+          //       "此操作将永久删除该数据, 是否继续?",
+          //       "提示",
+          //       {
+          //         confirmButtonText: "确定",
+          //         cancelButtonText: "取消",
+          //         type: "warning",
+          //       }
+          //     ).then(() => {
+          //       // 删除
+          //       proxy
+          //         .post("/productInfo/delete", {
+          //           id: row.id,
+          //         })
+          //         .then((res) => {
+          //           ElMessage({
+          //             message: "删除成功",
+          //             type: "success",
+          //           });
+          //           getList();
+          //         });
+          //     });
+          //   },
+          // },
         ];
       },
     },

+ 16 - 23
src/views/process/processApproval/index.vue

@@ -96,7 +96,7 @@
             <el-button
               type="primary"
               v-if="approvalRecordData.buttonInfoList.length == 0"
-              @click="handleSubmit()"
+              @click="handleSubmit"
               >提交</el-button
             >
             <el-button
@@ -227,7 +227,9 @@ const router = useRouter();
 const route = useRoute();
 // tab切换逻辑
 const activeName = ref("first");
-const handleClick = (tab, event) => {};
+const handleClick = (tab, event) => {
+  // console.log(tab, event);
+};
 // 意见表单
 const flowForm = reactive({
   flowKey: "",
@@ -270,7 +272,7 @@ const handleSubmit = async (_type) => {
     if (flag) {
       flowFormDom.value.validate((valid) => {
         if (valid) {
-          const data = makeDom.value.getFormData();
+          const data = { ...makeDom.value.submitData };
           if (flowForm.flowKey == "subscribe_flow") {
             data.subscribeDetailList = data.subscribeDetailList.map((x) => ({
               bussinessId: x.bussinessId,
@@ -300,18 +302,14 @@ const handleSubmit = async (_type) => {
             };
             data.victoriatouristJson = JSON.stringify(victoriatouristJson);
           } else if (flowForm.flowKey == "wdly_purchase") {
-            // data.purchaseDetailList = data.purchaseDetailList.map((x) => ({
-            //   ...x,
-            //   subscribeDetailId: x.id,
-            // }));
-            // data.purchaseDetailList = data.purchaseDetailList.map((x) => ({
-            //   bussinessId: x.bussinessId,
-            //   subscribeDetailId: x.id,
-            //   count: x.count,
-            //   price: x.price,
-            //   amount: x.amount,
-            //   deptId: x.deptId,
-            // }));
+            data.purchaseDetailList = data.purchaseDetailList.map((x) => ({
+              bussinessId: x.bussinessId,
+              subscribeDetailId: x.id,
+              count: x.count,
+              price: x.price,
+              amount: x.amount,
+              deptId: x.deptId,
+            }));
             const victoriatouristJson = {
               isAgreement: data.isAgreement,
               paymentMethod: data.paymentMethod,
@@ -426,14 +424,6 @@ const handleSubmit = async (_type) => {
               .then((res) => {
                 handleResult(res);
               });
-            // if (_type && _type == 1) {
-            //   proxy
-            //     .post("/flowExample/setStartData", {
-            //       exampleId: route.query.id,
-            //       startDate: data,
-            //     })
-            //     .then();
-            // }
             return;
           } else {
             proxy
@@ -460,6 +450,7 @@ const skipPage = () => {
     });
   } else {
     const useTagsStore = useTagsViewStore();
+    console.log(useTagsStore);
     useTagsStore.delVisitedView(router.currentRoute.value);
     ElMessage({
       message: "操作成功!",
@@ -547,6 +538,7 @@ const getRecords = (_id) => {
         id: _id,
       })
       .then((res) => {
+        console.log(res, "ass");
         recordList.value = res.recordList;
         queryData.data.recordList = res.recordList;
         approvalRecordData.value = res;
@@ -557,6 +549,7 @@ const getRecords = (_id) => {
         flowKey: flowForm.flowKey,
       })
       .then((res) => {
+        console.log(res, "ass");
         recordList.value = res;
       });
   }

+ 118 - 68
src/views/product/material/index.vue

@@ -7,7 +7,8 @@
         :data="treeListData"
         v-model="sourceList.pagination.productClassifyId"
         @change="treeChange"
-        @changeTreeList="getTreeList">
+        @changeTreeList="getTreeList"
+      >
       </treeList>
     </div>
     <div class="content">
@@ -38,18 +39,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="500" v-loading="loading" destroy-on-close>
+    <el-dialog
+      :title="modalType == 'add' ? '添加' : '编辑'"
+      v-model="dialogVisible"
+      width="500"
+      v-loading="loading"
+      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
@@ -59,7 +77,8 @@
                 list-type="picture-card"
                 :on-remove="handleRemove"
                 :on-success="handleSuccess"
-                :before-upload="handleBeforeUpload">
+                :before-upload="handleBeforeUpload"
+              >
                 <el-icon><Plus /></el-icon>
               </el-upload>
             </div>
@@ -69,13 +88,34 @@
 
       <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>
   </div>
@@ -110,7 +150,9 @@ const materialUnit = ref([]);
 const materialType = ref([]);
 const treeData = ref([]);
 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" }],
@@ -180,8 +222,8 @@ const config = computed(() => {
     {
       attrs: {
         label: "操作",
-        width: "200",
-        align: "right",
+        width: "120",
+        align: "center",
       },
       renderHTML(row) {
         return [
@@ -208,35 +250,35 @@ const config = computed(() => {
                   getDtl(row);
                 },
               },
-          props.selectStatus
-            ? {}
-            : {
-                attrs: {
-                  label: "删除",
-                  type: "danger",
-                  text: true,
-                },
-                el: "button",
-                click() {
-                  ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
-                    confirmButtonText: "确定",
-                    cancelButtonText: "取消",
-                    type: "warning",
-                  }).then(() => {
-                    proxy
-                      .post("/productInfo/delete", {
-                        id: row.id,
-                      })
-                      .then(() => {
-                        ElMessage({
-                          message: "删除成功",
-                          type: "success",
-                        });
-                        getList();
-                      });
-                  });
-                },
-              },
+          // props.selectStatus
+          //   ? {}
+          //   : {
+          //       attrs: {
+          //         label: "删除",
+          //         type: "danger",
+          //         text: true,
+          //       },
+          //       el: "button",
+          //       click() {
+          //         ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
+          //           confirmButtonText: "确定",
+          //           cancelButtonText: "取消",
+          //           type: "warning",
+          //         }).then(() => {
+          //           proxy
+          //             .post("/productInfo/delete", {
+          //               id: row.id,
+          //             })
+          //             .then(() => {
+          //               ElMessage({
+          //                 message: "删除成功",
+          //                 type: "success",
+          //               });
+          //               getList();
+          //             });
+          //         });
+          //       },
+          //     },
         ];
       },
     },
@@ -322,29 +364,33 @@ const generatePassword = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy.post("/productInfo/page", sourceList.value.pagination).then((message) => {
-    console.log(message);
-    sourceList.value.data = message.rows.map((x) => ({ ...x, fileList: [] }));
-    sourceList.value.pagination.total = message.total;
-    setTimeout(() => {
-      loading.value = false;
-    }, 200);
+  proxy
+    .post("/productInfo/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows.map((x) => ({ ...x, fileList: [] }));
+      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 uploadData = ref({});
 const fileList = ref([]);
@@ -410,10 +456,12 @@ const submitForm = () => {
 };
 
 const getTreeList = () => {
-  proxy.post("/productClassify/tree", { parentId: "", name: "", definition: "2" }).then((message) => {
-    treeListData.value = message;
-    treeData.value = message;
-  });
+  proxy
+    .post("/productClassify/tree", { parentId: "", name: "", definition: "2" })
+    .then((message) => {
+      treeListData.value = message;
+      treeData.value = message;
+    });
 };
 
 const getDtl = (row) => {
@@ -449,7 +497,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);
 };