update dialog: 多上传组件上传、下载和更新

This commit is contained in:
g7hoo 2022-08-16 15:49:51 +08:00
parent 3d851e4362
commit 8ad162aab6
2 changed files with 41 additions and 12 deletions

View File

@ -53,7 +53,7 @@
:is="ec.component"
v-bind="ec.props"
@uploader-update-filelist="handleUploadListUpdate($event, ec.props.extraParams.typeCode)"
:uploader-inject-file-list="dataForm.files"
:uploader-inject-file-list="/*用于设备分流的*/ fileList[ec.props.extraParams.typeCode]"
/>
</el-form-item>
</template>
@ -174,7 +174,8 @@ export default {
dataFormRules: {},
tempForm: [], // code
shouldWait: null,
fileForm: {} // typeCode
fileForm: {}, // typeCode
fileList: {} // typeCode
}
},
computed: {
@ -342,6 +343,33 @@ export default {
const dataFormKeys = Object.keys(this.dataForm)
console.log('data form keys: ', dataFormKeys, pick(res.data, dataFormKeys))
this.dataForm = pick(res.data, dataFormKeys)
// LABEL: FILE_RELATED
/** 对文件下载进行分流 */
this.fileList = {}
if (this.dataForm.files) {
console.log('files: ', this.dataForm.files)
this.dataForm.files.forEach(file => {
// const fileName = file.fileUrl.split('/').pop()
/** [1] 处理 fileList */
if (Object.hasOwn(this.fileList, file.typeCode)) {
/** 已存在 */
// this.fileList[file.typeCode].push({ id: file.id, name: fileName, typeCode: file.typeCode })
this.fileList[file.typeCode].push(file)
} else {
// this.fileList[file.typeCode] = [{ id: file.id, name: fileName, typeCode: file.typeCode }]
this.fileList[file.typeCode] = [file]
}
/** [2] 处理 fileForm */
if (Object.hasOwn(this.fileForm, file.typeCode)) {
this.fileForm[file.typeCode].push(file.id)
} else {
this.fileForm[file.typeCode] = [file.id]
}
})
console.log('after分流', this.fileList)
}
}
})
} else {
@ -446,6 +474,7 @@ export default {
// LABEL: FILE_RELATED
handleUploadListUpdate(filelist, typeCode = 'DefaultTypeCode') {
console.log('before handleUploadListUpdate(): ', JSON.parse(JSON.stringify(this.fileForm)))
// typeCode: EquipmentTypeFile
// typeCode: EquipmentInfoFile | EquipmentInfoImage
@ -462,7 +491,7 @@ export default {
typeCode,
filelist.map(item => item.id)
)
console.log('handleUploadListUpdate(): ', this.fileForm)
console.log('after handleUploadListUpdate(): ', this.fileForm)
},
handleClose() {

View File

@ -266,16 +266,16 @@ export default {
},
// /
addOrUpdateHandle(id) {
// this.addOrUpdateVisible = true
// this.$nextTick(() => {
// this.$refs.addOrUpdate.init(id)
// })
this.$router.push({
name: 'monitoring-equipmentAdd',
params: {
equipmentId: id
}
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
// this.$router.push({
// name: 'monitoring-equipmentAdd',
// params: {
// equipmentId: id
// }
// })
},
//
deleteHandle(id) {