| | |
| | | width="400px" |
| | | @ok="handleSubmit" |
| | | > |
| | | <BasicForm @register="registerForm" /> |
| | | <BasicForm @register="useFormData['forminfo'][0]" /> |
| | | </BasicDrawer> |
| | | </template> |
| | | <script lang="ts"> |
| | | import { defineComponent, ref, computed, unref } from 'vue'; |
| | | <script lang="ts" setup> |
| | | import { ref, computed, unref } from 'vue'; |
| | | import { BasicForm, useForm } from '/@/components/Form/index'; |
| | | import { formSchema } from './mesline.data'; |
| | | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| | | import { SaveEntity } from '/@/api/tigerapi/system'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | |
| | | export default defineComponent({ |
| | | name: 'MeslineDrawer', |
| | | components: { BasicDrawer, BasicForm }, |
| | | emits: ['success', 'register'], |
| | | setup(_, { emit }) { |
| | | const isUpdate = ref(true); |
| | | const emit = defineEmits(['success', 'register']); |
| | | const isUpdate = ref(true); |
| | | const useFormData = { |
| | | forminfo: useForm({ |
| | | labelWidth: 120, |
| | | schemas: formSchema, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | showActionButtonGroup: false, |
| | | }), |
| | | }; |
| | | |
| | | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
| | | labelWidth: 120, |
| | | schemas: formSchema, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | showActionButtonGroup: false, |
| | | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| | | useFormData['forminfo'][1].resetFields(); |
| | | setDrawerProps({ confirmLoading: false }); |
| | | isUpdate.value = !!data?.isUpdate; |
| | | |
| | | if (unref(isUpdate)) { |
| | | useFormData['forminfo'][1].setFieldsValue({ |
| | | ...data.record, |
| | | }); |
| | | |
| | | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| | | resetFields(); |
| | | setDrawerProps({ confirmLoading: false }); |
| | | isUpdate.value = !!data?.isUpdate; |
| | | |
| | | if (unref(isUpdate)) { |
| | | setFieldsValue({ |
| | | ...data.record, |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | const getTitle = computed(() => (!unref(isUpdate) ? '新增产线' : '编辑产线')); |
| | | |
| | | async function handleSubmit() { |
| | | try { |
| | | const values = await validate(); |
| | | setDrawerProps({ confirmLoading: true }); |
| | | // TODO custom api |
| | | //保存产线 |
| | | values.AUTH_PROD = useUserStore().getUserInfo.prodCode; |
| | | const apiAction = SaveEntity(values, unref(isUpdate), 'MES_LINE'); |
| | | apiAction.then((action) => { |
| | | if (action.IsSuccessed) { |
| | | closeDrawer(); |
| | | emit('success'); |
| | | } |
| | | }); |
| | | } finally { |
| | | setDrawerProps({ confirmLoading: false }); |
| | | } |
| | | } |
| | | |
| | | return { |
| | | registerDrawer, |
| | | registerForm, |
| | | getTitle, |
| | | handleSubmit, |
| | | }; |
| | | }, |
| | | } |
| | | }); |
| | | |
| | | const getTitle = computed(() => (!unref(isUpdate) ? '新增产线' : '编辑产线')); |
| | | |
| | | async function handleSubmit() { |
| | | try { |
| | | const values = await useFormData['forminfo'][1].validate(); |
| | | setDrawerProps({ confirmLoading: true }); |
| | | // TODO custom api |
| | | //保存产线 |
| | | values.AUTH_PROD = useUserStore().getUserInfo.prodCode; |
| | | const apiAction = SaveEntity(values, unref(isUpdate), 'MES_LINE'); |
| | | apiAction.then((action) => { |
| | | if (action.IsSuccessed) { |
| | | closeDrawer(); |
| | | emit('success'); |
| | | } |
| | | }); |
| | | } finally { |
| | | setDrawerProps({ confirmLoading: false }); |
| | | } |
| | | } |
| | | </script> |