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.raw.PurchaseWHSRM',
})
export class PurchaseWHSRM extends VuexModule {
  WlList = [];
  @MutationAction
  async queryLocation() {
    const result: any = await http.post('', {
      // factoryCode: session.factoryCode,
      loginName: session.loginName,
    });
    const WlList = result.data.map((_: any) => ({
      label: _.locationCode,
      value: _.locationCode,
    }));
    return { WlList };
  }
  orderNoItemList: any = [];
  productCodeList: any = [];
  @MutationAction
  async queryOrderNo(orderNo: any) {
    const result: any = await http.post('', {
      // factoryCode: session.factoryCode,
      loginName: session.loginName,
      orderNo,
    });
    const orderNoItemList = result.data;
    // const productCodeList = result.data.map((_: any) => ({
    //   label: _.productCode,
    //   value: _.productCode,
    // }));
    return { orderNoItemList };
  }
  SubmitCode: any = '';
  @MutationAction
  async OnSubmit(params: any) {
    const result: any = await http.post('', params);
    const SubmitCode = result.code;
    return { SubmitCode };
  }
  @MutationAction
  async empty() {
    const productCodeList = [];
    return { productCodeList };
  }
}

export default getModule(PurchaseWHSRM);
