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.Records',
})
export class Records extends VuexModule {
  WlList = [];
  orderNoItemList: any = [];
  selectList: any = [];
  @MutationAction
  async getCheckType() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getCheckType, {
      //loginName: session.loginName,
      params: {
        factoryCode: session.PoolName,
      },
    });
    const orderNoItemList = result.data;
    const selectList = result.data.map((item: any) => ({
      label: item.checkName,
      value: item.orderCode,
    }));
    return { orderNoItemList, selectList };
  }
  CheckTaskListall: any = [];
  @MutationAction
  async getCheckTaskListall(query: any) {
    const result: any = await http.get(url.lanjuquality.Records.getCheckTaskListall, {
      //loginName: session.loginName,
      params: query,
    });
    const CheckTaskListall = result;
    return { CheckTaskListall };
  }
  CheckTaskList: any = [];
  @MutationAction
  async getCheckTaskList(query: any) {
    const result: any = await http.get(url.lanjuquality.Records.getCheckTaskList, {
      //loginName: session.loginName,
      params: query,
    });
    const CheckTaskList = result.data;
    return { CheckTaskList };
  }
  locList1: any = [];
  getDefectList: any = '';
  @MutationAction
  async getDefectListPDA(params: any) {
    const result: any = await http.post(url.lanjuquality.Materialinspection.getDefectListPDA, params);
    console.log(result);
    const getDefectList: [] = result;
    const locList1 = getDefectList.map((item: any) => ({
      label: item.defectSubclass,
      value: item.defectCode,
    }));
    return { locList1 };
  }
  orderNoItemList1: any = [];
  selectList1: any = [];
  @MutationAction
  async getcheckLocList() {
    const result: any = await http.post(url.lanjuquality.Materialinspection.getcheckLocList, {
      factoryCode: session.PoolName,
    });
    const orderNoItemList1 = result;
    console.log(result, 'wwwwwww');
    const selectList1 = result.map((item: any) => ({
      label: item.defectSubclass,
      value: item.defectCode,
    }));
    return { orderNoItemList1, selectList1 };
  }
  locList2: any = [];
  materialtypeList: any = '';
  @MutationAction
  async getmaterialTypePDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'material_type_oa',
      },
    });
    console.log(result);
    const materialtypeList: [] = result;
    const locList2 = materialtypeList.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { locList2 };
  }
  locList3: any = [];
  materialFromList: any = '';
  @MutationAction
  async getmaterialFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'material_from_oa',
      },
    });
    console.log(result);
    const materialFromList: [] = result;
    const locList3 = materialFromList.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { locList3 };
  }
}

export default getModule(Records);
