import { getModule, Module, MutationAction, VuexModule } from 'vuex-module-decorators';
import store from '@/store';
import http from '@/utils/request';
import { url } from '@/utils/url';
import { session } from '@/store/modules/session';
@Module({
  namespaced: true,
  dynamic: true,
  store,
  name: 'page.WhiteManagement.WhiteOutstorage',
})
export class WhiteOutstorage extends VuexModule {
  orderNoItemList: any = [];
  @MutationAction
  async showProduceCode(orderNo: any) {
    const result: any = await http.post(url.lanjuwms.WhiteManagement.WhiteOutstorage.selectWhiteEmbryoDeliveryOrder, {
      produceCode: orderNo,
      siteCode: session.FactoryCode,
    });
    // http.defaults.headers.common['Accept-Language'] = session.PoolName;
    const orderNoItemList = result.data.list;
    return { orderNoItemList };
  }
  information: any = [];
  @MutationAction
  async queryinformation(item) {
    console.log(item);
    const result: any = await http.get(url.lanjuwms.product.SaleOutWH.queryinformation + '/' + item.orderNo + '/' + item.value, {});
    const information = result.data;
    return { information };
  }
  TraysList: any = [];
  @MutationAction
  async showTrays(item: any) {
    const result: any = await http.get(url.lanjuwms.product.SaleOutWH.showTrays + '/' + item.orderNo + '/' + item.value, {});
    const TraysList = result.data;
    return { TraysList };
  }
  SubmitCode: any = '';
  scanreturndata: any = {};
  @MutationAction
  async selloutconntray(boxnumber: string) {
    const result: any = await http.post(url.lanjuwms.WhiteManagement.WhiteOutstorage.selectQueryTrayInfor, {
      sn: boxnumber,
      factoryCode: session.FactoryCode,
    });
    const scanreturndata = result.data;
    const SubmitCode = result.code;
    return { scanreturndata, SubmitCode };
  }
  @MutationAction
  async deleteTray(item: any) {
    console.log(item);
    const result: any = await http.delete(url.lanjuwms.product.SaleOutWH.deleteTray + '/' + item.barcode);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
  @MutationAction
  async out(params: any) {
    const result: any = await http.post(url.lanjuwms.WhiteManagement.WhiteOutstorage.WhiteEmbryoOutbound, params);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
}

export default getModule(WhiteOutstorage);
