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
<template>
  <div class="form-content">
    <div class="title">
      <SectionTitle title="合同信息"></SectionTitle>
    </div>
 
    <p class="excel"> 
      <el-button type="primary" icon="el-icon-circle-plus-outline" @click="handleAdd" size="medium" v-if="type == 'edit'">新增合同附件</el-button>
      <el-button type="primary" :loading="exportLoading"  @click="handleExport" size="medium">导出合同附件</el-button>
    </p>
 
    <el-table stripe :data="contractList" :header-cell-style="{ background: '#f5f5f5', color: '#222222' }"  style="margin-top: 30px;"
      highlight-current-row   @selection-change="handleSelectionChange">
        <el-table-column
          type="selection"
          width="50">
        </el-table-column>
      <el-table-column property="contractNo" label="附件编号" width="220">
        <template slot-scope="{ row }">
            <el-link size="mini" type="primary" :underline="false" @click="openContract(row)">
              {{ row.contractNo }}</el-link>
          </template>
      </el-table-column>
      <el-table-column property="contractName" label="附件名称" min-width="200"></el-table-column>
      <!-- <el-table-column property="signStatus" label="签署状态" width="120">
        <template slot-scope="scope">
        {{ scope.row.signStatus | filterSingStatus(signStatusList)}}
        </template>
      </el-table-column> -->
      <el-table-column property="version" label="签署状态" width="120"></el-table-column>
      <el-table-column property="operationUser" label="维护人" width="160"></el-table-column>
      <el-table-column property="operationDate" label="维护时间" width="160"></el-table-column>
      <el-table-column  label="管理" width="200">
        <template slot-scope="scope">
          <el-link size="mini" type="primary" :underline="false" @click="openContract(scope.row, scope.$index)">查看附件明细</el-link>
          <el-link style="margin: 0 5px" size="mini" type="primary" :underline="false" @click="handleEdit(scope.row, scope.$index)" v-if="type == 'edit'">修改
          </el-link>
          <el-link size="mini" type="primary" :underline="false" @click="handleDelete(scope.row, scope.$index)" v-if="type == 'edit'">删除
          </el-link>
        </template>
      </el-table-column>
    </el-table>
 
 
    <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.objectNo" disabled></el-input>
        </el-form-item>
        <el-form-item label="档案名称">
          <el-input v-model="form.objectName" 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=""  :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>
    <!-- <el-form
      v-bind="$attrs"
      :model="formValues"
      ref="editForm"
      :label-width="labelWidth"
      :inline="inline"
      :class="`form-cols-${inline ? showColumn : '0'}`"
      size="small"
      :rules="formRules"
    > 
    </el-form> -->
  </div>
</template>
<script>
// 表单项-目前用于搜索部分
import SectionTitle from '../SectionTitle'
import {
  queryDictionaryByCode,
  archivePageContractInfo,
  archiveEditContract,
  archiveDelContract,
  archiveAddContract
 } from '@comprehensive/serve/public'
 
import {exportContractZip} from  '@/api/product'
import common from "@/utils/common";
import qs from 'qs'
export default {
  components: {
    SectionTitle,
  },
  data() {
    return {
      form: {},
      contractList: [],
      addShow: false,
      info: {},
      signStatusList: [],
      fileList: [],
      rules: {
        contractName: [{ required: true, message: '请输入附件名称', trigger: 'blur' }],
        // signStatus: [{ required: true, message: '请选择签署状态', trigger: 'change' }]
      },
      exportLoading: false,
      multipleSelection: [],
    }
  },
  async mounted() {
    this.info = this.$route.query
 
    this.signStatusList = await this.queryDictionaryByCode('SignStatus')
    this.getContractList()
    // this.archiveTypeList = await this.queryDictionaryByCode('ArchiveType')
    // this.archiveContentList = await this.queryDictionaryByCode('ArchiveContent')
  },
  filters: {
    filterSingStatus(status,signStatusList) {
      return signStatusList.find(res=>res.itemno == status).itemname
    }
  },
  methods: {
    queryDictionaryByCode(code) {
      return new Promise(resolve => {
        queryDictionaryByCode({
          codeNo: code
        }).then(res => {
          resolve(res.result)
        })
      })
    },
    getContractList() {
      this.loading = true
      archivePageContractInfo({
        "contractType": "03", //附件合同类型[01-客户合同、02-项目合同、03-档案合同]
        "pageSize": 999,
        "currentPage": 1,
        "objectNo": this.info.archiveNo,
      }).then(res => {
        this.loading = false
        if (res.code == "00") {
          this.contractList = res.result.records
        } else {
          this.contractList = [];
        }
      })
    },
    getCurrentRow() {
 
    },
    handleClose1() {
      this.fileList = []
      this.$refs.formData.clearValidate()
      this.addShow = false
    },
    handleDelete(row) {
      common.comfirm("提示", "附件删除后不可恢复,请确认是否删除?", () => {
        archiveDelContract({ id: row.id }).then(res => {
          if (res.code === "00") {
            this.$message.success("删除成功");
            this.getContractList()
          }
        });
      });
    },
    handleEdit(row) {
      this.form = row
      this.rules.fileData = [{ required: false, message: '请上传附件', trigger: 'change' }]
      this.fileList = []
      this.addShow = true
    },
    handleAdd(row) {
      this.form = {
        objectNo: this.info.archiveNo, // 项目/档案编号
        objectName: this.info.archiveName,           // 项目/档案名称
        contractType: "03",    // 附件合同类型[01-客户合同、02-项目合同、03-档案合同]
        contractNo: "",         // 合同编号,可自定义,否则系统生成
        contractName: "",     // 合同名称,自定义
        signStatus: "01", // 签署状态
        file: null,
      }
      this.rules.fileData = [{ required: true, message: '请上传附件', trigger: 'change' }]
      this.addShow = true
    },
    openContract(row) {
      const url = `${process.env.VUE_APP_API_ORIGIN}/rlc-cts/server/oss?bucket=${row.docBucket}&ossKey=${row.docKey}`;
      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)
        formData.append('contractNo', this.form.contractNo)
        formData.append('contractName', this.form.contractName)
        if (!this.form.id) {
          formData.append('objectNo', this.form.objectNo)
          formData.append('objectName', this.form.objectName)
          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()
            }
          });
        }
      })
    },
    // 导出文件
    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)
      if(this.multipleSelection.length == 0 ) return 
      this.exportLoading = true
      exportContractZip(qs.stringify({
        "contractType": "03", //附件合同类型[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)
          this.exportLoading = false
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
  },
  computed: {
    type() {
      return this.$route.query.type
    }
  }
}
</script>
<style lang="postcss" scoped>
.form-content {
  padding-right: 20px;
 
 
}
</style>