This commit is contained in:
@@ -44,16 +44,13 @@
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<ElForm label-width="120px">
|
||||
<ElFormItem label="配置 Key">
|
||||
<ElInput :model-value="currentConfig?.config_key || '-'" disabled />
|
||||
</ElFormItem>
|
||||
<ElFormItem label="配置说明">
|
||||
<span>{{ currentConfig?.description || '-' }}</span>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="配置值">
|
||||
<ElCheckboxGroup v-if="isPaymentConfig" v-model="editPaymentMethods">
|
||||
<ElCheckbox v-for="method in paymentMethods" :key="method" :label="method">
|
||||
{{ method }}
|
||||
{{ paymentMethodLabels[method] }}
|
||||
</ElCheckbox>
|
||||
</ElCheckboxGroup>
|
||||
<ElSwitch v-else-if="isBooleanConfig" v-model="editBoolean" />
|
||||
@@ -89,7 +86,6 @@
|
||||
placeholder="请输入配置值"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<div v-if="valueHint" class="config-hint">{{ valueHint }}</div>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
@@ -103,6 +99,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage, ElTag } from 'element-plus'
|
||||
import { SystemConfigService } from '@/api/modules'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
@@ -120,6 +117,7 @@
|
||||
|
||||
defineOptions({ name: 'SystemConfigs' })
|
||||
const { hasAuth } = useAuth()
|
||||
const route = useRoute()
|
||||
|
||||
const moduleOptions = [
|
||||
{ label: '运营商回调配置', value: 'carrier_callback' },
|
||||
@@ -149,14 +147,18 @@
|
||||
const editNumber = ref<number | null>(null)
|
||||
const editPaymentMethods = ref<AllowedPaymentMethod[]>([])
|
||||
const paymentMethods: AllowedPaymentMethod[] = ['wallet', 'wechat', 'alipay']
|
||||
const paymentMethodLabels: Record<AllowedPaymentMethod, string> = {
|
||||
wallet: '钱包',
|
||||
wechat: '微信',
|
||||
alipay: '支付宝'
|
||||
}
|
||||
const targetConfigHandled = ref(false)
|
||||
const pagination = reactive({ page: 1, page_size: 20, total: 0 })
|
||||
|
||||
const columnOptions = [
|
||||
{ label: '配置 Key', prop: 'config_key' },
|
||||
{ label: '模块', prop: 'module' },
|
||||
{ label: '配置说明', prop: 'description' },
|
||||
{ label: '配置值', prop: 'value' },
|
||||
{ label: '控件', prop: 'control' },
|
||||
{ label: '注册状态', prop: 'registered' },
|
||||
{ label: '只读', prop: 'readonly' },
|
||||
{ label: '敏感', prop: 'sensitive' },
|
||||
@@ -167,7 +169,6 @@
|
||||
moduleOptions.find((item) => item.value === module)?.label || module
|
||||
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{ prop: 'config_key', label: '配置 Key', minWidth: 220, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'module',
|
||||
label: '模块',
|
||||
@@ -178,10 +179,10 @@
|
||||
{
|
||||
prop: 'value',
|
||||
label: '配置值',
|
||||
minWidth: 150,
|
||||
formatter: (row: SystemConfigItem) => row.value || '-'
|
||||
minWidth: 260,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: SystemConfigItem) => formatConfigValue(row)
|
||||
},
|
||||
{ prop: 'control', label: '控件', width: 100 },
|
||||
{
|
||||
prop: 'registered',
|
||||
label: '注册状态',
|
||||
@@ -216,7 +217,8 @@
|
||||
)
|
||||
const isPaymentConfig = computed(() =>
|
||||
[PAYMENT_CONFIG_KEYS.card, PAYMENT_CONFIG_KEYS.device].includes(
|
||||
currentConfig.value?.config_key as (typeof PAYMENT_CONFIG_KEYS)[keyof typeof PAYMENT_CONFIG_KEYS]
|
||||
currentConfig.value
|
||||
?.config_key as (typeof PAYMENT_CONFIG_KEYS)[keyof typeof PAYMENT_CONFIG_KEYS]
|
||||
)
|
||||
)
|
||||
const isIntegerConfig = computed(
|
||||
@@ -233,14 +235,18 @@
|
||||
!isBooleanConfig.value && !isIntegerConfig.value && currentConfig.value?.value_type === 'json'
|
||||
)
|
||||
|
||||
const valueHint = computed(() => {
|
||||
if (!currentConfig.value) return ''
|
||||
const { min, max } = currentConfig.value
|
||||
if (min !== null && max !== null) return `取值范围:${min}~${max}`
|
||||
if (min !== null) return `最小值:${min}`
|
||||
if (max !== null) return `最大值:${max}`
|
||||
return ''
|
||||
})
|
||||
const isPaymentConfigKey = (configKey: string) =>
|
||||
Object.values(PAYMENT_CONFIG_KEYS).includes(
|
||||
configKey as (typeof PAYMENT_CONFIG_KEYS)[keyof typeof PAYMENT_CONFIG_KEYS]
|
||||
)
|
||||
|
||||
const formatConfigValue = (config: SystemConfigItem) => {
|
||||
if (isPaymentConfigKey(config.config_key)) {
|
||||
const methods = parsePaymentMethods(config.value)
|
||||
return methods.length ? methods.map((method) => paymentMethodLabels[method]).join('、') : '-'
|
||||
}
|
||||
return config.value || '-'
|
||||
}
|
||||
|
||||
const getSubmittedValue = () => {
|
||||
if (isPaymentConfig.value) return JSON.stringify(editPaymentMethods.value)
|
||||
@@ -293,6 +299,12 @@
|
||||
if (res.code === 0) {
|
||||
configList.value = res.data.list || []
|
||||
pagination.total = res.data.total || 0
|
||||
const targetKey = String(route.query.config_key || '')
|
||||
const targetConfig = configList.value.find((config) => config.config_key === targetKey)
|
||||
if (targetKey && targetConfig && !targetConfigHandled.value) {
|
||||
targetConfigHandled.value = true
|
||||
showEditDialog(targetConfig)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取系统配置失败:', error)
|
||||
@@ -370,10 +382,5 @@
|
||||
|
||||
<style scoped lang="scss">
|
||||
.system-configs-page {
|
||||
.config-hint {
|
||||
margin: -12px 0 0 120px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user