更新
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-model:open="visible"
|
||||
:open="visible"
|
||||
:title="isEdit ? '编辑配置' : '新增配置'"
|
||||
:width="600"
|
||||
:confirm-loading="loading"
|
||||
@@ -152,7 +152,7 @@
|
||||
<script setup>
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { systemApi } from '@/api/system'
|
||||
import systemApi from '@/api/system'
|
||||
|
||||
const props = defineProps({
|
||||
visible: Boolean,
|
||||
@@ -211,44 +211,6 @@ const parsedOptions = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
// 监听record变化,初始化表单
|
||||
watch(
|
||||
() => props.record,
|
||||
(newRecord) => {
|
||||
if (newRecord) {
|
||||
// 编辑模式
|
||||
Object.assign(formData, {
|
||||
group: newRecord.group || 'system',
|
||||
key: newRecord.key || '',
|
||||
name: newRecord.name || '',
|
||||
type: newRecord.type || 'string',
|
||||
value: parseValueByType(newRecord.value, newRecord.type),
|
||||
options: newRecord.options,
|
||||
sort: newRecord.sort || 0,
|
||||
status: newRecord.status ?? 1,
|
||||
description: newRecord.description || '',
|
||||
is_system: newRecord.is_system || false
|
||||
})
|
||||
|
||||
// 解析选项
|
||||
if (newRecord.options && typeof newRecord.options === 'object') {
|
||||
optionsText.value = newRecord.options
|
||||
.map((opt) => {
|
||||
if (typeof opt === 'object') {
|
||||
return `${opt.label}:${opt.value}`
|
||||
}
|
||||
return opt
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
} else {
|
||||
// 新增模式,重置表单
|
||||
resetForm()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// 根据类型解析值
|
||||
const parseValueByType = (value, type) => {
|
||||
if (!value) return value
|
||||
@@ -289,6 +251,44 @@ const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
// 监听record变化,初始化表单
|
||||
watch(
|
||||
() => props.record,
|
||||
(newRecord) => {
|
||||
if (newRecord) {
|
||||
// 编辑模式
|
||||
Object.assign(formData, {
|
||||
group: newRecord.group || 'system',
|
||||
key: newRecord.key || '',
|
||||
name: newRecord.name || '',
|
||||
type: newRecord.type || 'string',
|
||||
value: parseValueByType(newRecord.value, newRecord.type),
|
||||
options: newRecord.options,
|
||||
sort: newRecord.sort || 0,
|
||||
status: newRecord.status ?? 1,
|
||||
description: newRecord.description || '',
|
||||
is_system: newRecord.is_system || false
|
||||
})
|
||||
|
||||
// 解析选项
|
||||
if (newRecord.options && typeof newRecord.options === 'object') {
|
||||
optionsText.value = newRecord.options
|
||||
.map((opt) => {
|
||||
if (typeof opt === 'object') {
|
||||
return `${opt.label}:${opt.value}`
|
||||
}
|
||||
return opt
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
} else {
|
||||
// 新增模式,重置表单
|
||||
resetForm()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// 添加自定义分组
|
||||
const handleAddCustomGroup = () => {
|
||||
if (!customGroup.value) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="pages system-configs-page">
|
||||
<div class="pages-base-layout system-configs-page">
|
||||
<div class="tool-bar">
|
||||
<div class="left-panel">
|
||||
<a-space>
|
||||
@@ -129,8 +129,9 @@ import {
|
||||
EditOutlined,
|
||||
FileOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import scTable from '@/components/scTable/index.vue'
|
||||
import { useTable } from '@/hooks/useTable'
|
||||
import { systemApi } from '@/api/system'
|
||||
import systemApi from '@/api/system'
|
||||
import SaveDialog from './components/SaveDialog.vue'
|
||||
|
||||
// 表格引用
|
||||
@@ -380,8 +381,6 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
.system-configs-page {
|
||||
@extend .pages-base-layout;
|
||||
|
||||
.value-text {
|
||||
color: #666;
|
||||
font-family: monospace;
|
||||
|
||||
Reference in New Issue
Block a user