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.FGmanagement.FinishedProCheck',
})
export class FinishedProCheck extends VuexModule {
  orderNoItemList: any = [];
  @MutationAction
  async showProduceCode(orderNo: any) {
    const result: any = await http.post(url.lanjuwms.FGmanagement.FinishedProCheck.selectOdsProductEmbryoInventory, {
      orderCode: orderNo,
      siteCode: session.FactoryCode,
    });
    // http.defaults.headers.common['Accept-Language'] = session.PoolName;
    const orderNoItemList = result.data;
    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(params: any) {
    const result: any = await http.post(url.lanjuwms.FGmanagement.FinishedProCheck.selectScanningTray, params);
    let scanreturndata: any;
    if (result.data) {
      scanreturndata = result.data;
    } else {
      scanreturndata = null;
    }

    const SubmitCode = result.code;
    return { scanreturndata, SubmitCode };
  }
  confirmcode: any = '';
  @MutationAction
  async confirmscan(params: any) {
    const result: any = await http.post(url.lanjuwms.FGmanagement.FinishedProCheck.confirmInventory, params);
    const confirmcode = result.code;
    return { confirmcode };
  }
  //查询盘点数据接口
  seleconfirmcode: any = '';
  selectscandataobj: any = [];
  @MutationAction
  async selectscandata(params: string) {
    const result: any = await http.post(url.lanjuwms.FGmanagement.FinishedProCheck.selectOdsProductEmbryoInventoryCorrelation, {
      orderCode: params,
      siteCode: session.FactoryCode,
    });
    console.log('e32dwedc', result);
    const seleconfirmcode = result.code;
    const selectscandataobj = result.data;

    return { seleconfirmcode, selectscandataobj };
  }
  @MutationAction
  async deleteTray(item: string) {
    console.log(item);
    const result: any = await http.post(url.lanjuwms.FGmanagement.FinishedProCheck.cancelInventory, {
      siteCode: session.FactoryCode,
      id: item,
    });
    const SubmitCode = result.code;
    return { SubmitCode };
  }
  @MutationAction
  async check(params: any) {
    const result: any = await http.post(url.lanjuwms.FGmanagement.FinishedProCheck.confirmCompletion, params);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
}

export default getModule(FinishedProCheck);
