//setPopupVendor供应商选择
function setPopupVendor(obj = {}) {
  let name = '供应商'
  let code = 'vendor'
  let baseObject = { vendorcode: true, label: '选择供应商', remoteData: {}, required: false, ...obj }
  const { vendorcode, label, remoteData, search, ok, change, required } = baseObject

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