|
|
@@ -729,47 +729,60 @@
|
|
|
);
|
|
|
},
|
|
|
|
|
|
+ // chooseStationList(list, index) {
|
|
|
+ // const process = this.processList?.[index];
|
|
|
+
|
|
|
+ // if (!process) {
|
|
|
+ // console.warn(`processList[${index}] 不存在`);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // const oldList = structuredClone(
|
|
|
+ // Array.isArray(process.list) ? process.list : []
|
|
|
+ // );
|
|
|
+
|
|
|
+ // list.forEach((item) => {
|
|
|
+ // item.isNew = 1;
|
|
|
+ // });
|
|
|
+
|
|
|
+ // const newList = structuredClone(Array.isArray(list) ? list : []);
|
|
|
+
|
|
|
+ // this.$set(this.processList[index], 'list', [...oldList, ...newList]);
|
|
|
+ // },
|
|
|
+
|
|
|
chooseStationList(list, index) {
|
|
|
- const process = this.processList?.[index];
|
|
|
+ const process = this.processList[index];
|
|
|
+ if (!process) return;
|
|
|
|
|
|
- if (!process) {
|
|
|
- console.warn(`processList[${index}] 不存在`);
|
|
|
- return;
|
|
|
- }
|
|
|
+ const oldList = process.list || [];
|
|
|
|
|
|
- const oldList = structuredClone(
|
|
|
- Array.isArray(process.list) ? process.list : []
|
|
|
- );
|
|
|
+ const existingIds = new Set(oldList.map((i) => i.id || i.__tempKey));
|
|
|
|
|
|
- list.forEach((item) => {
|
|
|
- item.isNew = 1;
|
|
|
- });
|
|
|
+ const newList = list
|
|
|
+ .filter((item) => !existingIds.has(item.id || item.__tempKey))
|
|
|
+ .map((item) => ({
|
|
|
+ ...item,
|
|
|
+ isNew: 1,
|
|
|
+ __tempKey: item.id || `temp_${Date.now()}_${Math.random()}`,
|
|
|
+ disposalStatus: 0,
|
|
|
+ assetCode: item.extInfo?.assetCode,
|
|
|
+ assetId: item.extInfo?.assetId,
|
|
|
+ assetName: item.extInfo?.assetName
|
|
|
+ // status: { code: 0, desc: '未派单' }
|
|
|
+ }));
|
|
|
+
|
|
|
+ this.$set(process, 'list', [...oldList, ...newList]);
|
|
|
|
|
|
- const newList = structuredClone(Array.isArray(list) ? list : []);
|
|
|
+ const newIds = newList.map((i) => i.id || i.__tempKey);
|
|
|
+ if (!process.selection) process.selection = [];
|
|
|
+ process.selection.push(...newIds);
|
|
|
|
|
|
- this.$set(this.processList[index], 'list', [...oldList, ...newList]);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const tab = `tableRef${process.index}`;
|
|
|
+ this.$refs[tab]?.[0]?.setSelectedRowKeys(process.selection);
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
- // // 选择工作中心
|
|
|
- // async changeWork(e) {
|
|
|
- // this.form.workCenterId = e;
|
|
|
- // // this.changeDispatch(); // 查询工序列表
|
|
|
- // let data = this.workCenterList.find((item) => item.id == e);
|
|
|
- // this.form.workCenterName = data.name;
|
|
|
- // this.teamList = data.teamList || [];
|
|
|
- // if (this.teamList.length > 0) {
|
|
|
- // this.form.teamId = this.teamList[0].id;
|
|
|
- // await this.changeGroups(this.teamList[0].id);
|
|
|
- // } else {
|
|
|
- // // 如果没有 班组数据 将人员数据清空 并且判断
|
|
|
- // this.crewList = [];
|
|
|
- // this.form.teamId = '';
|
|
|
- // let data = this.processList.find((item) => item.id == this.processId);
|
|
|
- // if (data.assignType == 2) {
|
|
|
- // this.$set(data, 'list', []);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
// 选择工作中心
|
|
|
async changeWork(e) {
|
|
|
this.form.workCenterId = e;
|
|
|
@@ -899,48 +912,134 @@
|
|
|
return isWithdraw;
|
|
|
},
|
|
|
// 派单
|
|
|
+ // dispatch(row, type) {
|
|
|
+ // if (row.selection.length == 0) {
|
|
|
+ // return this.$message.warning('请最少选择一条数据');
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let isWithdraw = this.getWithdrawT(row, type);
|
|
|
+ // if (isWithdraw.length) {
|
|
|
+ // if (type == 1) {
|
|
|
+ // this.$message.warning(
|
|
|
+ // isWithdraw.toString() + ',状态为已派单,如需重新派单请先撤回!'
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // if (type == 2) {
|
|
|
+ // this.$message.warning(
|
|
|
+ // isWithdraw.toString() + '还未派单,无需撤回!'
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let assignees = [];
|
|
|
+ // let changeIds = [];
|
|
|
+ // let flag = true; // 是否填写 校验
|
|
|
+ // // let digit = true; // 数字校验
|
|
|
+ // row.selection.forEach((item) => {
|
|
|
+ // if (!item.quantity || !item.startTime || !item.endTime) {
|
|
|
+ // flag = false;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // // let Aobj = {
|
|
|
+ // // assigneeId: item.id,
|
|
|
+ // // quantity: item.quantity,
|
|
|
+ // // weight: item.weight,
|
|
|
+ // // startTime: item.startTime,
|
|
|
+ // // endTime: item.endTime,
|
|
|
+ // // assigneeType: row.assignType,
|
|
|
+ // // assigneeName: item.name,
|
|
|
+ // // measuringUnit: this.current.measuringUnit,
|
|
|
+ // // isNew: item.isNew ? item.isNew : '',
|
|
|
+ // // deviceId: item.extInfo.assetId ? item.extInfo.assetId : '',
|
|
|
+ // // deviceName: item.extInfo.assetName ? item.extInfo.assetName : ''
|
|
|
+ // // };
|
|
|
+ // let Aobj = {
|
|
|
+ // assigneeId: item.id,
|
|
|
+ // quantity: item.quantity,
|
|
|
+ // weight: item.weight,
|
|
|
+ // startTime: item.startTime,
|
|
|
+ // endTime: item.endTime,
|
|
|
+ // assigneeType: row.assignType,
|
|
|
+ // assigneeName: item.name,
|
|
|
+ // measuringUnit: this.current.measuringUnit,
|
|
|
+ // isNew: item.isNew ? item.isNew : '',
|
|
|
+ // deviceId:
|
|
|
+ // item.extInfo && item.extInfo.assetId ? item.extInfo.assetId : '',
|
|
|
+ // deviceName:
|
|
|
+ // item.extInfo && item.extInfo.assetName
|
|
|
+ // ? item.extInfo.assetName
|
|
|
+ // : '',
|
|
|
+ // workStationId: item.id,
|
|
|
+ // workStationName: item.name
|
|
|
+ // };
|
|
|
+ // if (item.teamTimeIds) {
|
|
|
+ // Aobj.teamTimeIds = item.teamTimeIds;
|
|
|
+ // }
|
|
|
+ // assignees.push(Aobj);
|
|
|
+ // changeIds.push(item.changeId);
|
|
|
+ // });
|
|
|
+ // if (!flag) {
|
|
|
+ // this.$message.warning(
|
|
|
+ // '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
|
|
|
+ // );
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // let data = null;
|
|
|
+ // this.toolbarLoading = true;
|
|
|
+ // if (type == 2) {
|
|
|
+ // data = changeIds;
|
|
|
+ // } else {
|
|
|
+ // data = {
|
|
|
+ // dispatchMethod: 0,
|
|
|
+ // dispatchType: this.dispatchType,
|
|
|
+ // taskId: this.processId,
|
|
|
+ // taskName: row.name,
|
|
|
+ // taskCode: row.code,
|
|
|
+ // teamName: this.form.teamName,
|
|
|
+ // teamId: this.form.teamId,
|
|
|
+ // workCenterId: this.form.workCenterId,
|
|
|
+ // workCenterName: this.form.workCenterName,
|
|
|
+ // workOrderId: this.current.apsWorkOrderId,
|
|
|
+ // sourceType: 2,
|
|
|
+ // mesWorkOrderId: this.current.id,
|
|
|
+ // mesWorkOrderCode: this.current.code,
|
|
|
+ // assignees
|
|
|
+ // };
|
|
|
+ // }
|
|
|
+ // const api =
|
|
|
+ // type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
|
|
|
+ // api(data)
|
|
|
+ // .then((res) => {
|
|
|
+ // this.toolbarLoading = false;
|
|
|
+ // if (res) {
|
|
|
+ // this.$message.success('操作成功');
|
|
|
+ // // 更改当前表格数据
|
|
|
+ // this.setCurrentTab(row);
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // .catch((err) => {
|
|
|
+ // this.toolbarLoading = false;
|
|
|
+ // this.$message.warning(err.message);
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+
|
|
|
dispatch(row, type) {
|
|
|
- if (row.selection.length == 0) {
|
|
|
+ if (!row.selection || row.selection.length === 0) {
|
|
|
return this.$message.warning('请最少选择一条数据');
|
|
|
}
|
|
|
|
|
|
- let isWithdraw = this.getWithdrawT(row, type);
|
|
|
- if (isWithdraw.length) {
|
|
|
- if (type == 1) {
|
|
|
- this.$message.warning(
|
|
|
- isWithdraw.toString() + ',状态为已派单,如需重新派单请先撤回!'
|
|
|
- );
|
|
|
- }
|
|
|
- if (type == 2) {
|
|
|
- this.$message.warning(
|
|
|
- isWithdraw.toString() + '还未派单,无需撤回!'
|
|
|
- );
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ // 获取选择行
|
|
|
let assignees = [];
|
|
|
let changeIds = [];
|
|
|
- let flag = true; // 是否填写 校验
|
|
|
- // let digit = true; // 数字校验
|
|
|
+ let flag = true;
|
|
|
+
|
|
|
row.selection.forEach((item) => {
|
|
|
if (!item.quantity || !item.startTime || !item.endTime) {
|
|
|
flag = false;
|
|
|
return;
|
|
|
}
|
|
|
- // let Aobj = {
|
|
|
- // assigneeId: item.id,
|
|
|
- // quantity: item.quantity,
|
|
|
- // weight: item.weight,
|
|
|
- // startTime: item.startTime,
|
|
|
- // endTime: item.endTime,
|
|
|
- // assigneeType: row.assignType,
|
|
|
- // assigneeName: item.name,
|
|
|
- // measuringUnit: this.current.measuringUnit,
|
|
|
- // isNew: item.isNew ? item.isNew : '',
|
|
|
- // deviceId: item.extInfo.assetId ? item.extInfo.assetId : '',
|
|
|
- // deviceName: item.extInfo.assetName ? item.extInfo.assetName : ''
|
|
|
- // };
|
|
|
+
|
|
|
let Aobj = {
|
|
|
assigneeId: item.id,
|
|
|
quantity: item.quantity,
|
|
|
@@ -951,31 +1050,31 @@
|
|
|
assigneeName: item.name,
|
|
|
measuringUnit: this.current.measuringUnit,
|
|
|
isNew: item.isNew ? item.isNew : '',
|
|
|
- deviceId:
|
|
|
- item.extInfo && item.extInfo.assetId ? item.extInfo.assetId : '',
|
|
|
- deviceName:
|
|
|
- item.extInfo && item.extInfo.assetName
|
|
|
- ? item.extInfo.assetName
|
|
|
- : '',
|
|
|
+ deviceId: item.extInfo?.assetId || '',
|
|
|
+ deviceName: item.extInfo?.assetName || '',
|
|
|
workStationId: item.id,
|
|
|
workStationName: item.name
|
|
|
};
|
|
|
+
|
|
|
if (item.teamTimeIds) {
|
|
|
Aobj.teamTimeIds = item.teamTimeIds;
|
|
|
}
|
|
|
+
|
|
|
assignees.push(Aobj);
|
|
|
changeIds.push(item.changeId);
|
|
|
});
|
|
|
+
|
|
|
if (!flag) {
|
|
|
- this.$message.warning(
|
|
|
- '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
|
|
|
+ return this.$message.warning(
|
|
|
+ '请将所选数据的数量、开始时间、完成时间填写完毕'
|
|
|
);
|
|
|
- return;
|
|
|
}
|
|
|
+
|
|
|
let data = null;
|
|
|
this.toolbarLoading = true;
|
|
|
- if (type == 2) {
|
|
|
- data = changeIds;
|
|
|
+
|
|
|
+ if (type === 2) {
|
|
|
+ data = changeIds; // 撤回
|
|
|
} else {
|
|
|
data = {
|
|
|
dispatchMethod: 0,
|
|
|
@@ -994,15 +1093,29 @@
|
|
|
assignees
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
const api =
|
|
|
- type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
|
|
|
+ type === 1 ? taskAssignment : type === 2 ? taskRevoked : taskSave;
|
|
|
+
|
|
|
api(data)
|
|
|
.then((res) => {
|
|
|
this.toolbarLoading = false;
|
|
|
if (res) {
|
|
|
this.$message.success('操作成功');
|
|
|
- // 更改当前表格数据
|
|
|
+
|
|
|
+ // 更新表格数据,包括新增工位状态
|
|
|
this.setCurrentTab(row);
|
|
|
+
|
|
|
+ row.list.forEach((item) => {
|
|
|
+ if (item.isNew === 1) {
|
|
|
+ // item.disposalStatus =
|
|
|
+ // type === 1 ? 1 : item.disposalStatus || 0;
|
|
|
+ item.status = {
|
|
|
+ code: type === 1 ? 1 : 0,
|
|
|
+ desc: type === 1 ? '已派单' : '已保存'
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
@@ -1010,6 +1123,7 @@
|
|
|
this.$message.warning(err.message);
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
cancel() {
|
|
|
this.$emit('update:dispatchVisible', false);
|
|
|
},
|
|
|
@@ -1052,41 +1166,100 @@
|
|
|
}
|
|
|
},
|
|
|
// 指派数据处理
|
|
|
- async getAssignData(index, arr) {
|
|
|
- let list = JSON.parse(JSON.stringify(arr));
|
|
|
- let dataRow = this.processList[index];
|
|
|
+ // async getAssignData(index, arr) {
|
|
|
+ // let list = JSON.parse(JSON.stringify(arr));
|
|
|
+ // let dataRow = this.processList[index];
|
|
|
|
|
|
- console.log('7777');
|
|
|
+ // console.log('7777');
|
|
|
|
|
|
- // return;
|
|
|
- // 不存在 班组数据的话 就不调用这个方法
|
|
|
- if (!this.form.teamId) {
|
|
|
- return;
|
|
|
- }
|
|
|
- let params = {
|
|
|
+ // // return;
|
|
|
+ // // 不存在 班组数据的话 就不调用这个方法
|
|
|
+ // if (!this.form.teamId) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // let params = {
|
|
|
+ // workOrderId: this.current.apsWorkOrderId,
|
|
|
+ // workCenterId: this.form.workCenterId,
|
|
|
+ // teamId: this.form.teamId,
|
|
|
+ // taskId: this.processId
|
|
|
+ // };
|
|
|
+ // this.tabLoading = true;
|
|
|
+ // try {
|
|
|
+ // const res = await listAssign(params);
|
|
|
+ // this.tabLoading = false;
|
|
|
+
|
|
|
+ // console.log(res, '数据11445');
|
|
|
+ // // 如果 res 没有数据 说明未对数据进行操作 直接赋值
|
|
|
+ // if (res.length == 0) {
|
|
|
+ // this.$set(dataRow, 'list', list);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // // 对有操作过的数据进行赋值
|
|
|
+ // this.operationalData(index, res, list);
|
|
|
+ // } catch (err) {
|
|
|
+ // this.tabLoading = false;
|
|
|
+ // this.$message.warning(err.message);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+
|
|
|
+ async getAssignData(index, arr, type = 0) {
|
|
|
+ const dataRow = this.processList[index];
|
|
|
+
|
|
|
+ const localNewList = (dataRow.list || []).filter((i) => i.isNew === 1);
|
|
|
+
|
|
|
+ let list = JSON.parse(JSON.stringify(arr || []));
|
|
|
+
|
|
|
+ if (!this.form.teamId) return;
|
|
|
+
|
|
|
+ const params = {
|
|
|
workOrderId: this.current.apsWorkOrderId,
|
|
|
workCenterId: this.form.workCenterId,
|
|
|
teamId: this.form.teamId,
|
|
|
taskId: this.processId
|
|
|
};
|
|
|
+
|
|
|
this.tabLoading = true;
|
|
|
try {
|
|
|
const res = await listAssign(params);
|
|
|
this.tabLoading = false;
|
|
|
|
|
|
- console.log(res, '数据11445');
|
|
|
- // 如果 res 没有数据 说明未对数据进行操作 直接赋值
|
|
|
- if (res.length == 0) {
|
|
|
- this.$set(dataRow, 'list', list);
|
|
|
+ if (!res || res.length === 0) {
|
|
|
+ // 没有后台数据,合并新增工位
|
|
|
+ const merged = [...list, ...localNewList];
|
|
|
+ this.$set(dataRow, 'list', merged);
|
|
|
return;
|
|
|
}
|
|
|
- // 对有操作过的数据进行赋值
|
|
|
+
|
|
|
+ // 已操作过数据处理
|
|
|
this.operationalData(index, res, list);
|
|
|
+
|
|
|
+ // 合并新增工位并去重
|
|
|
+ const existingIds = new Set(
|
|
|
+ (dataRow.list || []).map((i) => i.id || i.__tempKey)
|
|
|
+ );
|
|
|
+ const mergedList = [
|
|
|
+ ...dataRow.list,
|
|
|
+ ...localNewList.filter((i) => !existingIds.has(i.id || i.__tempKey))
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 更新新增工位状态
|
|
|
+ mergedList.forEach((item) => {
|
|
|
+ if (item.isNew === 1) {
|
|
|
+ item.disposalStatus = type === 1 ? 1 : item.disposalStatus || 0;
|
|
|
+ item.status = item.status || {
|
|
|
+ code: type === 1 ? 1 : 0,
|
|
|
+ desc: type === 1 ? '已派单' : '已保存'
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.$set(dataRow, 'list', mergedList);
|
|
|
} catch (err) {
|
|
|
this.tabLoading = false;
|
|
|
this.$message.warning(err.message);
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
// 操作过的数据 赋值
|
|
|
operationalData(index, res, list) {
|
|
|
const dataRow = this.processList[index];
|