mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-22 15:24:09 +00:00
feat(CRUD):根据字段字典重新生成字段的数据类型
This commit is contained in:
parent
4d1dd2d1db
commit
79c7b83e13
@ -234,6 +234,7 @@
|
|||||||
type="textarea"
|
type="textarea"
|
||||||
:input-attr="{
|
:input-attr="{
|
||||||
rows: 2,
|
rows: 2,
|
||||||
|
onChange: onFieldCommentChange,
|
||||||
}"
|
}"
|
||||||
:placeholder="
|
:placeholder="
|
||||||
t(
|
t(
|
||||||
@ -813,6 +814,37 @@ const handleFieldAttr = (field: FieldItem) => {
|
|||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字段字典重新生成字段的数据类型
|
||||||
|
*/
|
||||||
|
const onFieldCommentChange = (comment: string) => {
|
||||||
|
if (['enum', 'set'].includes(state.fields[state.activateField].type)) {
|
||||||
|
if (!comment) {
|
||||||
|
state.fields[state.activateField].dataType = `${state.fields[state.activateField].type}()`
|
||||||
|
return
|
||||||
|
}
|
||||||
|
comment = comment.replaceAll(':', ':')
|
||||||
|
comment = comment.replaceAll(',', ',')
|
||||||
|
let comments = comment.split(':')
|
||||||
|
if (comments[1]) {
|
||||||
|
comments = comments[1].split(',')
|
||||||
|
comments = comments
|
||||||
|
.map((value) => {
|
||||||
|
if (!value) return ''
|
||||||
|
let temp = value.split('=')
|
||||||
|
if (temp[0] && temp[1]) {
|
||||||
|
return `'${temp[0]}'`
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
})
|
||||||
|
.filter((str: string) => str != '')
|
||||||
|
|
||||||
|
// 字段数据类型
|
||||||
|
state.fields[state.activateField].dataType = `${state.fields[state.activateField].type}(${comments.join(',')})`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loadData = () => {
|
const loadData = () => {
|
||||||
if (!['db', 'sql', 'log'].includes(crudState.type)) return
|
if (!['db', 'sql', 'log'].includes(crudState.type)) return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user