//import * as WxJsApi from '@/utils/wxJsApi.js' import * as API from '@/apis/job/index.js' import * as API_common from '@/apis/common.js' import RecruitmentItem from '@/components/job/RecruitmentItem.vue' export default { data() { return { nochange:false, ing:false, myfocus:true, key:'', record:[], result:[], selectShow:false, selectShowTree:false, selectShowIndex:0, selectIndexList:[[],[],[],[]], pageIndex:1, recordsTotal:0, popupList:[], back:false, src:"", isReady:false, whereDataInit:[ { value:"", name:"月薪范围", label:"月薪范围" },{ value:"", name:"工作经验", label:"工作经验" },{ value:"", label:"学历", name:"学历", },{ value:"", name:"招聘岗位", label:"招聘岗位" } ], whereData:[ ], dataList:[ "b5e4a52a-9f89-4e3b-976f-79207a40587d",//月薪 "7724a25f-a781-46f4-b048-d9812108ff02" , //工作经验 "c1887d9d-e945-4875-be3f-905195cd8a8e"//学历 ], dataMap:{}, init:false, } }, components: { RecruitmentItem }, onReachBottom() { if(this.result.length { var list=response.data; var tree=[]; var map=new Map(); var max=0; var all={ extra:0, name:"全部岗位" } tree.push(all); list.forEach((item)=>{ if(item.level>max){ max=item.level; } if(item.parentId){ }else{ item.extra=tree.length, tree.push(item); } map.set(item.id,item); this.setChildren(item,max,item); }) this.setChildren(all,max,all); list.forEach((item)=>{ if(item.parentId){ var obj=map.get(item.parentId); item.extra=obj.children.length obj.children.push(item) } }) this.popupList=tree; uni.hideLoading() // .map((item)=>{ // return item.name; // }) }).catch(error => { uni.showToast({ title:error }) }) }, confirmSelect(obj){ if(obj[0].value==undefined){ obj[0].value=""; } var index=this.selectShowIndex; var list=[]; if(obj[0].extra){ list.push(obj[0].extra); }else{ list.push(0); } this.selectIndexList[index]=list; this.whereData[index]=obj[0]; this.submit() }, confirmSelectTree(obj){ console.log(obj) var list=[]; for(var i in obj){ if(i==0){ this.whereData[3]=obj[i]; } if(obj[i].extra){ list.push(obj[i].extra); }else{ list.push(0); } if(obj[i].value){ this.whereData[3]=obj[i]; } } this.selectIndexList[3]=list; this.submit() }, setChildren(item,i,it){ if(i>1){ var i2=i-1; var myit={extra:0} it.children=[myit] return this.setChildren(item,i2,myit); }else{ return item } }, getDataMap(){ uni.showLoading({ title: '加载中' }); API_common.getData(this.dataList.join()).then((res) => { this.dataMap=res.data; for(var key in this.dataMap){ this.dataMap[key].forEach((item,index)=>{ item.extra=(index+1); }) } this.getScreenList(); }).catch(error => { uni.showToast({ title:error }) }) }, gotoLine(item){ uni.redirectTo({ url:'/pages/route/index?id='+item.id+"&downid="+item.stationId }) }, setHistory(){ if(!this.key){ return } //搜索记录保存 var sz=this.carhelp.get("searchHistory"); if(!sz){ sz=[]; } var temp =[]; //去重 ,后插入的,排队到最前面 if(sz.length){ for(var i in sz){ if(i==0){ temp.push(this.key); } if(sz[i]==this.key){ continue; } temp.push(sz[i]); if(temp.length==10){ break } } }else{ temp.push(this.key); } this.record=temp; this.carhelp.set("searchHistory",temp); }, clearBtn(){ this.carhelp.set("searchHistory",[]); this.record=[]; //this.$refs.common.alert("搜索内容已清空") uni.showToast({ icon:'none' ,title:"搜索内容已清空" }) }, change(){ if(this.nochange){ this.nochange=false; return } this.ing=false; document.getElementsByTagName('uni-page-wrapper')[0].style="background-color: #ffffff;" if(this.key==""){ this.result=[] } }, noSearch(){ this.ing=true; this.whereData={ ...this.whereDataInit } this.key=""; this.submit() }, myLoadmore(){ this.submit(true); }, submit( bl){ this.setHistory(); if(bl){ this.pageIndex++; }else{ this.pageIndex=1; } var form= { title:this.key, pageIndex:this.pageIndex, pageSize:20, monthlySalary:this.whereData[0].value, workExperience:this.whereData[1].value, education:this.whereData[2].value, recruitmentPosition:this.whereData[3].value, }; // this.ing=true; // this.result=[{}] // this.$forceUpdate() // return; API.getRecruitmentList(form).then((res) => { this.ing=true; if(bl){ this.result=[ ...this.result, ...res.data.data ]; }else{ this.result=res.data.data; } this.recordsTotal=res.data.recordsTotal document.getElementsByTagName('uni-page-wrapper')[0].style="background-color: #f7f7f7;" }).catch(error => { uni.showToast({ title:error }) }) } },onReady(){ this.record=this.carhelp.get("searchHistory"); this.getDataMap(); this.isReady=true; if(this.init||this.key||!this.myfocus ){ this.submit() } },onShow(){ if(this.isReady){ } },computed:{ getShowDataList(){ var list=this.dataMap[this.dataList[this.selectShowIndex]]; if(list){ var re=[ ...list ] re.unshift( this.whereDataInit[this.selectShowIndex] ) return re; }else{ return []; } }, } }