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.Materialinspection',
})
export class Materialinspection 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,
      typeCode: item.typeCode,
    }));
    return { orderNoItemList, selectList };
  }
  CheckTaskListall: any = [];
  @MutationAction
  async getCheckTaskListall(query: any) {
    const result: any = await http.get(url.lanjuquality.Materialinspection.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.Materialinspection.getCheckTaskList, {
      //loginName: session.loginName,
      params: query,
    });
    console.log(result, '11111');
    const CheckTaskList = result.data;
    return { CheckTaskList };
  }
  //草稿查询
  returnobj: any = {};
  @MutationAction
  async queryCheckTaskDetailListCG(query: any) {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getCheckTaskDetailListCG, {
      //loginName: session.loginName,
      params: query,
    });
    //console.log(result, '11111');

    const returnobj = result.data || {};
    //console.log('0099999',returnobj);
    return { returnobj };
  }

  SubmitCode: any = '';
  @MutationAction
  async commitCheckTaskList(params: any) {
    const result: any = await http.post(url.lanjuquality.Materialinspection.commitCheckTaskList, params);
    const SubmitCode: [] = result;
    return { SubmitCode };
  }
  commitDraftCode: any = '';
  @MutationAction
  async commitDraft(params: any) {
    const result: any = await http.post(url.lanjuquality.Materialinspection.commitCheckResultsCg, params);
    const commitDraftCode: [] = result.code;
    return { commitDraftCode };
  }
  locList: any = [];
  @MutationAction
  async getBatchList(params: any) {
    const result: any = await http.post(url.lanjuquality.Materialinspection.getBatchList, params);
    console.log(result);
    const DictListoild: [] = result;
    const locList = DictListoild.map((item: any) => ({
      label: item.batchCode,
      value: item.batchCode,
    }));
    return { locList };
  }
  //获取不良描述字典表
  disqualificationlist: any = [];
  @MutationAction
  async getdisqualification(params: any) {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getdisqualification, { params: params });
    const disqualificationlist = result.data.map((item: any) => ({
      label: item.dictLabel,
      value: item.dictValue,
    }));
    return { disqualificationlist };
  }
  //获取首见，来料底部缺陷分类
  SJLLdefectList: any = [];
  @MutationAction
  async getSJLLdefect(params: any) {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getSJLLdefect, {
      params: {
        checkType: params,
      },
    });
    const SJLLdefectList = result.data.map((item: any) => ({
      label: item.className,
      value: item.id,
    }));
    return { SJLLdefectList };
  }
  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 };
  }
  orderNoItemList2: any = [];
  selectList2: any = [];
  @MutationAction
  async getQualitylimit() {
    const result: any = await http.post(url.lanjuquality.Materialinspection.getcheckLocList, {
      factoryCode: session.PoolName,
    });
    const orderNoItemList2 = result;
    console.log(result, 'wwwwwww');
    const selectList2 = result.map((item: any) => ({
      label: item.defectSubclass,
      value: item.defectCode,
    }));
    return { orderNoItemList2, selectList2 };
  }
  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 };
  }
  locList4: any = [];
  sampleaqlList: any = '';
  @MutationAction
  async getsampleaqlList() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'sample_aql',
      },
    });
    console.log(result);
    const sampleaqlList: [] = result;
    const locList4 = sampleaqlList.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { locList4 };
  }
  locList5: any = [];
  samplelevelList: any = '';
  @MutationAction
  async getsamplelevelList() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'sample_level',
      },
    });
    console.log(result);
    const samplelevelList: [] = result;
    const locList5 = samplelevelList.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { locList5 };
  }
  WeightInfoList: any = [];
  @MutationAction
  async getWeightInfo(query: any) {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getWeightInfo, {
      //loginName: session.loginName,
      params: query,
    });
    const WeightInfoList = result;
    return { WeightInfoList };
  }
  // 自动判定
  getAutoJudgeList: any = '';
  @MutationAction
  async getAutoJudge(params: any) {
    const result: any = await http.post(url.lanjuquality.Materialinspection.getAutoJudge, params);
    const getAutoJudgeList: [] = result;
    return { getAutoJudgeList };
  }
  //仓储报检人
  locList6: any = [];
  //materialFromList: any = '';
  @MutationAction
  async getstorgeFromListPDA() {
    const result: any = await http.post(
      url.lanjuquality.Materialinspection.getstorge,
      //loginName: session.loginName,
      {
        deptId: '10000612',
      },
    );
    console.log(result);
    const materialFromList: [] = result;
    const locList6 = materialFromList.map((item: any) => ({
      label: item.userName,
      value: item.userCode,
    }));
    return { locList6 };
  }
  //转出方
  locList7: any = [];
  //materialFromList: any = '';
  @MutationAction
  async gettrensferFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'oa_cq',
      },
    });
    console.log(result);
    const materialFromList: [] = result;
    const locList7 = materialFromList.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { locList7 };
  }
  //QC主管
  locList8: any = [];
  //materialFromList: any = '';
  @MutationAction
  async getqcFromListPDA() {
    const result: any = await http.post(url.lanjuquality.Materialinspection.getstorge, {
      deptId: '10000773',
    });
    console.log(result);
    const listqc: [] = result;
    const locList8 = listqc.map((item: any) => ({
      label: item.userName,
      value: item.userCode,
    }));
    return { locList8 };
  }
  //sqr
  sqrlist: any = {};
  @MutationAction
  async getOaUserIdlist() {
    console.log(session.loginName);
    const result11: any = await http.post(url.lanjuquality.Materialinspection.getOaUserId, {
      userCode: session.loginName,
    });
    console.log('报错接口', result11);
    const sqrlist = result11;

    return { sqrlist };
  }
  //厂区
  locList9: any = [];
  //materialFromList: any = '';
  @MutationAction
  async getworkFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'oa_cq',
      },
    });
    console.log(result);
    const listqc: [] = result;
    const locList9 = listqc.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { locList9 };
  }
  //所属部门]
  deptlist: any = [];
  //materialFromList: any = '';
  @MutationAction
  async getdeptFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'oa_sqbm',
      },
    });
    console.log(result);
    const listqc: [] = result;
    const deptlist = listqc.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { deptlist };
  }
  //异常范围
  abnormallist: any = [];
  //materialFromList: any = '';
  @MutationAction
  async getabnormallistFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'oa_cq_f',
      },
    });
    console.log(result);
    const listqc: [] = result;
    const abnormallist = listqc.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { abnormallist };
  }
  //是否需要主管
  ischecklist: any = [];
  @MutationAction
  async getischecklistFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'need_manager_check',
      },
    });
    //console.log(result);
    const listischeck: [] = result;
    const ischecklist = listischeck.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { ischecklist };
  }
  //是否供应商
  isclistsupplierlist: any = [];
  @MutationAction
  async getsupplierlistFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'supplier_issues',
      },
    });
    //console.log(result);
    const listsupplier: [] = result;
    const isclistsupplierlist = listsupplier.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { isclistsupplierlist };
  }
  SSCJlist: any = [];
  @MutationAction
  async getSSCJlistFromListPDA() {
    const result: any = await http.get(url.lanjuquality.Materialinspection.getDictData, {
      //loginName: session.loginName,
      params: {
        dictType: 'oa_sccj',
      },
    });
    //console.log(result);
    const listSSCJ: [] = result;
    const SSCJlist = listSSCJ.map((item: any) => ({
      label: item.ymdTypeName,
      value: item.ymdType,
    }));
    return { SSCJlist };
  }
  //合并
  togetherTaskcode: any = '';
  togetherTaskmsg: any = '';
  @MutationAction
  async mergeCheckTask(params: any) {
    const result: any = await http.post(url.lanjuquality.Materialinspection.togetherTask, {
      recordId: params,
      factoryCode: session.PoolName,
    });
    const togetherTaskcode = result.code;
    const togetherTaskmsg = result.msg;
    return {
      togetherTaskcode,
      togetherTaskmsg,
    };
  }
}

export default getModule(Materialinspection);
