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.mes.ProductionQtyInsp',
})
export class ProductionQtyInsp extends VuexModule {
  rowdata: any;
  WlList = [];
  // Checklist: any;
  orderNoItemList: any = [];
  productCodeList: any = [];
  @MutationAction
  async queryOrderNo(orderNo: any) {
    const result: any = await http.get(url.lanjumes.product.getInfoByRfid, {
      //loginName: session.loginName,
      params: {
        factoryCode: session.FactoryCode,
        rfid: orderNo,
      },
    });
    const orderNoItemList = result.data;
    return { orderNoItemList };
  }
  Checklist: any = [];
  @MutationAction
  async queryhandChecklist() {
    const result: any = await http.get(url.lanjumes.product.queryhandChecklist, {
      //loginName: session.loginName,
      params: {
        factoryCode: session.FactoryCode,
        createBy: session.user?.loginName,
      },
    });
    const Checklist: any = result.rows;
    console.log('this.tableData', Checklist);
    // debugger
    return { Checklist };
  }
  SubmitCode: any = '';
  @MutationAction
  async OnSubmit(params: any) {
    const result: any = await http.post(url.lanjumes.product.saveQcProCheck, params);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
  //烘房出来下发搬运任务
  SubmitCodeone: any = '';
  @MutationAction
  async sendDestinationStations(params: any) {
    const result: any = await http.post(url.lanjumes.product.sendDestinationStations, params);
    const SubmitCodeone = result.code;
    return { SubmitCodeone };
  }
  @MutationAction
  async empty() {
    const orderNoItemList = [];
    return { orderNoItemList };
  }
  //缓存区下拉列表
  DictList: any = [];
  @MutationAction
  async getDictList() {
    const result: any = await http.get(url.lanjumes.product.getDictList, {
      params: {
        equipmentTypeCode: 'cache',
      },
    });
    const DictListoild: [] = result.data;
    const DictList = DictListoild.map((item: any) => ({
      label: item.itemName,
      value: item.itemCode,
    }));
    return { DictList };
  }
}

export default getModule(ProductionQtyInsp);
