| | |
| | | |
| | | import { confirm, useVbenModal } from "@vben/common-ui"; |
| | | import { |
| | | BarcodeBizTypeEnum, |
| | | MesProWorkOrderStatusEnum, |
| | | } from "@vben/constants"; |
| | | |
| | |
| | | } from "#/api/mes/pro/workorder"; |
| | | import { batchSaveWorkOrderProcess, getWorkOrderProcessListByWorkOrderId } from "#/api/mes/pro/workorder/process"; |
| | | import { $t } from "#/locales"; |
| | | import { BarcodeDetail } from "#/views/wls/barcode/components"; |
| | | // import { BarcodeDetail } from "#/views/wls/barcode/components"; |
| | | |
| | | import { useFormSchema } from "../data"; |
| | | import PredictDelivery from "./ai/predict-delivery.vue"; |
| | | import PredictDuration from "./ai/predict-duration.vue"; |
| | | import PredictMaterial from "./ai/predict-material.vue"; |
| | | import PredictRisk from "./ai/predict-risk.vue"; |
| | | import ItemList from "./item-list.vue"; |
| | | import ProcessList from "./process-list.vue"; |
| | | |
| | |
| | | const formData = ref<MesProWorkOrderApi.WorkOrder>(); |
| | | const originalSnapshot = ref(""); |
| | | const subTabsName = ref("process"); |
| | | const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); |
| | | // const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); |
| | | const processListRef = ref<InstanceType<typeof ProcessList>>(); |
| | | const currentProductId = ref<number>(); // 当前选中的产品 ID(用于工序加载) |
| | | const tempProcessList = ref<MesProWorkOrderProcessApi.WorkOrderProcess[]>([]); // 临时工序列表 |
| | |
| | | () => |
| | | formType.value === "update" && |
| | | formData.value?.status === MesProWorkOrderStatusEnum.PREPARE |
| | | ); |
| | | const canUseAi = computed( |
| | | () => |
| | | formData.value?.id && |
| | | (formData.value?.status === MesProWorkOrderStatusEnum.PREPARE || |
| | | formData.value?.status === MesProWorkOrderStatusEnum.CONFIRMED) |
| | | ); |
| | | const getTitle = computed(() => { |
| | | const isChild = !!formData.value?.parentId; |
| | |
| | | if (!valid || !formData.value?.id) return; |
| | | modalApi.lock(); |
| | | try { |
| | | const data = (await formApi.getValues()) as MesProWorkOrderApi.WorkOrder; |
| | | const data = (await formApi.getValues()) as any; |
| | | if (Array.isArray(data.feedbackRole)) { |
| | | data.feedbackRole = data.feedbackRole.join(','); |
| | | } |
| | | await updateWorkOrder({ ...formData.value, ...data }); |
| | | if (tempProcessList.value.length > 0) { |
| | | const processList = tempProcessList.value.map(item => ({ |
| | |
| | | } |
| | | |
| | | /** 查看订单条码 */ |
| | | function handleBarcode() { |
| | | if (!formData.value?.id) { |
| | | return; |
| | | } |
| | | barcodeDetailRef.value?.openByBusiness( |
| | | formData.value.id, |
| | | BarcodeBizTypeEnum.WORKORDER, |
| | | formData.value.code, |
| | | formData.value.name |
| | | ); |
| | | } |
| | | // function handleBarcode() { |
| | | // if (!formData.value?.id) { |
| | | // return; |
| | | // } |
| | | // barcodeDetailRef.value?.openByBusiness( |
| | | // formData.value.id, |
| | | // BarcodeBizTypeEnum.WORKORDER, |
| | | // formData.value.code, |
| | | // formData.value.name |
| | | // ); |
| | | // } |
| | | |
| | | /** 工序列表变化回调 */ |
| | | function handleProcessListChange(list: MesProWorkOrderProcessApi.WorkOrderProcess[]) { |
| | |
| | | if (isEditable.value) { |
| | | const current = JSON.stringify(await formApi.getValues()); |
| | | if (current !== originalSnapshot.value) { |
| | | const data = (await formApi.getValues()) as MesProWorkOrderApi.WorkOrder; |
| | | const data = (await formApi.getValues()) as any; |
| | | if (Array.isArray(data.feedbackRole)) { |
| | | data.feedbackRole = data.feedbackRole.join(','); |
| | | } |
| | | await updateWorkOrder({ ...formData.value, ...data }); |
| | | originalSnapshot.value = current; |
| | | } |
| | |
| | | const { valid } = await formApi.validate(); |
| | | if (!valid) return; |
| | | modalApi.lock(); |
| | | const data = (await formApi.getValues()) as MesProWorkOrderApi.WorkOrder; |
| | | const data = (await formApi.getValues()) as any; |
| | | if (Array.isArray(data.feedbackRole)) { |
| | | data.feedbackRole = data.feedbackRole.join(','); |
| | | } |
| | | try { |
| | | if (formData.value?.id) { |
| | | // 编辑模式 |
| | |
| | | modalApi.lock(); |
| | | try { |
| | | formData.value = await getWorkOrder(data.id); |
| | | await formApi.setValues(formData.value); |
| | | const formValues: any = { ...formData.value }; |
| | | if (formValues.feedbackRole && typeof formValues.feedbackRole === 'string') { |
| | | formValues.feedbackRole = formValues.feedbackRole.split(','); |
| | | } |
| | | await formApi.setValues(formValues); |
| | | currentProductId.value = formData.value.productId; |
| | | } finally { |
| | | modalApi.unlock(); |
| | |
| | | </Tabs> |
| | | </template> |
| | | <template #prepend-footer> |
| | | <div class="flex flex-auto items-center"> |
| | | <Button v-if="showMainBtn" |
| | | type="primary" |
| | | @click="modalApi.onConfirm()"> |
| | | {{ mainActionText }} |
| | | </Button> |
| | | <div class="flex flex-auto flex-col gap-2"> |
| | | <div v-if="canUseAi" class="flex items-center gap-2"> |
| | | <PredictMaterial :work-order-id="formData!.id" /> |
| | | <PredictDuration :work-order-id="formData!.id" /> |
| | | <PredictRisk :work-order-id="formData!.id" /> |
| | | <PredictDelivery :work-order-id="formData!.id" /> |
| | | </div> |
| | | <div v-if="canUseAi && showMainBtn" class="border-t border-gray-200" /> |
| | | <div class="flex items-center"> |
| | | <Button v-if="showMainBtn" |
| | | type="primary" |
| | | @click="modalApi.onConfirm()"> |
| | | {{ mainActionText }} |
| | | </Button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <template #append-footer> |
| | |
| | | @click="handleSave"> |
| | | 保存修改 |
| | | </Button> |
| | | <Button v-if="formType === 'detail' && formData?.id" |
| | | <!-- <Button v-if="formType === 'detail' && formData?.id" |
| | | @click="handleBarcode"> |
| | | 查看条码 |
| | | </Button> |
| | | </Button> --> |
| | | <Button @click="modalApi.close()">取消</Button> |
| | | </div> |
| | | </template> |
| | | </Modal> |
| | | <BarcodeDetail ref="barcodeDetailRef" /> |
| | | <!-- <BarcodeDetail ref="barcodeDetailRef" /> --> |
| | | </template> |