Browse Source

QC生产车间负责人

master
han\hanst 2 weeks ago
parent
commit
a3fb713864
  1. 2
      src/api/erf/erf.js
  2. 190
      src/views/modules/erf/components/expApplyForm.vue
  3. 3
      src/views/modules/erf/expApplyList.vue

2
src/api/erf/erf.js

@ -21,7 +21,7 @@ export const getExpApplyDetail = data => createAPI(`/erf/expApply/getExpApplyDet
export const saveExpApply = data => createAPI(`/erf/expApply/saveExpApply`, 'post', data) export const saveExpApply = data => createAPI(`/erf/expApply/saveExpApply`, 'post', data)
/** /**
* 获取负责人列表PJM负责人 + 生产车间负责人
* 获取负责人列表PJM负责人 + 生产车间负责人 + QC车间负责人
*/ */
export const getPjmLeaderList = data => createAPI(`/erf/expApply/getPjmLeaderList`, 'post', data) export const getPjmLeaderList = data => createAPI(`/erf/expApply/getPjmLeaderList`, 'post', data)

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

@ -105,8 +105,8 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24">
<el-form-item label="生产车间负责人">
<el-col :span="12">
<el-form-item label="生产车间负责人" prop="workshopLeaderUserId">
<el-select <el-select
v-model="workshopLeaderUserIds" v-model="workshopLeaderUserIds"
:disabled="readonly" :disabled="readonly"
@ -114,7 +114,7 @@
collapse-tags-tooltip collapse-tags-tooltip
clearable clearable
filterable filterable
placeholder="可多选,非必填"
placeholder="可多选,请至少选择1人"
style="width: 100%" style="width: 100%"
@change="handleWorkshopLeaderChange"> @change="handleWorkshopLeaderChange">
<el-option <el-option
@ -126,6 +126,27 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="QC车间负责人">
<el-select
v-model="qcWorkshopLeaderUserIds"
:disabled="readonly"
multiple
collapse-tags-tooltip
clearable
filterable
placeholder="可多选,非必填"
style="width: 100%"
@change="handleQcWorkshopLeaderChange">
<el-option
v-for="item in qcWorkshopLeaderList"
:key="item.userId"
:label="item.userDisplay || item.username"
:value="item.userId">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="试验目的" prop="purpose"> <el-form-item label="试验目的" prop="purpose">
@ -214,45 +235,6 @@
</el-row>--> </el-row>-->
<!-- 只读模式下显示的附加信息 --> <!-- 只读模式下显示的附加信息 -->
<template v-if="readonly && saveHeaderData.applyNo">
<el-divider content-position="left">试验单信息</el-divider>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="试验单号">
<span>{{ saveHeaderData.applyNo }}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="状态">
<el-tag :type="getStatusType(saveHeaderData.status)">
{{ getStatusText(saveHeaderData.status) }}
</el-tag>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="申请人">
<span>{{ saveHeaderData.creatorName }}</span>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="创建时间">
<span>{{ saveHeaderData.createTime }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="更新时间">
<span>{{ saveHeaderData.updateTime }}</span>
</el-form-item>
</el-col>
</el-row>
</template>
</el-form> </el-form>
<!-- 用户选择弹窗 --> <!-- 用户选择弹窗 -->
@ -286,6 +268,7 @@ export default {
buList: [], buList: [],
pjmLeaderList: [], pjmLeaderList: [],
workshopLeaderList: [], workshopLeaderList: [],
qcWorkshopLeaderList: [],
saveHeaderData: { saveHeaderData: {
applyNo: '', applyNo: '',
originalApplyNo: '', originalApplyNo: '',
@ -305,12 +288,15 @@ export default {
pjmLeaderName: '', pjmLeaderName: '',
workshopLeaderUserId: '', workshopLeaderUserId: '',
workshopLeaderName: '', workshopLeaderName: '',
qcWorkshopLeaderUserId: '',
qcWorkshopLeaderName: '',
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: [], workshopLeaderUserIds: [],
qcWorkshopLeaderUserIds: [],
formRules: { formRules: {
applyNo: [ applyNo: [
@ -330,6 +316,9 @@ export default {
], ],
expectedFinishDate: [ expectedFinishDate: [
{ required: true, message: '请选择期望完成日期', trigger: 'change' } { required: true, message: '请选择期望完成日期', trigger: 'change' }
],
workshopLeaderUserId: [
{ required: true, message: '请选择生产车间负责人', trigger: 'change' }
] ]
}, },
@ -345,7 +334,10 @@ export default {
this.saveHeaderData.pjmLeaderName = '' this.saveHeaderData.pjmLeaderName = ''
this.saveHeaderData.workshopLeaderUserId = '' this.saveHeaderData.workshopLeaderUserId = ''
this.saveHeaderData.workshopLeaderName = '' this.saveHeaderData.workshopLeaderName = ''
this.saveHeaderData.qcWorkshopLeaderUserId = ''
this.saveHeaderData.qcWorkshopLeaderName = ''
this.workshopLeaderUserIds = [] this.workshopLeaderUserIds = []
this.qcWorkshopLeaderUserIds = []
// BU退 // BU退
this.loadPjmLeaderList('') this.loadPjmLeaderList('')
return return
@ -356,7 +348,10 @@ export default {
this.saveHeaderData.pjmLeaderName = '' this.saveHeaderData.pjmLeaderName = ''
this.saveHeaderData.workshopLeaderUserId = '' this.saveHeaderData.workshopLeaderUserId = ''
this.saveHeaderData.workshopLeaderName = '' this.saveHeaderData.workshopLeaderName = ''
this.saveHeaderData.qcWorkshopLeaderUserId = ''
this.saveHeaderData.qcWorkshopLeaderName = ''
this.workshopLeaderUserIds = [] this.workshopLeaderUserIds = []
this.qcWorkshopLeaderUserIds = []
} }
this.loadPjmLeaderList(newVal) this.loadPjmLeaderList(newVal)
} }
@ -396,29 +391,36 @@ export default {
}, },
/** /**
* 加载负责人列表PJM负责人 + 生产车间负责人
* 加载负责人列表PJM负责人 + 生产车间负责人 + QC车间负责人
*/ */
loadPjmLeaderList(buNo) { loadPjmLeaderList(buNo) {
getPjmLeaderList({ buNo: buNo || '' }).then(({data}) => { getPjmLeaderList({ buNo: buNo || '' }).then(({data}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.pjmLeaderList = data.pjmLeaderList || data.list || [] this.pjmLeaderList = data.pjmLeaderList || data.list || []
this.workshopLeaderList = data.workshopLeaderList || [] this.workshopLeaderList = data.workshopLeaderList || []
this.qcWorkshopLeaderList = data.qcWorkshopLeaderList || []
this.ensurePjmLeaderOption() this.ensurePjmLeaderOption()
this.ensureWorkshopLeaderOption() this.ensureWorkshopLeaderOption()
this.ensureQcWorkshopLeaderOption()
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.workshopLeaderUserIds.length > 0) { if (this.workshopLeaderUserIds.length > 0) {
this.handleWorkshopLeaderChange(this.workshopLeaderUserIds) this.handleWorkshopLeaderChange(this.workshopLeaderUserIds)
} }
if (this.qcWorkshopLeaderUserIds.length > 0) {
this.handleQcWorkshopLeaderChange(this.qcWorkshopLeaderUserIds)
}
} else { } else {
this.pjmLeaderList = [] this.pjmLeaderList = []
this.workshopLeaderList = [] this.workshopLeaderList = []
this.qcWorkshopLeaderList = []
this.$message.error(data.msg || '加载负责人失败') this.$message.error(data.msg || '加载负责人失败')
} }
}).catch(() => { }).catch(() => {
this.pjmLeaderList = [] this.pjmLeaderList = []
this.workshopLeaderList = [] this.workshopLeaderList = []
this.qcWorkshopLeaderList = []
this.$message.error('加载负责人异常') this.$message.error('加载负责人异常')
}) })
}, },
@ -476,6 +478,13 @@ export default {
this.saveHeaderData.workshopLeaderName = this.parseWorkshopLeaderNames( this.saveHeaderData.workshopLeaderName = this.parseWorkshopLeaderNames(
this.saveHeaderData.workshopLeaderName this.saveHeaderData.workshopLeaderName
).join(',') ).join(',')
this.qcWorkshopLeaderUserIds = this.parseQcWorkshopLeaderUserIds(this.saveHeaderData.qcWorkshopLeaderUserId)
this.saveHeaderData.qcWorkshopLeaderUserId = this.qcWorkshopLeaderUserIds.length > 0
? this.qcWorkshopLeaderUserIds.join(',')
: ''
this.saveHeaderData.qcWorkshopLeaderName = this.parseQcWorkshopLeaderNames(
this.saveHeaderData.qcWorkshopLeaderName
).join(',')
}, },
/** /**
@ -498,18 +507,84 @@ export default {
if (workshopLeaderIds.length === 0) { if (workshopLeaderIds.length === 0) {
this.saveHeaderData.workshopLeaderName = '' this.saveHeaderData.workshopLeaderName = ''
} else {
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(',')
}
this.$nextTick(() => {
if (this.$refs.applyForm) {
this.$refs.applyForm.validateField('workshopLeaderUserId')
}
})
},
/**
* 解析QC车间负责人ID列表
*/
parseQcWorkshopLeaderUserIds(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
},
/**
* 解析QC车间负责人姓名列表
*/
parseQcWorkshopLeaderNames(value) {
if (!value) {
return []
}
return String(value).split(',').map(item => item.trim()).filter(item => !!item)
},
/**
* 处理QC车间负责人变更
*/
handleQcWorkshopLeaderChange(userIds) {
const oldQcWorkshopLeaderIds = this.parseQcWorkshopLeaderUserIds(this.saveHeaderData.qcWorkshopLeaderUserId)
const oldQcWorkshopLeaderNames = this.parseQcWorkshopLeaderNames(this.saveHeaderData.qcWorkshopLeaderName)
const oldQcWorkshopLeaderNameMap = {}
oldQcWorkshopLeaderIds.forEach((id, index) => {
const oldName = oldQcWorkshopLeaderNames[index]
if (oldName) {
oldQcWorkshopLeaderNameMap[id] = oldName
}
})
const qcWorkshopLeaderIds = this.parseQcWorkshopLeaderUserIds(userIds)
this.qcWorkshopLeaderUserIds = qcWorkshopLeaderIds
this.saveHeaderData.qcWorkshopLeaderUserId = qcWorkshopLeaderIds.length > 0 ? qcWorkshopLeaderIds.join(',') : ''
if (qcWorkshopLeaderIds.length === 0) {
this.saveHeaderData.qcWorkshopLeaderName = ''
return return
} }
const workshopLeaderNameList = workshopLeaderIds.map(userId => {
const selected = this.workshopLeaderList.find(item => Number(item.userId) === Number(userId))
const qcWorkshopLeaderNameList = qcWorkshopLeaderIds.map(userId => {
const selected = this.qcWorkshopLeaderList.find(item => Number(item.userId) === Number(userId))
if (selected) { if (selected) {
return selected.userDisplay || selected.username || '' return selected.userDisplay || selected.username || ''
} }
return oldWorkshopLeaderNameMap[userId] || ''
return oldQcWorkshopLeaderNameMap[userId] || ''
}).filter(name => !!name) }).filter(name => !!name)
this.saveHeaderData.workshopLeaderName = workshopLeaderNameList.join(',')
this.saveHeaderData.qcWorkshopLeaderName = qcWorkshopLeaderNameList.join(',')
}, },
/** /**
@ -550,6 +625,27 @@ export default {
}) })
}, },
/**
* 编辑场景兜底已选QC车间负责人不在当前下拉项时补充显示
*/
ensureQcWorkshopLeaderOption() {
if (!this.qcWorkshopLeaderUserIds || this.qcWorkshopLeaderUserIds.length === 0) {
return
}
const qcWorkshopLeaderNames = this.parseQcWorkshopLeaderNames(this.saveHeaderData.qcWorkshopLeaderName)
this.qcWorkshopLeaderUserIds.forEach((userId, index) => {
const exist = this.qcWorkshopLeaderList.some(item => Number(item.userId) === Number(userId))
if (!exist) {
const userDisplay = qcWorkshopLeaderNames[index] || String(userId)
this.qcWorkshopLeaderList.push({
userId: userId,
username: userDisplay,
userDisplay: userDisplay
})
}
})
},
/** /**
* 获取表单数据用于验证 * 获取表单数据用于验证
*/ */

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

@ -135,10 +135,11 @@
<el-table-column <el-table-column
label="操作" label="操作"
width="110"
width="120"
align="center" align="center"
header-align="center"> header-align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<a @click="viewDetail(scope.row)">详情</a>
<a v-if="scope.row.status === '草稿' || scope.row.status === '已驳回'" @click="editApply(scope.row)">修改</a> <a v-if="scope.row.status === '草稿' || scope.row.status === '已驳回'" @click="editApply(scope.row)">修改</a>
<a v-if="scope.row.status === '草稿' || scope.row.status === '已驳回'" @click="submitApply(scope.row)">{{ scope.row.status === '已驳回' ? '重新下达' : '下达' }}</a> <a v-if="scope.row.status === '草稿' || scope.row.status === '已驳回'" @click="submitApply(scope.row)">{{ scope.row.status === '已驳回' ? '重新下达' : '下达' }}</a>
<a v-if="showSampleConfirmBtn(scope.row)" @click="openSampleConfirm(scope.row)">样品确认</a> <a v-if="showSampleConfirmBtn(scope.row)" @click="openSampleConfirm(scope.row)">样品确认</a>

Loading…
Cancel
Save