|
|
@@ -299,6 +299,7 @@
|
|
|
import addPlease from '@/views/produce/components/outsourcing/addPlease.vue';
|
|
|
import qualityInspection from '@/views/produce/components/qualityInspection/index.vue';
|
|
|
import { checkProductionResult } from '@/api/producetaskrulerecord/index.js';
|
|
|
+ import { getPlanDotLine } from '@/api/produceOrder/index.js';
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -392,7 +393,8 @@
|
|
|
workPlanType: '',
|
|
|
isPleaseEntrust: false,
|
|
|
workInfoList: {},
|
|
|
- drawerKey: 0
|
|
|
+ drawerKey: 0,
|
|
|
+ planDotLineEnabled: false
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -413,6 +415,7 @@
|
|
|
|
|
|
this.getTaskList();
|
|
|
this.getFactoryworkstationPageList();
|
|
|
+ this.getPlanDotLineConfig();
|
|
|
|
|
|
this.operationType = null;
|
|
|
this.workListIds = [];
|
|
|
@@ -422,6 +425,144 @@
|
|
|
this.name = '';
|
|
|
this.seekInput();
|
|
|
},
|
|
|
+
|
|
|
+ async getPlanDotLineConfig() {
|
|
|
+ try {
|
|
|
+ const res = await parameterGetByCode({
|
|
|
+ code: 'plan_dot_line'
|
|
|
+ });
|
|
|
+ this.planDotLineEnabled = !!res && res.value == '1';
|
|
|
+ } catch (error) {
|
|
|
+ this.planDotLineEnabled = false;
|
|
|
+ console.error('getPlanDotLineConfig error', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async syncPlanDotLineRouteList() {
|
|
|
+ if (!this.planDotLineEnabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const productionPlanId = this.workOrderInfo?.productionPlanId;
|
|
|
+ if (!productionPlanId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!Array.isArray(this.routeList) || this.routeList.length === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const res = await getPlanDotLine({
|
|
|
+ planId: productionPlanId
|
|
|
+ });
|
|
|
+ const detailList = Array.isArray(res?.detailList)
|
|
|
+ ? res.detailList
|
|
|
+ : [];
|
|
|
+ if (!detailList.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(detailList, 'detailList');
|
|
|
+ const detailMap = detailList.reduce((map, item) => {
|
|
|
+ const taskId = item?.taskId;
|
|
|
+ if (taskId !== undefined && taskId !== null && taskId !== '') {
|
|
|
+ map.set(String(taskId), item);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }, new Map());
|
|
|
+ this.routeList = this.routeList.map((item) => {
|
|
|
+ const taskId = item?.taskId;
|
|
|
+ if (taskId === undefined || taskId === null || taskId === '') {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ const detail = detailMap.get(String(taskId));
|
|
|
+
|
|
|
+ if (!detail) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ executionTeamName: detail.executionTeamName ?? '',
|
|
|
+ executionTeamId: detail.executionTeamId ?? ''
|
|
|
+ };
|
|
|
+ });
|
|
|
+ console.log(this.routeList, 'thisnewewewewrouteList');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('syncPlanDotLineRouteList error', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getUserTeamIds() {
|
|
|
+ const teamId = this.$store?.state?.user?.info?.teamId;
|
|
|
+ if (Array.isArray(teamId)) {
|
|
|
+ return teamId
|
|
|
+ .map((item) => String(item).trim())
|
|
|
+ .filter((item) => item);
|
|
|
+ }
|
|
|
+ if (typeof teamId !== 'string' || !teamId) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ return teamId
|
|
|
+ .split(',')
|
|
|
+ .map((item) => item.trim())
|
|
|
+ .filter((item) => item);
|
|
|
+ },
|
|
|
+ getCurrentRouteItem() {
|
|
|
+ if (
|
|
|
+ this.curTaskObj?.taskId !== undefined &&
|
|
|
+ this.curTaskObj?.taskId !== null
|
|
|
+ ) {
|
|
|
+ return this.curTaskObj;
|
|
|
+ }
|
|
|
+ if (!Array.isArray(this.routeList) || this.routeList.length === 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ const currentTaskId =
|
|
|
+ this.taskId ??
|
|
|
+ this.workOrderInfo?.taskId ??
|
|
|
+ this.routeList[this.desIndex]?.taskId;
|
|
|
+ if (
|
|
|
+ currentTaskId === undefined ||
|
|
|
+ currentTaskId === null ||
|
|
|
+ currentTaskId === ''
|
|
|
+ ) {
|
|
|
+ return this.routeList[this.desIndex] || null;
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ this.routeList.find(
|
|
|
+ (item) => String(item?.taskId) === String(currentTaskId)
|
|
|
+ ) ||
|
|
|
+ this.routeList[this.desIndex] ||
|
|
|
+ null
|
|
|
+ );
|
|
|
+ },
|
|
|
+ checkCurrentTaskTeamPermission(actionName) {
|
|
|
+ const deny = (message) => {
|
|
|
+ this.operationType = null;
|
|
|
+ this.$message.warning(message);
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ const currentTask = this.getCurrentRouteItem();
|
|
|
+ if (!currentTask) {
|
|
|
+ return deny(`未获取到当前工序,不能${actionName}`);
|
|
|
+ }
|
|
|
+ const executionTeamId = currentTask.executionTeamId;
|
|
|
+ if (
|
|
|
+ executionTeamId === undefined ||
|
|
|
+ executionTeamId === null ||
|
|
|
+ executionTeamId === ''
|
|
|
+ ) {
|
|
|
+ return deny(`当前工序未配置执行班组,不能${actionName}`);
|
|
|
+ }
|
|
|
+ const teamIds = this.getUserTeamIds();
|
|
|
+ if (!teamIds.length) {
|
|
|
+ return deny(`当前用户未配置班组,不能${actionName}`);
|
|
|
+ }
|
|
|
+ const executionTeamIdStr = String(executionTeamId).trim();
|
|
|
+ if (!executionTeamIdStr) {
|
|
|
+ return deny(`当前工序未配置执行班组,不能${actionName}`);
|
|
|
+ }
|
|
|
+ if (!teamIds.includes(executionTeamIdStr)) {
|
|
|
+ return deny(`当前用户班组无权限${actionName}`);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
// 前端筛选
|
|
|
seekInput() {
|
|
|
// console.log(activeName);
|
|
|
@@ -582,6 +723,7 @@
|
|
|
this.workOrderInfo = row;
|
|
|
this.routeObj.id = this.workOrderInfo.id;
|
|
|
this.operationType = '';
|
|
|
+ await this.getPlanDotLineConfig();
|
|
|
// this.getTaskFn();
|
|
|
this.drawer = true;
|
|
|
// this.getOrderData();
|
|
|
@@ -621,31 +763,42 @@
|
|
|
},
|
|
|
|
|
|
async getTaskFn() {
|
|
|
- await getTaskInstanceList(this.workOrderInfo.id).then((res) => {
|
|
|
- this.routeList = res;
|
|
|
+ const res = await getTaskInstanceList(this.workOrderInfo.id);
|
|
|
+ this.routeList = Array.isArray(res) ? res : [];
|
|
|
|
|
|
- console.log(this.routeList, 'routeList');
|
|
|
- console.log(this.workOrderInfo, 'this.workOrderInfo');
|
|
|
+ console.log(this.routeList, 'routeList');
|
|
|
+ console.log(this.workOrderInfo, 'this.workOrderInfo');
|
|
|
|
|
|
- // 使用findIndex方法查找
|
|
|
- const index = this.routeList.findIndex(
|
|
|
- (item) => item.taskId == this.workOrderInfo.taskId
|
|
|
- );
|
|
|
+ if (!this.routeList.length) {
|
|
|
+ this.desIndex = 0;
|
|
|
+ this.activeIndex = 0;
|
|
|
+ this.newId = '';
|
|
|
+ this.workData = this.workOrderInfo;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- this.desIndex = index;
|
|
|
- console.log(this.routeList, '888888');
|
|
|
- this.newId = this.routeList[this.desIndex].taskId || '';
|
|
|
+ await this.syncPlanDotLineRouteList();
|
|
|
|
|
|
- if (this.workOrderInfo.taskId != -2) {
|
|
|
- this.curTaskObj = JSON.parse(JSON.stringify(this.routeObj));
|
|
|
- } else {
|
|
|
- this.curTaskObj = JSON.parse(JSON.stringify(this.routeList[0]));
|
|
|
- this.desIndex = 0;
|
|
|
- }
|
|
|
- this.activeIndex = index;
|
|
|
- this.workData = this.workOrderInfo;
|
|
|
- this.handIdx(this.activeIndex, this.routeList[index]);
|
|
|
- });
|
|
|
+ const index = this.routeList.findIndex(
|
|
|
+ (item) => item.taskId == this.workOrderInfo.taskId
|
|
|
+ );
|
|
|
+ const currentIndex = index > -1 ? index : 0;
|
|
|
+
|
|
|
+ this.desIndex = currentIndex;
|
|
|
+ console.log(this.routeList, '888888');
|
|
|
+ this.newId = this.routeList[currentIndex]?.taskId || '';
|
|
|
+
|
|
|
+ if (this.workOrderInfo.taskId != -2) {
|
|
|
+ this.curTaskObj = JSON.parse(JSON.stringify(this.routeObj));
|
|
|
+ } else {
|
|
|
+ this.curTaskObj = JSON.parse(JSON.stringify(this.routeList[0] || {}));
|
|
|
+ this.desIndex = 0;
|
|
|
+ }
|
|
|
+ this.activeIndex = currentIndex;
|
|
|
+ this.workData = this.workOrderInfo;
|
|
|
+ if (this.routeList[currentIndex]) {
|
|
|
+ this.handIdx(this.activeIndex, this.routeList[currentIndex]);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
async getCodeData(req) {
|
|
|
@@ -715,6 +868,12 @@
|
|
|
this.$message.warning('请选择工单列表');
|
|
|
return false;
|
|
|
}
|
|
|
+ if ((t === 'feed' || t === 'job') && this.planDotLineEnabled) {
|
|
|
+ const actionName = t === 'feed' ? '投料' : '报工';
|
|
|
+ if (!this.checkCurrentTaskTeamPermission(actionName)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// console.log('按钮被点击了.....', t);
|