import { basicData } from './config/basic-data'
import { extendFormItems } from './config/extend'
import { packingColumns, packingColChange } from './config/packing'
import { purchaseSale } from './config/purchase-sale'
import { logistics } from './config/logistics'
import { healthFormItems } from './config/health'
import { logicColums } from './config/logic'
import { upcloud_base_item } from '@/config/serviceSettings'
import { HealthLicensecolumns } from './config/HealthLicensecolumns'

export function detailConfig(self) {
  return [
    {
      key: 'one',
      checkedKey: 'main',
      height: '225px',
      btns: [
        {
          label: '保存',
          vaction: 'add',
          click() {
            self.getDetailData()
          }
        }
      ],
      list: [
        {
          key: 'main',
          tab: '商品属性',
          item: { type: 'p-grid-form', config: basicData(self) }
        },
        {
          key: 'baseMtlItemProfiles',
          tab: '扩展属性',
          item: { type: 'p-grid-form', config: extendFormItems }
        }
      ]
    },
    {
      key: 'two',
      checkedKey: 'baseMtlItemUomConversionsList',
      list: [
        {
          key: 'baseMtlItemUomConversionsList',
          tab: '包装属性',
          item: {
            type: 'p-table-edit',
            rowKey: packingColumns[0].key,
            rowSelectType: 2,
            config: packingColumns,
            colChange(data) {
              let ref = self.$refs.detail.$refs.baseMtlItemUomConversionsList[0]
              packingColChange(data, ref.data)
            }
          },
          btns: [
            {
              label: '新增',
              vaction: 'add',
              click() {
                let ref = self.$refs.detail.$refs.baseMtlItemUomConversionsList[0]
                ref.addItem()
              }
            },
            {
              label: '删除',
              vaction: 'add',
              click() {
                let ref = self.$refs.detail.$refs.baseMtlItemUomConversionsList[0]
                ref.delSelectedItems()
              }
            }
          ]
        },
        {
          key: 'baseMtlItemOms',
          tab: '采销属性',
          item: { type: 'p-grid-form', config: purchaseSale }
        },
        {
          key: 'baseMtlItemWms',
          tab: '存储属性',
          item: { type: 'p-grid-form', config: logistics }
        },
        {
          key: 'baseMtlItemHealth',
          tab: '大健康属性',
          item: { type: 'p-grid-form', config: healthFormItems }
        },
        // {
        //   key: 'baseMtlItemLogic',
        //   tab: '商品与委托生产企业',
        //   item: {
        //     type: 'p-table',
        //     config: logicColums,
        //     rowKey: 'itemOemId',
        //     tableRemoteUrl: {
        //       url: upcloud_base_item + '/item/getItemOemByItemId',
        //       method: 'get',
        //       headers: {
        //         'Content-Type': 'x-www-form-urlencoded'
        //       },
        //       params: {}
        //     }
        //   }
        // },
        // {
        //   key: 'HealthLicense',
        //   tab: '证件资料',
        //   item: {
        //     type: 'p-table',
        //     config: HealthLicensecolumns,
        //     autoLoad: true,
        //     rowKey: 'id',
        //     tableRemoteUrl: {
        //       url: upcloud_base_item + '/item/itemCertificate',
        //       method: 'get',
        //       headers: {
        //         'Content-Type': 'x-www-form-urlencoded'
        //       },
        //       params: {}
        //     }
        //   }
        // }
      ]
    }
  ]
}
