Browse Source

bug整改

cz 2 years ago
parent
commit
1d3d35bd89

+ 2 - 0
src/views/product/material/index.vue

@@ -4,6 +4,7 @@
       <treeList
         title="物料分类"
         submitType="2"
+        :data="treeListData"
         v-model="sourceList.pagination.productClassifyId"
         @change="treeChange"
         @changeTreeList="getTreeList"
@@ -427,6 +428,7 @@ const getTreeList = () => {
   proxy
     .post("/productClassify/tree", { parentId: "", name: "", definition: "2" })
     .then((message) => {
+      treeListData.value = message;
       formConfig.value[0].data = message;
     });
 };

+ 2 - 0
src/views/product/product/index.vue

@@ -4,6 +4,7 @@
       <treeList
         title="产品分类"
         submitType="1"
+        :data="treeListData"
         v-model="sourceList.pagination.productClassifyId"
         @change="treeChange"
         @changeTreeList="getTreeList"
@@ -404,6 +405,7 @@ const getTreeList = () => {
   proxy
     .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
     .then((message) => {
+      treeListData.value = message;
       formConfig.value[0].data = message;
     });
 };

+ 15 - 11
src/views/product/treeList.vue

@@ -19,7 +19,7 @@
       </el-button>
     </div>
     <el-tree
-      :data="treeListData"
+      :data="data"
       ref="tree"
       node-key="id"
       @node-click="treeChange"
@@ -93,6 +93,10 @@ const props = defineProps({
     type: String,
     default: "1", //默认产品
   },
+  data: {
+    type: Array,
+    default: [],
+  },
 });
 onMounted(() => {});
 const search = ref("");
@@ -212,17 +216,17 @@ const submitForm = () => {
 
 const getTreeList = () => {
   emit("changeTreeList");
-  proxy
-    .post("/productClassify/tree", {
-      parentId: "",
-      name: "",
-      definition: props.submitType,
-    })
-    .then((message) => {
-      treeListData.value = message;
-    });
+  // proxy
+  //   .post("/productClassify/tree", {
+  //     parentId: "",
+  //     name: "",
+  //     definition: props.submitType,
+  //   })
+  //   .then((message) => {
+  //     treeListData.value = message;
+  //   });
 };
-getTreeList();
+// getTreeList();
 const handleMouseOver = (data) => {
   console.log(data, "sss");
   // currentNode.id = toRaw(data).id;

+ 93 - 43
src/views/production/project/processes/index.vue

@@ -21,8 +21,13 @@
         ]"
         @get-list="getList"
       >
-        <template #slotName="{ item }">
-          {{ item.createTime }}
+        <template #fileSlot="{ item }">
+          <div
+            style="cursor: pointer; color: #409eff"
+            @click="handleClickFile(item)"
+          >
+            {{ item.fileName }}
+          </div>
         </template>
       </byTable>
     </div>
@@ -42,17 +47,33 @@
         <template #slot>
           <div>
             <el-upload
-              v-model:file-list="fileList"
+              v-model:fileList="fileList"
               class="upload-demo"
               action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
-              :limit="1"
+              :limit="3"
               :data="uploadData"
               :on-preview="handlePreview"
               :on-remove="handleRemove"
               :on-success="handleSuccess"
               :before-upload="handleBeforeUpload"
+              accept="pdf"
             >
               <el-button type="primary">点击上传</el-button>
+              <template #file>
+                <div>
+                  <div style="margin-top: 15px">
+                    <el-tag
+                      class="ml-2"
+                      type="info"
+                      v-for="(item, index) in fileList"
+                      :key="index"
+                      closable
+                      @close="handleClose(index)"
+                      >{{ item.fileName }}</el-tag
+                    >
+                  </div>
+                </div>
+              </template>
             </el-upload>
           </div>
         </template>
@@ -127,7 +148,6 @@ const config = computed(() => {
       attrs: {
         label: "工序名称",
         prop: "name",
-        width: 150,
       },
     },
     {
@@ -139,18 +159,12 @@ const config = computed(() => {
     {
       attrs: {
         label: "工序文件",
-        prop: "type",
-        width: 120,
-      },
-      render(type) {
-        return type == 1
-          ? "普通车间"
-          : type == 2
-          ? "半自动化车间"
-          : type == "3"
-          ? "自动化车间"
-          : "";
+        prop: "fileName",
+        slot: "fileSlot",
       },
+      // render(fileName) {
+      //   return <div>fileName</div>;
+      // },
     },
 
     {
@@ -266,49 +280,85 @@ const openModal = () => {
 };
 
 const submitForm = () => {
-  console.log(fileList.value, "ass");
-  // byform.value.handleSubmit((valid) => {
-  //   submitLoading.value = true;
-  //   proxy.post("/productionProcesses/" + modalType.value, formData.data).then(
-  //     (res) => {
-  //       ElMessage({
-  //         message: modalType.value == "add" ? "添加成功" : "编辑成功",
-  //         type: "success",
-  //       });
-  //       dialogVisible.value = false;
-  //       submitLoading.value = false;
-  //       getList();
-  //     },
-  //     (err) => {
-  //       console.log(err, "aswwwww");
-  //       submitLoading.value = false;
-  //     }
-  //   );
-  // });
+  if (fileList.value.length > 0) {
+    byform.value.handleSubmit((valid) => {
+      formData.data.fileList = fileList.value;
+      submitLoading.value = true;
+      proxy.post("/productionProcesses/" + modalType.value, formData.data).then(
+        (res) => {
+          ElMessage({
+            message: modalType.value == "add" ? "添加成功" : "编辑成功",
+            type: "success",
+          });
+          fileList.value = [];
+          dialogVisible.value = false;
+          submitLoading.value = false;
+          getList();
+        },
+        (err) => {
+          console.log(err, "aswwwww");
+          submitLoading.value = false;
+        }
+      );
+    });
+  } else {
+    return ElMessage({
+      message: "请上传附件!",
+      type: "info",
+    });
+  }
 };
 
 const getDtl = (row) => {
   modalType.value = "edit";
   proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
-    res.type = res.type + "";
+    fileList.value = [
+      {
+        id: "",
+        fileName: res.fileName,
+        path: "",
+      },
+    ];
     formData.data = res;
-    console.log(formData);
     dialogVisible.value = true;
   });
 };
 const handleBeforeUpload = async (file) => {
   const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
   uploadData.value = res.uploadBody;
+  fileList.value = [
+    {
+      id: res.id,
+      fileName: res.fileName,
+      path: res.fileUrl,
+    },
+  ];
+};
+const handleClickFile = (row) => {
+  ElMessage({
+    message: "数据请求中,请稍后!",
+    type: "success",
+  });
+  let id = row.id;
+  proxy.post("/fileInfo/getList", { businessIdList: [id] }).then((res) => {
+    const file = res[id];
+    window.open(file.fileUrl, "_blank");
+  });
 };
 
-const handlePreview = () => {};
-const handleSuccess = (res) => {
-  console.log(res);
+const handlePreview = (file) => {
+  console.log(file);
+};
+const handleSuccess = (file) => {
+  console.log(file);
+};
+const handleRemove = (file) => {
+  fileList.value = [];
 };
-const handleRemove = (res) => {
-  console.log(res);
+const handleClose = (index) => {
+  fileList.value.splice(index, 1);
 };
-// getList();
+getList();
 </script>
   
 <style lang="scss" scoped>