Forráskód Böngészése

采购订单整单回退、新增附件管理

002390 2 éve
szülő
commit
b5d3a917e2

+ 8 - 0
src/views/purchase/purchase-order/add/column.js

@@ -138,6 +138,7 @@ export const Columns = [
     title: "单据状态",
     inputType: "Select",
     referName: "sys_status", // 字典名
+    disabled: true,
   },
   { key: "freezeCause", title: "冻结原因", inputType: "Checkbox", },
   { key: "isBack", title: "退货", inputType: "Input", inputType: "Checkbox", },
@@ -321,6 +322,13 @@ export const Columns = [
     inputType: "DatePicker",
     valueFormat: "yyyy-MM-dd",
   },
+  {
+    key: "sysFileRecordList",
+    title: "附件",
+    inputType: "Upload",
+    // fileType: ["pdf",""],
+    span: 24
+  },
 
 ];
 

+ 13 - 20
src/views/purchase/purchase-order/add/index.vue

@@ -15,12 +15,13 @@ NewTabColumns.forEach((column) => {
     ...column.tableColumns.filter((cColumn) => cColumn.inputType === "Select")
   );
 });
-console.log(SelectColumns, 'SelectColumns');
 
 export default {
   name: "AddPurchaseOrderDrawer",
   dicts: initDicts(SelectColumns),
-  components: {},
+  components: {
+    FileUploadCenter: () => import('../components/FileUploadCenter/index.vue'),
+  },
 
   data() {
     return {
@@ -87,7 +88,7 @@ export default {
       this.params.buyerName = nickName;
       this.params.puDept = deptId;
       this.params.puDeptName = deptName;
-      this.params.status = '0';
+      // this.params.status = '0';
 
     },
     setVisible(prop) {
@@ -195,16 +196,18 @@ export default {
     // 保存
     async handleSava() {
       // orderAddForm
-      console.log(this.params, "params");
+      console.log(this.params.sysFileRecordList, "params");
+
+      this.params.sysFileRecordList.forEach(item => {
+
+        item['']
+      })
       // this.$refs['orderAddForm'].validate(async (valid) => {
       //   if (valid) {
       try {
         const { code, msg } = await orderApi.create(this.params);
         if (code === 200) {
-          this.$notify.success({ title: msg });
           this.setVisible(false);
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
         //
@@ -234,10 +237,7 @@ export default {
               ...this.params,
             });
             if (code === 200) {
-              this.$notify.success({ title: msg });
               this.setVisible(false);
-            } else {
-              this.$notify.warning({ title: msg });
             }
           } catch (err) {
             this.$notify.error({ title: "error", message: err });
@@ -361,16 +361,9 @@ export default {
               <el-checkbox v-if="column.inputType === 'Checkbox'" v-model="params[column.key]" true-label="Y"
                 false-label="N">
               </el-checkbox>
-              <el-upload v-if="column.inputType === 'Upload'" :file-list="params[column.key]" :disabled="column.disabled"
-                drag action="https://jsonplaceholder.typicode.com/posts/" multiple>
-                <i class="el-icon-upload"></i>
-                <div class="el-upload__text">
-                  将文件拖到此处,或<em>点击上传</em>
-                </div>
-                <div class="el-upload__tip" slot="tip">
-                  只能上传jpg/png文件,且不超过500kb
-                </div>
-              </el-upload>
+              <file-upload-center v-if="column.inputType === 'Upload'" v-model="params[column.key]"
+                :file-type="column.fileType">
+              </file-upload-center>
             </el-form-item>
           </el-col>
         </el-row>

+ 225 - 0
src/views/purchase/purchase-order/components/FileUploadCenter/index.vue

@@ -0,0 +1,225 @@
+<template>
+  <div class="upload-file">
+    <el-upload multiple :action="uploadFileUrl" :before-upload="handleBeforeUpload" :file-list="fileList" :limit="limit"
+      :on-error="handleUploadError" :on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="false"
+      class="upload-file-uploader" ref="fileUpload">
+      <!-- 上传按钮 -->
+      <el-button size="mini" type="primary">选取文件</el-button>
+      <!-- 上传提示 -->
+      <div class="el-upload__tip" slot="tip" v-if="showTip">
+        请上传
+        <template v-if="fileSize">
+          大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
+        </template>
+        <template v-if="fileType">
+          格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b>
+        </template>
+        的文件
+      </div>
+    </el-upload>
+
+    <!-- 文件列表 -->
+    <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
+
+      <li :key="file.fileUrl" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
+        <el-link :href="`${baseUrl}${file.fileUrl}`" :underline="false" target="_blank">
+          <!-- <span class="el-icon-document"> {{ getFileName(file.name) }} </span> -->
+          <span class="el-icon-document"> {{ file.fileName }} </span>
+        </el-link>
+        <div class="ele-upload-list__item-content-action">
+          <el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
+        </div>
+      </li>
+    </transition-group>
+  </div>
+</template>
+
+<script>
+import { getToken } from "@/utils/auth";
+
+export default {
+  name: "FileUploadCenter",
+  props: {
+    // 值
+    value: [String, Object, Array],
+    // 数量限制
+    limit: {
+      type: Number,
+      default: 5,
+    },
+    // 大小限制(MB)
+    fileSize: {
+      type: Number,
+      default: 5,
+    },
+    // 文件类型, 例如['png', 'jpg', 'jpeg']
+    fileType: {
+      type: Array,
+      default: () => ["doc", "xls", "ppt", "txt", "pdf"],
+    },
+    // 是否显示提示
+    isShowTip: {
+      type: Boolean,
+      default: true,
+    },
+  },
+  data() {
+    console.log(process.env, 'process.env');
+    return {
+      number: 0,
+      uploadList: [],
+      baseUrl: '/file',
+      uploadFileUrl: '/file' + "/document-center/fastdfs/upload", // 上传文件服务器地址
+      fileList: [],
+    };
+  },
+  watch: {
+    value: {
+      handler(val) {
+        this.fileList = val ? val : [];
+
+        return this.fileList;
+        // if (val) {
+        //   let temp = 1;
+        //   // 首先将值转为数组
+        //   const list = Array.isArray(val) ? val : this.value.split(",");
+        //   console.log("list", list);
+        //   // 然后将数组转为对象数组
+        //   this.fileList = list.map((item) => {
+        //     if (typeof item === "string") {
+        //       item = { name: item, url: item };
+        //     }
+        //     item.uid = item.uid || new Date().getTime() + temp++;
+        //     return item;
+        //   });
+        // } else {
+        //   this.fileList = [];
+        //   return [];
+        // }
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
+  computed: {
+    // 是否显示提示
+    showTip() {
+      return this.isShowTip && (this.fileType || this.fileSize);
+    },
+  },
+  methods: {
+    // 上传前校检格式和大小
+    handleBeforeUpload(file) {
+      // 校检文件类型
+      if (this.fileType) {
+        const fileName = file.name.split(".");
+        const fileExt = fileName[fileName.length - 1];
+        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
+        if (!isTypeOk) {
+          this.$modal.msgError(
+            `文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
+          );
+          return false;
+        }
+      }
+      // 校检文件大小
+      if (this.fileSize) {
+        const isLt = file.size / 1024 / 1024 < this.fileSize;
+        if (!isLt) {
+          this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
+          return false;
+        }
+      }
+      this.$modal.loading("正在上传文件,请稍候...");
+      this.number++;
+      return true;
+    },
+    // 文件个数超出
+    handleExceed() {
+      this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
+    },
+    // 上传失败
+    handleUploadError(err) {
+      this.$modal.msgError("上传文件失败,请重试");
+      this.$modal.closeLoading();
+    },
+    // 上传成功回调
+    handleUploadSuccess(res, file) {
+      if (res.code == 200) {
+        console.log(res, 'res--------------');
+        this.uploadList.push({
+          fileName: res.filename,
+          fileUrl: `/${res.group}/${res.filepath}`,
+          fileFastId: res.id,
+        });
+        this.uploadedSuccessfully();
+      } else {
+        this.number--;
+        this.$modal.closeLoading();
+        this.$modal.msgError(res.msg);
+        this.$refs.fileUpload.handleRemove(file);
+        this.uploadedSuccessfully();
+      }
+    },
+    // 删除文件
+    handleDelete(index) {
+      this.fileList.splice(index, 1);
+      // this.$emit("input", this.listToString(this.fileList));
+      this.$emit("input", this.fileList);
+    },
+    // 上传结束处理
+    uploadedSuccessfully() {
+      if (this.number > 0 && this.uploadList.length === this.number) {
+        this.fileList = this.fileList.concat(this.uploadList);
+        console.log(this.fileList, 'this.fileList***************');
+        this.uploadList = [];
+        this.number = 0;
+        // this.$emit("input", this.listToString(this.fileList));
+        this.$emit("input", this.fileList);
+        this.$modal.closeLoading();
+      }
+    },
+    // 获取文件名称
+    // getFileName(name) {
+    //   if (name.lastIndexOf("/") > -1) {
+    //     return name.slice(name.lastIndexOf("/") + 1);
+    //   } else {
+    //     return "";
+    //   }
+    // },
+    // 对象转成指定字符串分隔
+    // listToString(list, separator) {
+    //   let strs = "";
+    //   separator = separator || ",";
+    //   for (let i in list) {
+    //     strs += list[i].url + separator;
+    //   }
+    //   return strs != "" ? strs.substr(0, strs.length - 1) : "";
+    // },
+  },
+};
+</script>
+
+<style scoped lang="scss">
+.upload-file-uploader {
+  margin-bottom: 5px;
+}
+
+.upload-file-list .el-upload-list__item {
+  border: 1px solid #e4e7ed;
+  line-height: 2;
+  margin-bottom: 10px;
+  position: relative;
+}
+
+.upload-file-list .ele-upload-list__item-content {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  color: inherit;
+}
+
+.ele-upload-list__item-content-action .el-link {
+  margin-right: 10px;
+}
+</style>

+ 7 - 19
src/views/purchase/purchase-order/edit/index.vue

@@ -19,7 +19,7 @@ export default {
   name: "EditPurchaseOrderDrawer",
   dicts: initDicts(SelectColumns),
   components: {
-
+    FileUploadCenter: () => import('../components/FileUploadCenter/index.vue'),
   },
   data() {
     return {
@@ -95,9 +95,6 @@ export default {
           this.params = { ...this.params, ...data };
           console.log(this.params, 'this.params----------123');
           this.handleIsForbidden(this.params.status);
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
         //
@@ -157,9 +154,6 @@ export default {
         )
         if (code === 200) {
           this.setVisible(false);
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
         }
       } catch (err) {
         //
@@ -287,16 +281,9 @@ export default {
               <el-checkbox v-if="column.inputType === 'Checkbox'" v-model="params[column.key]" :disabled="column.disabled"
                 true-label="Y" false-label="N">
               </el-checkbox>
-              <el-upload v-if="column.inputType === 'Upload'" :file-list="params[column.key]" :disabled="column.disabled"
-                drag action="https://sy.derom.com/document-center/fastdfs/upload" multiple>
-                <i class="el-icon-upload"></i>
-                <div class="el-upload__text">
-                  将文件拖到此处,或<em>点击上传</em>
-                </div>
-                <!-- <div class="el-upload__tip" slot="tip">
-                  只能上传jpg/png文件,且不超过500kb
-                </div> -->
-              </el-upload>
+              <file-upload-center v-if="column.inputType === 'Upload'" v-model="params[column.key]"
+                :file-type="column.fileType">
+              </file-upload-center>
             </el-form-item>
           </el-col>
         </el-row>
@@ -360,7 +347,7 @@ export default {
               编辑:自制:可删可增 -->
               <el-table-column fixed="right" label="操作" width="120">
                 <template slot-scope="scope">
-                  <el-button  v-if="params.source == '3'&& !handleIsRevise(params.status)" @click.native.prevent="
+                  <el-button v-if="params.source == '3' && !handleIsRevise(params.status)" @click.native.prevent="
                     delTableRow(params[tabName], scope.$index)
                     " type="text" size="small">
                     删行
@@ -371,7 +358,8 @@ export default {
           </el-tab-pane>
         </el-tabs>
         <el-row style="position: absolute; top: 20px; right: 20px">
-          <el-button v-if="params.source == '3'&& !handleIsRevise(params.status)" :size="size" @click="addTableRow(params[tabName])">增行</el-button>
+          <el-button v-if="params.source == '3' && !handleIsRevise(params.status)" :size="size"
+            @click="addTableRow(params[tabName])">增行</el-button>
         </el-row>
       </el-card>
     </el-form>

+ 18 - 24
src/views/purchase/purchase-order/index.vue

@@ -40,7 +40,6 @@ export default {
         puOrderExecuteList: [],
       },
       checkedList: [],
-      checkedTabList: [],
     };
   },
   computed: {
@@ -63,7 +62,6 @@ export default {
         if (code === 200) {
           this.page.total = total;
           this.tableData = rows;
-          this.$notify.success({ title: msg });
         }
       } catch (err) {
         //
@@ -73,9 +71,9 @@ export default {
     },
     handleSearchChange() {
       this.isSimpleSearch = !this.isSimpleSearch;
-      this.$notify.info({
-        title: this.isSimpleSearch ? "Simple Search" : "All Search",
-      });
+      // this.$notify.info({
+      //   title: this.isSimpleSearch ? "Simple Search" : "All Search",
+      // });
     },
     // 页大小变
     handleSizeChange(prop) {
@@ -146,7 +144,6 @@ export default {
           for (const key in this.tabTableDatas) {
             this.tabTableDatas[key] = data[key];
           }
-          this.$notify.success({ title: msg });
         }
       } catch (err) {
         //
@@ -190,18 +187,17 @@ export default {
     },
     // 判断“退回”按钮
     judgeIsAllSendBack() {
-
       if (this.checkedList.length == 1) {
 
         // 非手工、状态非审批通过  
-        if (this.checkedList[0].source != 3 && this.checkedList[0].status != 2) {
+        if (this.checkedList[0].source != 3 && (this.checkedList[0].status == 0 || this.checkedList[0].status == 3)) {
 
           return false
         }
       }
       return true;
     },
-    //  退回
+    //  整单退回
     handleAllSendBack() {
       let data = {
         id: this.checkedList[0].id,
@@ -211,7 +207,7 @@ export default {
       console.log(data);
       try {
         this.loading = true;
-        // let { code, msg } = orderApi.documentsReturn(data);
+        let { code, msg } = orderApi.documentsReturn(data);
 
       } catch (error) {
 
@@ -268,9 +264,6 @@ export default {
 
     },
 
-    handleTabSelect(selection, row) {
-      this.checkedTabList = selection; 
-    },
 
 
   },
@@ -311,22 +304,24 @@ export default {
     <el-row :gutter="24" style="padding: 0 20px">
       <!-- <el-col :span="6">123</el-col> -->
       <el-col :span="24" style="text-align: right;margin: 0 10px 0 0">
+
+        <!-- <el-button-group style="margin-left: 10px"> -->
+        <el-button size="mini" type="primary" plain @click="handleOpenAddDrawer"
+          v-hasPermi="['material:order:add']">新增</el-button>
+        <!-- </el-button-group> -->
+
         <el-button-group style="margin-left: 10px">
-          <el-button size="mini" type="danger" @click="handleOpenAddDrawer"
-            v-hasPermi="['material:order:add']">新增</el-button>
           <el-button size="mini" :disabled="checkedList.length != 1" @click="handleCopy">复制</el-button>
-
         </el-button-group>
 
-        <!-- <el-button-group style="margin-left: 10px">
-          <el-button size="mini" @click="handleAllSendBack" :key="checkedList.length"
-            :disabled="judgeIsAllSendBack()">整单退回</el-button>
-        </el-button-group> -->
+        <el-button-group style="margin-left: 10px" :key="checkedList.length + 1">
+          <el-button size="mini" @click="handleAllSendBack" :disabled="judgeIsAllSendBack()">整单退回</el-button>
+          <el-button size="mini" @click="handleAllClose" :disabled="judgeIsAllClose()">整单关闭</el-button>
+        </el-button-group>
 
         <el-button-group style="margin-left: 10px">
           <!-- <el-button size="mini">采购退货</el-button> -->
-          <el-button size="mini" @click="handleAllClose" :key="checkedList.length"
-            :disabled="judgeIsAllClose()">整单关闭</el-button>
+
           <!-- <el-button size="mini">附件管理</el-button>
           <el-button size="mini">单据追溯</el-button> -->
         </el-button-group>
@@ -373,9 +368,8 @@ export default {
     <el-tabs v-model="tabName" @tab-click="handleTabClick" style="width: 100%;padding: 20px 10px">
       <el-tab-pane v-for="(column, index) in tabColumns" :key="index" :label="column.title" :name="column.key">
 
-        <el-table :data="tabTableDatas[column.key]" style="width: 100%" highlight-current-row @select="handleTabSelect"
+        <el-table :data="tabTableDatas[column.key]" style="width: 100%" highlight-current-row
           :height="tabTableDatas[column.key].length ? 300 : 100">
-          <el-table-column type="selection" width="45"></el-table-column>
           <el-table-column type="index" width="50" label="序号"></el-table-column>
           <el-table-column v-for="(cColumn, cIndex)  in column.tableColumns" :key="cIndex" :prop="cColumn.key"
             :label="cColumn.title" :width="cColumn.width || 180"

+ 1 - 4
src/views/purchase/purchase-order/see/index.vue

@@ -53,10 +53,7 @@ export default {
         const { code, msg, data } = await orderApi.details(prop);
         if (code === 200) {
           this.params = data;
-          this.$notify.success({ title: msg });
-        } else {
-          this.$notify.warning({ title: msg });
-        }
+        } 
       } catch (err) {
         //
       } finally {

+ 7 - 2
vue.config.js

@@ -37,12 +37,12 @@ module.exports = {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
         // target: `http://172.16.100.107:8080/drp-admin`, //测试
-        // target: `http://test-sy.derom.com/drp-admin`, //测试
+        target: `http://test-sy.derom.com/drp-admin`, //测试
         // target: `http://release-sy.derom.com/drp-admin`, //预发
         // target: `http://sy.derom.com/drp-admin`, //生产
         // target: `http://172.16.63.202:8000/drp-admin`, // D本地
         // target: `http://172.16.62.241:8000/drp-admin`, //笑寒本地
-        target: `http://172.16.13.152:8000/drp-admin`, //豪哥本地
+        // target: `http://172.16.13.152:8000/drp-admin`, //豪哥本地
         // target: `http://172.16.13.47:8000/drp-admin`, //石杨本地
         // target: `http://172.16.13.113:8000/drp-admin`, //DWT本地
         // target: `http://172.16.13.77:8000/drp-admin`, //TQ本地
@@ -56,6 +56,11 @@ module.exports = {
         changeOrigin: true,
         pathRewrite: { [`^/drp-admin/mock34`]: "" },
       },
+      "/file": {
+        target: process.env.NODE_ENV == "development" ? `https://test-sy.derom.com` : `https://sy.derom.com`,
+        changeOrigin: true,
+        pathRewrite: { [`^/file`]: "" },
+      },
     },
     disableHostCheck: true,
   },