123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- var app = getApp()
- var that;
- Page({
- data: {
- userInfo: {},
- type: 1,//判断那个列表进入 1阶段排名,2累计排名,3自定义排名
- point: 0,
- base_point: 0,//基础分
- service_point: 0, //工龄发
- formData: {
- page: 1,
- page_size: 20,
- dc_status: JSON.stringify([1]),
- order_key: 'create_time',
- order_type: 'desc',
- pt_id: "3"
- },
- typesIndex: 0,//条件选择
- types: [
- { id: 0, name: '按最新事件时间排序' },
- { id: 1, name: '按积分由高到低排序' },
- { id: 2, name: '按积分由低到高排序' },
- ],
- },
- onLoad(e) {
- console.log(JSON.parse(e.data))
- that = this;
- dd.setNavigationBar({ title: "积分明细" });
- let data = JSON.parse(e.data);
- let newObj = {};
- this.setData({type:data.type})
- if (data.type == 1) {
- let formData = this.data.formData;
- let parameter = {
- pt_id: data.pt_id || 0,
- dept_ids: data.dept_id || 0,
- rule_id: data.rule || 0,
- employee_ids: data.item.employee_id,
- };
- if (data.dataType == '1') {
- parameter.year = data.year
- } else if (data.dataType == '2' || data.dataType == '4') {
- parameter.start_day = data.start_day
- parameter.end_day = data.end_day
- } else {
- parameter.month = data.month
- }
- Object.assign(newObj, formData, parameter);//合并对象
- this.setData({
- userInfo: data.item,
- formData: newObj
- })
- } else if (data.type == 2) {
- this.setData({
- userInfo: data.item,
- 'formData.dept_ids': data.dept_id || 0,
- 'formData.employee_ids': data.item.employee_id,
- })
- this.getUserInfo(data.item.employee_id)
- } else {
- if (data.date_interval == '1') {//统计时间区间只有type为custom时有值 1-月度 2-季度 3-年度
- this.setData({
- userInfo: data.item,
- 'formData.month': data.month.slice(0, 4)+'-'+data.month.slice(4),
- 'formData.employee_ids': data.item.employee_id,
- 'formData.item_id':data.items.toString()
- })
- }else if(data.date_interval == '3'){
- this.setData({
- userInfo: data.item,
- 'formData.year': data.month,
- 'formData.employee_ids': data.item.employee_id,
- 'formData.item_id':data.items.toString()
- })
- }else{
- this.setData({
- userInfo: data.item,
- 'formData.start_day': data.start_day,
- 'formData.end_day': data.end_day,
- 'formData.employee_ids': data.item.employee_id,
- 'formData.item_id':data.items.toString()
- })
- }
- }
- console.log(this.data.userInfo)
- this.getData();
- },
- getUserInfo(id){
- app.$get('/api/employee/detail',{target:id}).then(res => {
- this.setData({
- base_point:res.data.data.user.site_config.base_point,//基础分
- service_point:res.data.data.user.point_config.service_point //工龄发
- })
- })
- },
- onShareAppMessage() {
- return {
- title: '累计B分排名',
- desc: '积分排名有变动了,快来看看!',
- path: 'pages/statistics/B_ranking/B_ranking'
- };
- },
- onShow() {
- // if (app.globalData.userData) {
- // if (that.data.page == 1) {
- // dd.hideLoading();
- // that.getData();
- // }
- // } else {
- // app.login(app.globalData.corpId, function (is) {
- // if (is) {
- // if (that.data.page == 1) {
- // dd.hideLoading();
- // that.getData();
- // }
- // } else {
- // dd.reLaunch({
- // url: '../../noJurisdiction/noJurisdiction'
- // })
- // }
- // },function(){})
- // }
- },
- open2() {
- if (this.data.formData.pt_id == '2') {//A分
- dd.navigateTo({
- url: '../../workbench/statistics_A/statistics_A?employee_id=' + that.data.userInfo.employee_id + '&name=' + that.data.userInfo.employee_name
- })
- } else {
- dd.navigateTo({
- url: '../../workbench/statistics_B/statistics_B?employee_id=' + that.data.userInfo.employee_id + '&name=' + that.data.userInfo.employee_name
- })
- }
- },
- getData(is) {
- app.$get('api/integral/statistics/integral', this.data.formData).then((res) => {
- var data = res.data.data.list;
- data.map((item) => {
- item.ptObj = app.getTypesItem(item.pt_id);
- })
- if (is) {
- if (data.length == 0) {
- this.setData({
- isData: true
- })
- return;
- }
- var list = that.data.list;
- this.setData({
- list: list.concat(data)
- })
- } else {
- this.setData({ list: [] });
- this.setData({
- list: data,
- isData: false
- })
- }
- })
- },
- //选择事件来源
- bingIntegralType(e) {
- if (e.detail.value == 0) {
- this.setData({
- 'formData.order_key': 'create_time',
- 'formData.order_type': 'desc',
- });
- }
- if (e.detail.value == 1) {
- this.setData({
- 'formData.order_key': 'point',
- 'formData.order_type': 'desc',
- });
- }
- if (e.detail.value == 2) {
- this.setData({
- 'formData.order_key': 'point',
- 'formData.order_type': 'asc',
- });
- }
- this.setData({
- typesIndex: e.detail.value,
- 'formData.page': 1,
- });
- this.getData();
- },
- //上啦加载
- onScrollToLower() {
- if (!that.data.isData) {
- this.setData({ 'formData.page': ++that.data.formData.page })
- this.getData(true);
- }
- },
- //打开兴趣
- openDetail(e) {
- var item = e.target.dataset.item;
- dd.navigateTo({
- url: '../prizeBuckleDetail/prizeBuckleDetail?id=' + item.id
- })
- },
- });
|