update 2023.4.6 - 2
This commit is contained in:
@@ -10,8 +10,9 @@
|
||||
|
||||
<div class="dialog-body__inner relative">
|
||||
<!-- v-if="dataForm.id && !detailMode && /属性|详情/.test(activeMenu) && $hasPermission()" -->
|
||||
<el-button v-if="configs.allowAdd ?? (dataForm.id && !detailMode && /属性|详情|参数/.test(activeMenu))" plain type="primary" size="small"
|
||||
class="at-right-top" style="margin-bottom: 16px" @click="handleAddParam()">+ 添加</el-button>
|
||||
<el-button v-if="configs.allowAdd ?? (dataForm.id && !detailMode && /属性|详情|参数/.test(activeMenu))" plain
|
||||
type="primary" size="small" class="at-right-top" style="margin-bottom: 16px" @click="handleAddParam()">+
|
||||
添加</el-button>
|
||||
<template v-if="dataForm.id && !detailMode && /附件/.test(activeMenu)">
|
||||
<el-upload style="position: absolute; width: 100%; height: 0" name="files" :action="uploadUrl"
|
||||
:show-file-list="false" :headers="uploadHeaders" :on-success="handleUploadSuccess"
|
||||
@@ -185,6 +186,7 @@ export default {
|
||||
const dataForm = {};
|
||||
const autoDisabledQueue = [];
|
||||
const watingToRefreshQueue = [];
|
||||
const cached = {}
|
||||
|
||||
this.configs.form.rows.forEach((row) => {
|
||||
row.forEach((col) => {
|
||||
@@ -193,11 +195,17 @@ export default {
|
||||
|
||||
if (col.autoDisabled) autoDisabledQueue.push(col.prop);
|
||||
if (!!col.refreshOptionsAfterConfirm) watingToRefreshQueue.push(col);
|
||||
|
||||
if (col.fetchData)
|
||||
col.fetchData().then(({ data: res }) => {
|
||||
console.log("[Fetch Data]", "list" in res.data, res.data, res.data.list);
|
||||
if (res.code === 0) {
|
||||
if (!col.options || !col.options.length)
|
||||
if (col.cacheFetchedData) {
|
||||
// cache fetched data
|
||||
cached[col.prop] = 'list' in res.data ? res.data.list : (Array.isArray(res.data) ? res.data : [])
|
||||
}
|
||||
|
||||
if (!col.options || !col.options.length) {
|
||||
this.$set(
|
||||
col,
|
||||
"options",
|
||||
@@ -211,6 +219,7 @@ export default {
|
||||
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||
}))
|
||||
);
|
||||
}
|
||||
// col.options = res.data.list;
|
||||
else if (col.options.length) {
|
||||
"list" in res.data ? res.data.list.unshift(...col.options) : res.data.unshift(...col.options);
|
||||
@@ -273,6 +282,7 @@ export default {
|
||||
detailMode: false,
|
||||
autoDisabledQueue,
|
||||
watingToRefreshQueue,
|
||||
cached,
|
||||
showBaseDialog: false,
|
||||
baseDialogConfig: null,
|
||||
subList: [],
|
||||
@@ -309,6 +319,38 @@ export default {
|
||||
currentImgUrl: "",
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.configs.form.rows.forEach((row) => {
|
||||
row.forEach((col) => {
|
||||
if (col.changeReflects && typeof col.changeReflects === 'object' && 'fromKey' in col.changeReflects && 'toProp' in col.changeReflects) {
|
||||
this.$watch(
|
||||
() => this.dataForm[col.prop],
|
||||
val => {
|
||||
if (val && (col.prop in this.cached)) {
|
||||
console.log("here changeReflects", col.prop, col.changeReflects.toProp, this.cached[col.prop])
|
||||
if (typeof col.changeReflects.fromKey === 'string') {
|
||||
this.dataForm[col.changeReflects.toProp] = this.cached[col.prop].find(item => item.id === val)?.[col.changeReflects.fromKey]
|
||||
} else if (Array.isArray(col.changeReflects.fromKey) && col.changeReflects.delimiter) {
|
||||
const foundItem = this.dataForm[col.changeReflects.toProp] = this.cached[col.prop].find(item => item.id === val)
|
||||
if (foundItem) {
|
||||
const values = col.changeReflects.fromKey.map(key => foundItem[key])
|
||||
this.dataForm[col.changeReflects.toProp] = values.join(col.changeReflects.delimiter)
|
||||
} else {
|
||||
this.dataForm[col.changeReflects.toProp] = col.changeReflects.delimiter
|
||||
console.log("[DialogWithMenu] mounted() 没找到对应数据")
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: false
|
||||
}
|
||||
)
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
watch: {
|
||||
dialogVisible: function (val) {
|
||||
if (!!val) {
|
||||
@@ -923,4 +965,5 @@ ul.file-list>li:hover {
|
||||
|
||||
.force-disabled {
|
||||
margin-top: 42px;
|
||||
}</style>
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user