| | |
| | | import { BasicModal, useModalInner } from '@jnpf/ui/modal'; |
| | | |
| | | import { createTrainMode, getTrainModeInfo, updateTrainMode } from '#/api/x/tms/trainMode'; |
| | | |
| | | import { ENABLE_OPTIONS, SIGN_RULE_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: 'TmsTrainModeForm' }); |
| | | |
| | | const emit = defineEmits(['register', 'reload']); |
| | | const { createMessage } = useMessage(); |
| | | const baseStore = useBaseStore(); |
| | | |
| | | const state = reactive({ id: '' }); |
| | | const { id } = toRefs(state); |
| | |
| | | label: '签到规则', |
| | | component: 'Select', |
| | | defaultValue: 'both', |
| | | componentProps: { placeholder: '请选择', options: SIGN_RULE_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | label: '允许名单外签到', |
| | | component: 'Select', |
| | | defaultValue: '0', |
| | | componentProps: { placeholder: '请选择', options: YES_NO_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | label: '起止须同一天', |
| | | component: 'Select', |
| | | defaultValue: '0', |
| | | 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: 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 [signRule, yesNo, enable] = await Promise.all([ |
| | | loadTmsDic(baseStore, TMS_DIC.signRule), |
| | | loadTmsDic(baseStore, TMS_DIC.yesNo), |
| | | loadTmsDic(baseStore, TMS_DIC.enableStatus), |
| | | ]); |
| | | updateSchema([ |
| | | { |
| | | field: 'signRule', |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: signRule, |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | }, |
| | | { |
| | | field: 'allowGuestSign', |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: yesNo, |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | }, |
| | | { |
| | | field: 'sameDayRequired', |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: yesNo, |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | }, |
| | | { |
| | | field: 'placeRequired', |
| | | 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 { |
| | | await loadDicOptions(); |
| | | if (state.id) { |
| | | const info = await getTrainModeInfo(state.id); |
| | | setFieldsValue(info); |
| | | setFieldsValue(await getTrainModeInfo(state.id)); |
| | | } |
| | | } finally { |
| | | changeLoading(false); |