|
|
|
@ -16,15 +16,12 @@ |
|
|
|
<el-form-item label=" "> |
|
|
|
<el-button type="info" @click="updatePartModal">维护</el-button> |
|
|
|
</el-form-item> |
|
|
|
<!-- <el-form-item label=" ">--> |
|
|
|
<!-- <el-button type="info" @click="updateInquiryDetailStatus()">完成</el-button>--> |
|
|
|
<!-- </el-form-item>--> |
|
|
|
<el-form-item label=" "> |
|
|
|
<el-button type="primary" @click="handleBatchUpdatePart">物料属性批量维护</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-table |
|
|
|
:height="54" |
|
|
|
:height="60" |
|
|
|
:data="dataList" |
|
|
|
border |
|
|
|
v-loading="this.dataListLoading" |
|
|
|
@ -39,11 +36,20 @@ |
|
|
|
:fixed="item.fixed === ''?false:item.fixed" |
|
|
|
:min-width="item.columnWidth" |
|
|
|
:label="item.columnLabel"> |
|
|
|
<template slot="header" slot-scope="scope"> |
|
|
|
<a href="javascript:void(0)" @click="openColumnModal(item.columnLabel,item.columnProp)" style="cursor:pointer;color: white">{{ item.columnLabel }}</a> |
|
|
|
</template> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span> |
|
|
|
<div v-if="!item.columnHidden" @dblclick="startEditCell(scope.$index, item.columnProp, scope.row[item.columnProp])" style="min-height: 23px; cursor: pointer;" :title="editingCell.rowIndex === scope.$index && editingCell.columnProp === item.columnProp ? '' : '双击可编辑'"> |
|
|
|
<el-input |
|
|
|
v-if="editingCell.rowIndex === scope.$index && editingCell.columnProp === item.columnProp" |
|
|
|
v-model="editingCell.value" |
|
|
|
size="small" |
|
|
|
ref="editInput" |
|
|
|
:disabled="editingCell.isSaving" |
|
|
|
@keyup.enter.native="saveEditCell(scope.$index, item.columnProp, item.columnLabel)" |
|
|
|
@keyup.esc.native="cancelEditCell" |
|
|
|
style="width: 100%;"> |
|
|
|
</el-input> |
|
|
|
<span v-else>{{ scope.row[item.columnProp] || '-' }}</span> |
|
|
|
</div> |
|
|
|
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
@ -1821,6 +1827,12 @@ export default { |
|
|
|
] |
|
|
|
}, |
|
|
|
dataList: [{}], |
|
|
|
editingCell: { |
|
|
|
rowIndex: -1, |
|
|
|
columnProp: null, |
|
|
|
value: '', |
|
|
|
isSaving: false |
|
|
|
}, |
|
|
|
currentNode: {}, |
|
|
|
partCurrentRow: {}, |
|
|
|
bomCurrentRow: {}, |
|
|
|
@ -5343,6 +5355,171 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 双击单元格开始编辑 |
|
|
|
startEditCell(rowIndex, columnProp, value) { |
|
|
|
this.editingCell.rowIndex = rowIndex |
|
|
|
this.editingCell.columnProp = columnProp |
|
|
|
this.editingCell.value = value || '' |
|
|
|
|
|
|
|
// 下一帧聚焦输入框 |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.editInput && this.$refs.editInput[0]) { |
|
|
|
this.$refs.editInput[0].focus() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 保存单元格编辑 |
|
|
|
async saveEditCell(rowIndex, columnProp, columnLabel) { |
|
|
|
// 防止重复保存 |
|
|
|
if (this.editingCell.isSaving) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const newValue = this.editingCell.value |
|
|
|
const oldValue = this.dataList[rowIndex][columnProp] |
|
|
|
|
|
|
|
// 值未改变,直接取消编辑 |
|
|
|
if (newValue === oldValue) { |
|
|
|
this.cancelEditCell() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.editingCell.isSaving = true |
|
|
|
|
|
|
|
// 显示loading |
|
|
|
const loading = this.$loading({ |
|
|
|
lock: true, |
|
|
|
text: '保存中...', |
|
|
|
spinner: 'el-icon-loading', |
|
|
|
background: 'rgba(0, 0, 0, 0.5)' |
|
|
|
}) |
|
|
|
|
|
|
|
try { |
|
|
|
// 更新本地显示 |
|
|
|
this.$set(this.dataList[rowIndex], columnProp, newValue) |
|
|
|
|
|
|
|
// 先获取当前属性的完整信息 |
|
|
|
let itemTemplate = null |
|
|
|
await getPartItem({ |
|
|
|
site: this.$store.state.user.site, |
|
|
|
buNo: this.searchData.buNo, |
|
|
|
partNo: this.searchData.partNo, |
|
|
|
codeNo: this.searchData.codeNo, |
|
|
|
recordType: 'IP' |
|
|
|
}).then(({data}) => { |
|
|
|
if (data && data.code === 0 && data.rows) { |
|
|
|
itemTemplate = data.rows.find(item => item.itemDesc === columnLabel) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
if (!itemTemplate) { |
|
|
|
loading.close() |
|
|
|
this.$message.error('未找到属性配置') |
|
|
|
this.$set(this.dataList[rowIndex], columnProp, oldValue) |
|
|
|
this.editingCell.isSaving = false |
|
|
|
this.cancelEditCell() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 根据属性类型更新对应的值 |
|
|
|
if (itemTemplate.valueTypeDb === 'N') { |
|
|
|
// 数值类型 |
|
|
|
const parsedValue = parseFloat(newValue) |
|
|
|
if (newValue !== '' && isNaN(parsedValue)) { |
|
|
|
loading.close() |
|
|
|
this.$message.error('请输入有效的数值') |
|
|
|
this.$set(this.dataList[rowIndex], columnProp, oldValue) |
|
|
|
this.editingCell.isSaving = false |
|
|
|
this.cancelEditCell() |
|
|
|
return |
|
|
|
} |
|
|
|
itemTemplate.numValue = newValue === '' ? null : parsedValue |
|
|
|
itemTemplate.textValue = '' |
|
|
|
} else { |
|
|
|
// 文本类型 |
|
|
|
itemTemplate.textValue = newValue || '' |
|
|
|
itemTemplate.numValue = null |
|
|
|
} |
|
|
|
|
|
|
|
// 准备保存到后端 |
|
|
|
let tempData = { |
|
|
|
site: this.$store.state.user.site, |
|
|
|
buNo: this.searchData.buNo, |
|
|
|
partNo: this.searchData.partNo, |
|
|
|
codeNo: this.searchData.codeNo |
|
|
|
} |
|
|
|
|
|
|
|
// 获取所有物料 |
|
|
|
await partInfoByMainPart(tempData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.$set(this, 'partList1', data.rows) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// 构建保存数据 |
|
|
|
let list = [] |
|
|
|
let partList = this.partList1.filter(item => item.buNo === this.searchData.buNo) |
|
|
|
|
|
|
|
for (let i = 0; i < partList.length; i++) { |
|
|
|
if (partList[i].partNo && partList[i].partNo !== '' && partList[i].buNo) { |
|
|
|
// 克隆item对象并更新部分字段 |
|
|
|
let itemCopy = JSON.parse(JSON.stringify(itemTemplate)) |
|
|
|
itemCopy.site = partList[i].site |
|
|
|
itemCopy.buNo = partList[i].buNo |
|
|
|
itemCopy.partNo = partList[i].partNo |
|
|
|
itemCopy.codeNo = partList[i].codeNo |
|
|
|
itemCopy.recordType = 'IP' |
|
|
|
|
|
|
|
list.push({ |
|
|
|
site: partList[i].site, |
|
|
|
buNo: partList[i].buNo, |
|
|
|
partNo: partList[i].partNo, |
|
|
|
codeNo: partList[i].codeNo, |
|
|
|
recordType: 'IP', |
|
|
|
itemList: [itemCopy] |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 调用保存接口 |
|
|
|
commitItemsValue(list).then(({data}) => { |
|
|
|
loading.close() |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.$message.success('保存成功') |
|
|
|
this.editingCell.isSaving = false |
|
|
|
this.cancelEditCell() |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '保存失败') |
|
|
|
this.$set(this.dataList[rowIndex], columnProp, oldValue) |
|
|
|
this.editingCell.isSaving = false |
|
|
|
this.cancelEditCell() |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
loading.close() |
|
|
|
this.$message.error('保存异常') |
|
|
|
this.$set(this.dataList[rowIndex], columnProp, oldValue) |
|
|
|
this.editingCell.isSaving = false |
|
|
|
this.cancelEditCell() |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
loading.close() |
|
|
|
this.$message.error('操作失败') |
|
|
|
this.$set(this.dataList[rowIndex], columnProp, oldValue) |
|
|
|
this.editingCell.isSaving = false |
|
|
|
this.cancelEditCell() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 取消单元格编辑 |
|
|
|
cancelEditCell() { |
|
|
|
this.editingCell.rowIndex = -1 |
|
|
|
this.editingCell.columnProp = null |
|
|
|
this.editingCell.value = '' |
|
|
|
this.editingCell.isSaving = false |
|
|
|
}, |
|
|
|
|
|
|
|
openColumnModal(desc, prop) { |
|
|
|
this.partItemList1 = [] |
|
|
|
this.itemProp = prop |
|
|
|
@ -5856,6 +6033,20 @@ export default { |
|
|
|
width: 100%; |
|
|
|
min-width: 320px; |
|
|
|
} |
|
|
|
// 单元格编辑样式 |
|
|
|
::v-deep .el-table__body-wrapper { |
|
|
|
.el-table__row { |
|
|
|
.cell { |
|
|
|
div[style*="cursor: pointer"] { |
|
|
|
&:hover { |
|
|
|
background-color: #f5f7fa; |
|
|
|
border-radius: 2px; |
|
|
|
transition: background-color 0.2s; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.structure-tree { |
|
|
|
.el-scrollbar .el-scrollbar__wrap { |
|
|
|
overflow-x: hidden; |
|
|
|
|