| | |
| | | placeholder="请选择班组成员" |
| | | > |
| | | <el-option |
| | | v-for="user in userTeamOptions" |
| | | v-for="user in reportForm.userIdsList" |
| | | :key="user.userId" |
| | | :label="user.nickName" |
| | | :value="{ userId: user.userId, userName: user.nickName }" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="机台" prop="deviceId"> |
| | | <el-select |
| | | v-model="reportForm.deviceId" |
| | | placeholder="请选择机台" |
| | | filterable |
| | | clearable |
| | | @change="(val) => handleDeviceChange(val)" |
| | | :disabled="isDetail" |
| | | > |
| | | <el-option |
| | | v-for="item in deviceOptions" |
| | | :key="item.id" |
| | | :label="item.deviceName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :span="12">--> |
| | | <!-- <el-form-item label="机台" prop="deviceId">--> |
| | | <!-- <el-select--> |
| | | <!-- v-model="reportForm.deviceId"--> |
| | | <!-- placeholder="请选择机台"--> |
| | | <!-- filterable--> |
| | | <!-- clearable--> |
| | | <!-- @change="(val) => handleDeviceChange(val)"--> |
| | | <!-- :disabled="isDetail"--> |
| | | <!-- >--> |
| | | <!-- <el-option--> |
| | | <!-- v-for="item in deviceOptions"--> |
| | | <!-- :key="item.id"--> |
| | | <!-- :label="item.deviceName"--> |
| | | <!-- :value="item.id"--> |
| | | <!-- />--> |
| | | <!-- </el-select>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="审核人" prop="auditUserId"> |
| | |
| | | return [val]; |
| | | }; |
| | | |
| | | const isCurrentUserReportWorker = (row) => { |
| | | const isCurrentUserInUserIds = (row) => { |
| | | const uid = String(currentUserId.value || ""); |
| | | if (!uid) return false; |
| | | if (!row) return false; |
| | | |
| | | const candidateIds = [ |
| | | row.reportUserIds, |
| | | row.reportWorkerIds, |
| | | row.userIdList, |
| | | row.reportUserId, |
| | | row.userId, |
| | | ] |
| | | .flatMap((v) => normalizeArray(v)) |
| | | .map((v) => String(v)) |
| | | const ids = normalizeArray(row?.userIds) |
| | | .map(id => String(id)) |
| | | .filter(Boolean); |
| | | |
| | | if (candidateIds.includes(uid)) return true; |
| | | |
| | | const candidateNames = [ |
| | | row.userNames, |
| | | row.reportUserNames, |
| | | row.reportWorkerNames, |
| | | row.userName, |
| | | ] |
| | | .flatMap((v) => normalizeArray(v)) |
| | | .map((v) => String(v)) |
| | | .filter(Boolean); |
| | | |
| | | if (currentUserName.value && candidateNames.includes(currentUserName.value)) { |
| | | return true; |
| | | } |
| | | |
| | | if (Array.isArray(row.reportWorkerList)) { |
| | | const list = row.reportWorkerList |
| | | .map((item) => String(item?.userId ?? item?.id ?? "")) |
| | | .filter(Boolean); |
| | | if (list.includes(uid)) return true; |
| | | const nameList = row.reportWorkerList |
| | | .map((item) => String(item?.userName ?? item?.nickName ?? "")) |
| | | .filter(Boolean); |
| | | if (currentUserName.value && nameList.includes(currentUserName.value)) return true; |
| | | } |
| | | |
| | | return false; |
| | | return ids.includes(uid); |
| | | }; |
| | | |
| | | const canOperateByReportWorker = computed(() => { |
| | |
| | | clickFun: row => { |
| | | showReportDialog(row); |
| | | }, |
| | | // 用户当前id |
| | | disabled: row => row.completeQuantity === row.planQuantity || |
| | | !isCurrentUserInUserIds(row) |
| | | }, |
| | | { |
| | | name: "生产排产", |
| | |
| | | }; |
| | | |
| | | const showReportDialog = row => { |
| | | // if (!isCurrentUserReportWorker(row)) { |
| | | // ElMessage.warning("当前用户不是该工单的报工人,无法报工"); |
| | | // return; |
| | | // } |
| | | currentReportRowData.value = row; |
| | | reportForm.planQuantity = row.planQuantity - row.completeQuantity; |
| | | reportForm.quantity = |
| | | row.quantity !== undefined && row.quantity !== null ? row.quantity : null; |
| | | reportForm.quantity = row.quantity !== undefined && row.quantity !== null ? row.quantity : null; |
| | | reportForm.productProcessRouteItemId = row.productProcessRouteItemId; |
| | | reportForm.workOrderId = row.id; |
| | | reportForm.reportWork = row.reportWork; |
| | |
| | | reportForm.replenishQty = 0; |
| | | reportForm.teamList = []; |
| | | reportForm.scrapQty = 0; |
| | | reportForm.userIds = row.userIds || []; |
| | | |
| | | const ids = (row.userIds || "") |
| | | .split(",") |
| | | .map(id => id.trim()) |
| | | .filter(Boolean); |
| | | |
| | | reportForm.userIdsList = userTeamOptions.value |
| | | .filter(item => ids.includes(String(item.userId))) |
| | | .map(item => ({ |
| | | userId: item.userId, |
| | | nickName: item.nickName |
| | | })); |
| | | |
| | | |
| | | nextTick(() => { |
| | | reportFormRef.value?.clearValidate(); |
| | |
| | | |
| | | if (quantity > reportForm.planQuantity) { |
| | | ElMessageBox.alert("本次生产数量不能超过待生产数量", "提示", { |
| | | confirmButtonText: "确定", |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | if (!reportForm.startTime || !reportForm.endTime) { |
| | | ElMessageBox.alert("开始时间和结束时间不能为空", "提示", { |
| | | confirmButtonText: "确定", |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | if (dayjs(reportForm.startTime).isSame(dayjs(reportForm.endTime)) || dayjs(reportForm.startTime).isAfter(dayjs(reportForm.endTime))) { |
| | | ElMessageBox.alert("开始时间必须小于结束时间", "提示", { |
| | | confirmButtonText: "确定", |
| | | }); |
| | | return; |