plus-ui/src/views/set/setting.vue

72 lines
2.0 KiB
Vue
Raw Normal View History

<template>
<div class="app-container">
<el-tabs v-model="activeKey" @tab-click="changeType">
2025-06-07 15:51:05 +08:00
<el-tab-pane v-for="it in tabList" :key="it.value" :label="it.label" :name="it.value" />
</el-tabs>
<Editor v-model="currentConfig.configValue" placeholder="请输入内容" type="url"></Editor>
<el-button type="primary" class="mt20" @click="asyncOk">保存</el-button>
<el-button class="mt20 ml20" @click="getData">重置</el-button>
</div>
</template>
<script>
2025-06-07 15:51:05 +08:00
import { getConfigKey2, addOrUpdate } from '@/api/system/config';
export default {
data() {
return {
//常见问题,隐私协议,联系客服
activeKey: 'mall.contact',
tabList: [
2025-06-07 15:51:05 +08:00
{ label: '客服配置', value: 'mall.contact' },
{ label: '隐私协议', value: 'mall.privacyAgreement' },
{ label: '常见问题', value: 'mall.question' },
{ label: '关于我们', value: 'mall.aboutUs' }
],
configList: [],
currentConfig: {
2025-06-07 15:51:05 +08:00
configValue: ''
}
2025-06-07 15:51:05 +08:00
};
},
methods: {
changeType() {
2025-06-07 15:51:05 +08:00
this.currentConfig = this.configList.filter((it) => it.configKey === this.activeKey)[0];
console.log(this.currentConfig);
},
getData() {
2025-06-07 15:51:05 +08:00
const funcArr = this.tabList.map((it) => {
return getConfigKey2(it.value);
});
const list = [];
Promise.all(funcArr).then((res) => {
res.forEach((it, idx) => {
2025-06-07 15:51:05 +08:00
list.push(
it.data
? it.data
: {
configValue: '',
configType: 'N',
configKey: this.tabList[idx].value,
configName: this.tabList[idx].label,
configId: null
}
);
});
this.configList = list;
this.changeType();
});
},
asyncOk() {
2025-06-07 15:51:05 +08:00
addOrUpdate(this.currentConfig).then((res) => {
2025-06-14 16:44:46 +08:00
this.$modal.msgSuccess('保存成功');
2025-06-07 15:51:05 +08:00
this.getData();
});
}
},
created() {
2025-06-07 15:51:05 +08:00
this.getData();
}
};
</script>