index.js 28 KB

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