| | |
| | | import {ElMessageBox, ElMessage} from "element-plus"; |
| | | import Pagination from "@/components/PIMTable/Pagination.vue"; |
| | | import dayjs from "dayjs"; |
| | | import { processList } from '@/api/productionManagement/productionProcess.js' |
| | | import { |
| | | productWorkOrderPage, |
| | | updateProductWorkOrder, |
| | |
| | | { |
| | | name: "生产排产", |
| | | clickFun: row => { |
| | | if (!row.canSchedule) { |
| | | ElMessage.warning("当前用户不在该工序人员中,不能生产排产"); |
| | | return; |
| | | } |
| | | openScheduleDialog(row); |
| | | }, |
| | | }, |
| | | disabled: row => !row.canSchedule |
| | | } |
| | | // { |
| | | // name:"审核", |
| | | // color: "#f56c6c", |
| | |
| | | page.size = obj.limit; |
| | | getList(); |
| | | }; |
| | | const getList = () => { |
| | | const getList = async () => { |
| | | tableLoading.value = true; |
| | | const params = {...searchForm.value, ...page}; |
| | | productWorkOrderPage(params) |
| | | .then(res => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.data.records; |
| | | page.total = res.data.total; |
| | | }) |
| | | .catch(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | |
| | | try { |
| | | await ensureCurrentUser(); |
| | | await processLists(); |
| | | |
| | | const params = { ...searchForm.value, ...page }; |
| | | const res = await productWorkOrderPage(params); |
| | | |
| | | const records = Array.isArray(res?.data?.records) ? res.data.records : []; |
| | | |
| | | tableData.value = records.map(row => ({ |
| | | ...row, |
| | | canSchedule: canScheduleByWorkOrderNo(row) |
| | | })); |
| | | |
| | | page.total = res?.data?.total || 0; |
| | | } finally { |
| | | tableLoading.value = false; |
| | | } |
| | | }; |
| | | |
| | | // 下载并打印工单流转卡(文件流) |
| | |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | ensureCurrentUser(); |
| | | getList(); |
| | | const processData = ref([]); |
| | | |
| | | // 查询所有工序 |
| | | const processLists = async () => { |
| | | console.log(processData.value) |
| | | if (processData.value.length > 0) { |
| | | return processData.value; |
| | | } |
| | | const res = await processList(); |
| | | |
| | | processData.value = Array.isArray(res?.data) ? res.data : []; |
| | | return processData.value; |
| | | }; |
| | | |
| | | // 判断当前用户是否能排产 |
| | | const canScheduleByWorkOrderNo = (row) => { |
| | | if (!row) return false; |
| | | |
| | | const uid = String(currentUserId.value || ""); |
| | | if (!uid) return false; |
| | | |
| | | const currentProcess = processData.value.find(item => |
| | | String(item.id) === String(row.processId) |
| | | ); |
| | | |
| | | if (!currentProcess) return false; |
| | | |
| | | const ids = normalizeArray(currentProcess.userIds) |
| | | .map(id => String(id).trim()) |
| | | .filter(Boolean); |
| | | |
| | | return ids.includes(uid); |
| | | }; |
| | | |
| | | onMounted(async () => { |
| | | await ensureCurrentUser(); |
| | | await processLists(); |
| | | await getList(); |
| | | getUserList(); |
| | | getDeviceList(); |
| | | }); |