let grid = {
  labelCol: { span: 6 },
  span: 6
}
let grid1 = {
  labelCol: { span: 6 },
  span: 24
}
export function formItems(self) {
  let _this = self
  return [
    { type: 'input', name: 'checkTaskNo', label: '盘点任务号', ...grid, value: '' },
    // { type: 'select', name: 'agvFlag', label: '盘点区域',      
    //  options: [
    //       { value: '0', label: 'AGV' },
    //       { value: '1', label: '四向库' },
    //     ],
    // ...grid, value: '' },
    {
      type: 'select',
      name: 'checkState',
      label: '计划状态',
      options: [
        { value: '10', label: '已创建' },
        { value: '20', label: '已下发' },
        { value: '30', label: '盘点中' },
        { value: '40', label: '已完成' },
        { value: '50', label: '上传完成' },
        { value: '60', label: '取消' },
        { value: '70', label: '处理完成' },
        { value: '99', label: '失败' },
      ],
      ...grid,
      value: ''
    },
    { type: 'date', name: 'beginTime', label: '起始日期', ...grid, value: '' },
    { type: 'date', name: 'endTime', label: '截止日期', ...grid, value: '' },
    {
      type: 'buttonGroup',
      style: { textAlign: 'right' },
      // ...grid,
      span: 24,
      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 function setFormItems(self) {
  let _this = self
  return [
    { type: 'input', name: 'remark', required: true, label: '计划备注', ...grid1, value: '' },
    {
      type: 'select',
      name: 'taskType',
      label: '盘点区域',
      required: true,
      options: [
        { value: '0', label: 'AGV区域' },
        { value: '1', label: '四向库区域' }
      ],
      ...grid1,
      value: ''
    }
  ]
}
export function planFormItems(self) {
  let _this = self
  return [
    { type: 'input', name: 'goodsOwnerName', label: '货主', ...grid, value: '' },
    { type: 'input', name: 'goodsPackId', label: '包装id', ...grid, value: '' },
    { type: 'input', name: 'packName', label: '包装名称', ...grid, value: '' },
    { type: 'input', name: 'containerNo', label: self.agvFlag == 1? '托盘号' : '货架编码', ...grid, value: '' },
    { type: 'input', name: 'goodsName', label: '商品名称', ...grid, value: '' },
    // { type: 'input', name: 'goodsBigType', label: '商品大类1', ...grid, value: '' },
    {
      type: 'select', name: 'goodsBigType', label: '商品大类', value: '', allowClear: false,
      remoteUrl: {url:'/kz/dataDictionary/queryDataDictionaryByCode',method:"post"} ,
      remoteBefore(data, params) {
        params.data = { code: "goods_big_type" }
      },
      ...grid,
      doneBefore(vnode, data) {
        console.log(vnode,'vnodevnode')
        let option = []
        vnode.data.forEach((t) => {
          option.push({
            title: t.stateDescription,
            value: t.stateValues,
          })
        })
        vnode.data = option
        return vnode
      },
    },
    {
      type: 'select', name: 'goodsStatusId', label: '商品状态', value: '', allowClear: false,
      remoteUrl: {url:'/kz/dataDictionary/queryDataDictionaryByCode',method:"post"} ,
      remoteBefore(data, params) {
        params.data = { code: "goods_status_id" }
      },
      ...grid,
      doneBefore(vnode, data) {
        console.log(vnode,'vnodevnode')
        let option = []
        vnode.data.forEach((t) => {
          option.push({
            title: t.stateDescription,
            value: t.stateValues,
          })
        })
        vnode.data = option
        return vnode
      },
    },
    { type: 'input', name: 'goodsBarcode', label: '商品条码', ...grid, value: '' },
    { type: 'input', name: 'lotNo', label: '批号', ...grid, value: '' },
    {
      type: 'buttonGroup',
      style: { textAlign: 'left' },
      ...grid,
      // span: 24,
      options: [
        {
          value: '查询',
          icon: 'search',
          btnType: 'primary',
          style: 'margin-right:10px',
          htmlType: 'submit'
        },
        {
          value: '重置',
          icon: 'redo',
          style: 'margin-left:10px',
          on: {
            click: () => {
              self.$refs.planFormItems.form.resetFields()
            }
          }
        }
      ]
    }

  ]
}

export const tableColumns = [
  { hidden: true, title: 'id', dataIndex: 'id' },
  { title: '盘点任务号', dataIndex: 'checkTaskNo' },
  { title: '备注', dataIndex: 'remark' },
  {
    title: '计划状态',
    dataIndex: 'checkState',
    className: 'v_top',
    customRender: (text, record) => {
      if (text == 10) {
        return '已创建'
      } else if (text == 20) {
        return '已下发'
      } else if (text == 30) {
        return '盘点中'
      } else if (text == 40) {
        return '已完成'
      } else if (text == 50) {
        return '上传完成'
      } else if (text == 60) {
        return '取消'
      } else if (text == 70) {
        return '处理完成'
      } else if (text == 99) {
        return '失败'
      }
    }
  },
  { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' } }
]
export function detailColumns(self) {
  return  [
    { hidden: true, title: 'id', dataIndex: 'id' },
    { title: '盘点任务号', dataIndex: 'checkTask' },
    { title: '商品名称', dataIndex: 'goodsName' },
    { title: '货主', dataIndex: 'goodsOwnerName' },
    { title: '批号', dataIndex: 'lotNo' },
    { title: self.agvFlag == 1 ? '托盘号' : '货架编码', dataIndex: 'containerNo' } ,
    { title: '货位编码', dataIndex: 'containerLocation', hidden: self.agvFlag == 1 ? true : false },
    { title: '托盘区域', dataIndex: 'area' },
    { title: '计划数量', dataIndex: 'planCount' },
    {
      title: '差异类型',
      dataIndex: 'diffType',
      className: 'v_top',
      customRender: (text, record) => {
        if (text == 0) {
          return '无差异'
        } else if (text == 1) {
          return '报溢'
        } else if (text == -1) {
          return '报损'
        } else if (text == 2) {
          return '待复盘'
        }
      }
    },
    {
      title: '盘点类型',
      dataIndex: 'type',
      className: 'v_top',
      customRender: (text, record) => {
        if (text == 0) {
          return ''
        } else if (text == 1) {
          return '初盘'
        } else if (text == 2) {
          return '复盘'
        }
      }
    },
    {
      title: '盘点状态',
      dataIndex: 'state',
      className: 'v_top',
      customRender: (text, record) => {
        if (text == 0) {
          return '待盘点'
        } else if (text == 10) {
          return '初盘'
        } else if (text == 20) {
          return '复盘'
        } else if (text == 90) {
          return '完成'
        } else if (text == 91) {
          return '处理完成'
        } else if (text == -1) {
          return '失败'
        }
      }
    },
    { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' } }
  ]

}
export function Columns(self) {
  return [
    { hidden: true, title: 'id', dataIndex: 'id' },
    { title: self.agvFlag == 1? '托盘号' : '货架编码', dataIndex: 'containerNo' },
    { title: '有效期', dataIndex: 'validDate' },
    { title: '生产日期', dataIndex: 'prodDate' },
    { title: '生产厂家', dataIndex: 'lotFactName' },
    { title: '包装id', dataIndex: 'goodsPackId' },
    { title: '包装名称', dataIndex: 'packName' },
    { title: '货位编码', dataIndex: 'containerLocation', hidden: self.agvFlag == 1 ? true : false},
    { title: '商品名称', dataIndex: 'goodsName' },
    { title: '商品状态', dataIndex: 'goodsStatusId' },
    { title: '商品大类', dataIndex: 'bigType' },
    { title: '商品条码', dataIndex: 'goodsBarcode' },
    { title: '批号', dataIndex: 'lotNo' },
    { title: '货主', dataIndex: 'goodsOwnerName' },
    { title: '库存数量', dataIndex: 'qty',
      customRender: (text, record) => {
        if(self.agvFlag == '1') {
          return parseInt( text/record.packSize )
        } else {
          return text
        }
      }
     },
    // { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' } }
  ]
} 