//branch
function setBranch(obj = {}) {
  let vName = '仓库'
  let code = 'branch'
  let baseObject = { branchcode: true, label: '选择仓库', remoteData: {}, required: false, ...obj }
  const { name, targetValueKey, branchcode, label, remoteData, search, ok, change, required } = baseObject

  return [
    {
      type: 'searchModal',
      label,
      targetClick: true,
      required,
      name: name || code + 'name',
      targetValueKey: targetValueKey || code + 'name',
      remoteData,
      remoteUrl: { url: '/api/oms-std-maindata/pubBranch/queryWindow/v1.0', method: 'post' },
      tableConfig: {
        rowKey: code + 'id',
        columns: [
          {
            hidden: true,
            dataIndex: code + 'id',
            title: 'id'
          },
          {
            dataIndex: code + 'code',
            title: vName + '编码'
          },
          {
            dataIndex: code + 'name',
            title: vName + '名称'
          }
        ]
      },
      toolBar: {
        items: [
          {
            type: 'input',
            name: code + 'code',
            label: vName + '编码',
            value: ''
          },
          {
            type: 'input',
            name: code + 'name',
            label: vName + '名称',
            value: ''
          }
        ]
      },
      on: {
        change,
        search,
        ok,
      }
    },
    { name: code + 'code', required, label: vName + '编码', type: 'input', hidden: !branchcode, disabled: true },
    { name: code + 'id', required, label: vName + 'ID', type: 'input', hidden: true }
  ]
}
export default setBranch
