import moment from 'moment'
import { grid } from "./common";

import { genWarehouseSearchModal } from "../../../SearchModal";

const items = [
  /* ...genwarehouse(grid), */
  // 仓库
  ...genWarehouseSearchModal(1, true, false,null, 
  		function (rowData, form) {
  			if (!rowData) {
  				form.setFieldsValue({
  					dcId: '',
  					dcCode: '',
  					dcName: '',
  				})
  			} else {
  				form.setFieldsValue({
  					dcId: rowData[0].dcId,
  					dcCode: rowData[0].dcCode,
  					dcName: rowData[0].dcName,
  				})
  			}
  		},
  		{ span: 6, labelCol: { span: 6 } }
  	),
  { type: 'input', name: 'bldgCode', label: '建筑物编号'  },
  { type: 'input', name: 'bldgName', label: '建筑物名称' },
  {
    type: 'buttonGroup', style: { textAlign: 'right' },
    span: 6, lableCol: { span: 6 },
    options: [
      { value: '查询', icon: 'search', btnType: 'primary', style: 'margin-left:50px;margin-right:10px;', htmlType: 'submit' },
      {
        value: '重置', name: 'ccz', icon: 'redo', on: {
          click(event, form) {
            form.resetFields()
          }
        }
      }
    ]
  }
]

let dcId = null
let dcCode = null

const modalItems = [
  { hidden: true, type: 'input', name: 'dcId', },
  { hidden: true, type: 'input', name: 'dcCode', },
  // { hidden: true, type: 'input', name: 'warehouseId' },
  // { hidden: true, type: 'input', name: 'warehouseCode' },
  { type: 'input', name: 'dcName', disabled: true, label: '所属仓配中心',span: 8, labelCol: { span: 6 }, },
  // 仓库
  ...genWarehouseSearchModal(1, true, false,null, 
		function (rowData, form) {
			if (!rowData) {
				form.setFieldsValue({
					dcId: '',
					dcCode: '',
					dcName: '',
				})
			} else {
				form.setFieldsValue({
					dcId: rowData[0].dcId,
					dcCode: rowData[0].dcCode,
					dcName: rowData[0].dcName,
				})
			}
		},
		{ span: 8, labelCol: { span: 6 } }
	),
  { type: 'input', name: 'bldgCode', required: true, label: '建筑物编码',span: 8, labelCol: { span: 6 }, },
  { type: 'input', name: 'bldgName', required: true, label: '建筑物名称',span: 8, labelCol: { span: 6 }, },
  { type: 'SwitchValue', name: 'isEnable', label: '启用标识', value: 1,span: 8, labelCol: { span: 6 }, }
]

const columns = [
  { hidden: true, dataIndex: 'bldgId', title: '建筑物ID',ellipsis:true },
  { dataIndex: 'bldgCode', title: '建筑物编码', width: 160,ellipsis:true },
  { dataIndex: 'bldgName', title: '建筑物名称', width: 150,ellipsis:true },
  { dataIndex: 'dcCode', title: '仓配中心编码', width: 150,ellipsis:true },
  { dataIndex: 'dcName', title: '仓配中心名称', width: 140,ellipsis:true },
  { dataIndex: 'warehouseCode', title: '仓库编码', width: 120,ellipsis:true },
  { dataIndex: 'warehouseName', title: '仓库名称', width: 140,ellipsis:true },
  {
    title: '是否启用', width: 100, dataIndex: 'isEnable', customRender: text => {
      return text == '1' ? '启用' : '禁用'
    }
  },
  { title: '创建人', width: 120, dataIndex: 'creatorName',ellipsis:true },
  { title: '最后修改人', width: 120, dataIndex: 'modifierName',ellipsis:true },
  { title: '创建日期', dataIndex: 'gmtCreate',width: 120,ellipsis:true },
  { title: '最后修改日期', dataIndex: 'gmtModified',width: 120,ellipsis:true },
  { dataIndex: 'action', title: '操作', fixed: 'right', scopedSlots: { customRender: 'action' }, width: 90 }
]

export { items, modalItems, columns }