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.PalletChangeNew',
})
export class ChangePalletNew extends VuexModule {
  orderNoItemList: 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 };
  }
  @MutationAction
  async empty() {
    const orderNoItemList = [];
    return { orderNoItemList };
  }
  SubmitCode: any = '';
  //托盘信息变更x
  @MutationAction
  async palletInforUpdate(params: any) {
    const result: any = await http.post(url.lanjumes.product.palletInforUpdate, params);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
  //库位下拉列表
  DictList: any = [];
  @MutationAction
  async getpalletLocation(params) {
    const result: any = await http.post(url.lanjumes.product.getpalletLocation, {
      productionState: params,
    });
    const DictListoild: [] = result;
    if (DictListoild) {
      const DictList = DictListoild.map((item: any) => ({
        label: item.location,
        value: item.location,
      }));
      return { DictList };
    }
  }
  //缓存区下拉列表
  locList: any = [];
  @MutationAction
  async getDictList() {
    const result: any = await http.get(url.lanjumes.product.getDictList, {
      params: {
        equipmentTypeCode: 'cache',
      },
    });
    const DictListoild: [] = result.data;
    const locList = DictListoild.map((item: any) => ({
      label: item.itemName,
      value: item.itemCode,
    }));
    return { locList };
  }
}

export default getModule(ChangePalletNew);
