| | |
| | | import { addProductOrder, listProcessRoute } from "@/api/productionManagement/productionOrder.js"; |
| | | import { processList } from "@/api/productionManagement/productionProcess.js"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import {findProcessRouteItemList} from "@/api/productionManagement/processRouteItem.js"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | |
| | | const { proxy } = getCurrentInstance(); |
| | | const formRef = ref(); |
| | | |
| | | const validateProcessUserField = async () => { |
| | | const validateProcessUserField = async (shouldValidate = false) => { |
| | | await nextTick(); |
| | | if (!formRef.value) return; |
| | | |
| | | if (processListData.value.length) { |
| | | if (processListData.value.length && shouldValidate) { |
| | | formRef.value.validateField("processUserList"); |
| | | return; |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | processList({ routeId }) |
| | | findProcessRouteItemList({ |
| | | routeId, |
| | | productModelId: formState.value.productModelId, |
| | | }) |
| | | .then(res => { |
| | | processListData.value = res.data || []; |
| | | formState.value.processUserList = createProcessUserList(processListData.value); |
| | |
| | | const handleProcessUserChange = (index, userIds) => { |
| | | const selectedUsers = userOptions.value.filter(user => Array.isArray(userIds) && userIds.includes(user.userId)); |
| | | formState.value.processUserList[index].userNames = selectedUsers.map(user => user.nickName).join(","); |
| | | validateProcessUserField(); |
| | | validateProcessUserField(true); |
| | | }; |
| | | |
| | | const removeProcessItem = index => { |
| | | processListData.value.splice(index, 1); |
| | | formState.value.processUserList.splice(index, 1); |
| | | validateProcessUserField(); |
| | | validateProcessUserField(true); |
| | | }; |
| | | |
| | | const validateProcessUsers = (_, value, callback) => { |
| | |
| | | if (!products?.length) return; |
| | | |
| | | const product = products[0]; |
| | | formState.value.productId = product.productId; |
| | | formState.value.productId = product.id; |
| | | formState.value.productName = product.productName; |
| | | formState.value.productModelName = product.model; |
| | | formState.value.productModelId = product.id; |