UNPKG

dt-crud-x

Version:

基于d2-crud-x的自定义版本

62 lines (60 loc) 1.41 kB
export default { methods: { /** * @description 外部暴露的更新单元格数据方法 */ updateCell (rowIndex, key, value) { this.$set(this.d2CrudData, rowIndex, { ...this.d2CrudData[rowIndex], [key]: value }) }, /** * @description 外部暴露的新增行方法 */ addRow (row) { this.handleAddRow(row) }, /** * @description 外部暴露的编辑行方法 */ updateRow (index, row) { this.handleUpdateRow(index, row) }, /** * @description 外部暴露的删除行方法 */ removeRow (index) { this.handleRemoveRow(index) }, /** * @description 外部暴露的打开模态框方法 */ showDialog ({ mode, rowIndex = 0, template = null, addData = null }) { if (mode === 'edit') { this.handleEdit(rowIndex, {row: this.d2CrudData[rowIndex]}, template) } else if (mode === 'add') { this.handleAdd(template, addData) } else if (mode === 'view') { this.handleView(rowIndex, {row: this.d2CrudData[rowIndex]}, template) } }, /** * @description 外部暴露的关闭模态框方法 */ closeDialog () { this.handleCloseDialog() }, /** * 获取当前表格数据 */ getTableData () { return this.$refs.d2Crud.d2CrudData } } }