import { basicData } from './basic-data'
import { extendFormItems } from './extend'
import { baseUrl } from "../../../../config/baseUrl";

var params = {}
export function detailConfig(self) {
  return [
    {
      key: 'one',
      checkedKey: 'main',
      // height: '300px',
      btns: [
        // {
        //   label: '上架',
        //   click() {
        //     self.toShelf();
        //   }
        // },
      ],
      list: [
        {
          key: 'main',
          tab: '主要信息',
          item: {
            type: 'p-search-table',
            autoLoad: false,
            rowSelectType: 1,
            rowKey: 'rcvHeaderId',
            config: basicData(self),
            remoteUrl: baseUrl + '/rcvRejectLines/extractRcvH',
            remoteParams: {},
            operators: [],
            scroll: {y: 200},
            doneBefore(response) {
              response.data.list = response.data.list.map(item => {
                return {
                  ...item,
                  ...item.rcvHeadersDTO,
                  ...item.rcvHeadersProfilesDTO
                }
              })
              return response
            },
            selectChange(selectedRowKeys, selectedRows) {
              let ref = self.queryRefFromName('list');
              self.selectedMainItem = selectedRows[0];
              self.handleQuerySubList({ rcvHeaderId: selectedRowKeys[0], pageNum: 1, pageSize: 500 }).then(res => {
                res.forEach((t) => {
                  t.warehouseLocatorName = t.whLocatorName
                  t.realWhLocatorId = t.whLocatorId
                  t.realWhLocatorCode = t.whLocatorCode
                });
                ref.data = res;
              });
            },
          }
        }
      ]
    },
    {
      key: 'two',
      checkedKey: 'list',
      list: [
        {
          key: 'list',
          tab: '商品明细',
          btns: [
            // { label: '差异', click() { self.toErrorBill(); } },
          ],
          item: {
            type: 'p-table-edit',
            rowSelectType: 2,
            rowKey: 'taskRejectedId',
            config: extendFormItems(self),
            operations: [
              // { title: '拆分', click(record) { self.showSplitBill(record); } }
            ],
            colChange({ record, name, value }) { },
            onClick(selectedRowKeys, selectedRows, data) {
              
            },
          }
        }
      ]
    }
  ]
}
