<%_ if (position === 'import') { _%>
<%_ } _%>
<%_ if (position === 'field') { _%>
  public commonTableColumns = [];
<%_ } _%>
<%_ if (position === 'method') { _%>

  public changeFieldName({ row }, { value }) {
    console.log(value);
    let findColumn = this.commonTableColumns.find(column => column.value === value);
    console.log(findColumn);
    if (findColumn) {
      row.fieldType = findColumn.fieldType.toString();
    }
    console.log(row);
    console.log(this.commonTableColumns);
  }

  getCommonTableData() {
    const queryItemColumns = [];
    const checkBoxColumn = { type: 'checkbox', width: 60 };
    const idColumn = { field: 'id', minWidth: 100, params: { type: 'LONG' }, title: 'Id' };
    const prefixColumn = { field: 'prefix', minWidth: 100, params: { type: 'STRING' }, title: '前置符号', editRender: {} };
    prefixColumn.editRender = {
      name: '$select',
      options: [
        { value: '(', label: '左括号' },
        { value: ')', label: '右括号' },
        { value: 'AND', label: '并且' },
        { value: 'OR', label: '或者' }
      ]
    };
    const fieldNameColumn = { field: 'fieldName', minWidth: 100, params: { type: 'STRING' }, title: '字段名称', editRender: {} };
    fieldNameColumn.editRender = { name: '$select', options: this.commonTableColumns, events: { change: this.changeFieldName } };
    const fieldTypeColumn = { field: 'fieldType', minWidth: 100, params: { type: 'STRING' }, title: '字段类型' };
    const operatorColumn = { field: 'operator', minWidth: 100, params: { type: 'STRING' }, title: '操作符号', editRender: {} };
    operatorColumn.editRender = {
      name: '$select',
      options: [
        { value: '>', label: '大于' },
        { value: '<', label: '小于' },
        { value: '=', label: '等于' },
        { value: 'contains', label: '包含' }
      ]
    };
    const valueColumn = { field: 'value', minWidth: 100, params: { type: 'STRING' }, title: '比较值', editRender: { name: '$input' } };
    const suffixColumn = { field: 'suffix', minWidth: 100, params: { type: 'STRING' }, title: '后置符号', editRender: {} };
    suffixColumn.editRender = {
      name: '$select',
      options: [
        { value: '(', label: '左括号' },
        { value: ')', label: '右括号' },
        { value: 'AND', label: '并且' },
        { value: 'OR', label: '或者' }
      ]
    };
    const orderColumn = { field: 'order', minWidth: 100, params: { type: 'INTEGER' }, title: '顺序' };
    const actionColumn = { title: '操作', field: 'operation', fixed: 'right', width: 140, slots: { default: 'recordAction' } };
    this.xGridColumns = [];
    this.xGridColumns.push(checkBoxColumn);
    this.xGridColumns.push(idColumn);
    this.xGridColumns.push(prefixColumn);
    this.xGridColumns.push(fieldNameColumn);
    this.xGridColumns.push(fieldTypeColumn);
    this.xGridColumns.push(operatorColumn);
    this.xGridColumns.push(valueColumn);
    this.xGridColumns.push(suffixColumn);
    this.xGridColumns.push(orderColumn);
    this.xGridColumns.push(actionColumn);
    this.loading = false;
  }

  public saveAll() {
    this.xGridData.forEach(item => {
      if (item.id && typeof item.id === 'number') {
        this.commonConditionItemService()
          .update(item)
          .then(res => {
            console.log('更新成功');
          });
      } else {
        const copy = item;
        copy.id = null;
        this.commonConditionItemService()
          .create(copy)
          .then(res => {
            console.log('创建成功');
          });
      }
    });
  }
<%_ } _%>
<%_ if (position === 'vue-toolbar_buttons-right') { _%>
<%_ } _%>
