Browse Source

Merge branch 'dev_info' of https://git.agilestar.cn/spfm-group/spfm-market-front into dev_info

daiqisheng 3 years ago
parent
commit
29e42ab899

+ 47 - 11
src/pages/main/gridDivision/approvalExamination.vue

@@ -255,7 +255,7 @@ export default {
               sts: this.status + "",
             }))
           : [];
-        this.table_list && this.table_list[0].sts === "0"
+        this.table_list.length && this.table_list[0].sts === "0"
           ? (this.table_handle = [
               {
                 label: "返回",
@@ -300,8 +300,48 @@ export default {
       this.page = page;
       this.handleInit();
     },
-    handleDownload(data) {
-      console.log(data, "data");
+    handleDownload({index,rows}) {
+      let fileName = ''
+      let fileCode = ''
+      rows.attList.forEach((el,no) => {
+        if(no === index) {
+          fileName = el.fileName
+          fileCode = el.id
+        }
+      })
+      console.log(index,rows);
+      console.log(fileName,fileCode);
+      this.$http({
+        url: "/market/compatt/downfile",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json",
+        },
+        responseType: "blob",
+        data: { id: fileCode, fileName: fileName },
+      }).then((response) => {
+        if (window.navigator && window.navigator.msSaveOrOpenBlob) {
+          let blob = new Blob([response.data], {
+            type: "application/vnd.ms-excel",
+          });
+          window.navigator.msSaveOrOpenBlob(blob, fileName);
+        } else {
+          /* 火狐谷歌的文件下载方式 */
+          var blob = new Blob([response.data]);
+          var downloadElement = document.createElement("a");
+          var href = window.URL.createObjectURL(blob);
+          downloadElement.href = href;
+          downloadElement.download = fileName;
+          document.body.appendChild(downloadElement);
+          downloadElement.click();
+          document.body.removeChild(downloadElement);
+          window.URL.revokeObjectURL(href);
+        }
+      });
+
+
+      // // /market/compatt/downfile
+      // console.log(item);
     },
     handleVisible(props) {
       switch (props) {
@@ -351,7 +391,7 @@ export default {
     // 审批不通过
     handleBack(row) {
       // console.log(row);
-      this.ids = row.id.toString();
+      this.ids = row.wanggeId.toString();
       this.handleVisible("opinion");
       this.isAgree = false;
     },
@@ -362,12 +402,8 @@ export default {
         // 批量退回
         reqdata = {
           parentId: this.parentId,
-          mkWanggeList: [
-            {
-              id: this.ids,
-              remark: this.opinion_form.opinion,
-            },
-          ],
+          remark: this.opinion_form.opinion,
+          wanggeId: this.ids,
         };
         console.log(reqdata);
         this.$http({
@@ -403,7 +439,7 @@ export default {
           },
         }).then((res) => {
           console.log(res);
-          this.status = '1'
+          this.status = "1";
           this.handleInit();
         });
       }

+ 73 - 40
src/pages/main/gridDivision/workersList.vue

@@ -68,11 +68,12 @@
             class="upload-demo"
             drag
             :limit="3"
+            :on-exceed="uploadExceed"
             :on-remove="uploadRemove"
             :http-request="uploadBack"
             action="http://192.168.1.228:9600/spfm"
             multiple
-            :file-list="fileInfo.fileList"
+            :file-list="file"
           >
             <i class="el-icon-upload"></i>
             <div class="el-upload__text">
@@ -80,9 +81,9 @@
             </div>
           </el-upload>
           <div v-else>
-            <div v-if="fileInfo.fileList.length === 0">暂无附件</div>
+            <div v-if="file.length === 0">暂无附件</div>
             <div
-              v-for="(item, index) in fileInfo.fileList"
+              v-for="(item, index) in file"
               :key="index"
               class="simple-table-click cursor-pointer margin-left-10"
               @click="handleDownload(item)"
@@ -143,6 +144,9 @@
           <el-button @click="handleSubmit('failed')" type="default"
             >退回修改</el-button
           >
+          <el-button @click="handleVisible('add')" type="default"
+            >取消</el-button
+          >
         </div>
       </template>
     </simple-dialog>
@@ -222,10 +226,14 @@ export default {
           },
         ],
       },
-      file:[],
-      file1: '',
-      file2:'',
-      file3:'',
+      file: [],
+      file1: "",
+      file2: "",
+      file3: "",
+      // 删除的文件
+      delFile: "",
+      // 暂存删除文件
+      tmpDeleteFile: [],
       // 当前用户标识
       loginNoStr: "",
       fileInfo: {
@@ -395,10 +403,12 @@ export default {
         this.table_list = data
           ? data.map((element, index) => ({
               ...element,
-              id: element.id + '',
+              id: element.id + "",
               deal: element.draft === "1" && element.sts === "0" ? "1" : "0",
               isEdit:
-                element.draft === "0" && element.createId === this.loginNoStr && element.parentLevel === '0'
+                element.draft === "0" &&
+                element.createId === this.loginNoStr &&
+                element.parentLevel === "0"
                   ? "1"
                   : "0",
               No: index + 1,
@@ -423,7 +433,7 @@ export default {
           this.title = "新建";
           this.isCheck = false;
           this.add_form = {};
-          this.fileInfo.fileList = [];
+          this.file = [];
           break;
         case "summary":
           this.summary_visible = !this.summary_visible;
@@ -452,30 +462,47 @@ export default {
     },
     handleSelect(val) {
       this.summaryIds = val.map((item) => {
-        return item.wanggeId + '';
+        return item.wanggeId + "";
       });
       // console.log(this.summaryIds);
     },
     //文件返回值
     uploadBack({ file }) {
+      console.log({}.constructor.name, "obj");
+      console.log(file.constructor.name, "file");
+      // console.log( file instanceof Object,'sasdas');
       this.file.push(file);
       console.log(this.file);
-      this.file1 = this.file[0]
-      this.file2 = this.file[1]
-      this.file3 = this.file[2]
+      this.file1 = this.file[0];
+      this.file2 = this.file[1];
+      this.file3 = this.file[2];
     },
     // 删除文件
-    uploadRemove(file){
+    uploadRemove(file) {
       // console.log(file);
-      this.file.forEach((item,index) => {
-        if(item.uid === file.uid) {
-          this.file.splice(index,1)
+      this.file.forEach((item, index) => {
+        console.log(item, "rsr");
+        if (item.uid === file.uid) {
+          this.file.splice(index, 1);
+          if (item.id) {
+            this.tmpDeleteFile.push(item.id);
+            // this.delFile = this.delFile + item.id + ','
+            this.delFile = this.tmpDeleteFile.join(",");
+          }
         }
-      })
-      console.log(this.file);
-      this.file1 = this.file[0]
-      this.file2 = this.file[1]
-      this.file3 = this.file[2]
+      });
+      console.log(this.file, this.delFile);
+      this.file1 = this.file[0];
+      this.file2 = this.file[1];
+      this.file3 = this.file[2];
+    },
+    // 超出文件上传限制
+    uploadExceed(file) {
+      this.$message({
+        message: "附件最多可上传3个!",
+        type: "error",
+      });
+      console.log(file);
     },
     // 获取模态框信息
     getDialogData(row) {
@@ -492,7 +519,7 @@ export default {
           type,
         },
       }).then(({ data: { body } }) => {
-        console.log(body, "body");
+        // console.log(body, "body");
         this.ids = [body.wanggeId.toString()];
         this.add_form = {
           id: body.wanggeId,
@@ -508,10 +535,10 @@ export default {
               No: index + 1,
             }))
           : [];
-        this.fileInfo.fileList = body.attList
+        this.file = body.attList
           ? body.attList.map((item) => ({
               ...item,
-              name:item.fileName
+              name: item.fileName,
             }))
           : [];
       });
@@ -569,23 +596,29 @@ export default {
       this.$refs.add_ref.validate((valid) => {
         if (valid) {
           let formData = new FormData();
-          // this.file ? formData.append("file", this.file) : [] ;
-          this.file1 ? formData.append('file1',this.file1) : ''
-          this.file2 ? formData.append('file2',this.file2) : ''
-          this.file3 ? formData.append('file3',this.file3) : ''
-
+          // console.log(this.file1,'adasdsa')
           let reqdata = {
             ...this.add_form,
             procId: "729294602773110788",
             draft: draft,
             num: "1",
+            delFileId: this.delFile ? this.delFile : "",
           };
-          for(let key in reqdata) {
-            formData.append(key,reqdata[key])
+          // 这是处理文件的参数
+          this.file.forEach((el, index) => {
+            if (el.constructor.name === "File") {
+              formData.append(`file${index + 1}`, el);
+            }
+          });
+          // 表单的其他参数
+          for (let key in reqdata) {
+            formData.append(key, reqdata[key]);
           }
-          
-          console.log(formData);
-
+          // this.file1 ? formData.append("file1", this.file1) : "";
+          // this.file2 ? formData.append("file2", this.file2) : "";
+          // this.file3 ? formData.append("file3", this.file3) : "";
+          // this.file ? formData.append("file", this.file) : [] ;
+          // ;
           if (!this.approve_visible) {
             // 编辑/新增
             this.$http({
@@ -598,7 +631,7 @@ export default {
             }).then((res) => {
               console.log(res);
               this.handleInit();
-              this.handleVisible('add')
+              this.handleVisible("add");
             });
           } else {
             // 审批
@@ -620,12 +653,12 @@ export default {
             }).then((res) => {
               console.log(res);
               this.handleInit();
-              this.handleVisible('add')
+              this.handleVisible("add");
             });
           }
           // this.edit_visible = false;
           // this.add_visible = false;
-          this.fileInfo.fileList = [];
+          this.file = [];
         }
       });
     },
@@ -679,7 +712,7 @@ export default {
     handleDownload({ fileCode, fileName }) {
       console.log(fileCode, fileName);
       this.$http({
-        url: "/market/compatt/downfile",
+        url: "/bpm/api/download",
         method: "post",
         headers: {
           "Content-Type": "application/json",