index.js 27 KB

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