| | |
| | | createMiscIssue, |
| | | finishMiscIssue, |
| | | getMiscIssue, |
| | | submitMiscIssue, |
| | | updateMiscIssue, |
| | | } from '#/api/mes/wm/miscissue'; |
| | | import { $t } from '#/locales'; |
| | |
| | | ['create', 'update'].includes(formType.value), |
| | | ); |
| | | const isFinish = computed(() => formType.value === 'finish'); // 是否为执行出库模式 |
| | | const canSubmit = computed( |
| | | () => |
| | | // 是否可提交 |
| | | formType.value === 'update' && |
| | | formData.value?.status === MesWmMiscIssueStatusEnum.PREPARE, |
| | | ); |
| | | const getTitle = computed(() => { |
| | | if (formType.value === 'detail') { |
| | | return $t('ui.actionTitle.view', ['杂项出库单']); |
| | |
| | | showDefaultActions: false, |
| | | wrapperClass: 'grid-cols-3', |
| | | }); |
| | | |
| | | /** 提交出库单:表单有修改时先保存,再调用提交接口 */ |
| | | async function handleSubmit() { |
| | | const { valid } = await formApi.validate(); |
| | | if (!valid || !formData.value?.id) { |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | | try { |
| | | const current = JSON.stringify(await formApi.getValues()); |
| | | if (current !== originalSnapshot.value) { |
| | | const data = (await formApi.getValues()) as MesWmMiscIssueApi.MiscIssue; |
| | | await updateMiscIssue({ ...formData.value, ...data }); |
| | | originalSnapshot.value = current; |
| | | } |
| | | await submitMiscIssue(formData.value.id); |
| | | message.success('提交成功'); |
| | | await modalApi.close(); |
| | | emit('success'); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |
| | | } |
| | | |
| | | /** 执行出库 */ |
| | | async function handleFinish() { |
| | |
| | | </template> |
| | | <template #prepend-footer> |
| | | <div class="flex flex-auto items-center gap-2"> |
| | | <Popconfirm |
| | | v-if="canSubmit" |
| | | title="确认提交该杂项出库单?【提交后将不能修改】" |
| | | @confirm="handleSubmit" |
| | | > |
| | | <Button type="primary">提交</Button> |
| | | </Popconfirm> |
| | | <Popconfirm |
| | | v-if="isFinish" |
| | | title="确认执行出库?执行后将更新库存台账。" |