|
|
@@ -242,6 +242,7 @@
|
|
|
<el-date-picker
|
|
|
v-model="row.endTime"
|
|
|
:disabled="row.disposalStatus == 1"
|
|
|
+ @change="handleEndTimeChange(row, item)"
|
|
|
class="w100"
|
|
|
placeholder="完成时间"
|
|
|
type="datetime"
|
|
|
@@ -250,6 +251,15 @@
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:action="{ row }">
|
|
|
+ <el-link
|
|
|
+ v-if="canDeleteAddedStation(row)"
|
|
|
+ type="danger"
|
|
|
+ :underline="false"
|
|
|
+ style="margin-right: 8px"
|
|
|
+ @click="deleteRow(row, item)"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
<!-- :disabled="resetBtnDis(row)" -->
|
|
|
<el-popconfirm
|
|
|
v-if="resetBtnDis(row)"
|
|
|
@@ -769,6 +779,7 @@
|
|
|
.map((item) => ({
|
|
|
...item,
|
|
|
isNew: 1,
|
|
|
+ addedByChooseStation: true,
|
|
|
__tempKey: item.id || `temp_${Date.now()}_${Math.random()}`,
|
|
|
disposalStatus: 0,
|
|
|
assetCode: item.extInfo?.assetCode,
|
|
|
@@ -785,7 +796,71 @@
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
const tab = `tableRef${process.index}`;
|
|
|
- this.$refs[tab]?.[0]?.setSelectedRowKeys(process.selection);
|
|
|
+ this.$refs[tab]?.[0]?.setSelectedRowKeys?.(
|
|
|
+ this.getSelectionKeys(process.selection)
|
|
|
+ );
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ getRowUniqueKey(row) {
|
|
|
+ if (!row) return '';
|
|
|
+ return row.id || row.__tempKey || '';
|
|
|
+ },
|
|
|
+
|
|
|
+ getSelectionKeys(selection = []) {
|
|
|
+ return selection
|
|
|
+ .map((item) =>
|
|
|
+ item && typeof item === 'object' ? this.getRowUniqueKey(item) : item
|
|
|
+ )
|
|
|
+ .filter((item) => item !== undefined && item !== null && item !== '');
|
|
|
+ },
|
|
|
+
|
|
|
+ isAddedStationRow(row) {
|
|
|
+ return !!row && (row.addedByChooseStation === true || row.isNew === 1);
|
|
|
+ },
|
|
|
+
|
|
|
+ isSavedOrDispatched(row) {
|
|
|
+ const statusDesc = row?.status?.desc || '';
|
|
|
+ return statusDesc.includes('保存') || statusDesc.includes('派单');
|
|
|
+ },
|
|
|
+
|
|
|
+ canDeleteAddedStation(row) {
|
|
|
+ return this.isAddedStationRow(row) && !this.isSavedOrDispatched(row);
|
|
|
+ },
|
|
|
+
|
|
|
+ deleteRow(row, process) {
|
|
|
+ if (!this.canDeleteAddedStation(row)) {
|
|
|
+ this.$message.warning(
|
|
|
+ '只有通过添加工位新增且未保存、未派单的数据才可以删除'
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const rowKey = this.getRowUniqueKey(row);
|
|
|
+ if (!rowKey) return;
|
|
|
+
|
|
|
+ const nextList = (process.list || []).filter(
|
|
|
+ (item) => this.getRowUniqueKey(item) !== rowKey
|
|
|
+ );
|
|
|
+ this.$set(process, 'list', nextList);
|
|
|
+
|
|
|
+ const nextSelection = (process.selection || []).filter((item) => {
|
|
|
+ const currentKey =
|
|
|
+ item && typeof item === 'object' ? this.getRowUniqueKey(item) : item;
|
|
|
+ return currentKey !== rowKey;
|
|
|
+ });
|
|
|
+ this.$set(process, 'selection', nextSelection);
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const tabIndex =
|
|
|
+ process.index ?? this.processList.findIndex((item) => item === process);
|
|
|
+ const tab = `tableRef${tabIndex}`;
|
|
|
+ const selectedKeys = nextSelection
|
|
|
+ .map((item) =>
|
|
|
+ item && typeof item === 'object' ? this.getRowUniqueKey(item) : item
|
|
|
+ )
|
|
|
+ .filter(Boolean);
|
|
|
+ this.$refs[tab]?.[0]?.setSelectedRowKeys?.(selectedKeys);
|
|
|
});
|
|
|
},
|
|
|
|
|
|
@@ -1106,25 +1181,23 @@
|
|
|
type === 1 ? taskAssignment : type === 2 ? taskRevoked : taskSave;
|
|
|
|
|
|
api(data)
|
|
|
- .then((res) => {
|
|
|
- this.toolbarLoading = false;
|
|
|
+ .then(async (res) => {
|
|
|
if (res) {
|
|
|
- this.$message.success('操作成功');
|
|
|
-
|
|
|
- // 更新表格数据,包括新增工位状态
|
|
|
- this.setCurrentTab(row);
|
|
|
+ // 等待当前页数据刷新完成,确保新增工位能回填 changeId
|
|
|
+ await 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 ? '已派单' : '已保存'
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ this.$message.success('操作成功');
|
|
|
}
|
|
|
+ this.toolbarLoading = false;
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
this.toolbarLoading = false;
|
|
|
@@ -1145,7 +1218,7 @@
|
|
|
} else {
|
|
|
arr = this.productionList;
|
|
|
}
|
|
|
- this.getAssignData(row.index, arr);
|
|
|
+ return this.getAssignData(row.index, arr);
|
|
|
},
|
|
|
// 工序选择
|
|
|
async handleClick(tab) {
|
|
|
@@ -1154,10 +1227,7 @@
|
|
|
this.isTask = false;
|
|
|
await this.FirstTaskIdFn(id);
|
|
|
let data = this.processList.find((item) => item.id == this.processId);
|
|
|
- if (
|
|
|
- data &&
|
|
|
- (data.type == 2 || data.type == 3 || data.type == 6)
|
|
|
- ) {
|
|
|
+ if (data && (data.type == 2 || data.type == 3 || data.type == 6)) {
|
|
|
this.$message.warning('请前往质检系统派单');
|
|
|
}
|
|
|
await this.changeRadio(data.assignType, data.index);
|
|
|
@@ -1247,13 +1317,19 @@
|
|
|
// 已操作过数据处理
|
|
|
this.operationalData(index, res, list);
|
|
|
|
|
|
+ const syncedLocalNewList = this.syncAddedStationAssignments(
|
|
|
+ localNewList,
|
|
|
+ res?.[0]?.assignees || [],
|
|
|
+ dataRow.assignType
|
|
|
+ );
|
|
|
+
|
|
|
// 合并新增工位并去重
|
|
|
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))
|
|
|
+ ...syncedLocalNewList.filter((i) => !existingIds.has(i.id || i.__tempKey))
|
|
|
];
|
|
|
|
|
|
// 更新新增工位状态
|
|
|
@@ -1274,6 +1350,32 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ syncAddedStationAssignments(localNewList, assignees, assignType) {
|
|
|
+ const assignmentMap = new Map();
|
|
|
+
|
|
|
+ (assignees || []).forEach((item) => {
|
|
|
+ if (String(item?.assigneeType?.code) !== String(assignType)) return;
|
|
|
+ assignmentMap.set(String(item.assigneeId), item);
|
|
|
+ });
|
|
|
+
|
|
|
+ return (localNewList || []).map((item) => {
|
|
|
+ const matched = assignmentMap.get(String(item.id));
|
|
|
+ if (!matched) return item;
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ disposalStatus: matched.disposalStatus,
|
|
|
+ status: matched.status,
|
|
|
+ startTime: matched.startTime,
|
|
|
+ endTime: matched.endTime,
|
|
|
+ quantity: matched.quantity,
|
|
|
+ weight: matched.weight,
|
|
|
+ changeId: matched.id,
|
|
|
+ teamTimeIds: matched.teamTimeIds
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
// 操作过的数据 赋值
|
|
|
operationalData(index, res, list) {
|
|
|
const dataRow = this.processList[index];
|
|
|
@@ -1494,13 +1596,13 @@
|
|
|
// 默认选中当前更改数据
|
|
|
selectedListData(row, item) {
|
|
|
this.$nextTick(() => {
|
|
|
- let data = item.selection.find((el) => el.id == row.id);
|
|
|
- if (!data) {
|
|
|
- let ids = item.selection.map((el) => el.id);
|
|
|
- ids.push(row.id);
|
|
|
- let tab = `tableRef${[item.index]}`;
|
|
|
- this.$refs[tab][0].setSelectedRowKeys(ids);
|
|
|
+ const rowKey = this.getRowUniqueKey(row);
|
|
|
+ const selectedKeys = this.getSelectionKeys(item.selection || []);
|
|
|
+ if (!selectedKeys.includes(rowKey)) {
|
|
|
+ selectedKeys.push(rowKey);
|
|
|
}
|
|
|
+ let tab = `tableRef${[item.index]}`;
|
|
|
+ this.$refs[tab]?.[0]?.setSelectedRowKeys?.(selectedKeys);
|
|
|
});
|
|
|
},
|
|
|
// 多选班次时间数据
|
|
|
@@ -1690,11 +1792,11 @@
|
|
|
// 时间校验
|
|
|
checkEndTimeValid(row) {
|
|
|
const { startTime: start, endTime: end } = row;
|
|
|
- // if (!start || !end) return; // 开始/结束时间未填,跳过
|
|
|
+ if (!start || !end) return;
|
|
|
const startTime = new Date(start); // 开始时间
|
|
|
const endTime = new Date(end); // 结束时间
|
|
|
if (endTime < startTime) {
|
|
|
- row.endTime = new Date(startTime); // 修正为开始时间
|
|
|
+ row.endTime = start; // 修正为开始时间
|
|
|
this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
|
|
|
}
|
|
|
}
|