import {
  beforeSetup,
  exportIntercept,
  generateNetworkResult,
  intercept,
  intoMenu,
  selectAllFilters,
  validateExport,
  validateTableList,
  validateTableSearch,
} from './utils';

const basicData = {
  id: '16',
  askGoodsId: 'BCP001',
  entryNumber: null,
  productionCode: null,
  storageLocationName: null,
  userName: 'PDA',
  realName: 'PDA测试',
  materialId: null,
  wbs: '1',
  measurementId: null,
  num: '1',
  outNum: null,
  askGoodsCode: 'BCP001',
  companyNumber: null,
  companyCode: null,
  sqrq: null,
  departmentId: null,
  departmentName: null,
  department: '柜体组装班组',
  departmentCode: null,
  name: null,
  code: null,
  sourceType: null,
  moveType: null,
  materialName: '瑞银;一体式电表;DJZ1226;600A',
  materialCode: '5TK540010437W87',
  uniqueCode: null,
  storageLocationCode: null,
  supplierId: null,
  serial: null,
  type: null,
  userId: '36',
  scrq: '2023-04-11 11:11:42',
  supplierName: null,
  producDate: null,
  wllbCode: '5TK540010437W87',
  page: 0,
  limit: 0,
  askGoodsType: null,
  startTime: null,
  endTime: null,
  process: null,
  askGoodsApplyType: null,
  partType: null,
  attribute: null,
  deliveryId: null,
  customerName: null,
  customerCode: null,
  warehouseWhere: null,
  companyName: null,
  storageCode: 'CK2304110001',
  accountSleeve: '8130',
  inventoryId: null,
  storageLocationCodeRk: null,
  accountName: '青岛特来电智能设备有限公司',
  requestTypeNumber: null,
  requestTypeName: null,
  ifCommodity: null,
  amount: null,
};

describe('半成品出库明细', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('出库管理', '半成品出库明细');
  });

  beforeEach(function () {
    intercept('/askGoods/getRemovalHalfProduct', function ({reply, search}) {
      generateNetworkResult({search, reply, basicData, title: 'askGoodsCode'});
    });

    exportIntercept('/askGoods/getRemovalHalfProductExcel');
  });

  it('table', function () {
    selectAllFilters('semi_out_stream_filter', 10);
    validateTableList('semi_out_stream_table');
    validateTableSearch(
      'semi_out_stream_table',
      [
        'askGoodsCode',
        'storageCode',
        'wllbCode',
        'materialName',
        'userName',
        'realName',
        {id: 'departmentCode', type: 'select', value: '00029999'},
        'wbs',
        {id: 'startTime', type: 'date'},
        {id: 'accountSleeve', type: 'select', value: '8130'},
      ],
      {
        toolId: 'semi_out_stream_filter',
        url: '/askGoods/getRemovalHalfProduct',
      },
    );

    validateExport('semi_out_stream_table');
  });
});
