|
|
|
@ -7,7 +7,7 @@ |
|
|
|
type="primary" |
|
|
|
size="small" |
|
|
|
class="add-btn" |
|
|
|
v-if="!disabled" |
|
|
|
v-if="canEdit" |
|
|
|
@click="openAddDialog"> |
|
|
|
新增物料 |
|
|
|
</el-button> |
|
|
|
@ -15,11 +15,16 @@ |
|
|
|
type="primary" |
|
|
|
size="small" |
|
|
|
class="reset-btn" |
|
|
|
v-if="!disabled" |
|
|
|
v-if="canEdit" |
|
|
|
:disabled="selectedRows.length === 0" |
|
|
|
@click="batchDeleteRawMaterial"> |
|
|
|
批量删除 |
|
|
|
</el-button> |
|
|
|
<span |
|
|
|
v-if="!disabled && !canEdit" |
|
|
|
style="margin-left: 8px; color: #909399; font-size: 12px;"> |
|
|
|
仅试验负责人可维护原材料清单 |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 数据表格 --> |
|
|
|
@ -37,7 +42,7 @@ |
|
|
|
type="selection" |
|
|
|
width="55" |
|
|
|
align="center" |
|
|
|
v-if="!disabled"> |
|
|
|
v-if="canEdit"> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- 序号 --> |
|
|
|
@ -71,6 +76,19 @@ |
|
|
|
show-overflow-tooltip> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- 工序 --> |
|
|
|
<el-table-column |
|
|
|
prop="processStep" |
|
|
|
label="工序" |
|
|
|
min-width="140" |
|
|
|
align="center" |
|
|
|
header-align="center" |
|
|
|
show-overflow-tooltip> |
|
|
|
<template slot-scope="scope"> |
|
|
|
{{ scope.row.processStep || '-' }} |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- 数量 --> |
|
|
|
<el-table-column |
|
|
|
prop="quantity" |
|
|
|
@ -111,7 +129,7 @@ |
|
|
|
width="150" |
|
|
|
align="center" |
|
|
|
header-align="center" |
|
|
|
v-if="!disabled"> |
|
|
|
v-if="canEdit"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-link |
|
|
|
style="cursor:pointer; margin-right: 10px;" |
|
|
|
@ -136,6 +154,23 @@ |
|
|
|
:close-on-click-modal="false"> |
|
|
|
|
|
|
|
<el-form :model="formData" label-width="80px" size="small"> |
|
|
|
<el-form-item label="工序" required> |
|
|
|
<el-select |
|
|
|
v-model="formData.processStep" |
|
|
|
placeholder="请选择工序" |
|
|
|
filterable |
|
|
|
clearable |
|
|
|
:loading="processOptionsLoading" |
|
|
|
style="width: 100%"> |
|
|
|
<el-option |
|
|
|
v-for="item in processOptions" |
|
|
|
:key="item.value" |
|
|
|
:label="item.label" |
|
|
|
:value="item.value"> |
|
|
|
</el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item label="物料编码"> |
|
|
|
<el-input |
|
|
|
v-model="formData.partNo" |
|
|
|
@ -198,6 +233,7 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getRawMaterialList, saveRawMaterial, deleteRawMaterial, batchDeleteRawMaterial, getPartDescByPartNo } from '@/api/erf/erf' |
|
|
|
import { searchStandardRoutingOperationList } from '@/api/part/standardRoutingOperation' |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'ExpRawMaterialList', |
|
|
|
@ -218,6 +254,16 @@ export default { |
|
|
|
type: String, |
|
|
|
default: '' |
|
|
|
}, |
|
|
|
// 试验负责人(显示名) |
|
|
|
projectLeader: { |
|
|
|
type: String, |
|
|
|
default: '' |
|
|
|
}, |
|
|
|
// 试验负责人(用户名) |
|
|
|
projectLeaderName: { |
|
|
|
type: String, |
|
|
|
default: '' |
|
|
|
}, |
|
|
|
// 是否禁用编辑 |
|
|
|
disabled: { |
|
|
|
type: Boolean, |
|
|
|
@ -248,6 +294,7 @@ export default { |
|
|
|
applyNo: '', |
|
|
|
site: '', |
|
|
|
buNo: '', |
|
|
|
processStep: '', |
|
|
|
partNo: '', |
|
|
|
partDesc: '', |
|
|
|
quantity: '', |
|
|
|
@ -256,7 +303,13 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 保存加载状态 |
|
|
|
saveLoading: false |
|
|
|
saveLoading: false, |
|
|
|
|
|
|
|
// 标准工序下拉选项 |
|
|
|
processOptions: [], |
|
|
|
|
|
|
|
// 标准工序加载状态 |
|
|
|
processOptionsLoading: false |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
@ -269,6 +322,44 @@ export default { |
|
|
|
if (newVal) { |
|
|
|
this.loadRawMaterialList() |
|
|
|
} |
|
|
|
}, |
|
|
|
buNo(newVal, oldVal) { |
|
|
|
if (newVal !== oldVal) { |
|
|
|
if (this.canEdit) { |
|
|
|
this.loadProcessOptions() |
|
|
|
} else { |
|
|
|
this.processOptions = [] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
canEdit(newVal) { |
|
|
|
if (newVal) { |
|
|
|
this.loadProcessOptions() |
|
|
|
} else { |
|
|
|
this.processOptions = [] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
/** |
|
|
|
* 是否可编辑原材料清单(仅试验负责人) |
|
|
|
*/ |
|
|
|
canEdit() { |
|
|
|
if (this.disabled) { |
|
|
|
return false |
|
|
|
} |
|
|
|
const currentUserName = (this.$store.state.user.name || '').trim() |
|
|
|
const currentUserDisplay = (this.$store.state.user.userDisplay || '').trim() |
|
|
|
const leaderList = [this.projectLeaderName, this.projectLeader] |
|
|
|
.filter(item => item && item.trim()) |
|
|
|
.map(item => item.trim()) |
|
|
|
|
|
|
|
if (leaderList.length === 0) { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
return leaderList.some(item => item === currentUserName || item === currentUserDisplay) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
@ -297,16 +388,82 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 按BU加载标准工序下拉 |
|
|
|
*/ |
|
|
|
loadProcessOptions() { |
|
|
|
if (!this.buNo) { |
|
|
|
this.processOptions = [] |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.processOptionsLoading = true |
|
|
|
const queryData = { |
|
|
|
userName: this.$store.state.user.name, |
|
|
|
site: this.site || this.$store.state.user.site, |
|
|
|
buNo: this.buNo, |
|
|
|
page: 1, |
|
|
|
limit: 500 |
|
|
|
} |
|
|
|
|
|
|
|
searchStandardRoutingOperationList(queryData).then(({data}) => { |
|
|
|
this.processOptionsLoading = false |
|
|
|
if (data && data.code === 0) { |
|
|
|
const list = (data.page && data.page.list) ? data.page.list : [] |
|
|
|
const optionMap = {} |
|
|
|
list.forEach(item => { |
|
|
|
const processName = item.operationName ? item.operationName.trim() : '' |
|
|
|
if (!processName) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (!optionMap[processName]) { |
|
|
|
const hasOperationNo = item.operationNo !== null && item.operationNo !== undefined && item.operationNo !== '' |
|
|
|
optionMap[processName] = { |
|
|
|
value: processName, |
|
|
|
label: hasOperationNo ? `${item.operationNo} - ${processName}` : processName |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
this.processOptions = Object.values(optionMap) |
|
|
|
} else { |
|
|
|
this.processOptions = [] |
|
|
|
this.$message.error(data.msg || '加载标准工序失败') |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
this.processOptionsLoading = false |
|
|
|
this.processOptions = [] |
|
|
|
this.$message.error('加载标准工序异常') |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 编辑场景兜底:已选工序不在下拉时补充显示 |
|
|
|
*/ |
|
|
|
ensureProcessOption(processStep) { |
|
|
|
if (!processStep) { |
|
|
|
return |
|
|
|
} |
|
|
|
const exists = this.processOptions.some(item => item.value === processStep) |
|
|
|
if (!exists) { |
|
|
|
this.processOptions.push({ |
|
|
|
value: processStep, |
|
|
|
label: processStep |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 打开新增弹窗 |
|
|
|
*/ |
|
|
|
openAddDialog() { |
|
|
|
this.loadProcessOptions() |
|
|
|
this.dialogTitle = '新增物料' |
|
|
|
this.formData = { |
|
|
|
id: null, |
|
|
|
applyNo: this.applyNo, |
|
|
|
site: this.site || this.$store.state.user.site, |
|
|
|
buNo: this.buNo, |
|
|
|
processStep: '', |
|
|
|
partNo: '', |
|
|
|
partDesc: '', |
|
|
|
quantity: '', |
|
|
|
@ -326,12 +483,14 @@ export default { |
|
|
|
applyNo: row.applyNo, |
|
|
|
site: row.site, |
|
|
|
buNo: this.buNo, |
|
|
|
processStep: row.processStep || '', |
|
|
|
partNo: row.partNo, |
|
|
|
partDesc: row.partDesc, |
|
|
|
quantity: row.quantity, |
|
|
|
umid: row.umid || '', |
|
|
|
remark: row.remark |
|
|
|
} |
|
|
|
this.ensureProcessOption(this.formData.processStep) |
|
|
|
this.dialogVisible = true |
|
|
|
}, |
|
|
|
|
|
|
|
@ -345,6 +504,11 @@ export default { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (!this.formData.processStep) { |
|
|
|
this.$message.warning('请选择工序') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const qty = Number(this.formData.quantity) |
|
|
|
if (isNaN(qty) || qty <= 0) { |
|
|
|
this.$message.warning('请输入有效数字(必须大于0)') |
|
|
|
@ -358,6 +522,7 @@ export default { |
|
|
|
id: this.formData.id, |
|
|
|
applyNo: this.formData.applyNo, |
|
|
|
site: this.formData.site, |
|
|
|
processStep: this.formData.processStep, |
|
|
|
partNo: this.formData.partNo || null, |
|
|
|
partDesc: this.formData.partDesc, |
|
|
|
quantity: this.formData.quantity, |
|
|
|
|