From 27f1dd377b8bc68dc2a3b20ab78ac468871c58bd Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Thu, 09 Feb 2023 05:47:11 +0000
Subject: [PATCH] 修改

---
 eladmin-web-master/src/views/system/userContract/index.vue |   73 ++++++++++++++++++++++++++++++------
 1 files changed, 60 insertions(+), 13 deletions(-)

diff --git a/eladmin-web-master/src/views/system/userContract/index.vue b/eladmin-web-master/src/views/system/userContract/index.vue
index f8c4ff4..ef3592f 100644
--- a/eladmin-web-master/src/views/system/userContract/index.vue
+++ b/eladmin-web-master/src/views/system/userContract/index.vue
@@ -15,7 +15,7 @@
           v-model="query.contractName"
           clearable
           size="small"
-          placeholder="输入合同名称"
+          placeholder="合同名称"
           style="width: 200px;"
           class="filter-item"
           @keyup.enter.native="crud.toQuery"
@@ -24,23 +24,23 @@
           v-model="query.contractStartTime"
           type="daterange"
           clearable
-          class="filter-item"
+          class="date-item"
           value-format="yyyy-MM-dd HH:mm:ss"
           placeholder="请选择日期时间"
-          range-separator="至"
-          start-placeholder="合同开始日期"
-          end-placeholder="合同开始日期"
+          range-separator=" : "
+          start-placeholder="开始日期"
+          end-placeholder="开始日期"
         />
         <el-date-picker
           v-model="query.contractEndTime"
           type="daterange"
           clearable
-          class="filter-item"
+          class="date-item"
           value-format="yyyy-MM-dd HH:mm:ss"
           placeholder="请选择日期时间"
-          range-separator="至"
-          start-placeholder="合同结束日期"
-          end-placeholder="合同结束日期"
+          range-separator=" : "
+          start-placeholder="结束日期"
+          end-placeholder="结束日期"
         />
         <el-select v-model="query.companyId" filterable clearable placeholder="所属公司" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
           <el-option
@@ -106,10 +106,13 @@
           <el-form-item label="备注" prop="remarks">
             <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" />
           </el-form-item>
+          <el-form-item label="相关文件" prop="relatedDocuments">
+            <file-upload :key="random" ref="fileUpload" :file-url="form.relatedDocuments == null || form.relatedDocuments === '' ? null : form.relatedDocuments" :limit="5" @fileInfo="getFileInfo" />
+          </el-form-item>
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="text" @click="crud.cancelCU">取消</el-button>
-          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
+          <el-button :loading="crud.status.cu === 2" type="primary" @click="submitCU">确认</el-button>
         </div>
       </el-dialog>
       <!--表格渲染-->
@@ -162,11 +165,12 @@
 import pagination from '@crud/Pagination'
 import crudSysUserCompany from '@/api/system/sysUserCompany'
 import crudUser from '@/api/system/user'
+import fileUpload from '../../assembly/fileUpload/index.vue'
 
-const defaultForm = { id: null, userId: null, contractName: null, contractStartTime: null, contractEndTime: null, companyId: null, createBy: null, createTime: null, updateBy: null, updateTime: null, remarks: null }
+const defaultForm = { id: null, userId: null, contractName: null, contractStartTime: null, contractEndTime: null, companyId: null, createBy: null, createTime: null, updateBy: null, updateTime: null, relatedDocuments: null, remarks: null }
 export default {
   name: 'SysUserContract',
-  components: { pagination, crudOperation, rrOperation, udOperation },
+  components: { pagination, crudOperation, rrOperation, udOperation, fileUpload },
   mixins: [presenter(), header(), form(defaultForm), crud()],
   cruds() {
     return CRUD({ title: '合同部分', url: 'api/sysUserContract', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSysContract }})
@@ -197,7 +201,9 @@
         ]
       },
       companyList: [],
-      users: [] }
+      users: [],
+      // 随机数
+      random: 0 }
   },
   methods: {
     [CRUD.HOOK.beforeRefresh]() {
@@ -208,6 +214,12 @@
         this.companyList = res
       })
       return true
+    },
+    // 钩子:开始 "新建/编辑" - 之前
+    [CRUD.HOOK.beforeToCU]() {
+      const that = this
+      // 随机数
+      that.random = Math.random()
     },
     // 查询员工
     getUsers() {
@@ -227,6 +239,41 @@
       } else {
         this.form.companyId = null
       }
+    },
+    // 表单提交
+    submitCU() {
+      const that = this
+      // 通过“that.$refs.fileUpload”找到子页面,“submit”是子页面的方法。
+      that.$refs.fileUpload.submit()
+    },
+    // 获取文件信息
+    getFileInfo(info) {
+      const that = this
+      // 判断返回数据
+      if (info.length === 0) {
+        // 表单文件路径赋值
+        that.crud.form.relatedDocuments = null
+        // 表单提交
+        that.crud.submitCU()
+        // 终止
+        return
+      }
+      // 循环返回数据
+      for (let i = 0; i < info.length; i++) {
+        // 判断循环下标
+        if (i === 0) {
+          // 表单文件路径赋值
+          that.crud.form.relatedDocuments = info[i].response == null || info[i].response === '' ? info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : '/file/' + info[i].response.type + '/' + info[i].response.realName
+        } else {
+          // 表单文件路径赋值
+          that.crud.form.relatedDocuments += info[i].response == null || info[i].response === '' ? ',' + info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : ',/file/' + info[i].response.type + '/' + info[i].response.realName
+        }
+        // 判断循环是否结束
+        if (i === info.length - 1) {
+          // 表单提交
+          that.crud.submitCU()
+        }
+      }
     }
   }
 }

--
Gitblit v1.9.3