diff --git a/src/views/modules/longtron/production-plan-cable-cop-task.vue b/src/views/modules/longtron/production-plan-cable-cop-task.vue index 23c31695..d545a761 100644 --- a/src/views/modules/longtron/production-plan-cable-cop-task.vue +++ b/src/views/modules/longtron/production-plan-cable-cop-task.vue @@ -281,6 +281,35 @@ export default { this.searchTable() }, methods: { + getExpectedNodeCodeByTaskType(taskType) { + const text = (taskType || '').trim() + if (text.includes('线缆')) return 'lineProduction' + if (text.toUpperCase().includes('COP')) return 'copProduction' + return '' + }, + getExpectedNodeNameByTaskType(taskType) { + const nodeCode = this.getExpectedNodeCodeByTaskType(taskType) + if (nodeCode === 'lineProduction') return '线缆生产' + if (nodeCode === 'copProduction') return 'COP生产' + return '' + }, + getDefaultNodeListByTaskType(taskType) { + const nodeCode = this.getExpectedNodeCodeByTaskType(taskType) + const nodeName = this.getExpectedNodeNameByTaskType(taskType) + if (!nodeCode || !nodeName) { + return [ + { nodeCode: 'lineProduction', nodeName: '线缆生产', status: '未开始' }, + { nodeCode: 'copProduction', nodeName: 'COP生产', status: '未开始' } + ] + } + return [{ nodeCode: nodeCode, nodeName: nodeName, status: '未开始' }] + }, + filterNodeListByTaskType(taskType, nodeList) { + const list = Array.isArray(nodeList) ? nodeList : [] + const expectedNodeCode = this.getExpectedNodeCodeByTaskType(taskType) + if (!expectedNodeCode) return list + return list.filter(item => item && item.nodeCode === expectedNodeCode) + }, searchTable(flag) { if (flag === 'Y') this.pageIndex = 1 const queryData = { @@ -304,7 +333,7 @@ export default { }) }, normalizeRow(row) { - const list = row.nodeList || [] + const list = this.filterNodeListByTaskType(row.taskType, row.nodeList || []) const done = list.filter(item => item.status === '已完成').length const currentNode = (list.find(item => item.status !== '已完成') || {}).nodeName || '全部完成' const assigneeSummary = list.filter(item => item.assigneeUserName).map(item => `${item.nodeName}:${item.assigneeUserName}`).join(';') @@ -321,7 +350,7 @@ export default { nodeList: list, nodeDoneCount: done, nodeTotalCount: list.length, - currentNode: row.currentNode || currentNode, + currentNode: currentNode, reportQty: row.reportQty || 0, assigneeSummary: assigneeSummary || '-' } @@ -344,8 +373,7 @@ export default { finishDate: '', status: '进行中', nodeList: [ - { nodeCode: 'lineProduction', nodeName: '线缆生产', status: '已完成' }, - { nodeCode: 'copProduction', nodeName: 'COP生产', status: '进行中' } + { nodeCode: 'lineProduction', nodeName: '线缆生产', status: '进行中' } ] }, { @@ -364,7 +392,6 @@ export default { finishDate: '', status: '已排产', nodeList: [ - { nodeCode: 'lineProduction', nodeName: '线缆生产', status: '未开始' }, { nodeCode: 'copProduction', nodeName: 'COP生产', status: '未开始' } ] } @@ -418,7 +445,7 @@ export default { }, openEditDialog(row) { this.saveHeaderData = row - ? { ...row, projectNo: row.projectNo || row.taskNo || '', category: row.category || row.sourceProjectNo || '', autoAssignAllUsers: !!row.autoAssignAllUsers, nodeReportMode: row.nodeReportMode || 'PARALLEL' } + ? { ...row, projectNo: row.projectNo || row.taskNo || '', category: row.category || row.sourceProjectNo || '', autoAssignAllUsers: !!row.autoAssignAllUsers, nodeReportMode: row.nodeReportMode || 'PARALLEL', nodeList: this.filterNodeListByTaskType(row.taskType, row.nodeList || []) } : { orderNo: '', projectNo: '', taskType: '线缆自制', category: '新梯', materialName: '', materialSpec: '', reportQty: 0, planFinishDate: '', status: '已排产', autoAssignAllUsers: true, nodeReportMode: 'PARALLEL', nodeList: [] } this.setUp.reviewFlag = true }, @@ -433,6 +460,10 @@ export default { projectNo: this.saveHeaderData.projectNo, sourceProjectNo: this.saveHeaderData.category } + payload.nodeList = this.filterNodeListByTaskType(payload.taskType, payload.nodeList || []) + if (!payload.nodeList.length) { + payload.nodeList = this.getDefaultNodeListByTaskType(payload.taskType) + } delete payload.category this.setUp.saveButton = true saveCableCopTask(payload).then(({data}) => { @@ -449,10 +480,7 @@ export default { const saveData = this.normalizeRow({ ...payload, orderNo: orderNo, - nodeList: payload.nodeList && payload.nodeList.length ? payload.nodeList : [ - { nodeCode: 'lineProduction', nodeName: '线缆生产', status: '未开始' }, - { nodeCode: 'copProduction', nodeName: 'COP生产', status: '未开始' } - ] + nodeList: payload.nodeList && payload.nodeList.length ? payload.nodeList : this.getDefaultNodeListByTaskType(payload.taskType) }) if (index > -1) this.$set(this.dataList, index, saveData) else this.dataList.unshift(saveData) @@ -462,7 +490,8 @@ export default { }) }, openReportDialog(row) { - this.reportNodeOptions = (row.nodeList || []).filter(item => item.status !== '已完成') + const taskNodeList = this.filterNodeListByTaskType(row.taskType, row.nodeList || []) + this.reportNodeOptions = taskNodeList.filter(item => item.status !== '已完成') this.reportData = { orderNo: row.orderNo, taskNo: row.projectNo || row.taskNo, nodeCode: '', reportQty: 1, remark: '' } this.setUp.reportFlag = true }, @@ -471,7 +500,8 @@ export default { this.currentAssignOrder = { orderNo: row.orderNo, orderType: 'CABLE_COP' } getNodeAssigneeList({ orderNo: row.orderNo, orderType: 'CABLE_COP' }).then(({ data }) => { const assignRows = data && data.code === 0 ? (data.rows || []) : [] - this.assignNodeList = assignRows.map(item => ({ ...item, assigneeUserIdList: item.assigneeUserIdList || [], userOptions: [] })) + const filteredAssignRows = this.filterNodeListByTaskType(row.taskType, assignRows) + this.assignNodeList = filteredAssignRows.map(item => ({ ...item, assigneeUserIdList: item.assigneeUserIdList || [], userOptions: [] })) const requests = this.assignNodeList.map(item => getNodeAssigneeUsers({ orderType: 'CABLE_COP', nodeCode: item.nodeCode }).then(({ data: userData }) => { item.userOptions = userData && userData.code === 0 ? (userData.rows || []) : [] diff --git a/src/views/modules/longtron/production-work-report.vue b/src/views/modules/longtron/production-work-report.vue index 0953b9df..89ef440b 100644 --- a/src/views/modules/longtron/production-work-report.vue +++ b/src/views/modules/longtron/production-work-report.vue @@ -105,7 +105,7 @@