import { upcloud_base_strategy } from '@/config/serviceSettings'

const tablecolumns = function(that) {
  return {
    gridform: {
      ref: 'gridform',
      items: [
        {
          type: 'input',
          name: 'name',
          label: '规则名称',
          value: '',
          span: 6
        },
        {
          type: 'input',
          name: 'priority',
          label: '优先级',
          disabled: true,
          value: '',
          span: 6
        },
        {
          type: 'select',
          name: 'disabled',
          label: '规则状态',
          value: '',
          span: 6,
          disabled: true,
          options: [
            { value: '1', label: '开启' },
            { value: '0', label: '禁用' }
          ]
        },
        {
          span: 6,
          type: 'buttonGroup',
          style: { textAlign: 'right' },
          options: [
            {
              value: '保存',
              btnType: 'primary',
              htmlType: 'submit'
            }
          ]
        }

        // {
        //   span: 6,
        //   type: 'buttonGroup',
        //   style: { textAlign: 'right' },
        //   options: [
        //     {
        //       value: '保存',

        //       btnType: 'primary',
        //       on: {
        //         click(event, form) {
        //           // form.hiddenItem('field-number')
        //         }
        //       }
        //     }
        //   ]
        // }
      ]
    },
    // 查询匹配因子
    goods: {
      remoteUrl: {
        url: upcloud_base_strategy + '/rule/v1/match-factors',
        method: 'get',
        headers: {
          'Content-Type': 'application/JSON'
        }
      },
      ref: 'goods',
      rowkey: 'id',
      title: '根据匹配规则',
      columns: [
        {
          title: '因子名称',
          ellipsis: true,
          dataIndex: 'name',
          key: 'name'
        },
        {
          title: '字段名',
          dataIndex: 'fieldName',
          key: 'fieldName'
        },
        {
          title: '因子类型',
          dataIndex: 'type',
          key: 'type'
        },
        {
          title: '匹配类型',
          dataIndex: 'matchType',
          key: 'matchType'
        },
        {
          title: '值',
          dataIndex: 'value',
          key: 'value'
        },
        {
          title: '值类型',
          dataIndex: 'valueType',
          key: 'valueType'
        },

        {
          title: '数据源类型',
          dataIndex: 'datasourceType',
          key: 'datasourceType'
        },
        {
          title: '数据源',
          dataIndex: 'datasource',
          key: 'datasource'
        },

        {
          title: '操作',
          align: 'center',
          key: 'operation',
          scopedSlots: { customRender: 'operation' }
        }
      ]
    },
    // 查询搜索因子
    goodsallocation: {
      remoteUrl: {
        url: upcloud_base_strategy + '/rule/v1/search-factors',
        method: 'get',
        headers: {
          'Content-Type': 'application/JSON'
        },
        data: { ruleId: that.rule.id }
      },
      ref: 'goodsallocation',
      rowkey: 'id',
      title: '根据规则查找',
      columns: [
        {
          title: '因子名称',
          ellipsis: true,
          dataIndex: 'name',
          key: 'name'
        },
        {
          title: '字段名',
          dataIndex: 'fieldName',
          key: 'fieldName'
        },
        {
          title: '因子类型',
          dataIndex: 'type',
          key: 'type',
          hidden: true
        },
        {
          title: '匹配类型',
          dataIndex: 'matchType',
          key: 'matchType'
        },
        {
          title: '值',
          dataIndex: 'value',
          key: 'value'
        },
        {
          title: '值类型',
          dataIndex: 'valueType',
          key: 'valueType'
        },

        {
          title: '数据源类型',
          dataIndex: 'datasourceType',
          key: 'datasourceType',
          hidden: true
        },
        {
          title: '数据源',
          dataIndex: 'datasource',
          key: 'datasource',
          hidden: true
        },

        {
          title: '操作',
          align: 'center',
          key: 'operation',
          scopedSlots: { customRender: 'operation' }
        }
      ]
    },
    arithmetic: {
      //查询算法
      remoteUrl: {
        url: upcloud_base_strategy + '/rule/v1/algorithm	',
        method: 'get',
        headers: {
          'Content-Type': 'application/JSON'
        }
      },
      ref: 'arithmetic',
      rowkey: 'id',
      title: '查找结果选择合适的结果',
      columns: [
        {
          title: '算法名称',
          dataIndex: 'name',
          key: 'name'
        },
        {
          title: '算法语言',
          dataIndex: 'language',
          key: 'language'
        },
        {
          title: '优先级',
          dataIndex: 'priority',
          key: 'priority'
        },
        {
          title: '类',
          dataIndex: 'clz',
          key: 'clz'
        },
        {
          title: '脚本数据',
          dataIndex: 'scriptData',
          key: 'scriptData'
        },
        {
          title: '操作',
          align: 'center',
          key: 'operation',
          scopedSlots: { customRender: 'operation' }
        }
      ]
    }
  }
}
export default tablecolumns
