import { oms_std_maindata} from "@/config/serviceSettings";

/** pubConsignor货主弹出查询配置 */
function setPubConsignor(object) {
  return [
    // { name: 'consignorid', type: 'input', hidden: true },
    {
      label: '客户名称',
      type: 'searchModal',
      targetClick: true,
      disabled: false,
      name: 'customername',
      targetValueKey: 'customername',
      remoteUrl: { url: oms_std_maindata+'/pubCustomer/pubCustomerQuery/v1.0', method: 'post' },
      rowKey: 'customerid',
      rules: [{ required: true, message: '数据不能为空' }],
      toolBar: {
        items: [
          {
            type: 'input',
            name: 'customercode',
            label: '客户编码',
            value: ''
          },
          {
            type: 'input',
            name: 'customername',
            label: '客户名称',
            value: ''
          }
        ]
      },
      tableConfig: {
        columns: [
          {
            dataIndex: 'customercode',
            title: '客户编码'
          },
          {
            dataIndex: 'customername',
            title: '客户名称'
          }
        ]
      },
      on: {
        ok(event, value, rowData, form) {
          form.setFieldsValue({
            customercode: `${rowData[0].customercode}`,
            customerName: `${rowData[0].customername}`,
            customerid: `${rowData[0].customerid}`,

          })
          if (object && object.on && typeof object.on.ok == 'function') {
            object.on.ok(event, value, rowData, form)
          }
        }
      }
    },
    {
      label: '仓库名称',
      type: 'searchModal',
      targetClick: true,
      disabled: false,
      name: 'branchname',
      targetValueKey: 'branchname',
      remoteUrl: { url: oms_std_maindata+'/pubBranch/queryWindow/v1.0', method: 'post' },
      rowKey: 'branchid',
      rules: [{ required: true, message: '数据不能为空' }],
      toolBar: {
        items: [
          {
            type: 'input',
            name: 'branchcode',
            label: '仓库编码',
            value: ''
          },
          {
            type: 'input',
            name: 'branchname',
            label: '仓库名称',
            value: ''
          }
        ]
      },
      tableConfig: {
        columns: [
          {
            dataIndex: 'branchcode',
            title: '仓库编码'
          },
          {
            dataIndex: 'branchname',
            title: '仓库名称'
          }
        ]
      },
      on: {
        ok(event, value, rowData, form) {
          form.setFieldsValue({
            branchcode: `${rowData[0].branchcode}`,
            branchname: `${rowData[0].branchname}`,

          })
          if (object && object.on && typeof object.on.ok == 'function') {
            object.on.ok(event, value, rowData, form)
          }
        }
      }
    },
    {
      label: '路线',
      type: 'searchModal',
      targetClick: true,
      disabled: false,
      name: 'lineName',
      targetValueKey: 'lineName',
      remoteUrl: { url: oms_std_maindata+'/pubTransline/queryTransline/v1.0', method: 'post' },
      rowKey: 'lineId',
      rules: [{ required: true, message: '数据不能为空' }],
      toolBar: {
        items: [
          {
            type: 'input',
            name: 'lineCode',
            label: '路线编码',
            value: ''
          },
          {
            type: 'input',
            name: 'lineName',
            label: '路线名称',
            value: ''
          }
        ]
      },
      tableConfig: {
        columns: [
          {
            dataIndex: 'lineCode',
            title: '路线编码'
          },
          {
            dataIndex: 'lineName',
            title: '路线名称'
          }
        ]
      },
      on: {
        ok(event, value, rowData, form) {
          form.setFieldsValue({
            lineCode: `${rowData[0].lineCode}`,
            lineName: `${rowData[0].lineName}`,

          })
          if (object && object.on && typeof object.on.ok == 'function') {
            object.on.ok(event, value, rowData, form)
          }
        }
      }
    },

  ]
}
export default setPubConsignor
