let grid = {
  labelCol: { span: 4 },
  span: 8,
}
import { QN_BASEURL } from '../../serviceSettings'
const baseUrl = QN_BASEURL
var option = []
export function formItems(self) {
  let _this = self
  return [
    // { type: 'input', name: 'itemHealthCategoryName', label: '商品大类', ...grid, value: '' },
    { type: 'input', name: 'itemBarcode', label: '商品条码', ...grid, value: '' },
    { type: 'input', name: 'itemName', label: '商品名称', ...grid, value: '' },
    {
      type: 'buttonGroup',
      style: { textAlign: 'left' },
      // span: 24,
      ...grid,
      options: [
        {
          value: '查询',
          icon: 'search',
          btnType: 'primary',
          // style: "margin-right:10px",
          htmlType: 'submit',
        },
        {
          value: '重置',
          icon: 'redo',
          style: 'margin-left:10px',
          on: {
            click: () => {
              self.$refs.formTarget.form.resetFields()
            },
          },
        },
      ],
    },
  ]
}

export const tableColumns = [
  { hidden: true, title: 'id', dataIndex: 'id' },
  { hidden: true, title: 'goodsBigType', dataIndex: 'goodsBigType' },
  { hidden: true, title: '限定区域', dataIndex: 'belongArea', className: 'v_top' },
  { hidden: true, title: 'stateDescription', dataIndex: 'stateDescription', className: 'v_top' },

  { title: '货主名称', dataIndex: 'ownerName', className: 'v_top' },
  { title: '货主编号', dataIndex: 'ownerId', className: 'v_top' },
  { title: '商品规格', dataIndex: 'itemType', className: 'v_top' },
  { title: '商品条码', dataIndex: 'itemBarcode', className: 'v_top' },
  { title: '商品名称', dataIndex: 'itemName', className: 'v_top' },
  { title: '商品大类', dataIndex: 'itemHealthCategoryName', className: 'v_top' },
  { title: '限定区域', dataIndex: 'areaNo', className: 'v_top' },
//   { title: '创建人', dataIndex: 'createBy', className: 'v_top' },
  { title: '创建时间', dataIndex: 'createTime', className: 'v_top' },
//   { title: '更新人', dataIndex: 'updateBy', className: 'v_top' },
  { title: '更新时间', dataIndex: 'updateTime', className: 'v_top' },
  { title: '操作', key: 'operate', align: 'center', scopedSlots: { customRender: 'action' } },
]

export const detailColumns = [
  { hidden: true, title: 'id', dataIndex: 'id' },
  { title: '限定区域', dataIndex: 'belongArea', className: 'v_top' },
  { title: '点位编号', dataIndex: 'locationNo', className: 'v_top' },
]

export function detailItem(self) {
  let _this = self
  return [
    { hidden: true, type: 'input', name: 'id', label: 'id', value: '' },
    { type: 'input', name: 'ownerName', label: '货主名称', value: '', required: true },
    { type: 'input', name: 'ownerId', label: '货主编号', value: '', required: true },
    { type: 'input', name: 'itemType', label: '商品规格', value: '', required: true },
    { type: 'input', name: 'itemBarcode', label: '商品条码', value: '', required: true },
    {
      type: 'input',
      name: 'itemName',
      label: '商品名称',
      required: true,
      targetClick: true,
      targetValueKey: 'itemName',
      value: '',
      remoteUrl: {
        url: baseUrl + '/api/v1/locationRestricted/queryItem',
        method: 'post',
      },
      remoteBefore: function (vnode, remoteUrl) {
        console.log(remoteUrl)
        // remoteUrl.params.areaType = 20
        return remoteUrl
      },

      on: {
        search: () => {
          //   this.params = { name: 'hdwss' }
        },
        change: (event, value, rowData, form) => {
          console.log(arguments)
        },
      },

      tableConfig: {
        rowKey: 'itemId',
        remoteBefore: function (vnode, remoteUrl) {
          console.log(remoteUrl)
          remoteUrl.data = []
          return remoteUrl
        },
        columns: [
          {
            title: '货主名称',
            dataIndex: 'ownerName',
            align: 'center',
            key: 'ownerName',
          },
          {
            dataIndex: 'itemName',
            title: ' 商品名称',
            align: 'center',
            key: 'itemName',
          },
          {
            title: '商品规格',
            dataIndex: 'itemType',
            align: 'center',
            key: 'itemType',
          },
          {
            title: '商品条码',
            dataIndex: 'itemBarcode',
            align: 'center',
            key: 'itemBarcode',
          },
          {
            title: '货主编号',
            dataIndex: 'ownerId',
            align: 'center',
            key: 'ownerId',
          },

          // itemBarcode   ownerId ownerName
        ],
      },
    },
    { type: 'input', name: 'areaNo', label: '限定区域', value: '', required: true, min: 0, max: 4 },
    {
      type: 'input',
      name: 'itemHealthCategory',
      label: '商品大类',
      value: '',
      allowClear: false,
      required: true,
      remoteUrl: { url: baseUrl + '/api/v1/locationRestricted/queryArea', method: 'post' },
      remoteBefore(data, params) {
        params.data = { code: 'goods_big_type' }
      },
      doneBefore(vnode, data) {
        vnode.data.forEach((t) => {
          option.push({
            title: t.stateDescription,
            value: t.stateValues,
          })
        })
      },
      options: option,
    },
    { type: 'input', name: 'itemHealthCategoryName', label: '商品大类名称', value: '', required: true },
    {
      type: 'buttonGroup',
      style: { textAlign: 'right' },
      span: 24,
      options: [
        {
          value: '保存',
          btnType: 'primary',
          htmlType: 'submit',
        },
        // {
        //   value: '重置',
        //   style: 'margin-left:10px',
        //   on: {
        //     click: () => {
        //       self.$refs.detailForm.form.resetFields()
        //     },
        //   },
        // },
      ],
    },
  ]
}

export function detailItems(self) {
  let _this = self
  return [
    { hidden: true, type: 'input', name: 'id', label: 'id', value: '' },
    { type: 'input', name: 'locationNo', label: '点位编号', value: '', required: true },
    {
      type: 'buttonGroup',
      style: { textAlign: 'right' },
      span: 24,
      options: [
        {
          value: '保存',
          btnType: 'primary',
          htmlType: 'submit',
        },
        {
          value: '重置',
          style: 'margin-left:10px',
          on: {
            click: () => {
              self.$refs.detailForm.form.resetFields()
            },
          },
        },
      ],
    },
  ]
}
