-
+
+
+
+
+
+
+
this.$refs.operatorTable.clearSelection())
- this.setDefaultCollaborativeRole(() => {
+ this.setDefaultCollaborativeDepartment(() => {
this.$nextTick(() => {
this.fetchCollaborativeOperatorData(tempDataList, true)
})
})
},
- isMhmResponsibleBu () {
- return this.detailData.buNo === '04-MHM'
+ formatDepartmentLabel (dept) {
+ if (!dept) return ''
+ const id = dept.departmentId || ''
+ const name = dept.departmentName || ''
+ return name ? `${id} - ${name}` : id
},
- // 协同人员: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) : '')
+ // 协同人员:按部门筛选(与 sys-department 一致,数据来自 sys_department + Access_dept)
+ setDefaultCollaborativeDepartment (callback) {
+ this.loadDepartmentList(() => {
+ if (this.departmentList.length > 0) {
+ const current = this.operatorData.departmentId
+ const exists = this.departmentList.some(d => d.departmentId === current)
+ if (!exists) {
+ this.$set(this.operatorData, 'departmentId', this.departmentList[0].departmentId)
+ }
} else {
- this.$set(this.operatorData, 'roleId', '')
+ this.$set(this.operatorData, 'departmentId', '')
}
callback && callback()
- }
- if (this.roleList.length > 0) {
- apply()
- } else {
- getUserRoleList().then(({ data }) => {
- this.roleList = (data && data.code === 0) ? (data.rows || []) : []
- apply()
- })
+ })
+ },
+
+ loadDepartmentList (callback) {
+ departmentSearch({
+ site: this.currentUserSite(),
+ username: this.$store.state.user.name,
+ page: 1,
+ limit: 500
+ }).then(({ data }) => {
+ if (data && data.code === 0) {
+ this.departmentList = (data.page && data.page.list) || []
+ } else {
+ this.departmentList = []
+ }
+ callback && callback()
+ }).catch(() => {
+ this.departmentList = []
+ callback && callback()
+ })
+ },
+
+ buildCollaborativeOperatorParams () {
+ const site = this.currentUserSite()
+ return {
+ ...this.operatorData,
+ site,
+ bu: buildQcBu(site),
+ roleId: '',
+ roleName: '',
+ department: this.operatorData.departmentId
}
},
- // 协同人员:始终走 getOperatorList(sys_user),不用 getResponsibleOperatorList
+ // 协同人员:按部门成员(Access_dept)查询 sys_user
fetchCollaborativeOperatorData (tempDataList, showDialog) {
- this.operatorData.roleName = ''
- getOperatorList(this.operatorData).then(({ data }) => {
+ if (!this.operatorData.departmentId) {
+ if (showDialog) {
+ const msg = this.departmentList.length === 0
+ ? '当前工厂暂无部门,请先在部门管理中维护'
+ : '请选择部门'
+ this.$message.warning(msg)
+ }
+ this.operatorList = []
+ return
+ }
+ getOperatorList(this.buildCollaborativeOperatorParams()).then(({ data }) => {
if (data && data.code === 0) {
this.operatorList = data.rows
this.operatorList.forEach(val => {
@@ -2319,6 +2374,10 @@
})
},
+ isMhmResponsibleBu () {
+ return this.detailData.buNo === '04-MHM'
+ },
+
fetchResponsibleOperatorData (tempDataList, showDialog) {
let request
if (this.isMhmResponsibleBu()) {
@@ -2375,9 +2434,13 @@
}
},
- // 查询机修人员列表
+ // 查询人员列表
getOperatorList2 () {
if (this.operatorData.flag === '1') {
+ if (!this.operatorData.departmentId) {
+ this.$message.warning('请选择部门')
+ return
+ }
let tempDataList = (this.detailData.operator == null ? '' : this.detailData.operator).split(';')
this.fetchCollaborativeOperatorData(tempDataList, false)
} else {
@@ -2431,6 +2494,7 @@
adminName: '',
roleName: '',
roleId: '',
+ departmentId: '',
userName: this.$store.state.user.name
}
this.operatorModelFlag = false