供应商比选材料 附件上传

master
Harry Yang 2023-01-03 20:15:44 +08:00
parent 9f6d4a30b6
commit 326a3343ae
3 changed files with 70 additions and 52 deletions

View File

@ -302,20 +302,19 @@
:before-remove="(file, fileList) => beforeSupplierMaterialRemove(scope, file, fileList)"
:on-success="(response, file, fileList) => handleSupplierMaterialFileUploaded(scope, response, file, fileList)"
:on-exceed="(files, fileList) => handleSupplierMaterialExceed(scope, files, fileList)">
<el-button size="small" type="text">上传附件</el-button>
<el-popover placement="top-end" title="已经上传的附件" width="200" trigger="hover">
<el-popover placement="top-end" title="已经上传的附件" width="380" trigger="hover">
<el-button size="small" type="text" slot="reference">上传附件</el-button>
<#--展示已经上传的文件-->
<div v-if="scope.row.attachment">
<el-tag size="small" v-for="attachment in scope.row.attachment" closable
<div>只能上传PDF、excel、word、图片、压缩包且不超过50MB</div>
<div v-if="isNotEmpty(scope.row.attachment)" style="margin-top: 10px">
<el-tag size="small" v-for="attachment in scope.row.attachment" closable :key="attachment.name"
@close="removeSupplierMaterialAttachment(scope, attachment)">
<a :href="attachment.uri" target="_blank">
<i class="el-icon-document"></i> {{attachment.name}}
<i class="el-icon-document"></i> {{attachment.name|ellipsis}}
</a>
</el-tag>
</div>
<span v-else>暂未上传</span>
<span v-else style="margin-top: 10px;text-align: center"><strong>暂未上传</strong></span>
</el-popover>
</el-upload>
@ -723,9 +722,7 @@
const mapAttachment = attachment => {
if (hasText(attachment)) {
try {
return JSON.parse(attachment).map(item => ({
name: item.name, url: item.uri
}))
return JSON.parse(attachment)
} catch (e) {
return []
}
@ -1042,16 +1039,22 @@
},
handleSupplierMaterialRemove(scope, fileList) {
scope.row['attachment'] = fileList
scope.row['attachment'] = fileList.map(file => ({
uri: file.response.data.url,
name: file.name
}))
},
removeSupplierMaterialAttachment(scope, attachmentToRemove) {
scope.row['attachment'] = scope.row['attachment'].filter(item => item === attachmentToRemove)
scope.row['attachment'] = scope.row['attachment'].filter(item => item !== attachmentToRemove)
},
handleSupplierMaterialExceed(scope, files, fileList) {
this.$message.warning("当前限制选择只能选择10个文件");
scope.row['attachment'] = fileList
scope.row['attachment'] = fileList.map(file => ({
uri: file.response.data.url,
name: file.name
}))
},
beforeSupplierMaterialRemove(scope, file, fileList) {
@ -1064,18 +1067,16 @@
handleSupplierMaterialFileUploaded(scope, response, file, fileList) {
if (response.success) {
let attachments = scope.row['attachment']
let attachments = scope.row.attachment
if (isEmpty(attachments)) {
attachments = []
scope.row['attachment'] = attachments
}
attachments.push({
uri: response.data.url,
name: file.name
})
console.log(attachments)
console.log(scope.row['attachment'])
scope.row.attachment = attachments
this.$message.success("上传成功");
}
else {
@ -1090,6 +1091,7 @@
addSupplierRow() {
this.supplierMaterialsForm.push({
rowKey: this.rowKeyCounter++,
attachment: []
})
},
@ -1224,6 +1226,16 @@
this.loadProject(processId)
this.applyDeptSectorOptions = JSON.parse('${applyDeptSectorOptions}')
},
filters: {
ellipsis(value, limit = 40) {
if (!value) return ''
if (value.length > limit) {
return value.slice(0, limit) + '...'
}
return value
}
}
})
</script>

View File

@ -367,7 +367,7 @@
<div class="am-u-sm-12 am-u-md-12 supplierChoose" v-if="isProcurementContractMode">
<el-alert title="供应商比选材料" type="success" center :closable="false"></el-alert>
<el-table style="width: 100%" border :data="supplierMaterialsForm" v-model="supplierMaterialsForm" empty-text="暂无">
<el-table style="width: 100%" border :data="supplierMaterialsForm" empty-text="暂无">
<el-table-column type="index" :index="1" label="序号" fixed></el-table-column>
<el-table-column prop="companyName" label="公司名称" width="180" align="center">
@ -399,10 +399,6 @@
</el-table-column>
<el-table-column prop="remark" label="备注" align="center">
<template slot-scope="scope">
<#--
<el-input type="textarea" size="mini" maxlength="100"
v-model="scope.row.remark" placeholder="请输入备注限制100字" cols="90"></el-input>
-->
<el-input size="mini" placeholder="请输入备注"
v-model="scope.row.remark"></el-input>
</template>
@ -416,18 +412,19 @@
:before-remove="(file, fileList) => beforeSupplierMaterialRemove(scope, file, fileList)"
:on-success="(response, file, fileList) => handleSupplierMaterialFileUploaded(scope, response, file, fileList)"
:on-exceed="(files, fileList) => handleSupplierMaterialExceed(scope, files, fileList)">
<el-popover placement="top-end" title="已经上传的附件" width="200" trigger="hover">
<el-popover placement="top-end" title="已经上传的附件" width="380" trigger="hover">
<el-button size="small" type="text" slot="reference">上传附件</el-button>
<#--展示已经上传的文件-->
<div v-if="scope.row.attachment">
<div>只能上传PDF、excel、word、图片、压缩包且不超过50MB</div>
<div v-if="isNotEmpty(scope.row.attachment)" style="margin-top: 10px">
<el-tag size="small" v-for="attachment in scope.row.attachment" closable :key="attachment.name"
@close="removeSupplierMaterialAttachment(scope, attachment)">
<a :href="attachment.uri" target="_blank">
<i class="el-icon-document"></i> {{attachment.name}}
<i class="el-icon-document"></i> {{attachment.name|ellipsis}}
</a>
</el-tag>
</div>
<span v-else>暂未上传</span>
<span v-else style="margin-top: 10px;text-align: center"><strong>暂未上传</strong></span>
</el-popover>
</el-upload>
@ -1220,16 +1217,22 @@
},
handleSupplierMaterialRemove(scope, fileList) {
scope.row['attachment'] = fileList
scope.row['attachment'] = fileList.map(file => ({
uri: file.response.data.url,
name: file.name
}))
},
removeSupplierMaterialAttachment(scope, attachmentToRemove) {
scope.row['attachment'] = scope.row['attachment'].filter(item => item === attachmentToRemove)
scope.row['attachment'] = scope.row['attachment'].filter(item => item !== attachmentToRemove)
},
handleSupplierMaterialExceed(scope, files, fileList) {
this.$message.warning("当前限制选择只能选择10个文件");
scope.row['attachment'] = fileList
scope.row['attachment'] = fileList.map(file => ({
uri: file.response.data.url,
name: file.name
}))
},
beforeSupplierMaterialRemove(scope, file, fileList) {
@ -1242,19 +1245,16 @@
handleSupplierMaterialFileUploaded(scope, response, file, fileList) {
if (response.success) {
let attachments = scope.row['attachment']
let attachments = scope.row.attachment
if (isEmpty(attachments)) {
attachments = []
scope.row['attachment'] = attachments
}
attachments.push({
uri: response.data.url,
name: file.name
})
console.log(attachments)
console.log(scope.row['attachment'])
scope.row.attachment = attachments
this.$message.success("上传成功");
}
else {
@ -1269,6 +1269,7 @@
addSupplierRow() {
this.supplierMaterialsForm.push({
rowKey: this.rowKeyCounter++,
attachment: []
})
},
@ -1402,6 +1403,15 @@
// this.handleSelectProject({ id: 135 })
this.applyDeptSectorOptions = JSON.parse('${applyDeptSectorOptions}')
},
filters: {
ellipsis(value, limit = 40) {
if (!value) return ''
if (value.length > limit) {
return value.slice(0, limit) + '...'
}
return value
}
}
})
</script>

View File

@ -222,29 +222,25 @@
'Content-Type': 'application/json',
},
body: JSON.stringify(form),
}).then(response => {
if (response.ok) {
// 关闭对话框
this.auditFormVisible = false
this.queryTable()
this.$message({
showClose: true,
message: '撤销成功',
type: 'success'
})
}
else {
return Promise.reject(response)
}
}).then(checkStatus).then(parseJSON).then(data => {
// 关闭对话框
this.auditFormVisible = false
this.queryTable()
this.$message({
showClose: true,
message: '审核成功',
type: 'success'
})
}).catch(err => {
this.$message.error("审核失败");
}).catch(({ response }) => {
if (response) {
parseJSON(response)
.then(json => {
this.$message.error(json.message || "审核失败")
})
}
else {
this.$message.error("审核失败")
}
}).finally(() => loading.close())
}
else {