Browse Source

fix: 修改切换公式时的bug

refactor
alan 5 years ago
parent
commit
4863086bb1
  1. 4
      src/web/src/modules/components/database_index/database_index.model.ts
  2. 6
      src/web/src/modules/components/database_index/database_index.ts

4
src/web/src/modules/components/database_index/database_index.model.ts

@ -7,6 +7,7 @@ export class DatabaseIndexModel extends Model {
state() { state() {
return { return {
inputValue: '' as string | number, inputValue: '' as string | number,
inputType: 'int',
}; };
} }
@ -14,5 +15,8 @@ export class DatabaseIndexModel extends Model {
setInpueValue: (value: string | number) => { setInpueValue: (value: string | number) => {
this.model.inputValue = value; this.model.inputValue = value;
}, },
setInputType: (value: string) => {
this.model.inputType = value;
},
} }
} }

6
src/web/src/modules/components/database_index/database_index.ts

@ -23,11 +23,12 @@ export class DatabaseIndex extends BI.Widget {
render() { render() {
const { value, inputType } = this.options; const { value, inputType } = this.options;
this.store.setInpueValue(value); this.store.setInpueValue(value);
this.store.setInputType(inputType);
return { return {
type: TabXtype, type: TabXtype,
single: true, single: true,
showIndex: inputType, showIndex: this.model.inputType,
ref: (_ref: any) => { ref: (_ref: any) => {
this.databaseIndexTab = _ref; this.databaseIndexTab = _ref;
}, },
@ -68,6 +69,7 @@ export class DatabaseIndex extends BI.Widget {
public setSelect(value: string) { public setSelect(value: string) {
this.databaseIndexTab.setSelect(value); this.databaseIndexTab.setSelect(value);
this.store.setInputType(value);
if (value === 'formula') { if (value === 'formula') {
openFormulaPopover({ openFormulaPopover({
formula: this.model.inputValue === 0 ? '' : this.model.inputValue as string, formula: this.model.inputValue === 0 ? '' : this.model.inputValue as string,
@ -79,6 +81,6 @@ export class DatabaseIndex extends BI.Widget {
} }
public getValue() { public getValue() {
return this.model.inputValue; return this.model.inputType === 'int' ? parseInt(`${this.model.inputValue}`, 10) : this.model.inputValue;
} }
} }

Loading…
Cancel
Save