From 7453d52bbcf390270a566027bd44af32879cf85d Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Tue, 2 Jun 2026 17:09:55 +0800 Subject: [PATCH] =?UTF-8?q?QMS=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/qc/qc.js | 2 + src/views/modules/qc/FAIResultEntry.vue | 191 ++++++++++++++--------- src/views/modules/qc/FQCResultEntry.vue | 191 ++++++++++++++--------- src/views/modules/qc/IPQCResultEntry.vue | 167 ++++++++++++-------- src/views/modules/qc/IQCResultEntry.vue | 171 ++++++++++++-------- src/views/modules/qc/PQCResultEntry.vue | 160 +++++++++++++------ 6 files changed, 558 insertions(+), 324 deletions(-) diff --git a/src/api/qc/qc.js b/src/api/qc/qc.js index 242e80b..0a4efb7 100644 --- a/src/api/qc/qc.js +++ b/src/api/qc/qc.js @@ -209,6 +209,8 @@ export const actionFQCInspection = data => createAPI(`/pms/qc/actionFQCInspectio export const dataAcquisition = data => createAPI(`/pms/qc/dataAcquisition`,'post',data) export const getEquipmentNoList = data => createAPI(`/pms/qc/getEquipmentNoList`,'post',data) export const getResponsibleOperatorList = data => createAPI(`/pms/qc/getResponsibleOperatorList`,'post',data) +export const getMhmResponsibleRoleList = data => createAPI(`/pms/qc/getMhmResponsibleRoleList`,'post',data) +export const getMhmRoleByName = data => createAPI(`/pms/qc/getMhmRoleByName`,'post',data) export const getDataContentList = data => createAPI(`/pms/qc/getDataContentList`,'post',data) export const getObjectList = data => createAPI(`/pms/qc/getObjectList`,'post',data) export const getObjectListBy = data => createAPI(`/pms/qc/getObjectListBy`,'post',data) diff --git a/src/views/modules/qc/FAIResultEntry.vue b/src/views/modules/qc/FAIResultEntry.vue index c174657..1c24a08 100644 --- a/src/views/modules/qc/FAIResultEntry.vue +++ b/src/views/modules/qc/FAIResultEntry.vue @@ -736,7 +736,7 @@ - + @@ -858,6 +858,8 @@ import { searchPartAttributeDetails, // 查询物料属性模板 getEamPropertiesItemByItemNo, getCollectorDataByItem, + getResponsibleOperatorList, + getMhmResponsibleRoleList, } from '@/api/qc/qc.js' import { getTableDefaultListLanguage, @@ -900,6 +902,12 @@ export default { } return this.tableData.slice(start, end) }, + operatorRoleList() { + if (this.operatorData.flag === '2' && this.detailData.buNo === '04-MHM') { + return this.mhmRoleList + } + return this.roleList + }, }, watch: { detailData: { @@ -2239,6 +2247,8 @@ export default { authFile: false, menuId: this.$route.meta.menuId, roleList: [], + mhmRoleList: [], + defaultCollaborativeRoleName: 'FAI操作员', operatorList: [], operatorData: { flag: '', @@ -2529,132 +2539,163 @@ export default { getOperatorList() { this.operatorData.flag = '1' this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter( - (item) => item.roleName === '机修人员' - ) - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId + const tempDataList = ( + this.detailData.operator == null ? '' : this.detailData.operator + ).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + this.setDefaultCollaborativeRole(() => { + this.fetchCollaborativeOperatorData(tempDataList, true) + }) + }, + + isMhmResponsibleBu() { + return this.detailData.buNo === '04-MHM' + }, + + setDefaultCollaborativeRole(callback) { + const apply = () => { + if (this.roleList.length > 0) { + const roleName = this.isMhmResponsibleBu() ? this.defaultCollaborativeRoleName : '系统管理员' + const match = this.roleList.find((item) => item.roleName === roleName) + const roleId = match ? match.roleId : this.roleList[0].roleId + this.$set( + this.operatorData, + 'roleId', + roleId != null && roleId !== '' ? Number(roleId) : '' + ) } else { - this.operatorData.roleId = this.roleList[0].roleId + this.$set(this.operatorData, 'roleId', '') } + callback && callback() + } + if (this.roleList.length > 0) { + apply() } else { - this.operatorData.roleId = '' + getUserRoleList().then(({ data }) => { + this.roleList = data && data.code === 0 ? data.rows || [] : [] + apply() + }) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = ( - this.detailData.operator == null ? '' : this.detailData.operator - ).split(';') + }, + + fetchCollaborativeOperatorData(tempDataList, showDialog) { + this.operatorData.roleName = '' getOperatorList(this.operatorData).then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach((val) => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true) ) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定', }) + } else { + this.operatorList = [] } }) }, - // 获取责任人员列表 - getResponsiblePersonList() { - this.operatorData.flag = '2' - this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter( - (item) => item.roleName === '机修人员' - ) - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId - } else { - this.operatorData.roleId = this.roleList[0].roleId + loadMhmRoleList(callback) { + if (this.mhmRoleList.length > 0) { + callback && callback() + return + } + getMhmResponsibleRoleList({}).then(({ data }) => { + if (data && data.code === 0) { + this.mhmRoleList = data.rows || [] } + callback && callback() + }) + }, + + fetchResponsibleOperatorData(tempDataList, showDialog) { + let request + if (this.isMhmResponsibleBu()) { + this.operatorData.roleName = '' + request = getResponsibleOperatorList(this.operatorData) } else { - this.operatorData.roleId = '' + request = getOperatorList(this.operatorData) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = ( - this.detailData.responsiblePerson == null - ? '' - : this.detailData.responsiblePerson - ).split(';') - getOperatorList(this.operatorData).then(({ data }) => { + request.then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach((val) => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true) ) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定', }) + } else { + this.operatorList = [] } }) }, + // 获取责任人员列表 + getResponsiblePersonList() { + this.operatorData.flag = '2' + this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo + const tempDataList = ( + this.detailData.responsiblePerson == null + ? '' + : this.detailData.responsiblePerson + ).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + const openDialog = () => { + this.fetchResponsibleOperatorData(tempDataList, true) + } + if (this.isMhmResponsibleBu()) { + this.loadMhmRoleList(() => { + this.operatorData.roleId = '' + openDialog() + }) + } else { + if (this.roleList.length > 0) { + let filterList = this.roleList.filter( + (item) => item.roleName === '机修人员' + ) + if (filterList.length > 0) { + this.operatorData.roleId = filterList[0].roleId + } else { + this.operatorData.roleId = this.roleList[0].roleId + } + } else { + this.operatorData.roleId = '' + } + openDialog() + } + }, + // 查询机修人员列表 getOperatorList2() { if (this.operatorData.flag === '1') { - // 拿到选中的人员编号 let tempDataList = ( this.detailData.operator == null ? '' : this.detailData.operator ).split(';') - getOperatorList(this.operatorData).then(({ data }) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach((val) => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => - this.$refs.operatorTable.toggleRowSelection(val, true) - ) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchCollaborativeOperatorData(tempDataList, false) } else { - // 拿到选中的人员编号 let tempDataList = ( this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson ).split(';') - getOperatorList(this.operatorData).then(({ data }) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach((val) => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => - this.$refs.operatorTable.toggleRowSelection(val, true) - ) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchResponsibleOperatorData(tempDataList, false) } }, diff --git a/src/views/modules/qc/FQCResultEntry.vue b/src/views/modules/qc/FQCResultEntry.vue index 5de7831..2fe786b 100644 --- a/src/views/modules/qc/FQCResultEntry.vue +++ b/src/views/modules/qc/FQCResultEntry.vue @@ -718,7 +718,7 @@ - + @@ -842,6 +842,8 @@ import { searchPartAttributeDetails, // 查询物料属性模板 getEamPropertiesItemByItemNo, getCollectorDataByItem, + getResponsibleOperatorList, + getMhmResponsibleRoleList, } from '@/api/qc/qc.js' import { getTableDefaultListLanguage, @@ -884,6 +886,12 @@ export default { } return this.tableData.slice(start, end) }, + operatorRoleList() { + if (this.operatorData.flag === '2' && this.detailData.buNo === '04-MHM') { + return this.mhmRoleList + } + return this.roleList + }, }, watch: { detailData: { @@ -2222,6 +2230,8 @@ export default { authFile: false, menuId: this.$route.meta.menuId, roleList: [], + mhmRoleList: [], + defaultCollaborativeRoleName: 'FQC操作员', operatorList: [], operatorData: { flag: '', @@ -2511,132 +2521,163 @@ export default { getOperatorList() { this.operatorData.flag = '1' this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter( - (item) => item.roleName === '机修人员' - ) - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId + const tempDataList = ( + this.detailData.operator == null ? '' : this.detailData.operator + ).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + this.setDefaultCollaborativeRole(() => { + this.fetchCollaborativeOperatorData(tempDataList, true) + }) + }, + + isMhmResponsibleBu() { + return this.detailData.buNo === '04-MHM' + }, + + setDefaultCollaborativeRole(callback) { + const apply = () => { + if (this.roleList.length > 0) { + const roleName = this.isMhmResponsibleBu() ? this.defaultCollaborativeRoleName : '系统管理员' + const match = this.roleList.find((item) => item.roleName === roleName) + const roleId = match ? match.roleId : this.roleList[0].roleId + this.$set( + this.operatorData, + 'roleId', + roleId != null && roleId !== '' ? Number(roleId) : '' + ) } else { - this.operatorData.roleId = this.roleList[0].roleId + this.$set(this.operatorData, 'roleId', '') } + callback && callback() + } + if (this.roleList.length > 0) { + apply() } else { - this.operatorData.roleId = '' + getUserRoleList().then(({ data }) => { + this.roleList = data && data.code === 0 ? data.rows || [] : [] + apply() + }) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = ( - this.detailData.operator == null ? '' : this.detailData.operator - ).split(';') + }, + + fetchCollaborativeOperatorData(tempDataList, showDialog) { + this.operatorData.roleName = '' getOperatorList(this.operatorData).then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach((val) => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true) ) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定', }) + } else { + this.operatorList = [] } }) }, - // 获取责任人员列表 - getResponsiblePersonList() { - this.operatorData.flag = '2' - this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter( - (item) => item.roleName === '机修人员' - ) - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId - } else { - this.operatorData.roleId = this.roleList[0].roleId + loadMhmRoleList(callback) { + if (this.mhmRoleList.length > 0) { + callback && callback() + return + } + getMhmResponsibleRoleList({}).then(({ data }) => { + if (data && data.code === 0) { + this.mhmRoleList = data.rows || [] } + callback && callback() + }) + }, + + fetchResponsibleOperatorData(tempDataList, showDialog) { + let request + if (this.isMhmResponsibleBu()) { + this.operatorData.roleName = '' + request = getResponsibleOperatorList(this.operatorData) } else { - this.operatorData.roleId = '' + request = getOperatorList(this.operatorData) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = ( - this.detailData.responsiblePerson == null - ? '' - : this.detailData.responsiblePerson - ).split(';') - getOperatorList(this.operatorData).then(({ data }) => { + request.then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach((val) => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true) ) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定', }) + } else { + this.operatorList = [] } }) }, + // 获取责任人员列表 + getResponsiblePersonList() { + this.operatorData.flag = '2' + this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo + const tempDataList = ( + this.detailData.responsiblePerson == null + ? '' + : this.detailData.responsiblePerson + ).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + const openDialog = () => { + this.fetchResponsibleOperatorData(tempDataList, true) + } + if (this.isMhmResponsibleBu()) { + this.loadMhmRoleList(() => { + this.operatorData.roleId = '' + openDialog() + }) + } else { + if (this.roleList.length > 0) { + let filterList = this.roleList.filter( + (item) => item.roleName === '机修人员' + ) + if (filterList.length > 0) { + this.operatorData.roleId = filterList[0].roleId + } else { + this.operatorData.roleId = this.roleList[0].roleId + } + } else { + this.operatorData.roleId = '' + } + openDialog() + } + }, + // 查询机修人员列表 getOperatorList2() { if (this.operatorData.flag === '1') { - // 拿到选中的人员编号 let tempDataList = ( this.detailData.operator == null ? '' : this.detailData.operator ).split(';') - getOperatorList(this.operatorData).then(({ data }) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach((val) => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => - this.$refs.operatorTable.toggleRowSelection(val, true) - ) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchCollaborativeOperatorData(tempDataList, false) } else { - // 拿到选中的人员编号 let tempDataList = ( this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson ).split(';') - getOperatorList(this.operatorData).then(({ data }) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach((val) => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => - this.$refs.operatorTable.toggleRowSelection(val, true) - ) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchResponsibleOperatorData(tempDataList, false) } }, diff --git a/src/views/modules/qc/IPQCResultEntry.vue b/src/views/modules/qc/IPQCResultEntry.vue index f0abdee..5fbe765 100644 --- a/src/views/modules/qc/IPQCResultEntry.vue +++ b/src/views/modules/qc/IPQCResultEntry.vue @@ -797,7 +797,7 @@ @@ -950,6 +950,8 @@ searchPartAttributeDetails, // 查询物料属性模板 getEamPropertiesItemByItemNo, getCollectorDataByItem, + getResponsibleOperatorList, + getMhmResponsibleRoleList, } from "@/api/qc/qc.js" import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" import Chooselist from '@/views/modules/common/Chooselist_eam' @@ -984,6 +986,12 @@ end = this.tableData.length } return this.tableData.slice(start,end) + }, + operatorRoleList () { + if (this.operatorData.flag === '2' && this.detailData.buNo === '04-MHM') { + return this.mhmRoleList + } + return this.roleList } }, watch: { @@ -2371,6 +2379,8 @@ authFile: false, menuId: this.$route.meta.menuId, roleList: [], + mhmRoleList: [], + defaultCollaborativeRoleName: 'IPQC操作员', operatorList: [], operatorData: { flag: '', @@ -2693,108 +2703,141 @@ getOperatorList () { this.operatorData.flag = '1' this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter(item => item.roleName === '机修人员') - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId + const tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + this.setDefaultCollaborativeRole(() => { + this.fetchCollaborativeOperatorData(tempDataList, true) + }) + }, + + isMhmResponsibleBu () { + return this.detailData.buNo === '04-MHM' + }, + + setDefaultCollaborativeRole (callback) { + const apply = () => { + if (this.roleList.length > 0) { + const roleName = this.isMhmResponsibleBu() ? this.defaultCollaborativeRoleName : '系统管理员' + const match = this.roleList.find(item => item.roleName === roleName) + const roleId = match ? match.roleId : this.roleList[0].roleId + this.$set(this.operatorData, 'roleId', roleId != null && roleId !== '' ? Number(roleId) : '') } else { - this.operatorData.roleId = this.roleList[0].roleId + this.$set(this.operatorData, 'roleId', '') } + callback && callback() + } + if (this.roleList.length > 0) { + apply() } else { - this.operatorData.roleId = '' + getUserRoleList().then(({ data }) => { + this.roleList = (data && data.code === 0) ? (data.rows || []) : [] + apply() + }) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') - getOperatorList(this.operatorData).then(({data}) => { + }, + + fetchCollaborativeOperatorData (tempDataList, showDialog) { + this.operatorData.roleName = '' + getOperatorList(this.operatorData).then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach(val => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) + } else { + this.operatorList = [] } }) }, - // 获取责任人员列表 - getResponsiblePersonList () { - this.operatorData.flag = '2' - this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter(item => item.roleName === '机修人员') - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId - } else { - this.operatorData.roleId = this.roleList[0].roleId + loadMhmRoleList (callback) { + if (this.mhmRoleList.length > 0) { + callback && callback() + return + } + getMhmResponsibleRoleList({}).then(({ data }) => { + if (data && data.code === 0) { + this.mhmRoleList = data.rows || [] } + callback && callback() + }) + }, + + fetchResponsibleOperatorData (tempDataList, showDialog) { + let request + if (this.isMhmResponsibleBu()) { + this.operatorData.roleName = '' + request = getResponsibleOperatorList(this.operatorData) } else { - this.operatorData.roleId = '' + request = getOperatorList(this.operatorData) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') - getOperatorList(this.operatorData).then(({data}) => { + request.then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach(val => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) + } else { + this.operatorList = [] } }) }, + // 获取责任人员列表 + getResponsiblePersonList () { + this.operatorData.flag = '2' + this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo + const tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + const openDialog = () => { + this.fetchResponsibleOperatorData(tempDataList, true) + } + if (this.isMhmResponsibleBu()) { + this.loadMhmRoleList(() => { + this.operatorData.roleId = '' + openDialog() + }) + } else { + if (this.roleList.length > 0) { + let filterList = this.roleList.filter(item => item.roleName === '机修人员') + if (filterList.length > 0) { + this.operatorData.roleId = filterList[0].roleId + } else { + this.operatorData.roleId = this.roleList[0].roleId + } + } else { + this.operatorData.roleId = '' + } + openDialog() + } + }, + // 查询机修人员列表 getOperatorList2 () { if (this.operatorData.flag === '1') { - // 拿到选中的人员编号 let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') - getOperatorList(this.operatorData).then(({data}) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach(val => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchCollaborativeOperatorData(tempDataList, false) } else { - // 拿到选中的人员编号 let tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') - getOperatorList(this.operatorData).then(({data}) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach(val => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchResponsibleOperatorData(tempDataList, false) } }, diff --git a/src/views/modules/qc/IQCResultEntry.vue b/src/views/modules/qc/IQCResultEntry.vue index 1592909..cab831d 100644 --- a/src/views/modules/qc/IQCResultEntry.vue +++ b/src/views/modules/qc/IQCResultEntry.vue @@ -658,7 +658,7 @@ @@ -799,6 +799,8 @@ overLoadSearchPartInfo, // 查询物料属性信息 getEamPropertiesItemByItemNo, getCollectorDataByItem, + getResponsibleOperatorList, + getMhmResponsibleRoleList, } from "@/api/qc/qc.js" import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" import Chooselist from '@/views/modules/common/Chooselist_eam' @@ -833,6 +835,12 @@ end = this.tableData.length } return this.tableData.slice(start,end) + }, + operatorRoleList () { + if (this.operatorData.flag === '2' && this.detailData.buNo === '04-MHM') { + return this.mhmRoleList + } + return this.roleList } }, watch: { @@ -1912,6 +1920,8 @@ authFile: false, menuId: this.$route.meta.menuId, roleList: [], + mhmRoleList: [], + defaultCollaborativeRoleName: 'IQC操作员', operatorList: [], operatorData: { flag: '', @@ -2188,108 +2198,145 @@ getOperatorList () { this.operatorData.flag = '1' this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter(item => item.roleName === '机修人员') - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId + const tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + this.setDefaultCollaborativeRole(() => { + this.$nextTick(() => { + this.fetchCollaborativeOperatorData(tempDataList, true) + }) + }) + }, + + isMhmResponsibleBu () { + return this.detailData.buNo === '04-MHM' + }, + + // 协同人员:04-MHM 默认页面角色,其他 BU 默认系统管理员 + setDefaultCollaborativeRole (callback) { + const apply = () => { + if (this.roleList.length > 0) { + const roleName = this.isMhmResponsibleBu() ? this.defaultCollaborativeRoleName : '系统管理员' + const match = this.roleList.find(item => item.roleName === roleName) + const role = match || this.roleList[0] + this.$set(this.operatorData, 'roleId', role.roleId != null && role.roleId !== '' ? Number(role.roleId) : '') } else { - this.operatorData.roleId = this.roleList[0].roleId + this.$set(this.operatorData, 'roleId', '') } + callback && callback() + } + if (this.roleList.length > 0) { + apply() } else { - this.operatorData.roleId = '' + getUserRoleList().then(({ data }) => { + this.roleList = (data && data.code === 0) ? (data.rows || []) : [] + apply() + }) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') - getOperatorList(this.operatorData).then(({data}) => { + }, + + // 协同人员:始终走 getOperatorList(sys_user),不用 getResponsibleOperatorList + fetchCollaborativeOperatorData (tempDataList, showDialog) { + this.operatorData.roleName = '' + getOperatorList(this.operatorData).then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach(val => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) + } else { + this.operatorList = [] } }) }, - // 获取责任人员列表 - getResponsiblePersonList () { - this.operatorData.flag = '2' - this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - if (this.roleList.length > 0) { - let filterList = this.roleList.filter(item => item.roleName === '机修人员') - if (filterList.length > 0) { - this.operatorData.roleId = filterList[0].roleId - } else { - this.operatorData.roleId = this.roleList[0].roleId + loadMhmRoleList (callback) { + if (this.mhmRoleList.length > 0) { + callback && callback() + return + } + getMhmResponsibleRoleList({}).then(({ data }) => { + if (data && data.code === 0) { + this.mhmRoleList = data.rows || [] } + callback && callback() + }) + }, + + fetchResponsibleOperatorData (tempDataList, showDialog) { + let request + if (this.isMhmResponsibleBu()) { + this.operatorData.roleName = '' + request = getResponsibleOperatorList(this.operatorData) } else { - this.operatorData.roleId = '' + request = getOperatorList(this.operatorData) } - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') - getOperatorList(this.operatorData).then(({data}) => { + request.then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach(val => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) + } else { + this.operatorList = [] } }) }, + // 获取责任人员列表 + getResponsiblePersonList () { + this.operatorData.flag = '2' + this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo + const tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + const openDialog = () => { + this.fetchResponsibleOperatorData(tempDataList, true) + } + if (this.isMhmResponsibleBu()) { + this.loadMhmRoleList(() => { + this.operatorData.roleId = '' + openDialog() + }) + } else { + if (this.roleList.length > 0) { + let filterList = this.roleList.filter(item => item.roleName === '机修人员') + if (filterList.length > 0) { + this.operatorData.roleId = filterList[0].roleId + } else { + this.operatorData.roleId = this.roleList[0].roleId + } + } else { + this.operatorData.roleId = '' + } + openDialog() + } + }, + // 查询机修人员列表 getOperatorList2 () { if (this.operatorData.flag === '1') { - // 拿到选中的人员编号 let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') - getOperatorList(this.operatorData).then(({data}) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach(val => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchCollaborativeOperatorData(tempDataList, false) } else { - // 拿到选中的人员编号 let tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') - getOperatorList(this.operatorData).then(({data}) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach(val => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchResponsibleOperatorData(tempDataList, false) } }, diff --git a/src/views/modules/qc/PQCResultEntry.vue b/src/views/modules/qc/PQCResultEntry.vue index 36a2ecd..1399c77 100644 --- a/src/views/modules/qc/PQCResultEntry.vue +++ b/src/views/modules/qc/PQCResultEntry.vue @@ -894,7 +894,7 @@ @@ -1053,6 +1053,8 @@ import { querySopNum,//查询Sop编码 previewSopFile,//预览Sop文件 getColumnDisplayFlagList,//查询 检验单标准值角色用户 + getResponsibleOperatorList, + getMhmResponsibleRoleList, } from "@/api/qc/qc.js" import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" import Chooselist from '@/views/modules/common/Chooselist_eam' @@ -1089,6 +1091,12 @@ export default { } return this.tableData.slice(start,end) }, + operatorRoleList () { + if (this.operatorData.flag === '2' && this.detailData.buNo === '04-MHM') { + return this.mhmRoleList + } + return this.roleList + }, // returntemplateId(){ // let a = this.modalData.operationDesc // let list = this.operationList @@ -2515,6 +2523,8 @@ export default { authFile: false, menuId: this.$route.meta.menuId, roleList: [], + mhmRoleList: [], + defaultCollaborativeRoleName: 'PQC操作员', operatorList: [], operatorData: { flag: '', @@ -2787,91 +2797,141 @@ export default { getOperatorList () { this.operatorData.flag = '1' this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - this.setDefaultLineInspectionRole() - // 先清空缓存选中 + const tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') - getOperatorList(this.operatorData).then(({data}) => { + this.setDefaultCollaborativeRole(() => { + this.fetchCollaborativeOperatorData(tempDataList, true) + }) + }, + + setDefaultCollaborativeRole (callback) { + const apply = () => { + if (this.roleList.length > 0) { + const roleName = this.isMhmResponsibleBu() ? this.defaultCollaborativeRoleName : '系统管理员' + const match = this.roleList.filter(item => item.roleName === roleName) + const roleId = match.length > 0 ? match[0].roleId : this.roleList[0].roleId + this.$set(this.operatorData, 'roleId', roleId != null && roleId !== '' ? Number(roleId) : '') + } else { + this.$set(this.operatorData, 'roleId', '') + } + callback && callback() + } + if (this.roleList.length > 0) { + apply() + } else { + getUserRoleList().then(({ data }) => { + this.roleList = (data && data.code === 0) ? (data.rows || []) : [] + apply() + }) + } + }, + + fetchCollaborativeOperatorData (tempDataList, showDialog) { + this.operatorData.roleName = '' + getOperatorList(this.operatorData).then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach(val => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) + } else { + this.operatorList = [] } }) }, - // 获取责任人员列表 - getResponsiblePersonList () { - this.operatorData.flag = '2' - this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo - this.setDefaultLineInspectionRole() + isMhmResponsibleBu () { + return this.detailData.buNo === '04-MHM' + }, - // 先清空缓存选中 - this.$nextTick(() => this.$refs.operatorTable.clearSelection()) - // 拿到选中的人员编号 - let tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') - getOperatorList(this.operatorData).then(({data}) => { + loadMhmRoleList (callback) { + if (this.mhmRoleList.length > 0) { + callback && callback() + return + } + getMhmResponsibleRoleList({}).then(({ data }) => { + if (data && data.code === 0) { + this.mhmRoleList = data.rows || [] + } + callback && callback() + }) + }, + + fetchResponsibleOperatorData (tempDataList, showDialog) { + let request + if (this.isMhmResponsibleBu()) { + this.operatorData.roleName = '' + request = getResponsibleOperatorList(this.operatorData) + } else { + request = getOperatorList(this.operatorData) + } + request.then(({ data }) => { if (data && data.code === 0) { this.operatorList = data.rows this.operatorList.forEach(val => { - // 回显选中 if (tempDataList.includes(val.adminID)) { this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) } }) - this.operatorModelFlag = true - } else { + if (showDialog) { + this.operatorModelFlag = true + } + } else if (showDialog) { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) + } else { + this.operatorList = [] } }) }, + // 获取责任人员列表 + getResponsiblePersonList () { + this.operatorData.flag = '2' + this.operatorData.bu = this.detailData.site + '_' + this.detailData.buNo + const tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') + this.$nextTick(() => this.$refs.operatorTable.clearSelection()) + const openDialog = () => { + this.fetchResponsibleOperatorData(tempDataList, true) + } + if (this.isMhmResponsibleBu()) { + this.loadMhmRoleList(() => { + this.operatorData.roleId = '' + openDialog() + }) + } else { + if (this.roleList.length > 0) { + let filterList = this.roleList.filter(item => item.roleName === '机修人员') + if (filterList.length > 0) { + this.operatorData.roleId = filterList[0].roleId + } else { + this.operatorData.roleId = this.roleList[0].roleId + } + } else { + this.operatorData.roleId = '' + } + openDialog() + } + }, + // 查询机修人员列表 getOperatorList2 () { if (this.operatorData.flag === '1') { - // 拿到选中的人员编号 let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';') - getOperatorList(this.operatorData).then(({data}) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach(val => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchCollaborativeOperatorData(tempDataList, false) } else { - // 拿到选中的人员编号 let tempDataList = (this.detailData.responsiblePerson == null ? '' : this.detailData.responsiblePerson).split(';') - getOperatorList(this.operatorData).then(({data}) => { - if (data && data.code === 0) { - this.operatorList = data.rows - this.operatorList.forEach(val => { - // 回显选中的部门 - if (tempDataList.includes(val.adminID)) { - this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true)) - } - }) - } else { - this.operatorList = [] - } - }) + this.fetchResponsibleOperatorData(tempDataList, false) } },