| | |
| | | import { getCurrentInstance, reactive, toRefs } from "vue"; |
| | | import FilesDia from "./components/filesDia.vue"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const currentLoginUserId = ref(""); |
| | | |
| | | const normalizeId = value => String(value ?? "").trim(); |
| | | |
| | | const parseReportUserIds = reportUserIds => |
| | | String(reportUserIds ?? "") |
| | | .split(",") |
| | | .map(item => item.trim()) |
| | | .filter(Boolean); |
| | | |
| | | const canCurrentUserReport = row => { |
| | | const currentUserId = normalizeId(currentLoginUserId.value); |
| | | if (!currentUserId) return false; |
| | | return parseReportUserIds(row?.reportUserIds).includes(currentUserId); |
| | | }; |
| | | |
| | | const tableColumn = ref([ |
| | | { |
| | |
| | | { |
| | | label: "工序名称", |
| | | prop: "processName", |
| | | }, |
| | | { |
| | | label: "报工人", |
| | | prop: "reportUserNames", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "需求数量", |
| | |
| | | clickFun: row => { |
| | | showReportDialog(row); |
| | | }, |
| | | disabled: row => row.planQuantity <= 0, |
| | | disabled: row => row.planQuantity <= 0 || !canCurrentUserReport(row), |
| | | }, |
| | | ], |
| | | }, |
| | |
| | | }; |
| | | |
| | | const showReportDialog = row => { |
| | | if (!canCurrentUserReport(row)) { |
| | | proxy.$modal.msgWarning("当前登录用户没有该工单的报工权限"); |
| | | return; |
| | | } |
| | | currentReportRowData.value = row; |
| | | reportForm.planQuantity = row.planQuantity; |
| | | reportForm.quantity = |
| | |
| | | }; |
| | | |
| | | // 用户选择变化时更新 userName |
| | | const getCurrentLoginUser = () => { |
| | | getUserProfile() |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | currentLoginUserId.value = normalizeId(res.data?.userId); |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | console.error("获取当前登录用户失败", err); |
| | | }); |
| | | }; |
| | | |
| | | const handleUserChange = userId => { |
| | | if (userId) { |
| | | const selectedUser = userOptions.value.find(user => user.userId === userId); |
| | |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getCurrentLoginUser(); |
| | | getList(); |
| | | getUserList(); |
| | | }); |