export const defaultProps = {
  children: 'children',
  label: 'avmatCategoriesName'
}
/**
 *
 * @param {*} _this 当前vue 的实例
 * @returns  返回一个表格配置数组
 */
export const modalConfig = (_this) => ({
  formItems: [
    { key: 'avmatCatalogName', type: 'input', label: '航材名称', colLayout: { span: 12 } },
    { key: 'avmatCatalogCode', type: 'input', label: '航材编码', colLayout: { span: 12 } },
    { key: 'avmatCategoriesName', type: 'input', label: '所属分类', colLayout: { span: 12 }, disabled: true },
    { key: 'specification', type: 'input', label: '规格型号', colLayout: { span: 12 } },
    { key: 'diagramNumber', type: 'input', label: '图号', colLayout: { span: 12 } },
    { key: 'unit', type: 'input', label: '计量单位', colLayout: { span: 12 } },
    { key: 'specialty', type: 'input', label: '专业', colLayout: { span: 12 } },
    { key: 'manufacturer', type: 'input', label: '生产厂家', colLayout: { span: 12 } },
    {
      key: 'isRepairable',
      type: 'radio',
      label: '是否可修',
      valueOptions: [
        { value: 0, label: '否' },
        { value: 1, label: '是' }
      ],
      colLayout: { span: 12 }
    },
    {
      key: 'isCompleteSet',
      type: 'radio',
      label: '是否成套',
      valueOptions: [
        { value: 0, label: '否' },
        { value: 1, label: '是' }
      ],
      colLayout: { span: 12 }
    },
    {
      key: 'isOrdered',
      type: 'radio',
      label: '是否有寿',
      valueOptions: [
        { value: 0, label: '否' },
        { value: 1, label: '是' }
      ],
      colLayout: { span: 12 }
    },
    {
      key: 'isImported',
      type: 'radio',
      label: '是否进口',
      valueOptions: [
        { value: 0, label: '否' },
        { value: 1, label: '是' }
      ],
      colLayout: { span: 12 }
    }
  ],
  labelWidth: '80px',
  itemStyle: { padding: '10px' },
  width: '680px' // 弹框宽度
})

/**
 *
 * @param {*} _this 当前vue 的实例
 * @returns  返回一个表格配置数组
 */

export const columns = (_this) => [
  {
    prop: 'avmatCatalogName',
    label: '航材名称'
  },
  {
    prop: 'avmatCatalogCode',
    label: '航材编码'
  },
  {
    prop: 'avmatCategoriesName',
    label: '所属分类'
  },
  {
    prop: 'specification',
    label: '规格型号'
  },
  {
    prop: 'diagramNumber',
    label: '图号'
  },
  {
    prop: 'unit',
    label: '计量单位'
  },
  {
    prop: 'manufacturer',
    label: '生产厂家'
  },
  {
    prop: 'isRepairable',
    label: '是否可修',
    render: (h, params) => {
      if (params.row.isRepairable == 1) {
        return h('span', { class: 'success-state' }, '可修')
      } else {
        return h('span', { class: 'warning-state' }, '不可修')
      }
    }
  },
  {
    prop: 'isCompleteSet',
    label: '是否成套',
    render: (h, params) => {
      if (params.row.isCompleteSet == 1) {
        return h('span', { class: 'success-state' }, '是')
      } else {
        return h('span', { class: 'warning-state' }, '否')
      }
    }
  },
  {
    prop: 'isOrdered',
    label: '是否有寿',
    render: (h, params) => {
      if (params.row.isOrdered == 1) {
        return h('span', { class: 'success-state' }, '是')
      } else {
        return h('span', { class: 'warning-state' }, '否')
      }
    }
  },
  {
    prop: 'isImported',
    label: '是否进口',
    render: (h, params) => {
      if (params.row.isImported == 1) {
        return h('span', { class: 'success-state' }, '进口')
      } else {
        return h('span', { class: 'warning-state' }, '国产')
      }
    }
  },
  {
    prop: 'mappingCode',
    label: '映射编码'
  },
  {
    button: true,
    label: '操作',
    width: '100px',
    group: [
      {
        name: '编辑',
        type: 'text',
        round: false,
        plain: false,
        onClick: (row, index, scope) => {
          _this.handUpdate(row)
        }
      }
    ]
  }
]

/**
 *
 * @returns 返回表格基础配置项
 */
export const options = {
  rowKey: 'avmatCatalogCode',
  stripe: true, // 斑马纹
  mutiSelect: true, // 多选框
  index: true, // 显示序号， 多选则 mutiSelect
  loading: false, // 表格动画
  initTable: true, // 是否一挂载就加载数据
  border: true,
  height: 'calc(100vh - 300px)'
}
