|
|
@ -12,14 +12,14 @@ const useForm = Form.useForm |
|
|
|
const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber] |
|
|
|
const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber] |
|
|
|
|
|
|
|
|
|
|
|
const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState( |
|
|
|
const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState( |
|
|
|
(meta: Ref<TableType>, column?: Ref<ColumnType>) => { |
|
|
|
(meta: Ref<TableType | undefined>, column: Ref<ColumnType | undefined>) => { |
|
|
|
const { sqlUi } = useProject() |
|
|
|
const { sqlUi } = useProject() |
|
|
|
const { $api } = useNuxtApp() |
|
|
|
const { $api } = useNuxtApp() |
|
|
|
const { getMeta } = useMetas() |
|
|
|
const { getMeta } = useMetas() |
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
const { $e } = useNuxtApp() |
|
|
|
const { $e } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
const isEdit = computed(() => !!column?.value?.id) |
|
|
|
const isEdit = computed(() => !!column.value?.id) |
|
|
|
|
|
|
|
|
|
|
|
const idType = null |
|
|
|
const idType = null |
|
|
|
|
|
|
|
|
|
|
@ -32,7 +32,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
const formState = ref<Record<string, any>>({ |
|
|
|
const formState = ref<Record<string, any>>({ |
|
|
|
title: 'title', |
|
|
|
title: 'title', |
|
|
|
uidt: UITypes.SingleLineText, |
|
|
|
uidt: UITypes.SingleLineText, |
|
|
|
...clone(column?.value || {}), |
|
|
|
...clone(column.value || {}), |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
// actions
|
|
|
@ -101,8 +101,8 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
formState.value.dtxs = sqlUi.value.getDefaultScaleForDatatype(formState.value.dt) |
|
|
|
formState.value.dtxs = sqlUi.value.getDefaultScaleForDatatype(formState.value.dt) |
|
|
|
|
|
|
|
|
|
|
|
const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect] |
|
|
|
const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect] |
|
|
|
if (column && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column?.value?.uidt as UITypes)) { |
|
|
|
if (column && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column.value?.uidt as UITypes)) { |
|
|
|
formState.value.dtxp = column?.value?.dtxp |
|
|
|
formState.value.dtxp = column.value?.dtxp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (columnToValidate.includes(formState.value.uidt)) { |
|
|
|
if (columnToValidate.includes(formState.value.uidt)) { |
|
|
@ -112,7 +112,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isCurrency.value) { |
|
|
|
if (isCurrency.value) { |
|
|
|
if (column?.value?.uidt === UITypes.Currency) { |
|
|
|
if (column.value?.uidt === UITypes.Currency) { |
|
|
|
formState.value.dtxp = column.value.dtxp |
|
|
|
formState.value.dtxp = column.value.dtxp |
|
|
|
formState.value.dtxs = column.value.dtxs |
|
|
|
formState.value.dtxs = column.value.dtxs |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -140,12 +140,12 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
formState.value.dtx = 'specificType' |
|
|
|
formState.value.dtx = 'specificType' |
|
|
|
|
|
|
|
|
|
|
|
const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect] |
|
|
|
const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect] |
|
|
|
if (column?.value && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column?.value.uidt as UITypes)) { |
|
|
|
if (column.value && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column.value.uidt as UITypes)) { |
|
|
|
formState.value.dtxp = column?.value.dtxp |
|
|
|
formState.value.dtxp = column.value.dtxp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isCurrency.value) { |
|
|
|
if (isCurrency.value) { |
|
|
|
if (column?.value?.uidt === UITypes.Currency) { |
|
|
|
if (column.value?.uidt === UITypes.Currency) { |
|
|
|
formState.value.dtxp = column.value.dtxp |
|
|
|
formState.value.dtxp = column.value.dtxp |
|
|
|
formState.value.dtxs = column.value.dtxs |
|
|
|
formState.value.dtxs = column.value.dtxs |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -177,10 +177,10 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
formState.value.table_name = meta.value.table_name |
|
|
|
formState.value.table_name = meta.value?.table_name |
|
|
|
// formState.value.title = formState.value.column_name
|
|
|
|
// formState.value.title = formState.value.column_name
|
|
|
|
if (column?.value) { |
|
|
|
if (column.value) { |
|
|
|
await $api.dbTableColumn.update(column?.value?.id as string, formState.value) |
|
|
|
await $api.dbTableColumn.update(column.value?.id as string, formState.value) |
|
|
|
// Column updated
|
|
|
|
// Column updated
|
|
|
|
message.success(t('msg.success.columnUpdated')) |
|
|
|
message.success(t('msg.success.columnUpdated')) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -193,10 +193,10 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
// };
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
await $api.dbTableColumn.create(meta.value.id as string, formState.value) |
|
|
|
await $api.dbTableColumn.create(meta.value?.id as string, formState.value) |
|
|
|
|
|
|
|
|
|
|
|
/** if LTAR column then force reload related table meta */ |
|
|
|
/** if LTAR column then force reload related table meta */ |
|
|
|
if (formState.value.uidt === UITypes.LinkToAnotherRecord && meta.value.id !== formState.value.childId) { |
|
|
|
if (formState.value.uidt === UITypes.LinkToAnotherRecord && meta.value?.id !== formState.value.childId) { |
|
|
|
getMeta(formState.value.childId, true).then(() => {}) |
|
|
|
getMeta(formState.value.childId, true).then(() => {}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|