import shipbillTableConfig from './shipbillTableConfig.js';
import {  UPCLOUD_RDC_TMS_BUSINESS_SERVICE } from '@/config/serviceSettings.js'

//历史销售单
export const sellQueryUrl = UPCLOUD_RDC_TMS_BUSINESS_SERVICE + '/allShipbill/query_sell'
export default function (self) {
  return {
    title: '引用历史运单',
    targetClick: true,
    targetValueKey: 'name',
    modalWidth: 990,
    remoteUrl: { url:sellQueryUrl, method: 'post' },
    rowKey: '_row_count',
    toolBar: {
      span: 6,
      wrapperCol: { span: 16 },
      labelCol: { span: 8 },
      items: [
        { name: 'cargoOwnerName', label: '货主', type: 'input' },
        { name: 'orderNo', label: '订单号', type: 'input' },
        { name: 'shipbillNo', label: '运单号', type: 'input' },
        {
          name: 'orderBusinessType',
          label: '业务类型',
          type: 'select',

          get options() {

            return self.options?.ORDER_BUSINESS_TYPE
          },
        },
        { name: 'shipperName', label: '发货方', type: 'input' },
        { name: 'consigneeName', label: '收货方', type: 'input' },
        {
          span: 8,
          itemStyle: 'width:100%',
          wrapperCol: { span: 18 },
          labelCol: { span: 6 },
          name: 'date',
          label: '下单日期',
          type: 'a-range-picker',
          format: 'YYYY-MM-DD',
          valueFormat: 'YYYY-MM-DD',
          placeholder: ['开始时间', '结束时间'],
        },
      ],
    },
    tableConfig: {
      bordered: true,
      remoteBefore(vnode, response) {
        if (response.data.date) {
          response.data.startDate = response.data.date[0];
          response.data.endDate = response.data.date[1];
          delete response.data.date;
        }
      },
      scroll: { x: true },
      columns: shipbillTableConfig(self),
    },
  };
}
