forked from mt-fe-group/mt-yd-ui
update dialog: 多上传组件上传、下载和更新
This commit is contained in:
parent
3d851e4362
commit
8ad162aab6
@ -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() {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user