| | |
| | | @register="registerDrawer" |
| | | showFooter |
| | | :title="getTitle" |
| | | width="600px" |
| | | width="400px" |
| | | @ok="handleSubmit" |
| | | > |
| | | <BasicForm @register="registerForm" /> |
| | | <BasicForm @register="registerForm"> |
| | | <template #addItem="{ field }"> |
| | | <a-button |
| | | v-if="field" |
| | | class="mt-1 ml-1" |
| | | size="small" |
| | | @click="handleSelectItem" |
| | | preIcon="search|svg" |
| | | /> |
| | | <NormalModal @register="registerItemAdd" @success="handleItemSuccess" /> |
| | | </template> |
| | | </BasicForm> |
| | | </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 './biz_mes_wo.data'; |
| | | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| | | import { SaveEntity } from '/@/api/tigerapi/system'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { useI18n } from '/@/hooks/web/useI18n'; |
| | | import NormalModal from '/@/views/components/NormalModal.vue'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | |
| | | import { SaveMesWo } from '/@/api/tigerapi/mes/wo'; |
| | | |
| | | export default defineComponent({ |
| | | name: 'ToolDrawer', |
| | | components: { BasicDrawer, BasicForm }, |
| | | emits: ['success', 'register'], |
| | | setup(_, { emit }) { |
| | | const isUpdate = ref(true); |
| | | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => { |
| | | resetFields(); |
| | | setDrawerProps({ confirmLoading: false }); |
| | | isUpdate.value = !!data?.isUpdate; |
| | | if (unref(isUpdate)) { |
| | | setFieldsValue({ |
| | | ...data.record, |
| | | }); |
| | | } |
| | | const { t } = useI18n(); |
| | | const emit = defineEmits(['success', 'register']); |
| | | const isUpdate = ref(true); |
| | | const [registerItemAdd, { openModal: openItemModal }] = useModal(); |
| | | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => { |
| | | resetFields(); |
| | | setDrawerProps({ confirmLoading: false }); |
| | | isUpdate.value = !!data?.isUpdate; |
| | | if (unref(isUpdate)) { |
| | | setFieldsValue({ |
| | | ...data.record, |
| | | }); |
| | | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
| | | labelWidth: 120, |
| | | schemas: formSchema, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | showActionButtonGroup: false, |
| | | }); |
| | | |
| | | const getTitle = computed(() => (!unref(isUpdate) ? '新增工单' : '编辑工单')); |
| | | |
| | | async function handleSubmit() { |
| | | try { |
| | | const values = await validate(); |
| | | setDrawerProps({ confirmLoading: true }); |
| | | // TODO custom api |
| | | //保存工单 |
| | | if (!unref(isUpdate)) { |
| | | values.STATUS = 0; |
| | | } |
| | | const apiAction = SaveMesWo(values); |
| | | apiAction.then((action) => { |
| | | if (action.IsSuccessed) { |
| | | closeDrawer(); |
| | | emit('success'); |
| | | } |
| | | }); |
| | | } finally { |
| | | setDrawerProps({ confirmLoading: false }); |
| | | } |
| | | } |
| | | |
| | | return { |
| | | registerDrawer, |
| | | registerForm, |
| | | getTitle, |
| | | handleSubmit, |
| | | }; |
| | | }, |
| | | } |
| | | }); |
| | | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
| | | labelWidth: 120, |
| | | schemas: formSchema, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | showActionButtonGroup: false, |
| | | }); |
| | | |
| | | const getTitle = computed(() => (!unref(isUpdate) ? '新增工单' : '编辑工单')); |
| | | |
| | | async function handleSubmit() { |
| | | try { |
| | | const values = await validate(); |
| | | setDrawerProps({ confirmLoading: true }); |
| | | // TODO custom api |
| | | //保存工单 |
| | | if (!unref(isUpdate)) { |
| | | values.STATUS = 0; |
| | | } |
| | | values.AUTH_PROD = useUserStore().getUserInfo.prodCode; |
| | | values.FACTORY = useUserStore().getUserInfo.prodCode; |
| | | const apiAction = SaveEntity(values, unref(isUpdate), 'BIZ_MES_WO'); |
| | | apiAction.then((action) => { |
| | | if (action.IsSuccessed) { |
| | | closeDrawer(); |
| | | emit('success'); |
| | | } |
| | | }); |
| | | } finally { |
| | | setDrawerProps({ confirmLoading: false }); |
| | | } |
| | | } |
| | | |
| | | //点击打开物料列表框 |
| | | function handleSelectItem() { |
| | | openItemModal(true, { |
| | | title: '物料列表', |
| | | schemas: [ |
| | | { |
| | | field: 'ITEM_CODE', |
| | | component: 'Input', |
| | | label: '物料编码', |
| | | colProps: { |
| | | span: 12, |
| | | }, |
| | | }, |
| | | ], |
| | | ItemColumns: [ |
| | | { |
| | | title: t('物料编码'), |
| | | dataIndex: 'ITEM_CODE', |
| | | resizable: true, |
| | | sorter: true, |
| | | width: 200, |
| | | }, |
| | | { |
| | | title: t('物料名称'), |
| | | dataIndex: 'ITEM_NAME', |
| | | resizable: true, |
| | | sorter: true, |
| | | width: 180, |
| | | }, |
| | | ], |
| | | tableName: 'BAS_ITEM', |
| | | rowKey: 'ITEM_CODE', |
| | | }); |
| | | } |
| | | |
| | | function handleItemSuccess(d, u) { |
| | | setFieldsValue({ |
| | | ITEM_CODE: d.values['val'], |
| | | }); |
| | | } |
| | | </script> |