Browse Source

锁定计划员(郑宇)

master
han\hanst 2 weeks ago
parent
commit
4336e85329
  1. 72
      src/views/modules/erf/expApplyList.vue

72
src/views/modules/erf/expApplyList.vue

@ -647,13 +647,14 @@
placeholder="请选择计划员(可多选)" placeholder="请选择计划员(可多选)"
style="width: 100%" style="width: 100%"
multiple multiple
clearable
@change="handlePlannerSelectionChange"
@remove-tag="handlePlannerRemoveTag"> @remove-tag="handlePlannerRemoveTag">
<el-option <el-option
v-for="planner in plannerList" v-for="planner in plannerList"
:key="planner.userId" :key="planner.userId"
:label="planner.userDisplay || planner.username" :label="planner.userDisplay || planner.username"
:value="planner.userId">
:value="planner.userId"
:disabled="isLockedPlanner(planner.userId)">
</el-option> </el-option>
</el-select> </el-select>
<div style="margin-top: 1px; color: #909399; font-size: 12px"> <div style="margin-top: 1px; color: #909399; font-size: 12px">
@ -1089,8 +1090,7 @@ export default {
this.qualityManagerList = data.qualityManagers || [] this.qualityManagerList = data.qualityManagers || []
this.plannerList = data.planners || [] this.plannerList = data.planners || []
// userId // userId
const joyce = this.plannerList.find(p => p.userDisplay && p.userDisplay.includes('郑宇'))
this.lockedPlannerUserId = joyce ? joyce.userId : null
this.lockedPlannerUserId = this.getLockedPlannerUserId(this.plannerList)
// 使user_display // 使user_display
const defaultProdManagerIds = [] const defaultProdManagerIds = []
if (row.buDesc === 'RFID') { if (row.buDesc === 'RFID') {
@ -1134,11 +1134,8 @@ export default {
prodManagerAnyApproved: true, prodManagerAnyApproved: true,
qualityManagerAnyApproved: true, qualityManagerAnyApproved: true,
plannerIds: (() => { plannerIds: (() => {
// Joyce
const joyce = this.plannerList.find(p =>
p.userDisplay && p.userDisplay.toLowerCase().includes('郑宇')
)
if (joyce) return [joyce.userId]
//
if (this.lockedPlannerUserId) return [this.lockedPlannerUserId]
return this.plannerList.length === 1 ? [this.plannerList[0].userId] : [] return this.plannerList.length === 1 ? [this.plannerList[0].userId] : []
})() })()
} }
@ -1154,16 +1151,63 @@ export default {
}, },
/** /**
* 计划员移除标签拦截默认计划员不允许被移除
* 获取锁定计划员郑宇 userId
*/
getLockedPlannerUserId(planners) {
const plannerArr = Array.isArray(planners) ? planners : []
const lockedPlanner = plannerArr.find(planner => {
const userDisplay = (planner.userDisplay || '').toLowerCase()
const username = (planner.username || '').toLowerCase()
return userDisplay.includes('郑宇') ||
userDisplay.includes('joyce') ||
userDisplay.includes('zhengyu') ||
username.includes('郑宇') ||
username.includes('joyce') ||
username.includes('zhengyu')
})
return lockedPlanner ? lockedPlanner.userId : null
},
/**
* 判断是否为锁定计划员
*/
isLockedPlanner(userId) {
return !!this.lockedPlannerUserId && userId === this.lockedPlannerUserId
},
/**
* 确保锁定计划员始终被选中
*/
ensureLockedPlannerSelected(selectedIds, showWarning) {
if (!this.lockedPlannerUserId) return
const currentIds = Array.isArray(selectedIds)
? selectedIds
: (Array.isArray(this.submitData.plannerIds) ? this.submitData.plannerIds : [])
if (!currentIds.includes(this.lockedPlannerUserId)) {
const deduplicatedIds = currentIds.filter(id => id !== this.lockedPlannerUserId)
this.submitData.plannerIds = [this.lockedPlannerUserId, ...deduplicatedIds]
if (showWarning) {
this.$message.warning('郑宇为固定计划员,不可取消')
}
}
},
/**
* 计划员选择变更拦截郑宇不可取消
*/
handlePlannerSelectionChange(selectedIds) {
this.ensureLockedPlannerSelected(selectedIds, true)
},
/**
* 计划员移除标签拦截郑宇不可移除
*/ */
handlePlannerRemoveTag(removedId) { handlePlannerRemoveTag(removedId) {
if (this.lockedPlannerUserId && removedId === this.lockedPlannerUserId) { if (this.lockedPlannerUserId && removedId === this.lockedPlannerUserId) {
this.$nextTick(() => { this.$nextTick(() => {
if (!this.submitData.plannerIds.includes(this.lockedPlannerUserId)) {
this.submitData.plannerIds = [this.lockedPlannerUserId, ...this.submitData.plannerIds]
}
this.ensureLockedPlannerSelected(this.submitData.plannerIds, false)
}) })
this.$message.warning('该计划员不可移除')
} }
}, },

Loading…
Cancel
Save