liuyu
21 小时以前 93c133349a5ccd7a328371fa113dce69d5611f21
apps/jnpf-web-apps-main/src/views/x/tms/signMode/Form.vue
@@ -6,13 +6,18 @@
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);
@@ -48,7 +53,11 @@
      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' }],
    },
    {
@@ -56,7 +65,11 @@
      label: '启用状态',
      component: 'Select',
      defaultValue: '1',
      componentProps: { placeholder: '请选择', options: ENABLE_OPTIONS },
      componentProps: {
        placeholder: '请选择',
        options: [],
        fieldNames: TMS_DIC_FIELD_NAMES,
      },
      rules: [{ required: true, message: '必填', trigger: 'change' }],
    },
    {
@@ -69,6 +82,23 @@
});
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);
@@ -84,9 +114,8 @@
    },
  });
  try {
    if (state.id) {
      setFieldsValue(await getSignModeInfo(state.id));
    }
    await loadDicOptions();
    if (state.id) setFieldsValue(await getSignModeInfo(state.id));
  } finally {
    changeLoading(false);
  }