184 lines
4.2 KiB
JavaScript
184 lines
4.2 KiB
JavaScript
// pages/candidate/index.js
|
|
const api = require("../../utils/request.js");
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
search:null,
|
|
candidates:[],
|
|
query: {
|
|
page: 1,
|
|
limit: 10
|
|
},
|
|
query2: {
|
|
page: 1,
|
|
limit: 10000
|
|
},
|
|
currentTab: 'tab1' ,// 默认选中 Tab 1
|
|
consumers: [
|
|
],
|
|
searchQuery: '',
|
|
level:{4:'初级工',3:'中级工',2:'高级工',1:'技师',0:'高级技师'},
|
|
},
|
|
switchTab: function(event) {
|
|
const tab = event.currentTarget.dataset.tab;
|
|
this.setData({
|
|
currentTab: tab
|
|
});
|
|
},
|
|
onSearchInput: function (event) {
|
|
const query = event.detail.value.toLowerCase();
|
|
console.log(query)
|
|
if(query=="")
|
|
{
|
|
this.getList2();
|
|
}
|
|
|
|
const consumers = this.data.consumers.filter(item => {
|
|
return Object.values(item).some(value =>
|
|
String(value).toLowerCase().includes(query)
|
|
);
|
|
});
|
|
this.setData({ consumers });
|
|
|
|
},
|
|
|
|
onLoad: function () {
|
|
this.getList2();
|
|
|
|
},
|
|
onShow: function () {
|
|
this.getList();
|
|
},
|
|
getList: function() {
|
|
wx.showLoading({
|
|
title: '正在加载...',
|
|
})
|
|
api.request('/crm/candidate/my/', 'GET').then(res=>{
|
|
wx.hideLoading()
|
|
this.setData({
|
|
candidates:res.data,
|
|
})
|
|
}).catch(
|
|
wx.hideLoading()
|
|
)
|
|
},
|
|
//获证信息统计,查询所有证书
|
|
getList2: function() {
|
|
var that = this
|
|
wx.showLoading({
|
|
title: '正在加载...',
|
|
})
|
|
api.request('/crm/candidate/', 'GET',that.data.query2).then(res => {
|
|
if (that.data.query2.page == 1) {
|
|
that.data.results = res.data.results
|
|
} else {
|
|
that.data.results = that.data.results.concat(res.data.results)
|
|
}
|
|
this.setData({
|
|
consumers:res.data.results,
|
|
})
|
|
|
|
}).catch(
|
|
wx.hideLoading()
|
|
)
|
|
},
|
|
|
|
//获证信息统计点击弹窗展示详细信息
|
|
showModal: function (event) {
|
|
const item = event.currentTarget.dataset.item;
|
|
console.log(item)
|
|
// level:{2:'初级工',1:'中级工',0:'高级工',4:'技师',3:'高级技师'},
|
|
let level = ""
|
|
switch(item.opllevel){
|
|
case 0:
|
|
level='高级技师';
|
|
break;
|
|
case 1:
|
|
level='技师';
|
|
break;
|
|
case 2:
|
|
level='高级工';
|
|
break;
|
|
case 3:
|
|
level='中级工';
|
|
break;
|
|
default:
|
|
level='初级工';
|
|
|
|
}
|
|
wx.showModal({
|
|
title: '基本信息',
|
|
content: `姓名: ${item.consumer_name} \n 性别: ${item.gender}\n 职业方向: 地坪铺装工 \n职业等级: ${level}\n 获证时间: ${item.issue_date}\n 所在企业: ${item.company_name}`,
|
|
showCancel: false,
|
|
});
|
|
},
|
|
bindinput: function(e){
|
|
this.setData({
|
|
search:e.detail.value
|
|
})
|
|
},
|
|
copyUrl: function(e){
|
|
wx.setClipboardData({
|
|
data: e.currentTarget.dataset.url,
|
|
success: function (res) {
|
|
wx.showToast({
|
|
title: '复制成功,可前往自带浏览器粘贴访问',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
})
|
|
},
|
|
search: function() {
|
|
// debugger;
|
|
if(this.data.search!==null&&this.data.search!==''){
|
|
var data = {search:this.data.search};
|
|
wx.showLoading({
|
|
title: '查询中..',
|
|
mask:true
|
|
})
|
|
api.request('/crm/candidate/', 'GET', data).then(res => {
|
|
this.setData({
|
|
candidates:res.data.results
|
|
})
|
|
wx.hideLoading()
|
|
}).catch(e=>{
|
|
wx.hideLoading()
|
|
})
|
|
// api.request('/crm/consumer/realinfo/', 'POST', data).then(res=>{
|
|
// })
|
|
}else{
|
|
wx.showToast({
|
|
title: '请填写正确的身份证号',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
}
|
|
},
|
|
toDetail: function(e){
|
|
|
|
var url = e.currentTarget.dataset.url;
|
|
var id = e.currentTarget.dataset.id;
|
|
console.log(id)
|
|
getApp().globalData.candidate_url = url
|
|
wx.navigateTo({
|
|
url: 'detail?id='+id,
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
|
|
}
|
|
}) |