Browse Source

财务-合同归档

wangqiang 2 năm trước cách đây
mục cha
commit
c57ae4c373

+ 78 - 45
src/views/modules/cw/workContract/ContractFileForm.vue

@@ -182,52 +182,44 @@
         </el-tab-pane>
         <el-tab-pane label="参与签约方" name="contactParty">
           <el-row :gutter="15">
-            <el-button style="margin-bottom: 15px" type="primary" :disabled="true" size="medium" @click="insertEvent('contact')" plain>
-              新增
+            <el-button type="info" style="margin-bottom: 15px" size="mini" :disabled="true" @click="openWorkClient">
+              新增参与签约方
             </el-button>
           </el-row>
           <el-row  :gutter="15">
-            <vxe-table
-              border
-              :column-config="{resizable: true}"
-              show-overflow
-              show-footer
-              :key="2"
-              ref="contactTable"
-              class="vxe-table-element"
-              :data="inputForm.cwWorkClientContactDTOList"
-              style=""
-              @cell-click=""
-              @edit-closed=""
-              highlight-current-row
-              :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false}"
-            >
-              <vxe-column type="seq" width="60" align="center" title="序号"></vxe-column>
-              <vxe-table-column align="center" field="customerNo" title="客户编号" :edit-render="{}">
-                <template v-slot:edit="scope">
-                  <el-input v-model="scope.row.customerNo" placeholder="客户编号" clearable></el-input>
-                </template>
-              </vxe-table-column>
-              <vxe-table-column align="center" field="customerName" title="客户名称" :edit-render="{}">
-                <template v-slot:edit="scope">
-                  <el-form-item label="客户名称" prop="clientId">
-                    <work-client-select
-                      :size="'medium'"
-                      :value="clientId"
-                      :disabled="method==='view'"
-                      @getValue='(clientId,customerName) => {inputForm.clientId=scope.row.clientId;inputForm.clientName=scope.row.customerName}'
-                    >
-                    </work-client-select>
-                  </el-form-item>
-                  <!--                  <el-input v-model="scope.row.customerName" placeholder="客户名称" clearable></el-input>-->
-                </template>
-              </vxe-table-column>
-              <vxe-table-column align="center" title="操作" width="100">
-                <template v-slot="scope">
-                  <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'contact')">删除</el-button>
-                </template>
-              </vxe-table-column>
-            </vxe-table>
+            <el-form :disabled="method === 'view'">
+              <vxe-table
+                border
+                show-overflow
+                show-footer
+                :column-config="{resizable: true}"
+                ref="contactTable"
+                :key="tableKeyClient"
+                class="vxe-table-element"
+                :data="inputForm.cwWorkClientContactDTOList"
+                style=""
+                @cell-click=""
+                @edit-closed=""
+                highlight-current-row
+                :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false}"
+              >
+                <vxe-table-column align="center" field="no" title="客户编号" :edit-render="{}">
+                  <template v-slot:edit="scope">
+                    <el-input :readonly="true" v-model="scope.row.no" placeholder="客户编号" clearable></el-input>
+                  </template>
+                </vxe-table-column>
+                <vxe-table-column align="center" field="name" title="客户名称" :edit-render="{}">
+                  <template v-slot:edit="scope">
+                    <el-input :readonly="true" v-model="scope.row.name" placeholder="客户名称" clearable></el-input>
+                  </template>
+                </vxe-table-column>
+                <vxe-table-column align="center" title="操作" width="100">
+                  <template v-slot="scope">
+                    <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'client')">删除</el-button>
+                  </template>
+                </vxe-table-column>
+              </vxe-table>
+            </el-form>
           </el-row>
         </el-tab-pane>
         <el-tab-pane label="合同归档文件" name="archiveFile">
@@ -243,6 +235,7 @@
         :on-close="closeViewer"
         :url-list="[url]"
         zIndex="9999"/>
+    <WorkClientChooseForm ref="workClientChooseForm" @getWorkClientChoose="getWorkClientChoose"></WorkClientChooseForm>
   </div>
 </template>
 
@@ -250,6 +243,7 @@
   import ContractInfoService from '@/api/cw/workContract/ContractInfoService'
   import ContractFileService from '../../../../api/cw/workContract/ContractFileService'
   import UpLoadComponent from '@/views/common/UpLoadComponent'
+  import WorkClientChooseForm from '../workClientInfo/WorkClientChooseForm'
   import OSSSerive, {
     httpRequest,
     toHref,
@@ -331,7 +325,8 @@
         loadProgress: 0, // 动态显示进度条
         progressFlag: false, // 关闭进度条
         promi: null,
-        keyWatch: ''
+        keyWatch: '',
+        tableKeyClient: '1'
       }
     },
     props: {
@@ -350,7 +345,8 @@
     },
     components: {
       ElImageViewer,
-      UpLoadComponent
+      UpLoadComponent,
+      WorkClientChooseForm
     },
     ossService: null,
     // workContractService: null,
@@ -506,6 +502,43 @@
         this.inputForm = this.recover(this.inputForm, data)
         this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
       },
+      removeEvent (row, rowIndex, type) {
+        if (type === 'client') {
+          this.$refs.contactTable.remove(row)
+          this.inputForm.cwWorkClientContactDTOList.splice(rowIndex, 1)
+        }
+      },
+      openWorkClient () {
+        this.$refs.workClientChooseForm.init()
+      },
+      getWorkClientChoose (list) {
+        console.log('list', list)
+        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+          this.inputForm.cwWorkClientContactDTOList = []
+        }
+        let _this = this
+        let _list = list
+        const waitForEach = function () {
+          return new Promise(function (resolve, reject) {
+            _list.forEach((item) => {
+              _this.inputForm.cwWorkClientContactDTOList.forEach(client => {
+                if (item.no === client.no) {
+                  _this.$message.error('已存在客户 “' + client.name + '”,请重新选择')
+                  throw new Error('已存在客户 “' + client.name + '”,请重新选择')
+                }
+              })
+            })
+            resolve()
+          })
+        }
+        waitForEach().then(() => {
+          list.forEach(item => {
+            this.$refs.contactTable.insertAt(item)
+            this.inputForm.cwWorkClientContactDTOList.push(item)
+            this.tableKeyClient = Math.random()
+          })
+        })
+      },
       // 表单提交
       // 暂存
       async saveForm (callback) {

+ 149 - 87
src/views/modules/cw/workContract/ContractRegistrationForm.vue

@@ -120,11 +120,6 @@
               :accordion="true"
               @getValue="(value) => {inputForm.department=value}"/>
           </el-form-item>
-<!--          <el-form-item label="所属部门" prop="department"-->
-<!--                        :rules="[{required: true, message: '所属部门', trigger: 'blur'}-->
-<!--                 ]">-->
-<!--&lt;!&ndash;            <el-input maxlength="64" v-model="inputForm.department" placeholder="请输入所属部门"></el-input>&ndash;&gt;-->
-<!--          </el-form-item>-->
         </el-col>
 
         <el-col :span="12">
@@ -175,57 +170,44 @@
         </el-tab-pane>
         <el-tab-pane label="参与签约方" name="contactParty">
           <el-row :gutter="15">
-            <el-button style="margin-bottom: 15px" type="primary" :disabled="formReadOnly" size="medium" @click="insertEvent('contact')" plain>
-              新增
+            <el-button type="info" style="margin-bottom: 15px" size="mini" :disabled="method === 'view'" @click="openWorkClient">
+              新增参与签约方
             </el-button>
           </el-row>
           <el-row  :gutter="15">
-            <vxe-table
-              border
-              :column-config="{resizable: true}"
-              show-overflow
-              show-footer
-              :key="2"
-              ref="contactTable"
-              class="vxe-table-element"
-              :data="inputForm.cwWorkClientContactDTOList"
-              style=""
-              @cell-click=""
-              @edit-closed=""
-              highlight-current-row
-              :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false}"
-            >
-              <vxe-column type="seq" width="60" align="center" title="序号"></vxe-column>
-              <vxe-table-column align="center" field="customerNo" title="客户编号" :edit-render="{}">
-                <template v-slot:edit="scope">
-                  <el-input v-model="scope.row.customerNo" :disabled="true" placeholder="请填写客户编号" clearable></el-input>
-                </template>
-              </vxe-table-column>
-              <vxe-table-column align="center" field="customerName" title="客户名称" :edit-render="{}">
-                <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.customerName}}</el-link>
-                  <el-link  type="primary" :underline="false" v-else-if="hasPermission('cw_work_client:info:view')"  @click="view(scope.row.id,)">{{scope.row.customerName}}</el-link>
-                  <span v-else>{{scope.row.customerName}}</span>
-                </template>
-<!--                <template v-slot:edit="scope">-->
-<!--                  <el-form-item label="客户名称" prop="clientId">-->
-<!--                    <work-client-select-->
-<!--                      :size="'medium'"-->
-<!--                      :value="clientId"-->
-<!--                      :disabled="method==='view'"-->
-<!--                      @getValue='(clientId,customerName) => {inputForm.clientId=scope.row.clientId;inputForm.clientName=scope.row.customerName}'-->
-<!--                    >-->
-<!--                    </work-client-select>-->
-<!--                  </el-form-item>-->
-<!--&lt;!&ndash;                  <el-input v-model="scope.row.customerName" placeholder="客户名称" clearable></el-input>&ndash;&gt;-->
-<!--                </template>-->
-              </vxe-table-column>
-              <vxe-table-column align="center" title="操作" width="100">
-                <template v-slot="scope">
-                  <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'contact')">删除</el-button>
-                </template>
-              </vxe-table-column>
-            </vxe-table>
+            <el-form :disabled="method === 'view'">
+              <vxe-table
+                border
+                show-overflow
+                show-footer
+                :column-config="{resizable: true}"
+                ref="contactTable"
+                :key="tableKeyClient"
+                class="vxe-table-element"
+                :data="inputForm.cwWorkClientContactDTOList"
+                style=""
+                @cell-click=""
+                @edit-closed=""
+                highlight-current-row
+                :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false}"
+              >
+                <vxe-table-column align="center" field="no" title="客户编号" :edit-render="{}">
+                  <template v-slot:edit="scope">
+                    <el-input :readonly="true" v-model="scope.row.no" placeholder="客户编号" clearable></el-input>
+                  </template>
+                </vxe-table-column>
+                <vxe-table-column align="center" field="name" title="客户名称" :edit-render="{}">
+                  <template v-slot:edit="scope">
+                    <el-input :readonly="true" v-model="scope.row.name" placeholder="客户名称" clearable></el-input>
+                  </template>
+                </vxe-table-column>
+                <vxe-table-column align="center" title="操作" width="100">
+                  <template v-slot="scope">
+                    <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'client')">删除</el-button>
+                  </template>
+                </vxe-table-column>
+              </vxe-table>
+            </el-form>
           </el-row>
         </el-tab-pane>
         <el-tab-pane  label="合同归档文件" name="archiveFile">
@@ -241,7 +223,7 @@
         :on-close="closeViewer"
         :url-list="[url]"
         zIndex="9999"/>
-    <WorkClientForm ref="workClientForm"></WorkClientForm>
+    <WorkClientChooseForm ref="workClientChooseForm" @getWorkClientChoose="getWorkClientChoose"></WorkClientChooseForm>
   </div>
 </template>
 
@@ -252,6 +234,7 @@
   import SelectTree from '@/components/treeSelect/treeSelect.vue'
   import WorkClientSelect from '@/components/workClientInfoSelect'
   import WorkClientForm from '../workClientInfo/WorkClientForm'
+  import WorkClientChooseForm from '../workClientInfo/WorkClientChooseForm'
   import OSSSerive, {
     httpRequest,
     toHref,
@@ -315,9 +298,9 @@
           createBy: JSON.parse(localStorage.getItem('user')).name,
           createId: JSON.parse(localStorage.getItem('user')).id,
           createDate: '',
-          contractProperList: []
+          contractProperList: [],
+          cwWorkClientContactDTOList: []
         },
-        cwWorkClientContactDTOList: [],
         activeName: 'contractProper',
         filesArra2: [],
         fileList: [],
@@ -330,7 +313,9 @@
         type: '',
         loadProgress: 0, // 动态显示进度条
         progressFlag: false, // 关闭进度条
-        promi: null
+        promi: null,
+        tableKeyClient: '1',
+        keyWatch: ''
       }
     },
     props: {
@@ -348,13 +333,14 @@
       UpLoadComponent,
       SelectTree,
       WorkClientSelect,
-      WorkClientForm
-    },
-    computed: {
-      officeName () {
-        return JSON.parse(localStorage.getItem('user')).officeDTO.name
-      }
+      WorkClientForm,
+      WorkClientChooseForm
     },
+    // computed: {
+    //   officeName () {
+    //     return JSON.parse(localStorage.getItem('user')).officeDTO.name
+    //   }
+    // },
     ossService: null,
     contractInfoService: null,
     created () {
@@ -364,25 +350,38 @@
     mounted () {
       window.onPreview = this.onPreview
     },
+    computed: {
+      officeName () {
+        return JSON.parse(localStorage.getItem('user')).officeDTO.name
+      },
+      bus: {
+        get () {
+          this.$refs.archiveFile.setDividerName('附件', false)
+          this.$refs.uploadComponent.setDividerName('附件', false)
+          return this.businessId
+        },
+        set (val) {
+          this.businessId = val
+        }
+      }
+    },
     watch: {
-      'businessId': {
+      'keyWatch': {
         handler (newVal) {
-          if (this.businessId && this.businessId !== 'false') {
-            this.ossService = new OSSSerive()
-            this.init('edit', this.businessId)
+          if (this.commonJS.isNotEmpty(this.bus)) {
+            this.init('', this.bus)
           } else {
-            // this.$refs.inputForm.resetFields()
-            // this.visible = false
-            // this.showVi = true
-            // this.$refs.uploadComponent.clearUpload()
-            // this.init('clean', '')
+            this.$nextTick(() => {
+              this.$refs.inputForm.resetFields()
+            })
           }
-        },
-        immediate: true,
-        deep: false
+        }
       }
     },
     methods: {
+      getKeyWatch (keyWatch) {
+        this.keyWatch = keyWatch
+      },
       uploadVideoProcess (event, file, fileList) {
         this.progressFlag = true // 显示进度条
         this.loadProgress = parseInt(event.percent) // 动态获取文件上传进度
@@ -446,6 +445,23 @@
           this.loading = true
           this.contractInfoService.findById(this.inputForm.id).then(({data}) => {
             this.inputForm = this.recover(this.inputForm, data)
+            // 对数值进行判断是否为空,为空则赋值默认值
+            console.log('this.inputForm.contractStatus', this.inputForm.contractStatus)
+            if (this.inputForm.contractStatus === undefined || this.inputForm.contractStatus === '') {
+              this.inputForm.contractStatus = '新创建'
+            }
+            if (this.inputForm.contractNum === undefined || this.inputForm.contractNum === '') {
+              this.inputForm.contractNum = '2'
+            }
+            if (this.inputForm.changeNum === undefined || this.inputForm.changeNum === '') {
+              this.inputForm.changeNum = '0'
+            }
+            if (this.inputForm.createBy === undefined || this.inputForm.createBy === '') {
+              this.inputForm.createBy = JSON.parse(localStorage.getItem('user')).name
+            }
+            if (this.inputForm.createId === undefined || this.inputForm.createId === '') {
+              this.inputForm.createId = JSON.parse(localStorage.getItem('user')).id
+            }
             const f = []
             if (data.fees !== null && data.fees !== undefined && data.fees !== '') {
               data.fees.split(',').forEach(item => {
@@ -458,8 +474,8 @@
             if (this.formReadOnly) {
               method = 'view'
             }
-            this.$refs.uploadComponent.newUpload(method, this.inputForm.contractProperList, 'cwWorkContract', 300, '合同正文')
-            this.$refs.archiveFile.newUpload('view', null, 'cwWorkContract', 300, '合同正文')
+            this.$refs.uploadComponent.newUpload(method, this.inputForm.contractProperList, 'cwWorkContract', null, null, null, null, false)
+            this.$refs.archiveFile.newUpload('view', [], 'cwWorkContract', null, null, null, null, false)
             this.loading = false
           })
         })
@@ -471,31 +487,76 @@
       // 新增
       // eslint-disable-next-line no-dupe-keys
       async insertEvent (type) {
-        if (type === 'contact') {
-          await this.$refs.contactTable.insert().then((data) => {
-            if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
-              this.inputForm.cwWorkClientContactDTOList = []
-            }
-            this.$nextTick(() => {
-              this.inputForm.cwWorkClientContactDTOList.push(data)
-            })
-          })
+        if (type === 'client') {
+          let d = {
+            no: '',
+            name: ''
+          }
+          if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+            this.inputForm.cwWorkClientContactDTOList = []
+          }
+          this.$refs.contactTable.insertAt(d)
+          this.inputForm.cwWorkClientContactDTOList.push(d)
+          this.tableKeyClient = Math.random()
         }
+        // if (type === 'client') {
+        //   await this.$refs.contactTable.insert().then((data) => {
+        //     console.log('data', data)
+        //     if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+        //       this.inputForm.cwWorkClientContactDTOList = []
+        //     }
+        //     this.$nextTick(() => {
+        //       this.inputForm.cwWorkClientContactDTOList.push(data)
+        //     })
+        //   })
+        // }
       },
 
       // 删除
       removeEvent (row, rowIndex, type) {
-        if (type === 'contact') {
+        if (type === 'client') {
           this.$refs.contactTable.remove(row)
           this.inputForm.cwWorkClientContactDTOList.splice(rowIndex, 1)
         }
       },
+      openWorkClient () {
+        this.$refs.workClientChooseForm.init()
+      },
+      getWorkClientChoose (list) {
+        console.log('list', list)
+        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
+          this.inputForm.cwWorkClientContactDTOList = []
+        }
+        let _this = this
+        let _list = list
+        const waitForEach = function () {
+          return new Promise(function (resolve, reject) {
+            _list.forEach((item) => {
+              _this.inputForm.cwWorkClientContactDTOList.forEach(client => {
+                if (item.no === client.no) {
+                  _this.$message.error('已存在客户 “' + client.name + '”,请重新选择')
+                  throw new Error('已存在客户 “' + client.name + '”,请重新选择')
+                }
+              })
+            })
+            resolve()
+          })
+        }
+        waitForEach().then(() => {
+          list.forEach(item => {
+            this.$refs.contactTable.insertAt(item)
+            this.inputForm.cwWorkClientContactDTOList.push(item)
+            this.tableKeyClient = Math.random()
+          })
+        })
+      },
       // 表单提交
       // 暂存
       async saveForm (callback) {
         this.loading = true
         this.inputForm.status = '1'
         this.inputForm.contractProperList = this.$refs.uploadComponent.getDataList()
+        console.log('this.inputForm', this.inputForm)
         await this.contractInfoService.save(this.inputForm).then(({data}) => {
           callback()
           this.$refs.inputForm.resetFields()
@@ -546,6 +607,7 @@
       close () {
         this.$refs.inputForm.resetFields()
         this.inputForm.clientName = ''
+        this.inputForm.cwWorkClientContactDTOList = []
         this.visible = false
         this.showVi = true
         this.$refs.uploadComponent.clearUpload()