Skip to content

Commit

Permalink
fix兼容datetype和增加on-load回调
Browse files Browse the repository at this point in the history
  • Loading branch information
栾华亮 committed Sep 22, 2020
1 parent 8c1a54d commit a934e0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/components/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ export default {
} = this.focusCell
this.show = true;
this.dataType = dataType;
if (![...SIMPLE_DATE_TYPES, ...COMPLEX_DATE_TYPES].includes(dataType)) {
this.dataType = 'text';
}
this.selectOptions = options;
this.$refs.text.innerHTML = value;
this.grid.setTempData(value)
Expand Down Expand Up @@ -413,6 +416,9 @@ export default {
},
afterClear: (data) => {
self.$emit('after-clear', data)
},
onLoad: () => {
self.$emit('on-load')
}
});
});
Expand Down
1 change: 1 addition & 0 deletions src/core/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Body {
this.height = this.rows.reduce((sum, item) => {
return sum + item.height;
}, this.grid.tableHeaderHeight);
data.length > 0 && this.grid.onLoad()
}
/**
* CTRL+V 粘贴
Expand Down
10 changes: 5 additions & 5 deletions src/core/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ class Cell extends Context {
this.valid = flag;
this.message = message;
}
/**
* @param {String|Number} val 需要设置的值
* @param {Boolean} ignore 是否忽略readonly属性可以修改
*/
handleNumber(val) {
if (!isNaN(Number(val))) {
if (val && !isNaN(Number(val))) {
return Number(val)
} else {
return val
}
}
/**
* @param {String|Number} val 需要设置的值
* @param {Boolean} ignore 是否忽略readonly属性可以修改
*/
setData(val, ignore) {
if (!ignore && this.readonly) return;
let v = val
Expand Down
3 changes: 2 additions & 1 deletion src/core/DataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class DataGrid {
afterCopy: () => {},
beforePaste: () => {}, // 粘贴
afterPaste: () => {},
afterClear: () => {} // 清空数据
afterClear: () => {}, // 清空数据
onLoad: () => {} // 表格加载完成
},
options
);
Expand Down

0 comments on commit a934e0b

Please sign in to comment.