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