Browse Source

双击编辑

java8
han\hanst 4 months ago
parent
commit
78eac2f242
  1. 6
      src/views/modules/inquiry/inquiryTechnicalMaterialsNoBuilt.vue
  2. 207
      src/views/modules/part/quicklyCreateBom.vue

6
src/views/modules/inquiry/inquiryTechnicalMaterialsNoBuilt.vue

@ -412,7 +412,7 @@
<div class="rq ">
<el-table
@header-dragend="handleColumnResize"
:height="height - 78"
:height="localHeight - 78"
:data="inquiryPartItemDataList"
border
style="width: 100%;margin-top: 5px">
@ -562,6 +562,8 @@ export default {
},
data() {
return {
// heightpropprop
localHeight: this.height || 200,
userBuList: [],
copyPriceCheckDetail:{},
loading:false,
@ -1555,7 +1557,7 @@ export default {
mounted() {
this.$nextTick(() => {
/*第二个表格高度的动态调整*/
this.height = window.innerHeight - 210;
this.localHeight = window.innerHeight - 210;
})
EventBus.$on('refreshInquiryOneDetail2', () => {
this.refreshCurrentTabTable();

207
src/views/modules/part/quicklyCreateBom.vue

@ -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;

Loading…
Cancel
Save