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.WhiteReturn',
})
export class WhiteReturn extends VuexModule {
  orderNoItemList: any = {};
  @MutationAction
  async showProduceCode(materialCode: any) {
    const result: any = await http.post(url.lanjuwms.WhiteManagement.WhiteReturn.queryMaterialInfor, {
      materialCode: materialCode,
      factoryCode: session.FactoryCode,
    });
    // http.defaults.headers.common['Accept-Language'] = session.PoolName;
    const orderNoItemList = result.data;
    return { orderNoItemList };
  }
  SubmitCode: any = '';
  @MutationAction
  async into(params: any) {
    const result: any = await http.post(url.lanjuwms.WhiteManagement.WhiteReturn.WhiteBilletReturnConfir, params);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
  warehouselist: any = [];
  @MutationAction
  async getwarehouselist() {
    const result = await http.post(url.lanjuwms.raw.ProductionREQ.warehouselist, {
      factoryCode: session.FactoryCode,
    });
    const warehouselist = result.data.map((element: any) => ({
      label: element.warehouseName,
      value: element.warehouseCode,
      ...element,
    }));
    return { warehouselist };
  }
}

export default getModule(WhiteReturn);
