Browse Source

生产车间负责人

master
han\hanst 2 weeks ago
parent
commit
0ad645aff7
  1. 121
      src/views/modules/erf/components/expApplyForm.vue

121
src/views/modules/erf/components/expApplyForm.vue

@ -79,14 +79,14 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-col :span="12">
<el-form-item label="试验负责人"> <el-form-item label="试验负责人">
<span v-if="!readonly" style="cursor: pointer" slot="label" @click="getBaseList(103)"><a href="#">试验负责人</a></span> <span v-if="!readonly" style="cursor: pointer" slot="label" @click="getBaseList(103)"><a href="#">试验负责人</a></span>
<el-input v-model="saveHeaderData.projectLeader" disabled></el-input> <el-input v-model="saveHeaderData.projectLeader" disabled></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-col :span="12">
<el-form-item label="PJM负责人"> <el-form-item label="PJM负责人">
<el-select <el-select
v-model="saveHeaderData.pjmLeaderUserId" v-model="saveHeaderData.pjmLeaderUserId"
@ -105,14 +105,16 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-col :span="24">
<el-form-item label="生产车间负责人"> <el-form-item label="生产车间负责人">
<el-select <el-select
v-model="saveHeaderData.workshopLeaderUserId"
v-model="workshopLeaderUserIds"
:disabled="readonly" :disabled="readonly"
multiple
collapse-tags-tooltip
clearable clearable
filterable filterable
placeholder="非必填"
placeholder="可多选,非必填"
style="width: 100%" style="width: 100%"
@change="handleWorkshopLeaderChange"> @change="handleWorkshopLeaderChange">
<el-option <el-option
@ -301,13 +303,14 @@ export default {
projectLeader: this.$store.state.user.userDisplay, projectLeader: this.$store.state.user.userDisplay,
pjmLeaderUserId: null, pjmLeaderUserId: null,
pjmLeaderName: '', pjmLeaderName: '',
workshopLeaderUserId: null,
workshopLeaderUserId: '',
workshopLeaderName: '', workshopLeaderName: '',
contactMethod: '', contactMethod: '',
processRequirement: '', processRequirement: '',
creatorUserId: this.$store.state.user.id, creatorUserId: this.$store.state.user.id,
creatorName: this.$store.state.user.userDisplay creatorName: this.$store.state.user.userDisplay
}, },
workshopLeaderUserIds: [],
formRules: { formRules: {
applyNo: [ applyNo: [
@ -340,8 +343,9 @@ export default {
if (!newVal) { if (!newVal) {
this.saveHeaderData.pjmLeaderUserId = null this.saveHeaderData.pjmLeaderUserId = null
this.saveHeaderData.pjmLeaderName = '' this.saveHeaderData.pjmLeaderName = ''
this.saveHeaderData.workshopLeaderUserId = null
this.saveHeaderData.workshopLeaderUserId = ''
this.saveHeaderData.workshopLeaderName = '' this.saveHeaderData.workshopLeaderName = ''
this.workshopLeaderUserIds = []
// BU退 // BU退
this.loadPjmLeaderList('') this.loadPjmLeaderList('')
return return
@ -350,8 +354,9 @@ export default {
if (oldVal !== undefined && oldVal !== null && oldVal !== '') { if (oldVal !== undefined && oldVal !== null && oldVal !== '') {
this.saveHeaderData.pjmLeaderUserId = null this.saveHeaderData.pjmLeaderUserId = null
this.saveHeaderData.pjmLeaderName = '' this.saveHeaderData.pjmLeaderName = ''
this.saveHeaderData.workshopLeaderUserId = null
this.saveHeaderData.workshopLeaderUserId = ''
this.saveHeaderData.workshopLeaderName = '' this.saveHeaderData.workshopLeaderName = ''
this.workshopLeaderUserIds = []
} }
this.loadPjmLeaderList(newVal) this.loadPjmLeaderList(newVal)
} }
@ -369,6 +374,7 @@ export default {
} }
this.isEdit = true this.isEdit = true
} }
this.normalizeWorkshopLeaderSelection()
// BU // BU
this.loadPjmLeaderList(this.saveHeaderData.buNo || '') this.loadPjmLeaderList(this.saveHeaderData.buNo || '')
}, },
@ -402,8 +408,8 @@ export default {
if (this.saveHeaderData.pjmLeaderUserId && !this.saveHeaderData.pjmLeaderName) { if (this.saveHeaderData.pjmLeaderUserId && !this.saveHeaderData.pjmLeaderName) {
this.handlePjmLeaderChange(this.saveHeaderData.pjmLeaderUserId) this.handlePjmLeaderChange(this.saveHeaderData.pjmLeaderUserId)
} }
if (this.saveHeaderData.workshopLeaderUserId && !this.saveHeaderData.workshopLeaderName) {
this.handleWorkshopLeaderChange(this.saveHeaderData.workshopLeaderUserId)
if (this.workshopLeaderUserIds.length > 0) {
this.handleWorkshopLeaderChange(this.workshopLeaderUserIds)
} }
} else { } else {
this.pjmLeaderList = [] this.pjmLeaderList = []
@ -431,18 +437,79 @@ export default {
: (this.saveHeaderData.pjmLeaderName || '') : (this.saveHeaderData.pjmLeaderName || '')
}, },
/**
* 解析生产车间负责人ID列表
*/
parseWorkshopLeaderUserIds(value) {
if (value === null || value === undefined || value === '') {
return []
}
const sourceList = Array.isArray(value) ? value : String(value).split(',')
const idList = []
sourceList.forEach(item => {
const id = Number(String(item).trim())
if (Number.isFinite(id) && !idList.includes(id)) {
idList.push(id)
}
})
return idList
},
/**
* 解析生产车间负责人姓名列表
*/
parseWorkshopLeaderNames(value) {
if (!value) {
return []
}
return String(value).split(',').map(item => item.trim()).filter(item => !!item)
},
/**
* 初始化生产车间负责人多选数据
*/
normalizeWorkshopLeaderSelection() {
this.workshopLeaderUserIds = this.parseWorkshopLeaderUserIds(this.saveHeaderData.workshopLeaderUserId)
this.saveHeaderData.workshopLeaderUserId = this.workshopLeaderUserIds.length > 0
? this.workshopLeaderUserIds.join(',')
: ''
this.saveHeaderData.workshopLeaderName = this.parseWorkshopLeaderNames(
this.saveHeaderData.workshopLeaderName
).join(',')
},
/** /**
* 处理生产车间负责人变更 * 处理生产车间负责人变更
*/ */
handleWorkshopLeaderChange(userId) {
if (!userId) {
handleWorkshopLeaderChange(userIds) {
const oldWorkshopLeaderIds = this.parseWorkshopLeaderUserIds(this.saveHeaderData.workshopLeaderUserId)
const oldWorkshopLeaderNames = this.parseWorkshopLeaderNames(this.saveHeaderData.workshopLeaderName)
const oldWorkshopLeaderNameMap = {}
oldWorkshopLeaderIds.forEach((id, index) => {
const oldName = oldWorkshopLeaderNames[index]
if (oldName) {
oldWorkshopLeaderNameMap[id] = oldName
}
})
const workshopLeaderIds = this.parseWorkshopLeaderUserIds(userIds)
this.workshopLeaderUserIds = workshopLeaderIds
this.saveHeaderData.workshopLeaderUserId = workshopLeaderIds.length > 0 ? workshopLeaderIds.join(',') : ''
if (workshopLeaderIds.length === 0) {
this.saveHeaderData.workshopLeaderName = '' this.saveHeaderData.workshopLeaderName = ''
return return
} }
const selected = this.workshopLeaderList.find(item => item.userId === userId)
this.saveHeaderData.workshopLeaderName = selected
? (selected.userDisplay || selected.username || '')
: (this.saveHeaderData.workshopLeaderName || '')
const workshopLeaderNameList = workshopLeaderIds.map(userId => {
const selected = this.workshopLeaderList.find(item => Number(item.userId) === Number(userId))
if (selected) {
return selected.userDisplay || selected.username || ''
}
return oldWorkshopLeaderNameMap[userId] || ''
}).filter(name => !!name)
this.saveHeaderData.workshopLeaderName = workshopLeaderNameList.join(',')
}, },
/** /**
@ -466,17 +533,21 @@ export default {
* 编辑场景兜底已选生产车间负责人不在当前下拉项时补充显示 * 编辑场景兜底已选生产车间负责人不在当前下拉项时补充显示
*/ */
ensureWorkshopLeaderOption() { ensureWorkshopLeaderOption() {
if (!this.saveHeaderData.workshopLeaderUserId) {
if (!this.workshopLeaderUserIds || this.workshopLeaderUserIds.length === 0) {
return return
} }
const exist = this.workshopLeaderList.some(item => item.userId === this.saveHeaderData.workshopLeaderUserId)
if (!exist && this.saveHeaderData.workshopLeaderName) {
this.workshopLeaderList.push({
userId: this.saveHeaderData.workshopLeaderUserId,
username: this.saveHeaderData.workshopLeaderName,
userDisplay: this.saveHeaderData.workshopLeaderName
})
}
const workshopLeaderNames = this.parseWorkshopLeaderNames(this.saveHeaderData.workshopLeaderName)
this.workshopLeaderUserIds.forEach((userId, index) => {
const exist = this.workshopLeaderList.some(item => Number(item.userId) === Number(userId))
if (!exist) {
const userDisplay = workshopLeaderNames[index] || String(userId)
this.workshopLeaderList.push({
userId: userId,
username: userDisplay,
userDisplay: userDisplay
})
}
})
}, },
/** /**

Loading…
Cancel
Save