<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="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="signStatus">
|
<el-select v-model="form.signStatus" placeholder="请选择" >
|
<el-option v-for="(item, index) in signStatusList" :key="index" :label="item.itemname" :value="item.itemno">
|
</el-option>
|
</el-select>
|
</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": "02", //附件合同类型[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: "02", // 附件合同类型[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)
|
formData.append('signStatus', this.form.signStatus)
|
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)
|
this.exportLoading = false
|
},
|
handleExport() {
|
console.log(this.multipleSelection)
|
if(this.multipleSelection.length == 0 ) return
|
this.exportLoading = true
|
exportContractZip(qs.stringify({
|
"contractType": "02", //附件合同类型[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;
|
}
|
},
|
computed: {
|
type() {
|
return this.$route.query.type
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.form-content {
|
padding-right: 20px;
|
|
|
}
|
</style>
|