<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>
|