| | |
| | | import { BasicModal, useModalInner } from '@jnpf/ui/modal'; |
| | | |
| | | import { createSignMode, getSignModeInfo, updateSignMode } from '#/api/x/tms/signMode'; |
| | | |
| | | import { ENABLE_OPTIONS, YES_NO_OPTIONS } from './constants'; |
| | | import { useBaseStore } from '#/store'; |
| | | import { |
| | | TMS_DIC, |
| | | TMS_DIC_FIELD_NAMES, |
| | | loadTmsDic, |
| | | } from '#/views/x/tms/shared/dic'; |
| | | |
| | | defineOptions({ name: 'TmsSignModeForm' }); |
| | | |
| | | const emit = defineEmits(['register', 'reload']); |
| | | const { createMessage } = useMessage(); |
| | | const baseStore = useBaseStore(); |
| | | |
| | | const state = reactive({ id: '' }); |
| | | const { id } = toRefs(state); |
| | |
| | | label: '须匹配名单', |
| | | component: 'Select', |
| | | defaultValue: '1', |
| | | componentProps: { placeholder: '请选择', options: YES_NO_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | label: '启用状态', |
| | | component: 'Select', |
| | | defaultValue: '1', |
| | | componentProps: { placeholder: '请选择', options: ENABLE_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | }); |
| | | |
| | | const [registerModal, { closeModal, changeLoading, changeOkLoading }] = useModalInner(init); |
| | | |
| | | async function loadDicOptions() { |
| | | const [yesNo, enable] = await Promise.all([ |
| | | loadTmsDic(baseStore, TMS_DIC.yesNo), |
| | | loadTmsDic(baseStore, TMS_DIC.enableStatus), |
| | | ]); |
| | | updateSchema([ |
| | | { |
| | | field: 'matchRoster', |
| | | componentProps: { placeholder: '请选择', options: yesNo, fieldNames: TMS_DIC_FIELD_NAMES }, |
| | | }, |
| | | { |
| | | field: 'enabled', |
| | | componentProps: { placeholder: '请选择', options: enable, fieldNames: TMS_DIC_FIELD_NAMES }, |
| | | }, |
| | | ]); |
| | | } |
| | | |
| | | async function init(data: { id?: string }) { |
| | | changeLoading(true); |
| | |
| | | }, |
| | | }); |
| | | try { |
| | | if (state.id) { |
| | | setFieldsValue(await getSignModeInfo(state.id)); |
| | | } |
| | | await loadDicOptions(); |
| | | if (state.id) setFieldsValue(await getSignModeInfo(state.id)); |
| | | } finally { |
| | | changeLoading(false); |
| | | } |