|
|
@@ -554,7 +554,8 @@
|
|
|
chooseType: '1',
|
|
|
isUpdataTask: false,
|
|
|
treeKey: '1',
|
|
|
- taskData: null
|
|
|
+ taskData: null,
|
|
|
+ taskRequestController: null
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -599,6 +600,7 @@
|
|
|
},
|
|
|
methods: {
|
|
|
tabClickValue() {
|
|
|
+ this.abortTaskRequest();
|
|
|
this.isFinalCheckProduction = false;
|
|
|
this.operationType = '';
|
|
|
this.getTaskList();
|
|
|
@@ -632,6 +634,13 @@
|
|
|
};
|
|
|
},
|
|
|
|
|
|
+ abortTaskRequest() {
|
|
|
+ if (this.taskRequestController) {
|
|
|
+ this.taskRequestController.abort();
|
|
|
+ this.taskRequestController = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 前端筛选
|
|
|
seekInput() {
|
|
|
// console.log(activeName);
|
|
|
@@ -719,85 +728,146 @@
|
|
|
singleListTask(
|
|
|
JSON.parse(localStorage.getItem('chooseUserInfo'))
|
|
|
).then((res) => {
|
|
|
- res.map((v) => {
|
|
|
- v.newName = `${v.workCenterName}-${v.name}`;
|
|
|
- });
|
|
|
- this.produceTaskList = res;
|
|
|
- this.arr = JSON.parse(JSON.stringify(this.produceTaskList));
|
|
|
- //默认选择第一个工序
|
|
|
- if (this.produceTaskList?.length) {
|
|
|
- this.$store.commit('user/setTaskObj', this.produceTaskList[0]);
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.taskListRef?.setCurrentKey(
|
|
|
- this.produceTaskList[0].id
|
|
|
- );
|
|
|
- });
|
|
|
- this.produceTaskInfo = this.produceTaskList[0];
|
|
|
- }
|
|
|
+ this.handleTaskList(res);
|
|
|
});
|
|
|
} else {
|
|
|
listTask().then((res) => {
|
|
|
- res.map((v) => {
|
|
|
- v.newName = `${v.workCenterName}-${v.name}`;
|
|
|
- });
|
|
|
- this.produceTaskList = res;
|
|
|
- this.taskDataList = res;
|
|
|
- this.arr = JSON.parse(JSON.stringify(this.produceTaskList));
|
|
|
- //默认选择第一个工序
|
|
|
- if (this.produceTaskList?.length) {
|
|
|
- this.$store.commit('user/setTaskObj', this.produceTaskList[0]);
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.taskListRef?.setCurrentKey(
|
|
|
- this.produceTaskList[0].id
|
|
|
- );
|
|
|
- });
|
|
|
- this.produceTaskInfo = this.produceTaskList[0];
|
|
|
- }
|
|
|
- if (this.activeName == '0') {
|
|
|
+ this.handleTaskList(res);
|
|
|
+ if (this.activeName === '0') {
|
|
|
this.getTaskWorkNumber();
|
|
|
- } else if (this.activeName == '1') {
|
|
|
+ } else if (this.activeName === '1') {
|
|
|
this.getTaskWorkList();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ // if (localStorage.getItem('singleUserInfo') == '1') {
|
|
|
+ // singleListTask(
|
|
|
+ // JSON.parse(localStorage.getItem('chooseUserInfo'))
|
|
|
+ // ).then((res) => {
|
|
|
+ // res.map((v) => {
|
|
|
+ // v.newName = `${v.workCenterName}-${v.name}`;
|
|
|
+ // });
|
|
|
+ // this.produceTaskList = res;
|
|
|
+ // this.arr = JSON.parse(JSON.stringify(this.produceTaskList));
|
|
|
+ // if (this.produceTaskList?.length) {
|
|
|
+ // this.$store.commit('user/setTaskObj', this.produceTaskList[0]);
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // this.$refs.taskListRef?.setCurrentKey(
|
|
|
+ // this.produceTaskList[0].id
|
|
|
+ // );
|
|
|
+ // });
|
|
|
+ // this.produceTaskInfo = this.produceTaskList[0];
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // listTask().then((res) => {
|
|
|
+ // res.map((v) => {
|
|
|
+ // v.newName = `${v.workCenterName}-${v.name}`;
|
|
|
+ // });
|
|
|
+ // this.produceTaskList = res;
|
|
|
+ // this.taskDataList = res;
|
|
|
+ // this.arr = JSON.parse(JSON.stringify(this.produceTaskList));
|
|
|
+ // if (this.produceTaskList?.length) {
|
|
|
+ // this.$store.commit('user/setTaskObj', this.produceTaskList[0]);
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // this.$refs.taskListRef?.setCurrentKey(
|
|
|
+ // this.produceTaskList[0].id
|
|
|
+ // );
|
|
|
+ // });
|
|
|
+ // this.produceTaskInfo = this.produceTaskList[0];
|
|
|
+ // }
|
|
|
+ // if (this.activeName == '0') {
|
|
|
+ // this.getTaskWorkNumber();
|
|
|
+ // } else if (this.activeName == '1') {
|
|
|
+ // this.getTaskWorkList();
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
},
|
|
|
|
|
|
- createAbortSignal() {
|
|
|
- const controller = new AbortController();
|
|
|
- this.abortControllers.push(controller);
|
|
|
- return controller.signal;
|
|
|
- },
|
|
|
+ handleTaskList(res) {
|
|
|
+ res.forEach((v) => {
|
|
|
+ v.newName = `${v.workCenterName}-${v.name}`;
|
|
|
+ });
|
|
|
|
|
|
- //获取工序下所有的工单集合
|
|
|
- async getTaskWorkNumber() {
|
|
|
- for (const [index, item] of this.taskDataList.entries()) {
|
|
|
- await workorderPage2({
|
|
|
- pageNum: 1,
|
|
|
- size: 5000,
|
|
|
- taskId: item.id
|
|
|
- }).then((res) => {
|
|
|
- this.taskDataList[index].number = res.count;
|
|
|
+ this.produceTaskList = res;
|
|
|
+ this.taskDataList = res;
|
|
|
+ this.arr = JSON.parse(JSON.stringify(res));
|
|
|
+
|
|
|
+ // 默认选中第一个
|
|
|
+ if (res?.length) {
|
|
|
+ this.$store.commit('user/setTaskObj', res[0]);
|
|
|
+ this.produceTaskInfo = res[0];
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.taskListRef?.setCurrentKey(res[0].id);
|
|
|
});
|
|
|
}
|
|
|
+ },
|
|
|
+
|
|
|
+ async fetchTaskWorkCount(apiFn) {
|
|
|
+ // 新的一轮请求,创建 controller
|
|
|
+ this.taskRequestController = new AbortController();
|
|
|
+ const signal = this.taskRequestController.signal;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const requests = this.taskDataList.map((item) =>
|
|
|
+ apiFn(
|
|
|
+ {
|
|
|
+ pageNum: 1,
|
|
|
+ size: 5000,
|
|
|
+ taskId: item.id
|
|
|
+ },
|
|
|
+ { signal }
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ const results = await Promise.all(requests);
|
|
|
|
|
|
- this.produceTaskList = this.taskDataList;
|
|
|
- this.treeKey = Date.now();
|
|
|
+ this.taskDataList = this.taskDataList.map((item, index) => ({
|
|
|
+ ...item,
|
|
|
+ number: results[index]?.count || 0
|
|
|
+ }));
|
|
|
+
|
|
|
+ this.produceTaskList = this.taskDataList;
|
|
|
+ this.treeKey = Date.now();
|
|
|
+ } catch (err) {
|
|
|
+ if (err?.name == 'CanceledError' || err?.name == 'AbortError') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.error(err);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取工序下所有的工单集合
|
|
|
+ async getTaskWorkNumber() {
|
|
|
+ await this.fetchTaskWorkCount(workorderPage2);
|
|
|
+ // for (const [index, item] of this.taskDataList.entries()) {
|
|
|
+ // await workorderPage2({
|
|
|
+ // pageNum: 1,
|
|
|
+ // size: 5000,
|
|
|
+ // taskId: item.id
|
|
|
+ // }).then((res) => {
|
|
|
+ // this.taskDataList[index].number = res.count;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // this.produceTaskList = this.taskDataList;
|
|
|
+ // this.treeKey = Date.now();
|
|
|
},
|
|
|
|
|
|
//获取工序下所有的任务集合
|
|
|
async getTaskWorkList() {
|
|
|
- for (const [index, item] of this.taskDataList.entries()) {
|
|
|
- await pageByCurrentUser({
|
|
|
- pageNum: 1,
|
|
|
- size: 5000,
|
|
|
- taskId: item.id
|
|
|
- }).then((res) => {
|
|
|
- this.taskDataList[index].number = res.count;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- this.produceTaskList = this.taskDataList;
|
|
|
- this.treeKey = Date.now();
|
|
|
+ await this.fetchTaskWorkCount(pageByCurrentUser);
|
|
|
+ // for (const [index, item] of this.taskDataList.entries()) {
|
|
|
+ // await pageByCurrentUser({
|
|
|
+ // pageNum: 1,
|
|
|
+ // size: 5000,
|
|
|
+ // taskId: item.id
|
|
|
+ // }).then((res) => {
|
|
|
+ // this.taskDataList[index].number = res.count;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // this.produceTaskList = this.taskDataList;
|
|
|
+ // this.treeKey = Date.now();
|
|
|
},
|
|
|
|
|
|
// 获取工位
|
|
|
@@ -1880,7 +1950,7 @@
|
|
|
this.$refs.bomDrawer.open({
|
|
|
categoryId: row.categoryId,
|
|
|
categoryName: row.bomCategoryName,
|
|
|
- code: row.code,
|
|
|
+ code: row.code ? row.code : '',
|
|
|
versions: row.bomCategoryVersions,
|
|
|
rootPathIdParent: row.categoryLevelPathIdParent || '',
|
|
|
isProduct: true,
|