refactor(CRUD):远程下拉字段名视情况再自动修改

This commit is contained in:
妙码生花 2023-07-09 01:06:11 +08:00
parent 2b0a44a0a3
commit 438989cf43
2 changed files with 10 additions and 7 deletions

View File

@ -421,7 +421,7 @@
v-loading="state.remoteSelectPre.loading"
label-position="right"
label-width="160px"
v-if="state.remoteSelectPre.index != -1"
v-if="state.remoteSelectPre.index != -1 && state.fields[state.remoteSelectPre.index]"
>
<FormItem
prop="table"
@ -1350,10 +1350,13 @@ const onJoinTableChange = (val: string) => {
const onSaveRemoteSelect = () => {
const submitCallback = () => {
//
onFieldBackup(state.fields[state.remoteSelectPre.index], state.remoteSelectPre.index)
const newName = state.remoteSelectPre.form.table + (state.fields[state.remoteSelectPre.index].designType == 'remoteSelect' ? '_id' : '_ids')
state.fields[state.remoteSelectPre.index].name = newName
onFieldNameChange(newName, state.remoteSelectPre.index)
if (state.fields[state.remoteSelectPre.index].name == 'remote_select') {
onFieldBackup(state.fields[state.remoteSelectPre.index], state.remoteSelectPre.index)
const newName =
state.remoteSelectPre.form.table + (state.fields[state.remoteSelectPre.index].designType == 'remoteSelect' ? '_id' : '_ids')
state.fields[state.remoteSelectPre.index].name = newName
onFieldNameChange(newName, state.remoteSelectPre.index)
}
state.fields[state.remoteSelectPre.index].form['remote-table'].value = state.remoteSelectPre.form.table
state.fields[state.remoteSelectPre.index].form['remote-pk'].value = state.remoteSelectPre.form.pk

View File

@ -161,7 +161,7 @@ export const fieldItem: {
},
{
title: i18n.global.t('crud.state.Remote Select (association table)'),
name: 'user_id',
name: 'remote_select',
comment: i18n.global.t('utils.remote select'),
designType: 'remoteSelect',
tableBuildExclude: true,
@ -412,7 +412,7 @@ export const fieldItem: {
},
{
title: i18n.global.t('crud.state.Remote Select (Multi)'),
name: 'user_ids',
name: 'remote_select',
comment: i18n.global.t('utils.remote select'),
designType: 'remoteSelects',
tableBuildExclude: true,