<template>
|
<!--
|
描述:签约
|
-->
|
<el-dialog title="上传合同" :visible.sync="dialogVisible" @close='dialogFormVisible' :close-on-click-modal="false"
|
:close-on-press-escape="false">
|
<el-form size="small" :model="form" ref="form"><!-- :rules="rules" -->
|
|
<el-form-item label="合同" :label-width="formLabelWidth" prop="mark_manager">
|
<!--
|
list-type="picture" -->
|
<el-upload
|
:data="up_data"
|
class="upload-demo"
|
:action="up_url"
|
:before-remove="beforeRemove"
|
multiple
|
:on-change="tip"
|
:limit="7"
|
:on-exceed="handleExceed"
|
:file-list="fileList">
|
<el-button size="small" type="primary">上传合同</el-button>
|
</el-upload>
|
</el-form-item>
|
|
<el-form-item label="已有合同" :label-width="formLabelWidth">
|
<div v-for="(item,index) in get_list" :key="index" style="float: left;text-align: center;margin: 3px 5px;">
|
<img :src="item.url" style="width: 200px;" />
|
<span>{{item.name}}</span>
|
</div>
|
|
</el-form-item>
|
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="dialogFormVisible">取 消</el-button>
|
<el-button type="primary" @click="editClick()" :loading="loading">确定</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import ContractApi from '@/api/contract.js';
|
|
export default {
|
data() {
|
return {
|
form: {},
|
/*左边长度*/
|
formLabelWidth: '120px',
|
/*是否显示*/
|
dialogVisible: false,
|
/*是否正在加载*/
|
loading: false,
|
|
fileList: [],//上传图片数组
|
up_url:'/index.php/admin/admin.upload/contract_upload',
|
up_data:{
|
id:0,
|
name:'',
|
},
|
contract:[],
|
get_list:[1,2],
|
};
|
},
|
props: ['open_contract','curModel'],
|
created() {
|
|
this.dialogVisible = this.open_contract;
|
this.form=this.curModel;
|
this.up_data = {
|
id:this.form.client_id,
|
name:this.form.client_name,
|
};
|
this.get_contract();
|
},
|
methods: {
|
//获取相应客户下的合同
|
get_contract(){
|
let self = this;
|
self.loading = true;
|
ContractApi.getcontract([self.curModel.client_id],true)
|
.then(res => {
|
//self.contract = res.data.contract.split(';');
|
// for(let i=0;i<res.data.contract.length;i++){
|
// self.fileList.push(res.data.contract[i]);
|
// console.log(self.fileList,'sss');
|
// }
|
//self.contract = res.data.contract;
|
console.log(res.data.contract,'res1');
|
self.get_list = res.data.contract;
|
console.log(self.get_list,'res2');
|
self.loading = false;
|
})
|
.catch(error => {
|
self.loading = false;
|
});
|
},
|
|
|
tip(file, fileList){//上传完成后提示
|
let self = this;
|
if(file.response){
|
if(file.response.code == 1){
|
//self.fileList.push(file.response.data);
|
console.log(file.response.data);
|
self.$message({message: '上传成功',type: 'success'});
|
self.contract.push({
|
client_id:self.form.client_id,
|
name:file.name.split('.')[0],
|
suffix:file.name.split('.')[1],
|
url:file.response.data,
|
});
|
//console.log(self.contract,'*******');
|
//debugger;
|
//this.form.app_icon = file.response.data;
|
}else{
|
self.$message({message: '上传失败',type: 'error'});
|
}
|
}
|
},
|
handleExceed(files, fileList) {
|
this.$message.warning(`当前限制选择 7 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
},
|
beforeRemove(file, fileList) {
|
return this.$confirm(`确定移除 ${ file.name }?`);
|
},
|
|
/*修改合同*/
|
editClick() {
|
let self = this;
|
let params = this.contract;
|
self.$refs.form.validate((valid) => {
|
if (valid) {
|
console.log(self.contract,'con');
|
self.loading = true;
|
ContractApi.addcontract(params, true)
|
.then(res => {
|
self.loading = false;
|
self.$message({
|
message: '恭喜你,修改成功',
|
type: 'success'
|
});
|
self.dialogFormVisible(true);
|
})
|
.catch(error => {
|
self.loading = false;
|
});
|
}
|
});
|
|
},
|
/*关闭弹窗*/
|
dialogFormVisible(e) {
|
if (e) {
|
this.$emit('closeDialog', {
|
type: 'success',
|
openDialog: false
|
})
|
} else {
|
this.$emit('closeDialog', {
|
type: 'error',
|
openDialog: false
|
})
|
}
|
}
|
|
}
|
};
|
</script>
|
|
<style></style>
|