export const defaultProps = {
  children: 'children',
  label: 'avmatCategoriesName'
}

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

export const columns = (_this) => [
  {
    prop: 'avmatCatalogName',
    label: '航材名称',
    align: 'left'
  },
  {
    prop: 'avmatCatalogCode',
    label: '航材编码'
  },
  {
    prop: 'avmatCategoriesName',
    label: '所属分类'
  },
  {
    prop: 'repairPrice',
    label: '维修价格(万元)',
    edit: true,
    onChange: (scope, oldRow) => {
      const { row } = scope
      if (oldRow.repairPrice == row.repairPrice) return
      _this.updateRow(row)
    }
  },
  {
    prop: 'purchasePrice',
    label: '采购价格(万元)',
    edit: true,
    onChange: (scope, oldRow) => {
      const { row } = scope
      if (oldRow.purchasePrice == row.purchasePrice) return
      _this.updateRow(row)
    }
  }
]

export const modalConfig = (_this) => ({
  formItems: [
    {
      key: 'sparePart',
      type: 'input',
      label: '航材名称',
      disabled: true,
      colLayout: { span: 24 }
    },
    { key: 'maintainPrice', type: 'input', label: '维修价格(元)', colLayout: { span: 24 } },
    { key: 'procurementPrice', type: 'input', label: '采购价格', colLayout: { span: 24 } }
  ],
  labelWidth: '100px',
  itemStyle: { padding: '10px' },
  width: '500px', // 弹框宽度
  rules: {}
})

export const tableData = [
  { id: '1', sparePart: '大灯', bookNumber: 'D001', classificationName: '灯泡', maintainPrice: '0', procurementPrice: '200' },
  { id: '2', sparePart: '雾灯', bookNumber: 'D002', classificationName: '灯泡', maintainPrice: '10', procurementPrice: '150' },
  { id: '3', sparePart: '煤油', bookNumber: 'R01', classificationName: '燃料', maintainPrice: '30', procurementPrice: '500' },
  { id: '4', sparePart: '飞机发动机', bookNumber: 'W01', classificationName: '发动机', maintainPrice: '50', procurementPrice: '10' }
]

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