zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<template>
  <div class="contractManage" v-loading.fullscreen.lock="loading" element-loading-background="transparent">
    <el-dialog center width="1000px" :visible.sync="show" :close-on-click-modal="false" @close="handleClose" inline>
      <!-- {{info}} -->
      <el-button type="primary" icon="el-icon-circle-plus-outline" @click="handleAdd" size="medium">新增客户合同</el-button>
      <el-button type="primary" @click="handleExport" size="medium">导出合同</el-button>
 
      <el-table stripe :data="contractList" style="margin-top: 30px" highlight-current-row
      @selection-change="handleSelectionChange"
        :header-cell-style="{ background: '#f5f5f5', color: '#222222' }">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column min-width="200">
          <template slot="header">
            <span>
              <span style="padding-left: 8px">合同编号</span>
            </span>
          </template>
          <template slot-scope="{ row }">
            <el-link style="padding-left: 8px" size="mini" type="primary" :underline="false" @click="openContract(row)">
              {{ row.contractNo }}</el-link>
          </template>
        </el-table-column>
 
        <el-table-column min-width="200">
          <template slot="header">
            <span>
              <span style="padding-left: 8px">合同名称</span>
            </span>
          </template>
          <template slot-scope="{ row }">
            <span style="padding-left:  8px">{{
                row.contractName
            }}</span>
          </template>
        </el-table-column>
 
        <el-table-column min-width="180">
          <template slot="header">
            <span>
              <span style="padding-left: 8px">上传时间</span>
            </span>
          </template>
          <template slot-scope="{ row }">
            <span style="padding-left:  8px">{{
                row.operateTime
            }}</span>
          </template>
        </el-table-column>
 
        <el-table-column min-width="100">
          <template slot="header">
            <span>
              <span style="padding-left: 8px">合同类型</span>
            </span>
          </template>
          <template slot-scope="{ row }">
            <span style="padding-left:  8px">
              {{row.contractType == 'USER' ? '人工新增':''}}
              {{row.contractType == 'SYSTEM' ? '系统新增':''}}
              </span>
          </template>
        </el-table-column>
 
        <el-table-column min-width="100">
          <template slot="header">
            <span>
              <span style="padding-left: 8px">操作人</span>
            </span>
          </template>
          <template slot-scope="{ row }">
            <span style="padding-left:  8px">{{
                row.operationUser
            }}</span>
          </template>
        </el-table-column>
 
        <el-table-column label="操作" min-width="110">
          <template slot-scope="scope">
            <el-button type="text" :disabled="scope.row.contractType =='SYSTEM'" @click.native="handleEdit(scope.row)">修改</el-button>
            <el-button type="text" :disabled="scope.row.contractType =='SYSTEM'" @click.native="handleDelete(scope.row, scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="padding-bottom: 40px;"></div>
    </el-dialog>
 
    <el-dialog class="contractAddManage" center width="600px" :visible.sync="addShow" :close-on-click-modal="false"
      @close="handleClose1" inlinel>
      <el-form label-width="100px" ref="formData" :rules="rules" :model="form">
        <el-form-item label="申请编号">
          <el-input v-model="form.applySerialNo" disabled></el-input>
        </el-form-item>
        <el-form-item label="客户名称">
          <el-input v-model="form.customerName" disabled></el-input>
        </el-form-item>
        <el-form-item label="合同编号" prop="contractNo">
          <el-input v-model="form.contractNo" placeholder="不填则系统自动生成"></el-input>
        </el-form-item>
        <el-form-item label="合同名称" prop="contractName">
          <el-input v-model="form.contractName"></el-input>
        </el-form-item>
        <el-form-item label="合同附件" prop="fileData">
          <el-upload class="upload-main" action="" :headers="uploadHeader" :http-request="handleUpload"
            :show-file-list="true" :file-list="fileList">
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button plain @click="handleClose1">取消</el-button>
        <el-button type="primary" @click="submitContract(form)">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  archiveAddContract,
  archivePageContractInfo,
  archiveEditContract,
  archiveDelContract,
  contractInfoList
} from "@comprehensive/serve/public";
import common from "@/utils/common";
 
import {exportContractZip} from  '@/api/product'
import qs from 'qs'
export default {
  data: function () {
    return {
      loading: false,
      show: false,
      addShow: false,
      required: true,
      info: {},
      rules: {
        contractName: [{ required: true, message: '请输入合同名称', trigger: 'blur' }],
 
      },
      fileList: [],
      form: {},
      contractList: [],
      uploadHeader: {
        "Content-Type": "multipart/form-data; boundary=ReaquestHeader"
      },
      multipleSelection:[],
    }
  },
  created() {
 
    // this.getContractList()
  },
  methods: {
    async initInfo(info) {
      this.info = info
      this.getContractList()
      // debugger
      // this.opinionInfo = data
    },
    getContractList() {
      this.loading = true
      contractInfoList({
        "contractType": "01", //附件合同类型[01-客户合同、02-项目合同、03-档案合同]
        "pageSize": 999,
        "currentPage": 1,
        "applySerialNo": this.info.applySerialNo,
      }).then(res => {
        this.loading = false
        this.show = true
        if (res.code == "00") {
          this.contractList = res.result
        } else {
          return;
        }
      })
 
    },
    handleDelete(row) {
      common.comfirm("提示", "合同删除后不可恢复,请确认是否删除?", () => {
        archiveDelContract({ id: row.id }).then(res => {
          if (res.code === "00") {
            this.$message.success("删除成功");
            this.getContractList()
          }
        });
      });
    },
    openContract(row) {
      const fileName = row.contractName.split('.')
      fileName.splice(fileName.length-1,1)
      const fileRelName = fileName.join('')
      const url = `${process.env.VUE_APP_API_ORIGIN}/rlc-cts/server/oss?bucket=${row.docBucket}&ossKey=${row.docKey}&fileName=${fileRelName}`;
      var a = document.createElement("a");
      a.setAttribute("href", url);
      a.setAttribute("target", "_blank");
      a.setAttribute("id", "openwin");
      document.body.appendChild(a);
      //if(!document.getElementById(id)) document.body.appendChild(a);
      a.click();
      document.getElementById("openwin").remove();
    },
    handleUpload(file, fileList) {
      if (file.file) {
        this.$set(this.form, 'fileData', file.file)
        this.fileList = [file.file]
 
        this.$nextTick(() => {
          this.$refs.formData.validateField('fileData')
        })
      }
    },
    async submitContract() {
      this.$refs.formData.validate(async (validate) => {
        if (!validate) return
        let formData = new FormData()
        if (this.form.fileData) formData.append('file', this.form.fileData)
        const fileName = this.form.fileData && this.form.fileData.name.split('.')
        formData.append('contractNo', this.form.contractNo)
        const contractName  = this.form.contractName.split('.')
        var fileType = ['txt','xls','xlsx','doc','docx','pdf','zip','rar','7z','jpg','png','jpeg','gif']
        if(!this.form.fileData){
          formData.append('contractName', this.form.contractName)
        }else{
          if(fileType.includes(contractName[contractName.length-1])){
            // 如果名称只有后缀 删除后缀 
            var orgName = ''
            if(this.form.contractName.indexOf('.') > -1){
              contractName.pop()
              orgName = contractName.join('.')
            }
            // 修改的时候把后缀名重新添加
                formData.append('contractName', orgName ? orgName+'.'+fileName[fileName.length-1] : contractName[0]+'.'+fileName[fileName.length-1])
            }else{
              // 如果没有后缀则添加后缀
              formData.append('contractName', this.form.contractName+'.'+fileName[fileName.length-1])
            }
        }
        
        formData.append('signStatus', this.form.signStatus)
        if (!this.form.id) {
          formData.append('objectNo', this.form.applySerialNo)
          formData.append('objectName', this.form.customerName)
          formData.append('contractType', this.form.contractType)
          await archiveAddContract(formData).then(res => {
            if (res.code === "00") {
              this.$message.success("保存成功");
              this.getContractList()
              this.handleClose1()
            }
          });
        } else {
          formData.append('id', this.form.id)
          await archiveEditContract(formData).then(res => {
            if (res.code === "00") {
              this.$message.success("保存成功");
              this.getContractList()
              this.handleClose1()
            }
          });
        }
      })
    },
    handleClose() {
      // this.$refs.formData.resetFields()
      this.show = false
    },
    handleClose1() {
      this.fileList = []
      this.$refs.formData.resetFields()
      this.addShow = false
    },
    handleEdit(row) {
      this.form = JSON.parse(JSON.stringify(row))
      this.rules.fileData = [{ required: false, message: '请上传合同附件', trigger: 'change' }]
      this.fileList = []
      this.addShow = true
    },
    handleAdd(row) {
      this.form = {
        applySerialNo: this.info.applySerialNo, // 项目/档案编号
        customerName: this.info.customerName,           // 项目/档案名称
        contractType: "01",    // 附件合同类型[01-客户合同、02-项目合同、03-档案合同]
        contractNo: "",         // 合同编号,可自定义,否则系统生成
        contractName: "",     // 合同名称,自定义
        signStatus: "未签署", // 签署状态
        file: null,
      }
      this.rules.fileData = [{ required: true, message: '请上传合同附件', trigger: 'change' }]
      this.addShow = true
    },
    // 导出文件
    exportFile(blob,fileName){
      if (window.navigator.msSaveBlob) {
        // ie
        window.navigator.msSaveOrOpenBlob(blob, fileName)
        return
      }
      let elink = document.createElement('a')
      elink.style.display = 'none'
      elink.href = window.URL.createObjectURL(blob)
      elink.download = fileName
      document.body.appendChild(elink)
      elink.click()
      URL.revokeObjectURL(elink.href)
      document.body.removeChild(elink)
    },
    handleExport() {
      console.log(this.multipleSelection)
      exportContractZip(qs.stringify({
        "contractType": "01", //附件合同类型[01-客户合同、02-项目合同、03-档案合同]
        "ids": this.multipleSelection.map(res=>res.id),
      })).then(res=>{
          let blob = new Blob([res.data])
          let fileName = `${res.headers['content-disposition'].split('=')[1]}`
          this.exportFile(blob,fileName)
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
  },
}
</script>
 
<style lang="stylus">
.contractManage
  .w100
    width: 100% !important
    margin-right: 50px !important;
  .title
    width: 100%
    height: 20px;
    color: #222;
    font-weight: 500;
    font-size: 14px;
    position: relative;
    padding-left: 10px;
    margin-bottom: 20px;
    border-left: 2px solid #0081f0;
    
  .el-dialog
    width auto
    max-height 100%
    overflow hidden
    margin 0 !important
    position absolute
    left 50%
    top 50%
    transform translate(-50%,-50%)
    p 
      text-align: center
      color: #222222
      font-size: 18px
      font-weight:500
      margin-bottom: 20px
    .el-dialog__header
      padding: 40px 0 30px
      .el-dialog__headerbtn
        top:12px
    .el-dialog__body
      padding 0 20px 6px
      max-height: 60vh;
 
      min-height 50vh
      overflow: auto;
      .el-table
        td,th
          height 48px
          padding 0
          .cell
            line-height 18px
 
</style>