1
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="config-container">
|
<div class="config-container" v-loading="loading">
|
||||||
<!-- 左侧:配置表单 -->
|
<!-- 左侧:配置表单 -->
|
||||||
<div class="config-left">
|
<div class="config-left">
|
||||||
<div class="config-section">
|
<div class="config-section">
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<div class="config-list">
|
<div class="config-list">
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in configList"
|
v-for="(item, index) in configList"
|
||||||
:key="index"
|
:key="item.configId || item.configKey || `config-${index}`"
|
||||||
class="config-item"
|
class="config-item"
|
||||||
>
|
>
|
||||||
<el-form-item label="分销标识" style="margin-bottom: 10px;">
|
<el-form-item label="分销标识" style="margin-bottom: 10px;">
|
||||||
@@ -181,6 +181,7 @@ export default {
|
|||||||
configList: [],
|
configList: [],
|
||||||
saveLoading: false,
|
saveLoading: false,
|
||||||
loadLoading: false,
|
loadLoading: false,
|
||||||
|
loading: false,
|
||||||
commonDistributionMarks: ['F', 'PDD', 'H-TF', 'H', 'TF'],
|
commonDistributionMarks: ['F', 'PDD', 'H-TF', 'H', 'TF'],
|
||||||
configKeyPrefix: 'logistics.push.touser.'
|
configKeyPrefix: 'logistics.push.touser.'
|
||||||
}
|
}
|
||||||
@@ -201,7 +202,13 @@ export default {
|
|||||||
value(val) {
|
value(val) {
|
||||||
this.visible = val
|
this.visible = val
|
||||||
if (val) {
|
if (val) {
|
||||||
this.loadConfig()
|
// 延迟一下确保对话框已经打开
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.loadConfig()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 关闭时清空列表,避免下次打开时显示旧数据
|
||||||
|
this.configList = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
visible(val) {
|
visible(val) {
|
||||||
@@ -211,6 +218,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
/** 加载当前配置 */
|
/** 加载当前配置 */
|
||||||
async loadConfig() {
|
async loadConfig() {
|
||||||
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
// 先尝试从系统配置中加载已有的配置
|
// 先尝试从系统配置中加载已有的配置
|
||||||
// 由于我们不知道有哪些分销标识,先加载所有以 logistics.push.touser. 开头的配置
|
// 由于我们不知道有哪些分销标识,先加载所有以 logistics.push.touser. 开头的配置
|
||||||
@@ -220,9 +228,18 @@ export default {
|
|||||||
pageSize: 100
|
pageSize: 100
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.code === 200 && res.rows && res.rows.length > 0) {
|
console.log('加载配置响应:', res)
|
||||||
this.configList = res.rows
|
|
||||||
.filter(item => item.configKey && item.configKey.startsWith(this.configKeyPrefix))
|
// 重置配置列表
|
||||||
|
this.configList = []
|
||||||
|
|
||||||
|
if (res && res.code === 200 && res.rows && res.rows.length > 0) {
|
||||||
|
// 过滤并转换配置项
|
||||||
|
const configs = res.rows
|
||||||
|
.filter(item => {
|
||||||
|
// 确保 configKey 存在且以配置前缀开头
|
||||||
|
return item && item.configKey && item.configKey.startsWith(this.configKeyPrefix)
|
||||||
|
})
|
||||||
.map(item => {
|
.map(item => {
|
||||||
const distributionMark = item.configKey.replace(this.configKeyPrefix, '')
|
const distributionMark = item.configKey.replace(this.configKeyPrefix, '')
|
||||||
return {
|
return {
|
||||||
@@ -230,9 +247,16 @@ export default {
|
|||||||
touser: item.configValue || '',
|
touser: item.configValue || '',
|
||||||
configId: item.configId,
|
configId: item.configId,
|
||||||
configKey: item.configKey,
|
configKey: item.configKey,
|
||||||
configName: item.configName
|
configName: item.configName || `${distributionMark}分销标识接收人`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.configList = configs
|
||||||
|
console.log('解析后的配置列表:', this.configList)
|
||||||
|
|
||||||
|
if (configs.length > 0) {
|
||||||
|
this.$message.success(`成功加载 ${configs.length} 条配置`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有配置,至少添加一个空项
|
// 如果没有配置,至少添加一个空项
|
||||||
@@ -244,9 +268,11 @@ export default {
|
|||||||
configKey: '',
|
configKey: '',
|
||||||
configName: ''
|
configName: ''
|
||||||
})
|
})
|
||||||
|
console.log('未找到配置,添加空项')
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('加载配置失败:', e)
|
console.error('加载配置失败:', e)
|
||||||
|
this.$message.error('加载配置失败:' + (e.message || '未知错误'))
|
||||||
// 即使加载失败,也至少添加一个空项
|
// 即使加载失败,也至少添加一个空项
|
||||||
if (this.configList.length === 0) {
|
if (this.configList.length === 0) {
|
||||||
this.configList.push({
|
this.configList.push({
|
||||||
@@ -257,6 +283,8 @@ export default {
|
|||||||
configName: ''
|
configName: ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user