刘恒 1 год назад
Родитель
Сommit
628a5a4866

+ 1 - 0
package.json

@@ -45,6 +45,7 @@
     "vue-demi": "^0.14.6",
     "vue-dialog-drag": "^0.1.29",
     "vue-directive-window": "^0.8.0",
+    "vue-doc-preview": "^0.3.2",
     "vue-draggable-resizable-gorkys": "^2.4.8",
     "vue-i18n": "^8.22.3",
     "vue-multiselect": "^2.1.6",

+ 2 - 2
src/http/moudules/contract.js

@@ -50,9 +50,9 @@ export const editorShow = (data) => {
 //下载附件
 export const downloadFile = (data) => {
     return axios({
-        url: '/upload/file/' + data,
+        url: '/upload/file' + data,
         method: 'get',
-        data
+        responseType: 'blob'
     })
 }
 //补充协议

+ 155 - 39
src/views/FinancialManagement/ContractManagement/ContractManagement.vue

@@ -30,7 +30,8 @@
               }"
               clearable
               filterable
-              v-model="formInline.supplierId"
+              v-model="formInline.supplierIdList"
+              size="small"
             ></el-cascader>
             <!-- <el-select
               v-model="formInline.user"
@@ -214,7 +215,8 @@
           </el-tag>
         </template>
       </el-table-column>
-      <!-- <el-table-column prop="expiringDate" label="顺延时间"> </el-table-column> -->
+      <el-table-column prop="shouldPostponedDate" label="顺延时间">
+      </el-table-column>
 
       <el-table-column
         prop="shouldPostponedEffectiveDate"
@@ -415,9 +417,19 @@
             :span="24"
             v-show="form.contractType == '1' || form.contractType == '2'"
           >
-            <el-form-item label="供应商" label-width="130px" class="supplier">
+            <el-form-item
+              label="供应商"
+              label-width="130px"
+              class="supplier"
+              :prop="
+                form.contractType == '1' || form.contractType == '2'
+                  ? 'supplierIdList'
+                  : '123'
+              "
+            >
               <!-- <treeSelect :options="esmInsCompanyList" @getValue="getValue" /> -->
               <treeselect
+                style="width: 600px"
                 v-model="form.supplierIdList"
                 placeholder="请选择"
                 :options="esmInsCompanyList"
@@ -465,7 +477,11 @@
             <el-form-item
               label="失效日期"
               label-width="130px"
-              :prop="form.isOpenContract == '0' ? 'expiringDate' : '1'"
+              :prop="
+                form.isOpenContract == '0' || form.shouldPostponed == '0'
+                  ? 'expiringDate'
+                  : '1'
+              "
             >
               <!-- {{ form.contractType }} -->
               <el-date-picker
@@ -482,8 +498,18 @@
           </el-col>
           <el-col :span="24">
             <el-form-item label="是否顺延" label-width="130px">
-              <el-radio v-model="form.shouldPostponed" label="0">是</el-radio>
-              <el-radio v-model="form.shouldPostponed" label="1">否</el-radio>
+              <el-radio
+                v-model="form.shouldPostponed"
+                label="0"
+                @input="shouldPostponedChange"
+                >是</el-radio
+              >
+              <el-radio
+                v-model="form.shouldPostponed"
+                label="1"
+                @input="shouldPostponedChange"
+                >否</el-radio
+              >
             </el-form-item>
           </el-col>
           <el-col :span="24">
@@ -566,7 +592,7 @@
                 :file-list="form.filePathIdList"
                 :http-request="httpRequest"
                 :on-remove="handleRemove"
-                accept=".pdf,.doc,.docx"
+                accept=".pdf,.docx"
               >
                 <el-button size="small" type="primary">点击上传</el-button>
                 <!-- <div slot="tip" class="el-upload__tip">
@@ -579,17 +605,17 @@
       </el-row>
 
       <div slot="footer" class="dialog-footer">
-        <el-button @click="dialogVisible = false">取 消</el-button>
+        <el-button @click="cancel">取 消</el-button>
         <el-button type="primary" @click="submit">确 定</el-button>
       </div>
     </el-dialog>
     <el-dialog title="附件" :visible.sync="fileDialog" width="50%">
       <div class="block">
-        <el-carousel trigger="click" height="600px" :autoplay="false">
+        <el-carousel trigger="click" height="1200px" :autoplay="false">
           <el-carousel-item
             v-for="item in showFileList"
             :key="item.url"
-            style="height: 1400px; overflow-y: auto"
+            style="height: 1200px; overflow-y: auto"
           >
             <div
               style="
@@ -603,9 +629,21 @@
                 icon="el-icon-download"
                 size="small"
                 label="下载"
-                perms="fnc:contract:download"
+                :perms="
+                  isMessage
+                    ? 'fnc:contract:viewDownloadFile'
+                    : 'fnc:contract:download'
+                "
+                v-show="isMessage != true"
+                @click="downLoadFile(item)"
               ></kt-button>
             </div>
+
+            <!-- <vue-doc-preview
+              v-show="item.url != null ? item.url.includes('.doc') : false"
+              :value="base + item.url"
+              :type="'office'"
+            /> -->
             <vue-office-docx
               v-show="item.url != null ? item.url.includes('.docx') : false"
               :src="base + item.url"
@@ -667,12 +705,7 @@
             <div>{{ item.contractCode }}</div>
           </div>
           <el-row>
-            <el-form
-              :model="form"
-              :inline="true"
-              :disabled="true"
-              ref="ruleForm"
-            >
+            <el-form :model="form" :inline="true" :disabled="true">
               <el-col :span="12">
                 <el-form-item label="合同编号" label-width="130px">
                   <el-input
@@ -796,6 +829,7 @@
                 >
                   <!-- <treeSelect :options="esmInsCompanyList" @getValue="getValue" /> -->
                   <treeselect
+                    style="width: 600px"
                     v-model="item.supplierIdList"
                     placeholder="请选择"
                     :options="esmInsCompanyList"
@@ -948,6 +982,17 @@
                   只能上传jpg/png文件,且不超过500kb
                 </div> -->
                   </el-upload>
+                  <div>
+                    <kt-button
+                      @click="view(item.contractFileEntityList)"
+                      type="primary"
+                      icon="el-icon-view"
+                      size="small"
+                      label="预览"
+                      perms="fnc:contract:viewFile"
+                    >
+                    </kt-button>
+                  </div>
                 </el-form-item>
               </el-col>
             </el-form>
@@ -965,19 +1010,20 @@
 </template>
 
 <script>
-import treeSelect from "../../../components/TreeSelect/treeSelectCheck.vue";
 import moment from "moment"; //引入js日期处理类库
 import VueOfficeDocx from "@vue-office/docx";
 import VueOfficePdf from "@vue-office/pdf";
 import "@vue-office/docx/lib/index.css";
 import KtButton from "@/views/Core/KtButton";
 
+import VueDocPreview from "vue-doc-preview";
 export default {
   components: {
-    treeSelect,
     VueOfficeDocx,
     VueOfficePdf,
     KtButton,
+    KtButton,
+    VueDocPreview,
   },
   data() {
     return {
@@ -990,7 +1036,7 @@ export default {
         contractType: "",
         externalCompaniesId: "",
         internalCompanyId: "",
-        supplierId: "",
+        supplierIdList: [],
       },
       messageDialog: false,
       tableDialog: false,
@@ -1061,6 +1107,13 @@ export default {
             trigger: "change",
           },
         ],
+        effectiveDate: [
+          {
+            required: true,
+            message: "请选择生效日期",
+            trigger: "change",
+          },
+        ],
       },
       pickerOptionsEnd: {
         disabledDate: (time) => {
@@ -1076,9 +1129,8 @@ export default {
       tableData: [],
       statusTable: [],
       data: [],
-      date: "",
-      time: "",
 
+      date: "",
       month: "",
       year: "",
       days: "",
@@ -1096,8 +1148,11 @@ export default {
       operation: "",
       fileIdList: [],
       contractStatus: "",
+      shoulDisabled: true,
+      isMessage: false,
     };
   },
+
   computed: {},
   created() {},
   mounted() {
@@ -1108,6 +1163,39 @@ export default {
     this.resetForm = { ...this.form };
   },
   methods: {
+    downLoadFile(row) {
+      let name = row.fileName;
+      fetch(`${process.env.BASE_URL}${row.url}`)
+        .then((response) => response.blob())
+        .then((blob) => {
+          this.saveAs(blob, name);
+        })
+        .catch((error) => {});
+    },
+    saveAs(blob, filename) {
+      var link = document.createElement("a");
+      link.href = window.URL.createObjectURL(blob);
+      link.target = "_ blank";
+      link.download = filename;
+      link.click();
+    },
+    view(row) {
+      this.isMessage = true;
+      this.fileDialog = true;
+      this.showFileList = [...row];
+    },
+    shouldPostponedChange(val) {
+      if (val == 0) {
+        this.shoulDisabled = true;
+      } else {
+        this.shoulDisabled = false;
+      }
+      this.date = "";
+      this.month = "";
+      this.year = "";
+      this.days = "";
+    },
+
     handleSizeChange(val) {
       // console.log(`每页 ${val} 条`);
 
@@ -1159,7 +1247,10 @@ export default {
                 // contractName: res.data.contractName,
                 externalCompaniesId: res.data.externalCompaniesId,
                 internalCompanyId: res.data.internalCompanyId,
-                supplierIdList: res.data.supplierIdList,
+                supplierIdList:
+                  res.data.supplierIdList != null
+                    ? res.data.supplierIdList
+                    : [],
                 // isOpenContract: res.data.isOpenContract,
                 // effectiveDate: res.data.effectiveDate,
                 // expiringDate: res.data.expiringDate,
@@ -1192,6 +1283,7 @@ export default {
               }
               if (commad == "watch") {
                 this.fileDialog = true;
+                this.isMessage = false;
               }
             }
           });
@@ -1236,6 +1328,7 @@ export default {
           });
       }
       if (commad == "message") {
+        this.statusTable = [];
         this.messageDialog = true;
 
         this.$api.contract
@@ -1247,12 +1340,16 @@ export default {
               let arr = [];
               res.data.forEach((v, i) => {
                 arr.push(v);
-                v.contractFileEntityList.forEach((item, index) => {
-                  arr[i].contractFileEntityList[index] = {
-                    name: item.fileName,
-                    url: item.url,
-                  };
-                });
+                if (v.contractFileEntityList != null) {
+                  v.contractFileEntityList.forEach((item, index) => {
+                    arr[i].contractFileEntityList[index] = {
+                      name: item.fileName,
+                      url: item.url,
+                    };
+                  });
+                } else {
+                  v.contractFileEntityList = [];
+                }
               });
               // console.log(arr);
               this.statusTable = [...arr];
@@ -1302,11 +1399,15 @@ export default {
         }
       });
     },
+    cancel() {
+      this.form = {};
+      this.dialogVisible = false;
+      this.$nextTick(() => {
+        this.$refs.ruleForm.clearValidate();
+      });
+    },
     //新增
     submit() {
-      // console.log(this.form.supplierIdList);
-      // console.log(this.fileIdList);
-
       this.$refs["ruleForm"].validate((valid) => {
         if (valid) {
           if (this.operation != "supplement") {
@@ -1318,6 +1419,9 @@ export default {
                   ...this.supplierIdChildList,
                 ],
                 filePathIdList: this.fileIdList,
+                yearTime: this.date == "year" ? this.year : "",
+                monthTime: this.date == "month" ? this.month : "",
+                dayTime: this.date == "day" ? this.days : "",
               })
               .then((res) => {
                 if (res.code === 200) {
@@ -1328,7 +1432,7 @@ export default {
                   });
                   this.getList();
                 } else {
-                  this.$message.success(res.msg);
+                  this.$message.error(res.msg);
                 }
               });
           } else {
@@ -1340,6 +1444,9 @@ export default {
                   ...this.supplierIdChildList,
                 ],
                 filePathIdList: this.fileIdList,
+                yearTime: this.date == "year" ? this.year : "",
+                monthTime: this.date == "month" ? this.month : "",
+                dayTime: this.date == "day" ? this.days : "",
               })
               .then((res) => {
                 if (res.code === 200) {
@@ -1350,7 +1457,7 @@ export default {
                   });
                   this.getList();
                 } else {
-                  this.$message.success(res.msg);
+                  this.$message.error(res.msg);
                 }
               });
           }
@@ -1436,16 +1543,17 @@ export default {
     },
 
     timeChange(type) {
+      let date = moment().format("YYYY-MM-DD HH:mm:ss");
       if (type == "year") {
-        this.form.shouldPostponedEffectiveDate = moment(this.form.expiringDate)
+        this.form.shouldPostponedEffectiveDate = moment(date)
           .add(this[type], "year")
           .format("YYYY-MM-DD HH:mm:ss");
       } else if (type == "month") {
-        this.form.shouldPostponedEffectiveDate = moment(this.form.expiringDate)
+        this.form.shouldPostponedEffectiveDate = moment(date)
           .add(this[type], "month")
           .format("YYYY-MM-DD HH:mm:ss");
       } else {
-        this.form.shouldPostponedEffectiveDate = moment(this.form.expiringDate)
+        this.form.shouldPostponedEffectiveDate = moment(date)
           .add(this[type], "days")
           .format("YYYY-MM-DD HH:mm:ss");
       }
@@ -1453,6 +1561,11 @@ export default {
     },
     handleClose(done) {
       done();
+      this.form = {};
+      this.dialogVisible = false;
+      this.$nextTick(() => {
+        this.$refs.ruleForm.clearValidate();
+      });
     },
     addContract() {
       this.dialogVisible = true;
@@ -1461,6 +1574,9 @@ export default {
       this.form = { ...this.resetForm };
       this.form.filePathIdList = [];
       this.fileIdList = [];
+      this.year = "";
+      this.month = "";
+      this.days = "";
       this.$nextTick(() => {
         this.$refs.ruleForm.clearValidate();
       });
@@ -1482,7 +1598,8 @@ export default {
               contractName: res.data.contractName,
               externalCompaniesId: res.data.externalCompaniesId,
               internalCompanyId: res.data.internalCompanyId,
-              supplierIdList: res.data.supplierIdList,
+              supplierIdList:
+                res.data.supplierIdList != null ? res.data.supplierIdList : [],
               isOpenContract: res.data.isOpenContract,
               effectiveDate: res.data.effectiveDate,
               expiringDate: res.data.expiringDate,
@@ -1492,7 +1609,6 @@ export default {
               externType: res.data.externType,
               internalType: res.data.internalType,
               id: res.data.id,
-
               filePathIdList: res.data.contractFileEntityList
                 ? res.data.contractFileEntityList.map((v, i) => {
                     return { name: v.fileName, url: v.url, id: v.fileId };

+ 20 - 0
src/views/FinancialManagement/ContractManagement/ContractStatement.vue

@@ -20,6 +20,7 @@
         <el-col :span="6">
           <el-form-item label="供应商名称">
             <el-cascader
+              v-model="formInline.supplierIdList"
               :options="esmInsCompanyList"
               :props="{
                 checkStrictly: true,
@@ -27,6 +28,7 @@
                 label: 'name',
                 children: 'children',
               }"
+              filterable
               clearable
             ></el-cascader>
             <!-- <el-select
@@ -205,6 +207,7 @@
                 size="small"
                 label="下载"
                 perms="fnc:contract:reportDownloadFile"
+                @click="downLoadFile(item)"
                 >下载</kt-button
               >
             </div>
@@ -247,6 +250,7 @@ export default {
         contractType: "",
         externalCompaniesId: "",
         internalCompanyId: "",
+        supplierIdList: [],
       },
       tableData: [],
       fileDialog: false,
@@ -271,6 +275,22 @@ export default {
     this.getInvAccountList();
   },
   methods: {
+    downLoadFile(row) {
+      let name = row.fileName;
+      fetch(`${process.env.BASE_URL}${row.url}`)
+        .then((response) => response.blob())
+        .then((blob) => {
+          this.saveAs(blob, name);
+        })
+        .catch((error) => {});
+    },
+    saveAs(blob, filename) {
+      var link = document.createElement("a");
+      link.href = window.URL.createObjectURL(blob);
+      link.target = "_ blank";
+      link.download = filename;
+      link.click();
+    },
     handleSizeChange(val) {
       // console.log(`每页 ${val} 条`);