index.js 28 KB

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