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.product.ProductionRecord',
})
// http.defaults.headers.common['poolName'] = session.PoolName;
export class ProductionRecord extends VuexModule {
  @MutationAction
  async getlistBaseEquipment() {
    const result: any = await http.post(url.lanjuwms.product.ProductionRecord.getlistBaseEquipment, {
      factoryCode: session.FactoryCode,
    });
    const Linelist = result.data.map((element: any) => ({
      label: element.equipmentName,
      value: element.equipmentCode,
      ...element,
    }));
    return { WlList: Linelist };
  }
  WlList = [];
  orderNoItemList: any = [];
  @MutationAction
  async queryOrderNo(params: any) {
    const result: any = await http.post(url.lanjuwms.product.ProductionRecord.listProOrderWorkorder, params);
    const orderNoItemList = result.data;
    return { orderNoItemList };
  }
  productCodeList: any = [];
  @MutationAction
  async list(orderNo: any) {
    const result: any = await http.get(url.lanjuwms.product.OfflineStorage.list + '/' + orderNo, {});
    const productCodeList = result.data;
    return { productCodeList };
  }
  submitcode: any = '';
  @MutationAction
  async getwarehouselist(params: any) {
    const result: any = await http.post(url.lanjuwms.product.ProductionRecord.finishedProductProductionRecords, params);
    const submitcode = result.code;
    return { submitcode };
  }
  queryByAttr1List: any = {};
  @MutationAction
  async queryByAttr1(params: any) {
    const result: any = await http.post(url.lanjuwms.product.ProductionRecord.queryByAttr1, params);
    return { queryByAttr1List: result.data };
  }
}

export default getModule(ProductionRecord);
