【V12】通过celltype页面弹框时,cell没有失去焦点,还会重复激活输入事件。
自定义的celltype,继承了new GC.Spread.Sheets.CellTypes.Text(),通过activateEditor事件,进行了一个弹框业务处理,但是弹框出来后,键盘输入时,仍然激活的时spread的cell输入事件,输入的东西不能正常的输入到弹框页面中。
- import GC from '@grapecity/spread-sheets'
- let CZElementCellTypeV12 = function CZElementCellTypeV12(columnTag, csList, showStyle, _parent, sourceElementEditOff, setTableData) {
- this.ColumnInfo = columnTag
- this.CSList = csList
- this.ShowStyle = showStyle
- this._parent = _parent
- this.sourceElementEditOff = sourceElementEditOff
- this.setTableData = setTableData
- }
- CZElementCellTypeV12.prototype = new GC.Spread.Sheets.CellTypes.Text() // new GcSpread.Sheets.TextCellType()
- CZElementCellTypeV12.prototype.deactivateEditor = function (editorContext, context) {
- // alert("deactivateEditor4");
- }
- CZElementCellTypeV12.prototype.getEditorValue = function (editorContext, cellStyle, cellRect, context) {
- // alert("getEditorValue3");
- }
- CZElementCellTypeV12.prototype.setEditorValue = function (editorContext, cellStyle, cellRect, context) {
- // alert("setEditorValue1");
- }
- CZElementCellTypeV12.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
- // alert("updateEditor2");
- }
- CZElementCellTypeV12.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
- let row = context.row
- let col = context.col
- let gridhelper = new GridHelperV12(this._parent.spread)
- let oldValue = gridhelper.GetCellValue(row, col)
- let that = this
- // this._parent.spread.getActiveSheet().startEdit(false);
- this._parent.$faspDialog({
- config: {
- width: '500px',
- title: '请选择<' + that.ColumnInfo.columnName + '>',
- center: false
- },
- vmcolumnId: that.ColumnInfo.vmColumnID,
- VoucherId: that.ColumnInfo.voucherID,
- RuleId: that._parent.RuleId,
- BusiDate: that._parent.BusiDate,
- isMultiple: false,
- sourceElement: that.ColumnInfo.sourceElement,
- funcTableData: that.setTableData,
- cickHoder: that._parent,
- cameBackData: function (data) {
- if (data != null && data !== '' && data !== 'undefined') {
- let checkMode = JSON.parse(data)
- gridhelper.SetCellValue(row, col, checkMode[0].id)
- } else {
- gridhelper.SetCellValue(row, col, null)
- }
- let newValue = gridhelper.GetCellValue(row, col)
- // that.sourceElementEditOff(that._parent, context, oldValue, newValue)
- }
- })
- }
- CZElementCellTypeV12.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
- try {
- if (value) {
- if (value == '0') {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options]);
- return
- }
- let findvalue = this.CSList.find(t => t.key == value)
- if (findvalue != null && findvalue !== 'undefined') {
- // console.log(findvalue);
- if (this.ShowStyle === 1) {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, findvalue.itemCode, x, y, w, h, style, options])
- } else if (this.ShowStyle == 2) {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, findvalue.itemName, x, y, w, h, style, options])
- } else {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, '[' + findvalue.itemCode + ']' + findvalue.itemName, x, y, w, h, style, options])
- }
- } else {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options])
- // console.log('undefined');
- }
- } else {
- if (value == '0') {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options])
- } else {
- GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options])
- }
- }
- } catch (e) {
- console.log(e);
- }
- }
- window.CZElementCellTypeV12 = CZElementCellTypeV12
复制代码
请帮忙解答,谢谢。
|