Преглед изворни кода

导出功能及功能优化

lizhenhao пре 2 година
родитељ
комит
0fc0b9cca7

+ 8 - 0
src/api/cw/projectRecords/ProjectRecordsService.js

@@ -43,4 +43,12 @@ export default class ProjectRecordsService {
       data: data
     })
   }
+  exportFile (params) {
+    return request({
+      url: '/cwProjectRecords/export',
+      method: 'get',
+      params: params,
+      responseType: 'blob'
+    })
+  }
 }

+ 8 - 0
src/api/cw/projectRecords/ProjectReportArchiveService.js

@@ -50,4 +50,12 @@ export default class ProjectReportArchiveService {
       data: data
     })
   }
+  exportFile (params) {
+    return request({
+      url: '/cwProjectReportArchive/export',
+      method: 'get',
+      params: params,
+      responseType: 'blob'
+    })
+  }
 }

+ 8 - 0
src/api/cw/workClientInfo/WorkClientService.js

@@ -43,4 +43,12 @@ export default class WorkClientService {
       data: data
     })
   }
+  exportFile (params) {
+    return request({
+      url: '/cw_work_client/info/export',
+      method: 'get',
+      params: params,
+      responseType: 'blob'
+    })
+  }
 }

+ 12 - 2
src/views/modules/cw/projectRecords/ProjectRecordsForm.vue

@@ -19,8 +19,6 @@
             <el-col :span="24">
               <el-form-item label="合同名称" prop="contractName"
                             :rules="[
-                          {required: true, message:'合同不能为空', trigger:'blur'},
-                          {required: true, message:'合同不能为空', trigger:'change'}
                  ]">
                 <el-input size="medium" :readonly="true" @focus="openContract()" v-model="inputForm.contractName" placeholder="请选择合同">
                   <el-button slot="append" icon="el-icon-search" @click="openContract()"></el-button>
@@ -479,6 +477,17 @@
           // 暂存
           // this.inputForm.status = '1'
           this.loading = true
+          if (this.commonJS.isNotEmpty(this.inputForm.planEndDate) && this.commonJS.isNotEmpty(this.inputForm.planStartDate)) {
+            if (this.moment(this.inputForm.planEndDate).format('YYYY-MM-DD') < this.moment(this.inputForm.planStartDate).format('YYYY-MM-DD') || this.moment(this.inputForm.planEndDate).format('YYYY-MM-DD') === this.moment(this.inputForm.planStartDate).format('YYYY-MM-DD')) {
+              this.$message.error('项目预计开始时间要小于项目预计结束时间')
+              this.loading = false
+              throw new Error('项目预计开始时间要小于项目预计结束时间')
+            }
+          } else {
+            this.$message.error('“项目预计开始时间”和“项目预计结束时间”不允许为空')
+            this.loading = false
+            throw new Error('“项目预计开始时间”和“项目预计结束时间”不允许为空')
+          }
           if (this.$refs.uploadComponent.checkProgress()) {
             this.loading = false
             return
@@ -580,6 +589,7 @@
         }
         this.$refs.uploadComponent.clearUpload()
         this.$refs.inputForm.resetFields()
+        this.$emit('refreshList')
         this.visible = false
       },
       tabHandleClick (event) {

+ 47 - 10
src/views/modules/cw/projectRecords/ProjectRecordsList.vue

@@ -9,7 +9,8 @@
         <el-input size="small" v-model="searchForm.projectNumber" placeholder="请输入项目编号" clearable></el-input>
       </el-form-item>
       <el-form-item label="项目经理" prop="projectMasterName">
-        <el-input size="small" v-model="searchForm.projectMasterName" placeholder="请输入项目经理" clearable></el-input>
+<!--        <el-input size="small" v-model="searchForm.projectMasterName" placeholder="请输入项目经理" clearable></el-input>-->
+        <UserSelect :limit='1' :userName="searchForm.projectMasterName" @getValue='(value, label) => {searchForm.projectMasterName = label}'></UserSelect>
       </el-form-item>
       <el-form-item label="创建时间" prop="createDates">
         <el-date-picker
@@ -40,7 +41,7 @@
       </el-form-item>
     </el-form>
     <div class="bg-white top" style="">
-      <vxe-toolbar :refresh="{query: refreshList}" custom>
+      <vxe-toolbar :refresh="{query: refreshList}" export custom>
         <template #buttons>
           <el-button v-if="hasPermission('cwProjectRecords:add')" type="primary" size="small" icon="el-icon-plus" @click="start()">新建</el-button>
           <!--          <el-button v-if="hasPermission('klg:question:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.questionsTable && $refs.questionsTable.getCheckboxRecords().length === 0" plain>删除</el-button>-->
@@ -62,9 +63,18 @@
           :menu-config="{}"
           @sort-change="sortChangeHandle"
           :sort-config="{remote:true}"
+          :export-config="{
+                    remote: true,
+                    filename: `项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
+                    sheetName: `项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
+                    exportMethod: exportMethod,
+                    types: ['xlsx'],
+                    modes: ['current', 'selected', 'all']
+                  }"
           :data="dataList"
           :checkbox-config="{}">
           <vxe-column type="seq" width="60" title="序号"></vxe-column>
+          <vxe-column type="checkbox" width="40" ></vxe-column>
           <vxe-column min-width="230" align="center" title="项目名称" field="projectName">
             <template slot-scope="scope">
               <el-link  type="primary" :underline="false" v-if="hasPermission('cwProjectRecords:view')" @click="view(scope.row.id)">{{scope.row.projectName}}</el-link>
@@ -86,11 +96,11 @@
           </vxe-column>
           <vxe-column title="操作" width="150px" fixed="right" align="center">
             <template  slot-scope="scope">
-              <el-button v-if="hasPermission('cwProjectRecords:edit')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text" icon="el-icon-edit" size="small" @click="push(scope.row)">修改</el-button>
-              <el-button v-else-if="hasPermission('cwProjectRecords:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
-              <el-button v-if="hasPermission('cwProjectRecords:edit')&&scope.row.createBy.id === $store.state.user.id&&scope.row.status==='2'" type="text" icon="el-icon-edit" size="small" @click="reback(scope.row)">撤回</el-button>
-              <el-button v-if="hasPermission('cwProjectRecords:del')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
-              <el-button v-else-if="hasPermission('cwProjectRecords:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
+              <el-button v-if="hasPermission('cwProjectRecords:edit')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"  size="small" @click="push(scope.row)">修改</el-button>
+              <el-button v-else-if="hasPermission('cwProjectRecords:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"  size="small" @click="edit(scope.row.id)">修改</el-button>
+              <el-button v-if="hasPermission('cwProjectRecords:edit')&&scope.row.createBy.id === $store.state.user.id&&scope.row.status==='2'" type="text"  size="small" @click="reback(scope.row)">撤回</el-button>
+              <el-button v-if="hasPermission('cwProjectRecords:del')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
+              <el-button v-else-if="hasPermission('cwProjectRecords:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
             </template>
           </vxe-column>
         </vxe-table>
@@ -106,7 +116,7 @@
         </vxe-pager>
       </div>
     </div>
-    <ProjectRecordsForm ref="projectRecordsForm"></ProjectRecordsForm>
+    <ProjectRecordsForm ref="projectRecordsForm" @refreshList="refreshList"></ProjectRecordsForm>
   </div>
 </template>
 
@@ -117,6 +127,7 @@
   import ProjectRecordsForm from './ProjectRecordsForm'
   import pick from 'lodash.pick'
   import UserService from '@/api/sys/UserService'
+  import UserSelect from '@/components/userSelect'
   export default {
     data () {
       return {
@@ -152,7 +163,8 @@
       this.userService = new UserService()
     },
     components: {
-      ProjectRecordsForm
+      ProjectRecordsForm,
+      UserSelect
     },
     computed: {
       userName () {
@@ -202,7 +214,7 @@
         }).then(({data}) => {
           this.dataList = data.records
           this.tablePage.total = data.total
-          this.tableKey = Math.random()
+          // this.tableKey = Math.random()
           this.loading = false
         })
         this.checkIsAdmin()
@@ -346,6 +358,31 @@
             }
           })
         })
+      },
+      // 自定义服务端导出
+      exportMethod ({ options }) {
+        // 传给服务端的参数
+        const params = {
+          'current': this.tablePage.currentPage,
+          'size': this.tablePage.pageSize,
+          'orders': this.tablePage.orders,
+          ...this.searchForm,
+          filename: options.filename,
+          sheetName: options.sheetName,
+          isHeader: options.isHeader,
+          original: options.original,
+          mode: options.mode,
+          selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
+          exportFields: options.columns.map(column => column.property)
+        }
+        return this.projectRecordsService.exportFile(params).then((res) => {
+          // 将二进制流文件写入excel表,以下为重要步骤
+          this.$utils.downloadExcel(res.data, options.filename)
+        }).catch(function (err) {
+          if (err.response) {
+            console.log(err.response)
+          }
+        })
       }
     }
   }

+ 11 - 3
src/views/modules/cw/projectRecords/ProjectRecordsTaskForm.vue

@@ -10,8 +10,6 @@
             <el-col :span="24">
               <el-form-item label="合同名称" prop="contractName"
                             :rules="[
-                          {required: true, message:'合同不能为空', trigger:'blur'},
-                          {required: true, message:'合同不能为空', trigger:'change'}
                  ]">
                 <el-input size="medium" :readonly="true" @focus="openContract()" v-model="inputForm.contractName" placeholder="请选择合同">
                   <el-button slot="append" icon="el-icon-search" @click="openContract()"></el-button>
@@ -439,7 +437,17 @@
         this.doSubmit('save', callback)
       },
       startForm (callback) {
-        this.doSubmit('start', callback)
+        if (this.commonJS.isNotEmpty(this.inputForm.planEndDate) && this.commonJS.isNotEmpty(this.inputForm.planStartDate)) {
+          if (this.moment(this.inputForm.planEndDate).format('YYYY-MM-DD') < this.moment(this.inputForm.planStartDate).format('YYYY-MM-DD') || this.moment(this.inputForm.planEndDate).format('YYYY-MM-DD') === this.moment(this.inputForm.planStartDate).format('YYYY-MM-DD')) {
+            this.$message.error('项目预计开始时间要小于项目预计结束时间')
+            this.loading = false
+            throw new Error('项目预计开始时间要小于项目预计结束时间')
+          } else {
+            this.doSubmit('start', callback)
+          }
+        } else {
+          this.doSubmit('start', callback)
+        }
       },
       async agreeForm (callback) {
         await this.projectRecordsService.queryById(this.inputForm.id).then(({data}) => {

+ 48 - 10
src/views/modules/cw/projectReportArchive/ProjectReportArchiveList.vue

@@ -12,7 +12,8 @@
         <el-input size="small" v-model="searchForm.cwProjectRecordsDTO.projectName" placeholder="请输入项目名称" clearable></el-input>
       </el-form-item>
       <el-form-item label="项目经理" prop="cwProjectRecordsDTO.projectMasterName">
-        <el-input size="small" v-model="searchForm.cwProjectRecordsDTO.projectMasterName" placeholder="请输入项目经理" clearable></el-input>
+<!--        <el-input size="small" v-model="searchForm.cwProjectRecordsDTO.projectMasterName" placeholder="请输入项目经理" clearable></el-input>-->
+        <UserSelect :limit='1' :userName="searchForm.cwProjectRecordsDTO.projectMasterName" @getValue='(value, label) => {searchForm.cwProjectRecordsDTO.projectMasterName = label}'></UserSelect>
       </el-form-item>
       <el-form-item label="档案年度" prop="year">
         <el-date-picker
@@ -53,7 +54,8 @@
         </el-select>
       </el-form-item>
       <el-form-item label="创建人" prop="createBy.name">
-        <el-input size="small" v-model="searchForm.createBy.name" placeholder="请输入创建人" clearable></el-input>
+<!--        <el-input size="small" v-model="searchForm.createBy.name" placeholder="请输入创建人" clearable></el-input>-->
+        <UserSelect :limit='1' :userName="searchForm.createBy.name" @getValue='(value, label) => {searchForm.createBy.name = label}'></UserSelect>
       </el-form-item>
       <el-form-item label="创建时间" prop="createDates">
         <el-date-picker
@@ -78,7 +80,7 @@
       </el-form-item>
     </el-form>
     <div class="bg-white top" style="">
-      <vxe-toolbar :refresh="{query: refreshList}" custom>
+      <vxe-toolbar :refresh="{query: refreshList}" export custom>
         <template #buttons>
           <el-button v-if="hasPermission('cwProjectReportArchive:add')" type="primary" size="small" icon="el-icon-plus" @click="start()">新建</el-button>
         </template>
@@ -95,6 +97,14 @@
           ref="projectTable"
           show-header-overflow
           show-overflow
+          :export-config="{
+                    remote: true,
+                    filename: `报告归档数据${moment(new Date()).format('YYYY-MM-DD')}`,
+                    sheetName: `报告归档数据${moment(new Date()).format('YYYY-MM-DD')}`,
+                    exportMethod: exportMethod,
+                    types: ['xlsx'],
+                    modes: ['current', 'selected', 'all']
+                  }"
           highlight-hover-row
           :menu-config="{}"
           @sort-change="sortChangeHandle"
@@ -102,6 +112,7 @@
           :data="dataList"
           :checkbox-config="{}">
           <vxe-column type="seq" width="60" title="序号"></vxe-column>
+          <vxe-column type="checkbox" width="40" ></vxe-column>
           <vxe-column min-width="230" align="center" title="档案名称" field="name">
             <template slot-scope="scope">
               <el-link  type="primary" :underline="false" v-if="hasPermission('cwProjectReportArchive:view')" @click="view(scope.row.id)">{{scope.row.name}}</el-link>
@@ -134,11 +145,11 @@
           </vxe-column>
           <vxe-column title="操作" width="150px" fixed="right" align="center">
             <template  slot-scope="scope">
-              <el-button v-if="hasPermission('cwProjectReportArchive:edit')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text" icon="el-icon-edit" size="small" @click="push(scope.row)">修改</el-button>
-              <el-button v-else-if="hasPermission('cwProjectReportArchive:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
-              <el-button v-if="hasPermission('cwProjectReportArchive:edit')&&scope.row.createBy.id === $store.state.user.id&&scope.row.status==='2'" type="text" icon="el-icon-edit" size="small" @click="reback(scope.row)">撤回</el-button>
-              <el-button v-if="hasPermission('cwProjectReportArchive:del')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
-              <el-button v-else-if="hasPermission('cwProjectReportArchive:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
+              <el-button v-if="hasPermission('cwProjectReportArchive:edit')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"  size="small" @click="push(scope.row)">修改</el-button>
+              <el-button v-else-if="hasPermission('cwProjectReportArchive:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"  size="small" @click="edit(scope.row.id)">修改</el-button>
+              <el-button v-if="hasPermission('cwProjectReportArchive:edit')&&scope.row.createBy.id === $store.state.user.id&&scope.row.status==='2'" type="text"  size="small" @click="reback(scope.row)">撤回</el-button>
+              <el-button v-if="hasPermission('cwProjectReportArchive:del')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
+              <el-button v-else-if="hasPermission('cwProjectReportArchive:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
             </template>
           </vxe-column>
         </vxe-table>
@@ -167,6 +178,7 @@
   import UserService from '@/api/sys/UserService'
   import ProjectRecordsForm from '../projectRecords/ProjectRecordsForm'
   import ProjectReportArchiveForm from './ProjectReportArchiveForm'
+  import UserSelect from '@/components/userSelect'
   export default {
     data () {
       return {
@@ -213,7 +225,8 @@
     },
     components: {
       ProjectRecordsForm,
-      ProjectReportArchiveForm
+      ProjectReportArchiveForm,
+      UserSelect
     },
     computed: {
       userName () {
@@ -266,7 +279,7 @@
         }).then(({data}) => {
           this.dataList = data.records
           this.tablePage.total = data.total
-          this.tableKey = Math.random()
+          // this.tableKey = Math.random()
           this.loading = false
         })
         this.checkIsAdmin()
@@ -410,6 +423,31 @@
             }
           })
         })
+      },
+      // 自定义服务端导出
+      exportMethod ({ options }) {
+        // 传给服务端的参数
+        const params = {
+          'current': this.tablePage.currentPage,
+          'size': this.tablePage.pageSize,
+          'orders': this.tablePage.orders,
+          ...this.searchForm,
+          filename: options.filename,
+          sheetName: options.sheetName,
+          isHeader: options.isHeader,
+          original: options.original,
+          mode: options.mode,
+          selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
+          exportFields: options.columns.map(column => column.property)
+        }
+        return this.projectReportArchiveService.exportFile(params).then((res) => {
+          // 将二进制流文件写入excel表,以下为重要步骤
+          this.$utils.downloadExcel(res.data, options.filename)
+        }).catch(function (err) {
+          if (err.response) {
+            console.log(err.response)
+          }
+        })
       }
     }
   }

+ 40 - 1
src/views/modules/cw/workClientInfo/WorkClientForm.vue

@@ -951,7 +951,12 @@
         this.doSubmit('save', callback)
       },
       startForm (callback) {
-        this.doSubmit('start', callback)
+        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+          this.$message.error('“客户联系人”信息中至少有一条数据')
+          throw new Error('“客户联系人”信息中至少有一条数据')
+        } else {
+          this.doSubmit('start', callback)
+        }
       },
       async agreeForm (callback) {
         await this.workClientService.queryById(this.inputForm.id).then(({data}) => {
@@ -969,6 +974,14 @@
           // 暂存
           // this.inputForm.status = '1'
           this.loading = true
+          if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+            this.$message.error('“客户联系人”信息中至少有一条数据')
+            this.loading = false
+            throw new Error('“客户联系人”信息中至少有一条数据')
+          }
+          this.billingSubmit()
+          this.contactSubmit()
+          this.baseSubmit()
           if (this.$refs.uploadComponent.checkProgress()) {
             this.loading = false
             return
@@ -1106,6 +1119,7 @@
         }
         this.$refs.uploadComponent.clearUpload()
         this.$refs.inputForm.resetFields()
+        this.$emit('refreshList')
         this.visible = false
       },
       tabHandleClick (event) {
@@ -1340,6 +1354,31 @@
               throw new Error('客户联系人中,第' + (index + 1) + '条数据的“邮箱”填写错误')
             }
           }
+          if (this.commonJS.isEmpty(item.name)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“姓名”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“姓名”未填写')
+          }
+          if (this.commonJS.isEmpty(item.sex)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“性别”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“性别”未填写')
+          }
+          if (this.commonJS.isEmpty(item.officeId)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“部门”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“部门”未填写')
+          }
+          if (this.commonJS.isEmpty(item.position)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“职务”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“职务”未填写')
+          }
+          if (this.commonJS.isEmpty(item.contactFirst)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“联系方式1”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“联系方式1”未填写')
+          }
         })
       }
     }

+ 42 - 8
src/views/modules/cw/workClientInfo/WorkClientList.vue

@@ -70,10 +70,11 @@
       </el-form-item>
     </el-form>
     <div class="bg-white top" style="">
-      <vxe-toolbar :refresh="{query: refreshList}" custom>
+      <vxe-toolbar :refresh="{query: refreshList}" export custom>
         <template #buttons>
           <el-button v-if="hasPermission('cw_work_client:info:add')" type="primary" size="small" icon="el-icon-plus" @click="start()">新建</el-button>
           <!--          <el-button v-if="hasPermission('klg:question:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.questionsTable && $refs.questionsTable.getCheckboxRecords().length === 0" plain>删除</el-button>-->
+<!--          <el-button type="warning" size="small" icon="el-icon-download" @click="exportFile()" plain>导出</el-button>-->
         </template>
       </vxe-toolbar>
       <div style="height: calc(100% - 90px)">
@@ -91,10 +92,19 @@
           highlight-hover-row
           :menu-config="{}"
           @sort-change="sortChangeHandle"
+          :export-config="{
+                    remote: true,
+                    filename: `客户信息数据${moment(new Date()).format('YYYY-MM-DD')}`,
+                    sheetName: `客户信息数据${moment(new Date()).format('YYYY-MM-DD')}`,
+                    exportMethod: exportMethod,
+                    types: ['xlsx'],
+                    modes: ['current', 'selected', 'all']
+                  }"
           :sort-config="{remote:true}"
           :data="dataList"
           :checkbox-config="{}">
           <vxe-column type="seq" width="60" title="序号"></vxe-column>
+          <vxe-column type="checkbox" width="40" ></vxe-column>
           <vxe-column min-width="230" align="center" title="客户名称" field="name">
             <template slot-scope="scope">
               <el-link  type="primary" :underline="false" v-if="hasPermission('cw_work_client:info:view')" @click="view(scope.row.id)">{{scope.row.name}}</el-link>
@@ -148,11 +158,11 @@
           </vxe-column>
           <vxe-column title="操作" width="150px" fixed="right" align="center">
             <template  slot-scope="scope">
-              <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text" icon="el-icon-edit" size="small" @click="push(scope.row)">修改</el-button>
-              <el-button v-else-if="hasPermission('cw_work_client:info:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
-              <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.createBy.id === $store.state.user.id&&scope.row.status==='2'" type="text" icon="el-icon-edit" size="small" @click="reback(scope.row)">撤回</el-button>
-              <el-button v-if="hasPermission('cw_work_client:info:del')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
-              <el-button v-else-if="hasPermission('cw_work_client:info:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
+              <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"  size="small" @click="push(scope.row)">修改</el-button>
+              <el-button v-else-if="hasPermission('cw_work_client:info:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"  size="small" @click="edit(scope.row.id)">修改</el-button>
+              <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.createBy.id === $store.state.user.id&&scope.row.status==='2'" type="text"  size="small" @click="reback(scope.row)">撤回</el-button>
+              <el-button v-if="hasPermission('cw_work_client:info:del')&&scope.row.createBy.id === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
+              <el-button v-else-if="hasPermission('cw_work_client:info:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='4'||scope.row.status==='5')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
             </template>
           </vxe-column>
         </vxe-table>
@@ -168,7 +178,7 @@
         </vxe-pager>
       </div>
     </div>
-    <WorkClientForm ref="workClientForm"></WorkClientForm>
+    <WorkClientForm ref="workClientForm" @refreshList="refreshList"></WorkClientForm>
   </div>
 </template>
 
@@ -269,7 +279,6 @@
         }).then(({data}) => {
           this.dataList = data.records
           this.tablePage.total = data.total
-          this.tableKey = Math.random()
           this.loading = false
         })
         this.checkIsAdmin()
@@ -413,6 +422,31 @@
             }
           })
         })
+      },
+      // 自定义服务端导出
+      exportMethod ({ options }) {
+        // 传给服务端的参数
+        const params = {
+          'current': this.tablePage.currentPage,
+          'size': this.tablePage.pageSize,
+          'orders': this.tablePage.orders,
+          ...this.searchForm,
+          filename: options.filename,
+          sheetName: options.sheetName,
+          isHeader: options.isHeader,
+          original: options.original,
+          mode: options.mode,
+          selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
+          exportFields: options.columns.map(column => column.property)
+        }
+        return this.workClientService.exportFile(params).then((res) => {
+          // 将二进制流文件写入excel表,以下为重要步骤
+          this.$utils.downloadExcel(res.data, options.filename)
+        }).catch(function (err) {
+          if (err.response) {
+            console.log(err.response)
+          }
+        })
       }
     }
   }

+ 31 - 1
src/views/modules/cw/workClientInfo/WorkClientTaskForm.vue

@@ -931,7 +931,12 @@
         this.doSubmit('save', callback)
       },
       startForm (callback) {
-        this.doSubmit('start', callback)
+        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+          this.$message.error('“客户联系人”信息中至少有一条数据')
+          throw new Error('“客户联系人”信息中至少有一条数据')
+        } else {
+          this.doSubmit('start', callback)
+        }
       },
       async agreeForm (callback) {
         await this.workClientService.queryById(this.inputForm.id).then(({data}) => {
@@ -1319,6 +1324,31 @@
               throw new Error('客户联系人中,第' + (index + 1) + '条数据的“邮箱”填写错误')
             }
           }
+          if (this.commonJS.isEmpty(item.name)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“姓名”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“姓名”未填写')
+          }
+          if (this.commonJS.isEmpty(item.sex)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“性别”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“性别”未填写')
+          }
+          if (this.commonJS.isEmpty(item.officeId)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“部门”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“部门”未填写')
+          }
+          if (this.commonJS.isEmpty(item.position)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“职务”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“职务”未填写')
+          }
+          if (this.commonJS.isEmpty(item.contactFirst)) {
+            this.$message.error('客户联系人中,第' + (index + 1) + '条数据的“联系方式1”未填写')
+            this.loading = false
+            throw new Error('客户联系人中,第' + (index + 1) + '条数据的“联系方式1”未填写')
+          }
         })
       }
     }