|
65 | 65 | this.$emit('update:table-data', this.copyData); |
66 | 66 | // 暴露编辑完成事件,将修改的信息传回 |
67 | 67 | this.$emit('edit-ok', { row, column, index, newValue }); |
| 68 | + this.$message.success('保存成功'); |
68 | 69 | }, |
69 | 70 | onBlur ({ row, column, index }) { |
70 | 71 | this.copyData[index][column.prop] = row[column.prop]; |
|
77 | 78 | const render = (h, { row, column, index }) => { |
78 | 79 | const isEditing = this.editIds.includes(`${column.prop}_${index}`); |
79 | 80 | return ( |
80 | | - <div class="edit-col"> |
81 | | - { |
82 | | - (isEditing || trigger === 'blur') |
83 | | - ? |
84 | | - <col.editable.widget |
85 | | - vModel={row[column.prop]} |
86 | | - on-input={this.onInput.bind(this, { row, column, index })} |
87 | | - on-blur={ |
88 | | - trigger === 'blur' ? this.onBlur.bind(this, { row, column, index }) : () => {} |
89 | | - } |
90 | | - {...{ attrs: rest }} |
| 81 | + <el-row type="flex" align="middle" gutter={16} class="edit-col"> |
| 82 | + <el-col span={14}> |
| 83 | + { |
| 84 | + (isEditing || trigger === 'blur') |
| 85 | + ? |
| 86 | + <col.editable.widget |
| 87 | + vModel={row[column.prop]} |
| 88 | + on-input={this.onInput.bind(this, { row, column, index })} |
| 89 | + on-blur={ |
| 90 | + trigger === 'blur' ? this.onBlur.bind(this, { row, column, index }) : () => {} |
| 91 | + } |
| 92 | + {...{ attrs: rest }} |
| 93 | + > |
| 94 | + </col.editable.widget> |
| 95 | + : |
| 96 | + <span>{row[column.prop]}</span> |
| 97 | + } |
| 98 | + </el-col> |
| 99 | + <el-col span={8}> |
| 100 | + { |
| 101 | + trigger !== 'blur' && |
| 102 | + <el-button |
| 103 | + size="small" |
| 104 | + on-click={this.onClick.bind(this, { row, column, index })} |
| 105 | + className="edit-button" |
91 | 106 | > |
92 | | - </col.editable.widget> |
93 | | - : |
94 | | - <span>{row[column.prop]}</span> |
95 | | - } |
96 | | - { |
97 | | - trigger !== 'blur' && |
98 | | - <el-button |
99 | | - on-click={this.onClick.bind(this, { row, column, index })} |
100 | | - className="edit-button" |
101 | | - > |
102 | | - {isEditing ? '保存' : '编辑'} |
103 | | - </el-button> |
104 | | - } |
105 | | - </div> |
| 107 | + {isEditing ? '保存' : '编辑'} |
| 108 | + </el-button> |
| 109 | + } |
| 110 | + </el-col> |
| 111 | + </el-row> |
106 | 112 | ); |
107 | 113 | }; |
108 | 114 | return { ...col, render }; |
|
118 | 124 | <style lang="scss" scoped> |
119 | 125 | .edit-table { |
120 | 126 | /deep/ .edit-col { |
121 | | - display: flex; |
122 | | - justify-content: space-between; |
123 | | - align-items: center; |
| 127 | + .el-input__inner { |
| 128 | + height: 32px; |
| 129 | + line-height: 32px; |
| 130 | + } |
| 131 | + .el-input-number .el-input__inner { |
| 132 | + text-align: left; |
| 133 | + } |
| 134 | + .el-input-number { |
| 135 | + width: 100%; |
| 136 | + line-height: 32px; |
| 137 | + } |
124 | 138 | } |
125 | 139 | } |
126 | 140 | </style> |
0 commit comments