feat: mock功能
This commit is contained in:
@@ -58,11 +58,22 @@
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
open.value = true
|
||||
if (record) {
|
||||
let recordData = cloneDeep(record)
|
||||
formData.value = Object.assign({}, recordData)
|
||||
}
|
||||
// 加载是否启用字典(0=否,1=是)
|
||||
isEnabledOptions.value = tool.dictList('IS_USED')
|
||||
if (record) {
|
||||
const recordData = cloneDeep(record)
|
||||
// 后端/表格里是布尔值 true/false,这里统一转换成字典需要的 '0' / '1'
|
||||
if (typeof recordData.isEnabled === 'boolean') {
|
||||
recordData.isEnabled = recordData.isEnabled ? '1' : '0'
|
||||
} else if (recordData.isEnabled === 1 || recordData.isEnabled === 0) {
|
||||
recordData.isEnabled = String(recordData.isEnabled)
|
||||
}
|
||||
formData.value = Object.assign({}, recordData)
|
||||
} else {
|
||||
// 新增时默认启用:'1'
|
||||
formData.value = {}
|
||||
formData.value.isEnabled = '1'
|
||||
}
|
||||
}
|
||||
// 关闭抽屉
|
||||
const onClose = () => {
|
||||
@@ -80,6 +91,12 @@
|
||||
.then(() => {
|
||||
submitLoading.value = true
|
||||
const formDataParam = cloneDeep(formData.value)
|
||||
// 提交前将 '0' / '1' 转回数字 0 / 1(如果后端需要的话)
|
||||
if (formDataParam.isEnabled === '1') {
|
||||
formDataParam.isEnabled = 1
|
||||
} else if (formDataParam.isEnabled === '0') {
|
||||
formDataParam.isEnabled = 0
|
||||
}
|
||||
mockConfigApi
|
||||
.mockConfigSubmitForm(formDataParam, formDataParam.id)
|
||||
.then(() => {
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'isEnabled'">
|
||||
{{ record.isEnabled ? '启用' : '禁用' }}
|
||||
{{ $TOOL.dictTypeData('IS_USED', record.isEnabled === true ? '1' : record.isEnabled === false ? '0' : record.isEnabled) }}
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
|
||||
Reference in New Issue
Block a user