index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. var app = getApp();
  2. var that;
  3. var chart1;
  4. var chart2;
  5. var chart3;
  6. var AParse = require('../../../Component/aParse/aParse.js');
  7. import 'dingtalk-jsapi/entry/union';
  8. import { setCache, getCache } from '../../../utils/util'
  9. import { contactAdminToUseApp } from 'dingtalk-design-libs';
  10. import moment from 'moment' // 时间库
  11. Page({
  12. data: {
  13. headDayBs: {},
  14. userData: {},
  15. isBh: false,
  16. chartData: [],//折线图数据
  17. pieData: [1],//饼型图数据
  18. isAdministrator: app.globalData.isAdministrator,//是否管理员角色
  19. rankingTotal: 0,
  20. rankingList: [],
  21. getRole_four: app.globalData.isCreator,//是否系统管理员
  22. setECharts: [],//柱形图数据
  23. pieTotal: 1,
  24. total: '',
  25. menuList: [
  26. { name: '审批', imgUrl: '../../../image/sp.png', url: '../my_approve/my_approve', code: 'creator admin' },
  27. { name: '任务', imgUrl: '../../../image/a7.png', url: '../../statistics/my_task/my_task', code: 'admin employee' },
  28. { name: '复核', imgUrl: '../../../image/fuhe.png', url: '../review/review', code: 'creator admin' },
  29. { name: '奖扣B分', imgUrl: '../../../image/point_entry.png', url: '../jk_B/jk_B?type=B', code: 'creator admin' },
  30. { name: '指派任务', imgUrl: '../../../image/my_publish.png', url: '../../statistics/assaign/assaign', code: 'creator admin' },
  31. { name: '申请积分', imgUrl: '../../../image/a_apply.png', url: '../apply/apply', code: 'admin employee' },
  32. { name: '奖扣A分', imgUrl: '../../../image/a_entry.png', url: '../jk_B/jk_B?type=A', code: 'creator admin' },
  33. { name: '领任务', imgUrl: '../../../image/task_hall.png', url: '../../statistics/getTask/getTask', code: 'admin employee' },
  34. { name: '发布悬赏', imgUrl: '../../../image/caback6.png', url: '../../statistics/offerAreward/offerAreward', code: 'creator admin' },
  35. // { name: '发放奖票', imgUrl: '../../../image/add_ticket.png', url: '../../statistics/grant/grant', code: 'creator admin' },
  36. { name: '全部', imgUrl: '../../../image/all2.png', url: 'all', code: 'creator admin employee' },
  37. ],
  38. isUpdate: false,
  39. title: '',//系统消息标题
  40. textId: '',//系统消息ID
  41. isSubject: false,//判断是否是个人版进入
  42. mainCorpId: '',//如果是个人版,这个企业ID是登录者所在的企业ID,不是钉钉那边提供的隐藏企业ID
  43. noticeTitle:'',
  44. isGz:false,
  45. islog:true,
  46. announcementList:[],
  47. isShowYy:false,
  48. isShowAn:true,
  49. selectPlItem:{},
  50. },
  51. onLoad() {
  52. that = this;
  53. chart1, chart2, chart3 = '';
  54. },
  55. onShow() {
  56. if (app.globalData.userData) {
  57. dd.setNavigationBar({ title: app.globalData.userData.name });
  58. that.getUserData();
  59. that.getGg();
  60. that.getNotice();
  61. that.opneWebSocket();
  62. let isShowYy=false;
  63. app.globalData.userData.employee_detail.role_list.forEach(item=>{
  64. if(item.name=='admin'||item.name=='creator'|| item.name == 'point_manager'){
  65. isShowYy=true;
  66. }
  67. })
  68. that.setData({
  69. isAdministrator: app.globalData.isAdministrator,
  70. getRole_four: app.globalData.isCreator,
  71. isSubject: app.globalData.userData.is_personal == 1 ? true : false,
  72. mainCorpId: app.globalData.userData.main_corp_id,
  73. isShowYy:isShowYy,
  74. isShowAn:getCache('isShowAn')? false:true,
  75. })
  76. if(that.data.isShowYy&&that.data.isShowAn){
  77. that.getAnnouncement();
  78. }
  79. if(!getCache('init_rule_check')){
  80. app.globalData.userData.init_rule_check? '':that.setData({ isGz: true})
  81. }
  82. if (app.globalData.isCreator) {
  83. that.setMenuList("creator");
  84. } else if (app.globalData.isAdministrator) {
  85. that.setMenuList("admin");
  86. } else if (!app.globalData.isCreator && !app.globalData.isAdministrator) {
  87. that.setMenuList("employee");
  88. }
  89. } else {
  90. app.login(app.globalData.corpId,function (is) {
  91. if (is) {
  92. dd.setNavigationBar({ title: app.globalData.userData.name });
  93. if (app.globalData.isCreator) {
  94. that.setMenuList("creator");
  95. } else if (app.globalData.isAdministrator) {
  96. that.setMenuList("admin");
  97. } else if (!app.globalData.isCreator && !app.globalData.isAdministrator) {
  98. that.setMenuList("employee");
  99. }
  100. that.getUserData();
  101. that.getGg();
  102. that.getNotice();
  103. that.opneWebSocket();
  104. if(!getCache('init_rule_check')){
  105. app.globalData.userData.init_rule_check? '':that.setData({ isGz: true})
  106. }
  107. let isShowYy=false;
  108. app.globalData.userData.employee_detail.role_list.forEach(item=>{
  109. if(item.name=='admin'||item.name=='creator'|| item.name == 'point_manager'){
  110. isShowYy=true;
  111. }
  112. })
  113. that.setData({
  114. isAdministrator: app.globalData.isAdministrator,
  115. getRole_four: app.globalData.isCreator,
  116. isSubject: app.globalData.userData.is_personal == 1 ? true : false,
  117. mainCorpId: app.globalData.userData.main_corp_id,
  118. isShowYy:isShowYy,
  119. isShowAn:getCache('isShowAn')? false:true,
  120. })
  121. if(that.data.isShowYy&&that.data.isShowAn){
  122. that.getAnnouncement();
  123. }
  124. } else {
  125. dd.reLaunch({
  126. url: '../../noJurisdiction/noJurisdiction'
  127. })
  128. }
  129. },function(){},true)
  130. }
  131. },
  132. closeAn(){
  133. setCache('isShowAn',true);
  134. this.setData({
  135. isShowYy:false,
  136. })
  137. },
  138. openaN(e){
  139. var index = e.target.dataset.index;
  140. dd.navigateTo({
  141. url: '../noticeDetailTow/noticeDetailTow?id=' + this.data.announcementList[index].id+'&index='+index
  142. })
  143. },
  144. getAnnouncement(){
  145. app.$get2("api/announcement/list",{type:3}).then((res) => {
  146. let list=res.data.data.list;
  147. that.setData({ announcementList:list})
  148. })
  149. },
  150. gettrees(fn) {
  151. app.$get2("api/integral/rule/trees", {cycle_type: 3 }).then((res)=>{
  152. var rule_tree = res.data.data.rule_tree
  153. if(rule_tree.length==0&&app.globalData.isCreator){
  154. fn(false)
  155. }else{
  156. fn(true)
  157. }
  158. })
  159. },
  160. opneWebSocket() {
  161. let data={type:"es_info",recorder_id:app.globalData.userData.id,month:app.globalData.month};
  162. app.globalData.socketApi.sendData(data, (res) => {
  163. if (res.code == 1&&res.type=='es_info') {
  164. let data = res.result;
  165. var task = data.task;
  166. var ratio = task.ratio.enable== 0 ? '-' : `${task.ratio.reward_ratio}:1`
  167. var target_ratio = task.ratio.target <= 0 ? '0:1' : `${task.ratio.target}:1`
  168. data.ratio = {
  169. ratio: ratio,
  170. target_ratio: target_ratio
  171. }
  172. that.getLsit();
  173. that.setData({
  174. userData: data
  175. })
  176. app.globalData.socketApi.closewebsocket();
  177. }
  178. }, true);
  179. },
  180. openWs(){
  181. if(!that.data.islog){
  182. return false;
  183. }
  184. that.setData({
  185. islog:false
  186. })
  187. app.globalData.socketApi.sendData({type:'init_rule'}, function(e){
  188. that.setData({islog:true})
  189. setCache('init_rule_check',true)
  190. if (e.type == 'init_rule') {
  191. if(e.code==1&&e.result.done){
  192. that.setData({ isGz:false})
  193. app.globalData.showToast('已导入');
  194. app.globalData.socketApi.closewebsocket();
  195. }else{
  196. // app.globalData.showToast(e.msg);
  197. }
  198. }
  199. });
  200. },
  201. openWs2(){
  202. app.$post("api/integral/employee/init_rule_notice").then((res) => {
  203. app.globalData.showToast('已发送通知');
  204. setCache('init_rule_check',true)
  205. that.setData({ isGz:false})
  206. }, (err) => { })
  207. },
  208. openGly() {
  209. contactAdminToUseApp({ id: '55493', corpId: that.data.mainCorpId })
  210. .catch((err) => {
  211. // 入参不正确,或者遇到技术异常时才会进入这个链路
  212. console.error(err);
  213. })
  214. },
  215. openUrl(e) {
  216. var url = e.target.dataset.url;
  217. if (url == 'all') {
  218. dd.switchTab({
  219. url: '../../statistics/index/index'
  220. })
  221. return
  222. }
  223. dd.navigateTo({
  224. url: url
  225. })
  226. },
  227. openUrl2() {
  228. dd.navigateTo({
  229. url: '../noticeDetail/noticeDetail?id=' + that.data.noticeId
  230. })
  231. },
  232. openText() {
  233. that.colseText();
  234. dd.navigateTo({
  235. url: '../../deploy/upgradeDetail/upgradeDetail?id=' + that.data.textId
  236. })
  237. },
  238. //获取缓存的公告
  239. getReviewerObj(fuc) {
  240. dd.getStorage({
  241. key: 'isShowMessage',
  242. success: function (res) {
  243. if (res.data) {
  244. fuc(res.data);
  245. } else {
  246. fuc({});
  247. }
  248. }
  249. });
  250. },
  251. // 获取公告
  252. getNotice() {
  253. app.$get2("api/information/index", { page: 1, page_size: 1 }).then((res) => {
  254. let data= res.data.data;
  255. that.setData({
  256. noticeTitle: data[0]? data[0].name:'',
  257. noticeId: data[0]? data[0].id:'',
  258. });
  259. })
  260. },
  261. // 获取公告
  262. getGg() {
  263. if (that.data.title) {
  264. return
  265. }
  266. app.$get2("api/announcement/list", { page: 1, page_size: 1 }).then((res) => {
  267. var data = res.data.data.list[0];
  268. AParse.aParse('article', 'html', data.focus, that, 5);
  269. that.setData({
  270. title: data.title,
  271. textId: data.id
  272. });
  273. that.getReviewerObj(function (res) {
  274. if (res != data.id) {
  275. that.colseText();
  276. dd.setStorage({
  277. key: 'isShowMessage',
  278. data: data.id,
  279. });
  280. }
  281. })
  282. })
  283. },
  284. setMenuList(str) {
  285. var arr = [];
  286. that.data.menuList.forEach(item => {
  287. if(item.name=='复核'){
  288. app.globalData.userData.employee_detail.role_list.some(e=>{
  289. if(e.name=='admin'||e.name=='creator'|| e.name == 'point_manager'){
  290. arr.push(item)
  291. return true;
  292. }
  293. })
  294. }else{
  295. if (item.code.indexOf(str) >= 0) {
  296. arr.push(item)
  297. }
  298. }
  299. })
  300. that.setData({
  301. menuList: arr
  302. })
  303. },
  304. colseText() {
  305. this.setData({ isUpdate: !this.data.isUpdate })
  306. },
  307. showText() {
  308. this.setData({ isBh: !this.data.isBh })
  309. },
  310. openViewRanking() {
  311. var item = this.data.selectPlItem
  312. var url = '';
  313. if (item.type == 'normal') {
  314. url = '../../statistics/sectionRanking/sectionRanking';
  315. } else if (item.type == 'all') {
  316. url = '../../statistics/B_ranking/B_ranking';
  317. } else {
  318. url = '../../statistics/C_ranking/C_ranking?id=' + item.target_id + '&name=' + item.group_name + '&date_interval=' + item.date_interval;
  319. }
  320. dd.navigateTo({
  321. url: url
  322. })
  323. },
  324. //跳转
  325. openView(e) {
  326. var index = e.target.dataset.index - 1;
  327. var urls;
  328. if (e.target.dataset.item) {
  329. urls = [
  330. { url: '../statistics_B/statistics_B', query: '' },
  331. { url: '../statistics_A/statistics_A', query: '' },
  332. { url: '../jk_B/jk_B', query: 'type=B' },
  333. { url: '../jk_B/jk_B', query: 'type=A' },
  334. { url: '../apply/apply', query: '' },
  335. { url: '../my_approve/my_approve', query: '' },
  336. { url: '../prize_buckle/prize_buckle', query: '' },
  337. { url: '../../statistics/prizeBuckleDetail/prizeBuckleDetail', query: 'id=' + e.target.dataset.item.id },
  338. { url: '../../statistics/integralEvent/integralEvent', query: '' },
  339. { url: '../../statistics/userRamking/userRamking', query: '' },
  340. { url: '../../statistics/glz_execute/glz_execute', query: '' },
  341. ];
  342. } else {
  343. urls = [
  344. { url: '../statistics_B/statistics_B', query: '' },
  345. { url: '../statistics_A/statistics_A', query: '' },
  346. { url: '../jk_B/jk_B', query: 'type=B' },
  347. { url: '../jk_B/jk_B', query: 'type=A' },
  348. { url: '../apply/apply', query: '' },
  349. { url: '../my_approve/my_approve', query: '' },
  350. { url: '../prize_buckle/prize_buckle', query: '' },
  351. { url: '../../statistics/prizeBuckleDetail/prizeBuckleDetail', query: '' },
  352. { url: '../../statistics/integralEvent/integralEvent', query: '' },
  353. { url: '../../statistics/userRamking/userRamking', query: '' },
  354. { url: '../../statistics/glz_execute/glz_execute', query: '' },
  355. ];
  356. }
  357. dd.navigateTo({
  358. url: urls[index].url + '?' + urls[index].query
  359. })
  360. },
  361. //则线图
  362. onInitChart(F2, config) {
  363. chart1 = new F2.Chart(config);
  364. chart1.source(that.data.chartData, {
  365. date: { tickCount: 4 }
  366. });
  367. chart1.tooltip({
  368. showCrosshairs: true,
  369. showItemMarker: true,
  370. onShow: function onShow(ev) {
  371. const items = ev.items;
  372. items[0].name = "月份:" + items[0].origin.date;
  373. items[0].value = "分值:" + items[0].value;
  374. }
  375. });
  376. chart1.axis('date', {
  377. label: function label(text, index, total) {
  378. const textCfg = {};
  379. if (index === 0) {
  380. textCfg.textAlign = 'left';
  381. } else if (index === total - 1) {
  382. textCfg.textAlign = 'right';
  383. }
  384. return textCfg;
  385. }
  386. });
  387. chart1.line().position('date*value');
  388. chart1.point().position('date*value').style({
  389. stroke: '#fff',
  390. lineWidth: 1
  391. });
  392. chart1.render();
  393. return chart1;
  394. },
  395. //饼型图
  396. onInitChart2(F2, config) {
  397. chart2 = new F2.Chart(config);
  398. chart2.source(that.data.pieData, {
  399. percent: {
  400. formatter: function formatter(val) {
  401. return val * 100 + '%';
  402. }
  403. }
  404. });
  405. chart2.legend({
  406. position: 'right',
  407. itemFormatter: function itemFormatter(val, index) {
  408. var str = '';
  409. that.data.pieData.forEach(item => {
  410. if (item.name == val) {
  411. str = val + ' ' + item.point + '分';
  412. }
  413. })
  414. return str;
  415. }
  416. });
  417. chart2.tooltip(false);
  418. chart2.coord('polar', {
  419. transposed: true,
  420. radius: 0.85
  421. });
  422. chart2.axis(false);
  423. chart2.interval()
  424. .position('a*percent')
  425. .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0'])
  426. .adjust('stack')
  427. .style({ lineWidth: 1, stroke: '#fff', lineJoin: 'round', lineCap: 'round' }).animate({
  428. appear: { duration: 1200, easing: 'bounceOut' }
  429. });
  430. chart2.render();
  431. // 注意:需要把chart return 出来
  432. // that.getLsit();
  433. return chart2;
  434. },
  435. //柱形图
  436. onInitChart3(F2, config) {
  437. chart3 = new F2.Chart(config);
  438. chart3.source(that.data.setECharts, {
  439. date: { tickCount: 5 }
  440. });
  441. chart3.axis('field', {
  442. grid: {
  443. lineDash: null,
  444. stroke: '#e8e8e8',
  445. lineWidth: 1
  446. }
  447. });
  448. chart3.legend(false);
  449. chart3.interval().position('name*val').color('type', (type) => { // 通过回调函数
  450. if (type === '奖分') {
  451. return 'l(90) 0:#4ECFFF 1:#26A2FF';
  452. }
  453. return 'l(90) 0:#F8C748 1:#F2A640';
  454. }).adjust({
  455. type: 'dodge',
  456. marginRatio: 0.05 // 设置分组间柱子的间距
  457. });
  458. chart3.render()
  459. return chart3;
  460. },
  461. //获取统计数据
  462. getLsit() {
  463. var date1 = new Date();
  464. var date2 = new Date(date1);
  465. date2.setDate(date1.getDate() - 30);
  466. var start_date = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate();
  467. var incident = app.$get2("api/integral/statistics/b", { employee_id: 0, start_date: start_date, end_date: app.globalData.day, show_type: '1' });
  468. Promise.all([incident]).then(resArr => {
  469. if (resArr[0].data.code == 1) {
  470. const { b, chart, good, bad } = resArr[0].data.data
  471. const points = chart.reward.map((rewardItem, index) => {
  472. return { date: rewardItem.date, value: rewardItem.point - (chart.deduction[index].point || 0) }
  473. })
  474. chart1.changeData(points);
  475. that.setData({
  476. data_b: b,
  477. data_good: good,
  478. data_bad: bad,
  479. });
  480. }
  481. }).catch(e => {
  482. console.error(e)
  483. })
  484. },
  485. //获取个人统计
  486. getUserData() {
  487. var http2 = app.$get2("api/integral/statistics/integral", {
  488. month: app.globalData.month,
  489. page: 1,
  490. page_size: 5,
  491. order_key:'update_time',
  492. employee_ids: app.globalData.isCreator ? '' : app.globalData.userData.id
  493. })
  494. var http3 = app.$get2("api/integral/review/list", { type: 'waiting', source_type: 0, page: 1, pt_id: 0 })
  495. var ranking = app.$get2('api/integral/statistics/ranking/list', { page: 1, page_size: 100 })// 获取排行榜
  496. var task = app.$get2('api/integral/statistics/task/pie', { month: app.globalData.month })// 管理者奖扣任务柱状图
  497. var work = app.$get2('api/integral/work/list', { status: 'running', page: 1, pt_id: 0, source_type: 0 })// 管理者奖扣任务柱状图
  498. var headDayBs = app.$get2("api/integral/statistics", { employee_id: app.globalData.userData.id, day: app.globalData.day },'application/vnd.test.v3+json')//获取个人统计-当天B分 - V2
  499. var config = app.$get2('api/integral/site/config',{})// 系统配置
  500. Promise.all([http2, http3, ranking, task, work, headDayBs,config]).then(function (values) {
  501. if (values[0]) {
  502. let data = values[0].data.data.list;
  503. data.map((item) => {
  504. item.ptObj = app.getTypesItem(item.pt_id);
  505. })
  506. that.setData({
  507. incidentLsit: data,
  508. incidentLsitTotal: values[0].data.data.total
  509. })
  510. }
  511. if (values[1]) {
  512. let data = values[1].data.data;
  513. that.setData({
  514. total: data.total
  515. })
  516. }
  517. if (values[2]) {
  518. let list=values[2].data.data.list;
  519. that.setData({
  520. rankingList: list,
  521. rankingTotal: values[2].data.data.total
  522. })
  523. if(that.data.selectPlItem.group_name){
  524. list.some(item=>{
  525. if(item.target_id==0&&that.data.selectPlItem.group_name==item.group_name){
  526. that.setData({
  527. selectPlItem:item
  528. })
  529. return true
  530. }
  531. if(item.target_id==that.data.selectPlItem.target_id){
  532. that.setData({
  533. selectPlItem:item
  534. })
  535. return true
  536. }
  537. })
  538. }else{
  539. that.setData({
  540. selectPlItem:values[2].data.data.list[0]
  541. })
  542. }
  543. that.tabPositions({target:{dataset:{item:that.data.selectPlItem}}});
  544. }
  545. if (values[3]) {
  546. if (that.data.isAdministrator) {
  547. var data = values[3].data.data.list
  548. if (data.length > 5) {
  549. data.pop()
  550. }
  551. that.setData({
  552. pieTotal: values[3].data.data.total
  553. })
  554. if (that.data.pieTotal != 0) {
  555. var employees = [];
  556. data.forEach((item) => {
  557. var obj = [{
  558. type: '奖分',
  559. name: item.employee_name,
  560. val: item.reward
  561. }, {
  562. type: '扣分',
  563. name: item.employee_name,
  564. val: item.deduction
  565. }]
  566. employees.push(...obj)
  567. })
  568. // chart3.changeData(employees);
  569. }
  570. }
  571. }
  572. if (values[4]) {
  573. let data = values[4].data.data;
  574. that.setData({
  575. workTotal: data.total
  576. })
  577. }
  578. if(values[5]){
  579. let data = values[5].data.data;
  580. that.setData({
  581. headDayBs:data
  582. })
  583. }
  584. if(values[6]){
  585. let data = values[6].data.data;
  586. app.globalData.config=data;
  587. let menuList=JSON.parse(JSON.stringify( that.data.menuList))
  588. if(data.shop_status==1){
  589. if(menuList[menuList.length-2].name!='福利兑换'){
  590. menuList.splice(menuList.length-1,0, { name: '福利兑换', imgUrl: '../../../image/fl.png', url: '../../exchange/exchange/exchange', code: 'creator admin employee' })
  591. that.setData({
  592. menuList:menuList
  593. })
  594. }
  595. }else{
  596. if(menuList[menuList.length-2].name=='福利兑换'){
  597. menuList.splice(menuList.length-2,1)
  598. that.setData({
  599. menuList:menuList
  600. })
  601. }
  602. }
  603. }
  604. })
  605. },
  606. tabPositions(e) {
  607. var item = e.target.dataset.item;
  608. this.setData({
  609. selectPlItem:item
  610. })
  611. if (item.type == 'normal') {
  612. this.departmentOfRanking();
  613. } else if (item.type == 'all') {
  614. this.addUpRanking();
  615. } else if (item.type == 'custom') {
  616. this.customRanking(item.target_id, item.date_interval);
  617. }
  618. },
  619. departmentOfRanking(){
  620. let data={
  621. dept_id: 0,
  622. sort: 'DESC',
  623. pt_id: 3,
  624. time_type: 1,
  625. page: 1,
  626. page_size: 4,
  627. position: 'all',
  628. month: moment().format('YYYY-MM'),
  629. index_ranking: 1,
  630. }
  631. app.$get('api/integral/statistics/ranking',data,'application/vnd.test.v2+json').then((res) => {
  632. let list=res.data.data.list
  633. if(list[0].employee_id!=app.globalData.userData.id){
  634. let data={
  635. employee_id: app.globalData.userData.id,
  636. employee_img_url: app.globalData.userData.img_url,
  637. employee_name: app.globalData.userData.name,
  638. rank: '--',
  639. }
  640. list.unshift(data);
  641. }
  642. this.setData({
  643. rankingListDetails:list
  644. })
  645. })
  646. },
  647. addUpRanking() {
  648. //累计B分排名
  649. let params = {
  650. dept_id: 0,
  651. sort: 'DESC',
  652. page: 1,
  653. page_size: 4,
  654. pt_id: 3,
  655. type: 'all',
  656. index_ranking: 1
  657. };
  658. app.$get('/api/integral/statistics/ranking', params, 'application/vnd.test.v2+json').then(res => {
  659. let list=res.data.data.list
  660. if(list[0].employee_id!=app.globalData.userData.id){
  661. let data={
  662. employee_id: app.globalData.userData.id,
  663. employee_img_url: app.globalData.userData.img_url,
  664. employee_name: app.globalData.userData.name,
  665. rank: '--',
  666. }
  667. list.unshift(data);
  668. }
  669. this.setData({
  670. rankingListDetails:list
  671. })
  672. })
  673. },
  674. //分组排行榜
  675. customRanking(target_id, date_interval) {
  676. //自定义排名 date_interval=时间
  677. let data = {
  678. group_id: target_id,
  679. pt_id: 3,
  680. index_ranking: 1,
  681. page_size:4
  682. };
  683. data.date =
  684. date_interval == 1
  685. ? moment().format('YYYYMM')
  686. : date_interval == 2
  687. ? moment().format('YYYYQ')
  688. : date_interval == 3
  689. ? moment().format('YYYY')
  690. : '0';
  691. app.$get('/api/integral/statistics/groups/rank', data,'application/vnd.test.v2+json').then(res => {
  692. let lists = res.data.data.list;
  693. let rankingList = [];
  694. let arr = false;
  695. for (let i in lists) {
  696. let rankingJson = {};
  697. if (lists[i].employee_name) {
  698. arr = true;
  699. } else {
  700. arr = false;
  701. rankingJson.employee_id = lists[i].employee_id;
  702. rankingJson.employee_img_url = lists[i].img_url;
  703. rankingJson.employee_name = lists[i].name;
  704. rankingJson.point = lists[i].point;
  705. rankingJson.rank = lists[i].rank;
  706. rankingJson.status_remark = '';
  707. rankingList.push(rankingJson);
  708. }
  709. }
  710. if (arr) {
  711. if(lists[0].employee_id!=app.globalData.userData.id){
  712. let data={
  713. employee_id: app.globalData.userData.id,
  714. employee_img_url: app.globalData.userData.img_url,
  715. employee_name: app.globalData.userData.name,
  716. rank: '--',
  717. }
  718. lists.unshift(data);
  719. }
  720. this.setData({rankingListDetails:lists })
  721. } else {
  722. if(rankingList[0].employee_id!=app.globalData.userData.id){
  723. let data={
  724. employee_id: app.globalData.userData.id,
  725. employee_img_url: app.globalData.userData.img_url,
  726. employee_name: app.globalData.userData.name,
  727. rank: '--',
  728. }
  729. rankingList.unshift(data);
  730. }
  731. this.setData({rankingListDetails:rankingList})
  732. }
  733. })
  734. },
  735. //获取积分事件
  736. getIncidentLsit() {
  737. app.$get2("api/integral/statistics/integral", { month: app.globalData.month, page: 1, page_size: 5, employee_ids: app.globalData.userData.id }).then((res) => {
  738. var data = res.data.data.list;
  739. data.map((item) => {
  740. item.ptObj = app.getTypesItem(item.pt_id);
  741. })
  742. this.setData({
  743. incidentLsit: data,
  744. incidentLsitTotal: res.data.data.total
  745. })
  746. }, (err) => { })
  747. },
  748. });