@@ -17,45 +18,32 @@
-
-
- {{ scope.row.warehouse }}
-
+
+
+ {{ scope.row.warehouse }}
+
-
-
- {{ scope.row.count }}
-
+
+
+ {{ scope.row.count }}
+
-
-
- {{ scope.row.newPrice }}
-
+
+
+ {{ scope.row.newPrice }}
+
-
-
- {{ scope.row.remark }}
-
+
+
+ {{ scope.row.remark }}
+
@@ -90,7 +78,10 @@ export default {
loading: false,
list: [],
includeColumn: ['count', 'totalPrice'],
- randomKey: Math.random(),
+ // 需要编辑的属性
+ editProp: this.soByType ? ['warehouse', 'count', 'newPrice', 'remark'] : ['count', 'remark'],
+ // 保存进入编辑的cell
+ clickCellMap: {}
}
},
watch: {
@@ -107,7 +98,6 @@ export default {
this.list.push(newData)
}else {
this.list = []
- this.refreshTable()
}
},
list: {
@@ -146,27 +136,93 @@ export default {
});
return sums
},
- editData(row, column) {
- row[column.property + "isShow"] = true
- //refreshTable是table数据改动时,刷新table的
- this.refreshTable()
- // this.$nextTick(() => {
- // this.$refs[column.property] && this.$refs[column.property].focus()
- // })
+ /** 鼠标移入cell */
+ handleCellEnter(row, column, cell, event) {
+ const property = column.property
+ if (this.editProp.includes(property)) {
+ cell.querySelector('.item__txt').classList.add('item__txt--hover')
+ }
},
- alterData(row, column) {
- row[column.property + "isShow"] = false
- const data = this.list.find(item => item.id === row.id)
- data.totalPrice = data.newPrice * data.count
- this.refreshTable()
+ /** 鼠标移出cell */
+ handleCellLeave(row, column, cell, event) {
+ const property = column.property
+ if (this.editProp.includes(property)) {
+ cell.querySelector('.item__txt').classList.remove('item__txt--hover')
+ }
},
- refreshTable() {
- this.randomKey = Math.random()
+ /** 点击cell */
+ handleCellClick(row, column, cell, event) {
+ const property = column.property
+ if (this.editProp.includes(property)) {
+ // 保存cell
+ this.saveCellClick(row, cell)
+ cell.querySelector('.item__txt').style.display = 'none'
+ cell.querySelector('.item__input').style.display = 'inline'
+ cell.querySelector('input').focus()
+ }
},
+ /** 取消编辑状态 */
+ cancelEditable(cell) {
+ cell.querySelector('.item__txt').style.display = 'inline'
+ cell.querySelector('.item__input').style.display = 'none'
+ },
+ /** 保存进入编辑的cell */
+ saveCellClick(row, cell) {
+ const id = row.id
+ if (this.clickCellMap[id] !== undefined) {
+ if (!this.clickCellMap[id].includes(cell)) {
+ this.clickCellMap[id].push(cell)
+ }
+ } else {
+ this.clickCellMap[id] = [cell]
+ }
+ },
+ /** 保存数据 */
+ save (row) {
+ // 更新表格的数据
+ row.totalPrice = row.count * row.newPrice
+ const id = row.id
+ // 取消本行所有cell的编辑状态
+ this.clickCellMap[id].forEach(cell => {
+ this.cancelEditable(cell)
+ })
+ this.clickCellMap[id] = []
+ }
}
}
diff --git a/src/views/repair/stockOperate/Components/SoVoid.vue b/src/views/repair/stockOperate/Components/SoVoid.vue
index ee577c7..d7d02cd 100644
--- a/src/views/repair/stockOperate/Components/SoVoid.vue
+++ b/src/views/repair/stockOperate/Components/SoVoid.vue
@@ -13,16 +13,16 @@