|
@@ -268,7 +268,8 @@
|
|
|
<el-form-item label-width="120px" v-model="postForm.contractUrl" style=" width: 100%">
|
|
|
<el-upload
|
|
|
action="/api/upload"
|
|
|
- :limit="1" :on-success="changeres" :file-list="fileList" :on-exceed="handleExceed">
|
|
|
+ :limit="1" :on-success="changeres" :on-exceed="handleExceed" :on-preview="handleAttachmentPreview"
|
|
|
+ :file-list="fileList" :before-remove="beforeRemove">
|
|
|
<el-button type="primary">上传电子合同<i class="el-icon-upload el-icon--right"></i></el-button>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
@@ -325,6 +326,8 @@
|
|
|
return item.label.indexOf(query) > -1;
|
|
|
},
|
|
|
departmentsOptions:[],
|
|
|
+ contractName:'',
|
|
|
+ fileList:[],
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -333,13 +336,22 @@
|
|
|
this.getDetail();
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleAttachmentPreview(file){
|
|
|
+ // var a = document.createElement('a');
|
|
|
+ // var event = new MouseEvent('click');
|
|
|
+ // a.download = file.url;
|
|
|
+ // a.href = file.url;//路径前拼上前缀,完整路径
|
|
|
+ // a.dispatchEvent(event);
|
|
|
+ window.open(file.url)
|
|
|
+ },
|
|
|
handleExceed(files, fileList) {
|
|
|
this.$message.warning(`当前限制选择 1个文件,本次选择了 ${files.length} 个文件`);
|
|
|
},
|
|
|
// 上传
|
|
|
changeres(res, file) {
|
|
|
- this.postForm.contractUrl = res.data.fileName;
|
|
|
- console.log(file,res,this.filePath);
|
|
|
+ this.postForm.contractUrl = res.data.url;
|
|
|
+ const arr = res.data.url.split("-");
|
|
|
+ this.contractName = arr[1];
|
|
|
},
|
|
|
changePrefix(e){
|
|
|
this.postForm.belongTo = e;
|
|
@@ -371,6 +383,11 @@
|
|
|
if (this.dataId) {
|
|
|
this.$api.item.detail(this.dataId).then(res => {
|
|
|
this.postForm = res.data;
|
|
|
+ if (res.data.contractUrl){
|
|
|
+ const arr = res.data.contractUrl.split("-");
|
|
|
+ this.contractName = arr[1];
|
|
|
+ this.fileList.push({name: this.contractName, url:this.postForm.contractUrl});
|
|
|
+ }
|
|
|
this.userIds = res.data.userIds.map(item => {
|
|
|
return item
|
|
|
})
|
|
@@ -438,7 +455,14 @@
|
|
|
})
|
|
|
},
|
|
|
beforeRemove(file, fileList) {
|
|
|
- return this.$confirm(`确定移除 ${ file.name }?`);
|
|
|
+ this.$confirm(`确定移除 ${ file.name }?`, '警告', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ .then(async () => {
|
|
|
+ this.postForm.contractUrl = '';
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|