mainStatistics.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="">
  5. <image class="userFlagimg" src="../../static/img/userFlag.png" mode=""></image>
  6. </view>
  7. <view class="pname">
  8. <font class="wenzi" style="color: #BDD6F3;font-size:28upx"> {{$t('mainStatistics.name')}}: {{pnameData}}
  9. </font>
  10. </view>
  11. <view class="company">
  12. <font style="color: #BDD6F3;font-size:28upx">{{$t('mainStatistics.company')}}</font>
  13. </view>
  14. </view>
  15. <view class="ri">
  16. <view class="riShell">
  17. <view class="riImg">
  18. <image style="width: 64upx;height: 64upx;padding-top: 20upx;" :src="$t('mainStatistics.dayImg')">
  19. </image>
  20. </view>
  21. <view class="riTitle">
  22. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  23. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalMoney')}}:</font>
  24. <font style="color: #ED341F;">{{dayTotalMoney}}</font>
  25. </view>
  26. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  27. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalNum')}}:</font>
  28. <font style="color: #ED341F;">{{dayTotalNum}}</font>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="riqi">
  33. <view style="text-align:right" class="tody">
  34. <font style="color: #596D83;">{{today}}</font>
  35. </view>
  36. <view style="text-align:right" class="xingqi">
  37. <font style="color: #596D83;">{{week}}</font>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="fourTitle">
  42. <view class="four">
  43. <view class="fourImg">
  44. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.weekImg')"
  45. mode=""></image>
  46. </view>
  47. <view class="fourShell">
  48. <view class="one">
  49. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalMoney')}}:</font>
  50. <font style="color: #ED341F;">{{weekTotalMoney}}</font>
  51. </view>
  52. <view class="two">
  53. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalNum')}}:</font>
  54. <font style="color: #ED341F;">{{weekTotalNum}}</font>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="four">
  59. <view class="fourImg">
  60. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.monthImg')"
  61. mode=""></image>
  62. </view>
  63. <view class="fourShell">
  64. <view class="one">
  65. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalMoney')}}:</font>
  66. <font style="color: #ED341F;">{{monthTotalMoney}}</font>
  67. </view>
  68. <view class="two">
  69. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalNum')}}:</font>
  70. <font style="color: #ED341F;">{{monthTotalNum}}</font>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="four">
  75. <view class="fourImg">
  76. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.yearImg')"
  77. mode=""></image>
  78. </view>
  79. <view class="fourShell">
  80. <view class="one">
  81. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalMoney')}}:</font>
  82. <font style="color: #ED341F;">{{yearTotalMoney}}</font>
  83. </view>
  84. <view class="two">
  85. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalNum')}}:</font>
  86. <font style="color: #ED341F;">{{yearTotalNum}}</font>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="four">
  91. <view class="fourImg">
  92. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.allImg')"
  93. mode=""></image>
  94. </view>
  95. <view class="fourShell">
  96. <view class="one">
  97. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineTotalNum')}}:</font>
  98. <font style="color: #ED341F;">{{machineTotalNum}}</font>
  99. </view>
  100. <view class="two">
  101. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineUseNum')}}:</font>
  102. <font style="color: #ED341F;">{{machineUseNum}}</font>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <!-- 商家选择 -->
  108. <view v-if="id!=1&&type<4&&length>0" class="td-right">
  109. <view class="uni-list">
  110. <view class="uni-list-cell">
  111. <view class="uni-list-cell-left">
  112. 当前商家:
  113. </view>
  114. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  115. <picker @change="changeAdmin" :value="index" :range="adminList">
  116. <view class="uni-input">{{adminList[index]}}</view>
  117. </picker>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <view class="qiun-columns">
  123. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  124. <view class="qiun-title-dot-light">
  125. <view class="dis">{{$t('mainStatistics.day')}}</view>
  126. </view>
  127. <view class="shijian" style="text-align: center;position: relative;">
  128. <image @click="pre('day')" class="preImg" src="/static/img/leftTriangle.png"></image>
  129. <span>{{startDate1}}</span>
  130. <image @click="next('day')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  131. </view>
  132. </view>
  133. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  134. <canvas canvas-id="canvaColumn1" id="canvaColumn1" class="charts" disable-scroll=true
  135. @touchstart="touchLine1" @touchmove="moveLine1" @touchend="touchEndLine1"
  136. style="background-color: #FFFFFF;"></canvas>
  137. </view>
  138. </view>
  139. <view class="line"></view>
  140. <view class="qiun-columns">
  141. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  142. <view class="qiun-title-dot-light">
  143. <view class="dis">{{$t('mainStatistics.week')}}</view>
  144. </view>
  145. <view class="shijian" style="text-align: center;position: relative;">
  146. <image @click="pre('week')" class="preImg" src="/static/img/leftTriangle.png"></image>
  147. <span>{{startDate2}} -- {{endDate2}}</span>
  148. <image @click="next('week')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  149. </view>
  150. </view>
  151. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  152. <canvas canvas-id="canvaColumn2" id="canvaColumn2" class="charts" disable-scroll=true
  153. @touchstart="touchLine2" @touchmove="moveLine2" @touchend="touchEndLine2"
  154. style="background-color: #FFFFFF;"></canvas>
  155. </view>
  156. </view>
  157. <view class="line"></view>
  158. <view class="qiun-columns">
  159. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  160. <view class="qiun-title-dot-light">
  161. <view class="dis">{{$t('mainStatistics.month')}}</view>
  162. </view>
  163. <view class="shijian" style="text-align: center;position: relative;">
  164. <image @click="pre('month')" class="preImg" src="/static/img/leftTriangle.png"></image>
  165. <span>{{startDate3}} -- {{endDate3}}</span>
  166. <image @click="next('month')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  167. </view>
  168. </view>
  169. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  170. <canvas canvas-id="canvaColumn3" id="canvaColumn3" class="charts" disable-scroll=true
  171. @touchstart="touchLine3" @touchmove="moveLine3" @touchend="touchEndLine3"
  172. style="background-color: #FFFFFF;"></canvas>
  173. </view>
  174. </view>
  175. <view class="line"></view>
  176. <view class="qiun-columns">
  177. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  178. <view class="qiun-title-dot-light">
  179. <view class="dis">{{$t('mainStatistics.year')}}</view>
  180. </view>
  181. <view class="shijian" style="text-align: center;position: relative;">
  182. <image @click="pre('year')" class="preImg" src="/static/img/leftTriangle.png"></image>
  183. <span>{{startDate4}} -- {{endDate4}}</span>
  184. <image @click="next('year')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  185. </view>
  186. </view>
  187. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  188. <canvas canvas-id="canvaColumn4" id="canvaColumn4" class="charts" disable-scroll=true
  189. @touchstart="touchLine4" @touchmove="moveLine4" @touchend="touchEndLine4"
  190. style="background-color: #FFFFFF;"></canvas>
  191. </view>
  192. </view>
  193. <view v-show="noticeShow">
  194. <uni-popup id="popupDialog" ref="popupDialog" type="dialog">
  195. <uni-popup-dialog :type="msgType" title="通知" content="欢迎使用 unisdfdd-popup!"
  196. :before-close="true" @confirm="dialogConfirm(noticeId)" @close="dialogClose">
  197. <scroll-view scroll-y="true" class="scroll-Y" :style="{height:scrollHeight*0.8+'px'}">
  198. <view class="scroll-view-item ">
  199. {{noticeTitle}}<br/>
  200. <p v-html="noticeNote">{{noticeNote}}</p>
  201. </view>
  202. </scroll-view>
  203. </uni-popup-dialog>
  204. </uni-popup>
  205. </view>
  206. </view>
  207. </template>
  208. <script>
  209. import {
  210. mapState,
  211. mapActions,
  212. mapMutations
  213. } from 'vuex';
  214. import uCharts from '@/components/u-charts/u-charts.js';
  215. import {
  216. dateUtils
  217. } from '@/common/util.js';
  218. var _self;
  219. var canvaColumn1 = null;
  220. var canvaColumn2 = null;
  221. var canvaColumn3 = null;
  222. var canvaColumn4 = null;
  223. export default {
  224. name: 'mainStatistics',
  225. props: {
  226. equipmentId: '',
  227. adminId: '',
  228. pname: '',
  229. },
  230. data() {
  231. return {
  232. machineTotalNum: 0,
  233. machineUseNum: 0,
  234. dayTotalMoney: 0,
  235. dayTotalNum: 0,
  236. weekTotalMoney: 0,
  237. weekTotalNum: 0,
  238. monthTotalMoney: 0,
  239. monthTotalNum: 0,
  240. yearTotalMoney: 0,
  241. yearTotalNum: 0,
  242. cWidth: '',
  243. cHeight: '',
  244. pixelRatio: 1,
  245. startDate1: '',
  246. startDate2: '',
  247. endDate2: '',
  248. startDate3: '',
  249. endDate3: '',
  250. startDate4: '',
  251. endDate4: '',
  252. today: '',
  253. week: '',
  254. adminList: [],
  255. admins: [],
  256. index: 0,
  257. id: 0,
  258. length:0,
  259. type:null,
  260. noticeShow:false,
  261. noticeTRUE:true,
  262. noticeTitle:'',
  263. noticeNote:'',
  264. noticeId:'',
  265. msgType: 'success',
  266. scrollHeight:uni.getSystemInfoSync().windowHeight - 130,
  267. }
  268. },
  269. onReady() {
  270. // 页面打开自动打开对话框
  271. // setTimeout(() => {
  272. // // this.msgType = 'success'
  273. // this.$refs.popupDialog.open()
  274. // }, 500)
  275. },
  276. computed: {
  277. ...mapState(['loginUser']),
  278. pnameData: {
  279. get() {
  280. return this.pname;
  281. }
  282. },
  283. },
  284. onShow() {
  285. uni.setNavigationBarTitle({
  286. title: this.$t('mainStatistics.title')
  287. });
  288. uni.setTabBarItem({
  289. index: 0,
  290. text: this.$t('tabs.tab1')
  291. });
  292. this.id = 0;
  293. this.index = 0;
  294. var test = uni.getStorageSync('test');
  295. var globalUser = uni.getStorageSync("globalUser");
  296. //test 判断是不是初次登陆
  297. if(globalUser.id!=1&&test==1){
  298. setTimeout(()=>{
  299. this.getNOtice();
  300. }, 5000);
  301. }
  302. var token = uni.getStorageSync("token");
  303. if (token.toString().length > 1) {
  304. this.init();
  305. } else {
  306. uni.reLaunch({
  307. url: '../Login/Login',
  308. });
  309. }
  310. if (globalUser.toString().length > 1) {
  311. if (globalUser.type > 0&&globalUser.type<4) {
  312. this.getAdmin();
  313. }
  314. this.id = globalUser.id;
  315. this.type = globalUser.type;
  316. }
  317. this.day();
  318. },
  319. mounted() {
  320. var token = uni.getStorageSync("token");
  321. if (token.toString().length > 1) {
  322. this.init();
  323. } else {
  324. uni.reLaunch({
  325. url: '../Login/Login',
  326. });
  327. }
  328. // this.day();
  329. this.equipmentStatus();
  330. },
  331. methods: {
  332. // open() {
  333. // this.show = true;
  334. // },
  335. ...mapActions('chart', ['getStatistics', 'getMachineNum']),
  336. async init() {
  337. if (!this.pname) {
  338. this.pname = this.loginUser.name;
  339. }
  340. _self = this;
  341. //图表中图
  342. this.cWidth = uni.upx2px(690);
  343. this.cHeight = uni.upx2px(370);
  344. await this.getMainStatisticsData();
  345. await this.initDateRang(new Date(), 'day');
  346. await this.initDateRang(new Date(), 'week');
  347. await this.initDateRang(new Date(), 'month');
  348. await this.initDateRang(new Date(), 'year');
  349. var test = uni.getStorageSync('test');
  350. var globalUser = uni.getStorageSync("globalUser");
  351. //初次登陆跳转后,把test变成2
  352. uni.setStorageSync('test', '2');
  353. },
  354. getNOtice(){
  355. // console.log("notice")
  356. var globalUser = uni.getStorageSync("globalUser");
  357. var token = uni.getStorageSync("token");
  358. uni.request({
  359. url: this.serverurl + '/TNotice/getNotice?id='+globalUser.id,
  360. // data: {
  361. // "id": globalUser.id
  362. // },
  363. header: {
  364. 'token': token
  365. },
  366. method: "POST",
  367. success: (res) => {
  368. if(res.data.code){
  369. if(res.data.message=='1'){
  370. var notice = res.data.data;
  371. this.noticeTitle =notice.title,
  372. this.noticeNote = notice.note,
  373. this.noticeId = notice.id,
  374. this.noticeTRUE = false,
  375. this.noticeShow = true,
  376. this.$refs.popupDialog.open()
  377. }
  378. }
  379. },
  380. });
  381. },
  382. day() {
  383. var date = new Date();
  384. // var daystr = dateUtils.formateDate(date, 'yyyy年MM月dd日');
  385. var daystr = dateUtils.formateDate(date, 'yyyy-MM-dd');
  386. this.today = daystr;
  387. // var str= '星期'+'日一二三四五六'.charAt(date.getDay());
  388. this.week = this.$t('mainStatistics.week' + date.getDay());
  389. },
  390. //查询下级用户
  391. getAdmin() {
  392. var param = {};
  393. var token = uni.getStorageSync("token");
  394. var globalUser = uni.getStorageSync("globalUser");
  395. param['id'] = globalUser.id;
  396. uni.request({
  397. url: this.serverurl + '/TAdmin/selectLowAdmin',
  398. data: param,
  399. header: {
  400. 'token': token
  401. },
  402. method: "POST",
  403. success: (res) => {
  404. if (res.data.code) {
  405. var admins = res.data.data;
  406. // this.admins = admins;
  407. var adminss = [];
  408. var adminList = [];
  409. adminList.push('本商户');
  410. if (admins.length > 0) {
  411. this.length = admins.length;
  412. adminList.push('所有下级');
  413. for (var i = 0; i < admins.length; i++) {
  414. // console.log(admins[i].name)
  415. if(i==0){
  416. var globalUser = uni.getStorageSync("globalUser");
  417. var id = admins[i].id;
  418. if(id==globalUser.id){
  419. continue;
  420. }
  421. }
  422. if (admins[i].name != null || admins[i].name != '') {
  423. adminss.push(admins[i]);
  424. adminList.push(admins[i].name);
  425. } else {
  426. adminList.push(admins[i].username);
  427. adminss.push(admins[i]);
  428. }
  429. }
  430. }
  431. this.adminList = adminList;
  432. this.admins = adminss;
  433. } else {
  434. uni.showToast({
  435. title: `获取信息失败:` + res.data.message,
  436. icon: 'none'
  437. })
  438. }
  439. },
  440. });
  441. },
  442. // 改变商家
  443. changeAdmin: function(e){
  444. this.index = e.target.value;
  445. var id = '';
  446. if(e.target.value>1){
  447. id = this.admins[e.target.value-2].id;
  448. }
  449. if(e.target.value==1){
  450. id = 'all';
  451. }
  452. if(e.target.value==0){
  453. id = 0;
  454. }
  455. // console.log("adminID="+id);
  456. this.id = id;
  457. this.init();
  458. },
  459. equipmentStatus() {
  460. var that = this;
  461. var id = uni.getStorageSync("globalUser").id;
  462. var token = uni.getStorageSync("token");
  463. uni.request({
  464. url: this.serverurl + '/TEquipment/equipmentStatus',
  465. data: {
  466. "adminId": id
  467. },
  468. header: {
  469. 'token': token
  470. },
  471. method: "POST",
  472. success: (res) => {
  473. setTimeout(function() {
  474. that.checkEquipmentStatus(id);
  475. }, 5000);
  476. },
  477. });
  478. },
  479. checkEquipmentStatus(id) {
  480. var token = uni.getStorageSync("token");
  481. uni.request({
  482. url: this.serverurl + '/TEquipment/checkEquipmentStatus',
  483. data: {
  484. "adminId": id
  485. },
  486. header: {
  487. 'token': token
  488. },
  489. method: "POST",
  490. success: (res) => {
  491. },
  492. });
  493. },
  494. initDateRang(day, chartType) {
  495. const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
  496. if (chartType === 'day') {
  497. this.startDate1 = dateUtils.formateDate(day, 'yyyy/MM/dd');
  498. }
  499. if (chartType === 'week') {
  500. this.startDate2 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
  501. this.endDate2 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
  502. }
  503. if (chartType === 'month') {
  504. this.startDate3 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
  505. this.endDate3 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
  506. }
  507. if (chartType === 'year') {
  508. this.startDate4 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
  509. this.endDate4 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
  510. }
  511. return this.getStatisticsData(chartType);
  512. },
  513. /**上一个 */
  514. pre(chartType) {
  515. let day;
  516. if (chartType === 'day') { // 日
  517. day = new Date(this.startDate1);
  518. day.setDate(day.getDate() - 1);
  519. }
  520. if (chartType === 'week') { // 周
  521. day = new Date(this.startDate2);
  522. day.setDate(day.getDate() - 7);
  523. }
  524. if (chartType === 'month') { // 月
  525. day = new Date(this.startDate3);
  526. day.setMonth(day.getMonth() - 1);
  527. }
  528. if (chartType === 'year') { // 年
  529. day = new Date(this.startDate4);
  530. day.setFullYear(day.getFullYear() - 1);
  531. }
  532. this.initDateRang(day, chartType);
  533. },
  534. /**下一个 */
  535. next(chartType) {
  536. let day;
  537. if (chartType === 'day') { // 日
  538. day = new Date(this.startDate1);
  539. day.setDate(day.getDate() + 1);
  540. }
  541. if (chartType === 'week') { // 周
  542. day = new Date(this.startDate2);
  543. day.setDate(day.getDate() + 7);
  544. }
  545. if (chartType === 'month') { // 月
  546. day = new Date(this.startDate3);
  547. day.setMonth(day.getMonth() + 1);
  548. }
  549. if (chartType === 'year') { // 年
  550. day = new Date(this.startDate4);
  551. day.setFullYear(day.getFullYear() + 1);
  552. }
  553. this.initDateRang(day, chartType);
  554. },
  555. getStatisticsData(chartType) {
  556. const param = {
  557. 'chartType': chartType
  558. };
  559. if (chartType == 'day') {
  560. param['startDate'] = this.startDate1;
  561. param['endDate'] = this.startDate1;
  562. }
  563. if (chartType == 'week') {
  564. param['startDate'] = this.startDate2;
  565. param['endDate'] = this.endDate2;
  566. }
  567. if (chartType == 'month') {
  568. param['startDate'] = this.startDate3;
  569. param['endDate'] = this.endDate3;
  570. }
  571. if (chartType == 'year') {
  572. param['startDate'] = this.startDate4;
  573. param['endDate'] = this.endDate4;
  574. }
  575. if (this.adminId) { // 子组件,则拿传过来的参
  576. param['adminId'] = this.adminId;
  577. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  578. param['adminId'] = this.loginUser['id'];
  579. }
  580. var globalUser = uni.getStorageSync("globalUser");
  581. if (globalUser.id != 1) {
  582. if (param.adminId == null || param.adminId == undefined) {
  583. param['adminId'] = globalUser.id;
  584. }
  585. }
  586. if (this.equipmentId) {
  587. param['equipmentId'] = this.equipmentId;
  588. }
  589. if (this.id!=1) {
  590. var id = this.id;
  591. }else{
  592. var id = 0;
  593. }
  594. if(id=='all'){
  595. param['adminId'] = null;
  596. if(this.type==1){
  597. param['agencyId'] = globalUser.id;
  598. }
  599. if(this.type==2){
  600. param['merchantId'] = globalUser.id;
  601. }
  602. }else if(id==0){
  603. }else{
  604. param['adminId'] = id;
  605. }
  606. return this.getStatistics(param)
  607. .then(data => {
  608. uni.stopPullDownRefresh();
  609. if (param['chartType'] == 'day') {
  610. canvaColumn1 = this.initChart('canvaColumn1', data);
  611. }
  612. if (param['chartType'] == 'week') {
  613. canvaColumn2 = this.initChart('canvaColumn2', data);
  614. }
  615. if (param['chartType'] == 'month') {
  616. canvaColumn3 = this.initChart('canvaColumn3', data);
  617. }
  618. if (param['chartType'] == 'year') {
  619. canvaColumn4 = this.initChart('canvaColumn4', data);
  620. }
  621. }, _ => {
  622. uni.stopPullDownRefresh();
  623. if (param['chartType'] == 'day') {
  624. canvaColumn1 = this.initChart('canvaColumn1', {
  625. categories: ['暂无数据'],
  626. series: [{
  627. name: '销售个数',
  628. data: [0]
  629. }]
  630. });
  631. }
  632. if (param['chartType'] == 'week') {
  633. canvaColumn2 = this.initChart('canvaColumn2', {
  634. categories: ['暂无数据'],
  635. series: [{
  636. name: '销售个数',
  637. data: [0]
  638. }]
  639. });
  640. }
  641. if (param['chartType'] == 'month') {
  642. canvaColumn3 = this.initChart('canvaColumn3', {
  643. categories: ['暂无数据'],
  644. series: [{
  645. name: '销售个数',
  646. data: [0]
  647. }]
  648. });
  649. }
  650. if (param['chartType'] == 'year') {
  651. canvaColumn4 = this.initChart('canvaColumn4', {
  652. categories: ['暂无数据'],
  653. series: [{
  654. name: '销售个数',
  655. data: [0]
  656. }]
  657. });
  658. }
  659. });
  660. },
  661. initChart(canvasId, chartData) {
  662. if (this.$t('lang') != null && this.$t('lang') != '') {
  663. if (this.$t('lang') != 'zh') {
  664. chartData.categories = chartData.categories.map(e => {
  665. if (e.indexOf('点') >= 0) {
  666. return e.replace('点', this.$t('mainStatistics.oclock'));
  667. }
  668. if (e.indexOf('周') >= 0) {
  669. const weekNum = e.substring(e.length - 1) == '日' ? '0' : e.substring(e.length - 1);
  670. return this.$t('mainStatistics.week' + weekNum);
  671. }
  672. if (e.indexOf('月') >= 0) {
  673. var res = e.toString();
  674. if (res.length > 3) {
  675. return e.replace('月', this.$t('mainStatistics.mon'));
  676. } else {
  677. return e.replace('月', this.$t('mainStatistics.y'));
  678. }
  679. }
  680. return e;
  681. });
  682. chartData.series = chartData.series.map(e => {
  683. if (e['name'] == '销售个数') {
  684. e['name'] = this.$t('mainStatistics.saleNum');
  685. }
  686. if (e['name'] == '销售额') {
  687. e['name'] = this.$t('mainStatistics.saleroom');
  688. }
  689. return e;
  690. });
  691. }
  692. }
  693. return new uCharts({
  694. $this: _self,
  695. canvasId: canvasId,
  696. enableScroll: true,
  697. type: 'column',
  698. legend: true,
  699. fontSize: 10,
  700. background: '#FFFFFF', //y轴颜色
  701. pixelRatio: 1,
  702. animation: true,
  703. categories: chartData.categories,
  704. series: chartData.series,
  705. xAxis: {
  706. type: 'grid',
  707. gridType: 'dash',
  708. itemCount: 5, //x轴单屏显示数据的数量,默认为5个
  709. scrollShow: true, //新增是否显示滚动条,默认false
  710. scrollAlign: 'left', //滚动条初始位置
  711. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF 滚动条颜色底色
  712. scrollColor: '#DEE7F7', //默认为 #A6A6A6 滚动条颜色
  713. disableGrid: true,
  714. },
  715. yAxis: {
  716. type: 'grid',
  717. gridType: 'soild',
  718. // disabled:true
  719. // disableGrid:true,
  720. },
  721. dataLabel: true,
  722. width: _self.cWidth * _self.pixelRatio,
  723. height: _self.cHeight * _self.pixelRatio,
  724. extra: {
  725. column: {
  726. // width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
  727. width: 18
  728. }
  729. }
  730. });
  731. },
  732. getMainStatisticsData() {
  733. const param = {};
  734. if (this.adminId) { // 子组件,则拿传过来的参
  735. param['adminId'] = this.adminId;
  736. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  737. param['adminId'] = this.loginUser['id'];
  738. }
  739. var globalUser = uni.getStorageSync("globalUser");
  740. if (globalUser.id != 1) {
  741. if (param.adminId == null || param.adminId == undefined) {
  742. param['adminId'] = globalUser.id;
  743. }
  744. }
  745. if (this.equipmentId) {
  746. param['equipmentId'] = this.equipmentId;
  747. }
  748. if (this.id!=1) {
  749. var id = this.id;
  750. }else{
  751. var id = 0;
  752. }
  753. var aid = param.adminId;
  754. if(id=='all'){
  755. param['adminId'] = null;
  756. if(this.type==1){
  757. param['agencyId'] = globalUser.id;
  758. }
  759. if(this.type==2){
  760. param['merchantId'] = globalUser.id;
  761. }
  762. }else if(id==0){
  763. }else{
  764. param['adminId'] = id;
  765. aid = id;
  766. }
  767. // console.log('getMainStatisticsData:{}', param);
  768. var adminId = param.adminId;
  769. var equipmentId = this.equipmentId;
  770. var serverurl = this.serverurl;
  771. var token = uni.getStorageSync("token");
  772. uni.request({
  773. url: serverurl + '/TEquipment/getMachineNum',
  774. data: {
  775. "adminId": aid,
  776. "equipmentId": equipmentId
  777. },
  778. method: "POST",
  779. header: {
  780. 'token': token
  781. },
  782. success: (res) => {
  783. var list = res.data.data;
  784. this.machineTotalNum = list[0];
  785. this.machineUseNum = list[1];
  786. }
  787. });
  788. uni.request({
  789. url: serverurl + '/TOrder/getMainStatistics',
  790. data: param,
  791. method: "POST",
  792. header: {
  793. 'token': token
  794. },
  795. success: (res) => {
  796. var list = res.data.data;
  797. for (let bean of list) {
  798. if (bean['categorie'] === 'day') {
  799. this.dayTotalMoney = bean['salePrice'];
  800. this.dayTotalNum = bean['saleNum'];
  801. }
  802. if (bean['categorie'] === 'week') {
  803. this.weekTotalMoney = bean['salePrice'];
  804. this.weekTotalNum = bean['saleNum'];
  805. }
  806. if (bean['categorie'] === 'month') {
  807. this.monthTotalMoney = bean['salePrice'];
  808. this.monthTotalNum = bean['saleNum'];
  809. }
  810. if (bean['categorie'] === 'year') {
  811. this.yearTotalMoney = bean['salePrice'];
  812. this.yearTotalNum = bean['saleNum'];
  813. }
  814. }
  815. }
  816. });
  817. // return this.getMainStatistics(param)
  818. // .then(data => {
  819. // for (let bean of data) {
  820. // if (bean['categorie'] === 'day') {
  821. // this.dayTotalMoney = bean['salePrice'];
  822. // this.dayTotalNum = bean['saleNum'];
  823. // }
  824. // if (bean['categorie'] === 'week') {
  825. // this.weekTotalMoney = bean['salePrice'];
  826. // this.weekTotalNum = bean['saleNum'];
  827. // }
  828. // if (bean['categorie'] === 'month') {
  829. // this.monthTotalMoney = bean['salePrice'];
  830. // this.monthTotalNum = bean['saleNum'];
  831. // }
  832. // if (bean['categorie'] === 'year') {
  833. // this.yearTotalMoney = bean['salePrice'];
  834. // this.yearTotalNum = bean['saleNum'];
  835. // }
  836. // }
  837. // uni.stopPullDownRefresh();
  838. // }, _ => void uni.stopPullDownRefresh());
  839. },
  840. touchLine1(e) {
  841. if (canvaColumn1) {
  842. canvaColumn1.scrollStart(e);
  843. }
  844. },
  845. moveLine1(e) {
  846. if (canvaColumn1) {
  847. canvaColumn1.scroll(e);
  848. }
  849. },
  850. touchEndLine1(e) {
  851. if (canvaColumn1) {
  852. canvaColumn1.scrollEnd(e);
  853. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  854. canvaColumn1.showToolTip(e, {
  855. format: function(item, category) {
  856. return category + ' ' + item.name + ':' + item.data
  857. }
  858. });
  859. }
  860. },
  861. touchLine2(e) {
  862. if (canvaColumn2) {
  863. canvaColumn2.scrollStart(e);
  864. }
  865. },
  866. moveLine2(e) {
  867. if (canvaColumn2) {
  868. canvaColumn2.scroll(e);
  869. }
  870. },
  871. touchEndLine2(e) {
  872. if (canvaColumn2) {
  873. canvaColumn2.scrollEnd(e);
  874. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  875. canvaColumn2.showToolTip(e, {
  876. format: function(item, category) {
  877. return category + ' ' + item.name + ':' + item.data
  878. }
  879. });
  880. }
  881. },
  882. touchLine3(e) {
  883. if (canvaColumn3) {
  884. canvaColumn3.scrollStart(e);
  885. }
  886. },
  887. moveLine3(e) {
  888. if (canvaColumn3) {
  889. canvaColumn3.scroll(e);
  890. }
  891. },
  892. touchEndLine3(e) {
  893. if (canvaColumn3) {
  894. canvaColumn3.scrollEnd(e);
  895. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  896. canvaColumn3.showToolTip(e, {
  897. format: function(item, category) {
  898. return category + ' ' + item.name + ':' + item.data
  899. }
  900. });
  901. }
  902. },
  903. touchLine4(e) {
  904. if (canvaColumn4) {
  905. canvaColumn4.scrollStart(e);
  906. }
  907. },
  908. moveLine4(e) {
  909. if (canvaColumn4) {
  910. canvaColumn4.scroll(e);
  911. }
  912. },
  913. touchEndLine4(e) {
  914. if (canvaColumn4) {
  915. canvaColumn4.scrollEnd(e);
  916. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  917. canvaColumn4.showToolTip(e, {
  918. format: function(item, category) {
  919. return category + ' ' + item.name + ':' + item.data
  920. }
  921. });
  922. }
  923. },
  924. // 点击确定
  925. dialogConfirm(id){
  926. this.noticeTRUE = true;
  927. var adminId = uni.getStorageSync("globalUser").id;
  928. var token = uni.getStorageSync("token");
  929. uni.request({
  930. url: this.serverurl + '/TNotice/updateNotice?adminId='+adminId+'&noticeId='+id,
  931. // data: {
  932. // "adminId": adminId,
  933. // "noticeId":id
  934. // },
  935. header: {
  936. 'token': token
  937. },
  938. method: "POST",
  939. success: (res) => {
  940. uni.showModal({
  941. title: "提示",
  942. content: res.data.message,
  943. success: (res) => {
  944. }
  945. })
  946. },
  947. });
  948. this.$refs.popupDialog.close()
  949. },
  950. //点击取消
  951. dialogClose(done){
  952. this.noticeTRUE = true,
  953. // this.msgType = 'success'
  954. // 需要执行 done 才能关闭对话框
  955. this.$refs.popupDialog.close()
  956. }
  957. }
  958. }
  959. </script>
  960. <style>
  961. page {
  962. /* background: #F2F2F2; */
  963. background: #FFFFFF;
  964. width: 750upx;
  965. overflow-x: hidden;
  966. }
  967. .head {
  968. display: flex;
  969. flex-direction: row;
  970. background: #206DC3;
  971. width: 750upx;
  972. height: 180upx;
  973. }
  974. .company {
  975. width: 48%;
  976. text-align: right;
  977. }
  978. .pname {
  979. display: flex;
  980. flex-direction: row;
  981. width: 40%;
  982. }
  983. .userFlagimg {
  984. padding-left: 30upx;
  985. padding-top: 10upx;
  986. width: 26upx;
  987. height: 28upx;
  988. }
  989. .wenzi {
  990. padding-left: 5upx;
  991. /* text-align:right; */
  992. white-space: nowrap;
  993. overflow: hidden;
  994. /* text-overflow: ellipsis; */
  995. }
  996. .ri {
  997. width: 690upx;
  998. height: 180upx;
  999. background: #FFFFFF;
  1000. border-radius: 15upx;
  1001. /* 上移 */
  1002. transform: translateY(-90upx);
  1003. text-align: center;
  1004. margin: auto;
  1005. display: flex;
  1006. flex-direction: row;
  1007. /* 阴影 */
  1008. box-shadow: 0upx -1upx 20upx #D3D3D3;
  1009. /* box-shadow:0px 0px 10px 5px #aaa; */
  1010. }
  1011. .riShell {
  1012. display: flex;
  1013. flex-direction: row;
  1014. margin: auto;
  1015. }
  1016. .riTitle {
  1017. display: flex;
  1018. flex-direction: column;
  1019. margin: auto;
  1020. }
  1021. .riqi {
  1022. display: flex;
  1023. flex-direction: column;
  1024. margin: auto;
  1025. }
  1026. .fourTitle {
  1027. width: 690upx;
  1028. height: 294upx;
  1029. display: flex;
  1030. flex-direction: row;
  1031. flex-wrap: wrap;
  1032. background: #FFFFFF;
  1033. box-shadow: 0upx 0upx 20upx #D3D3D3;
  1034. margin: auto;
  1035. border-radius: 15upx;
  1036. transform: translateY(-60upx);
  1037. }
  1038. .four {
  1039. display: flex;
  1040. flex-direction: row;
  1041. margin: auto;
  1042. width: 48%;
  1043. }
  1044. .fourImg {
  1045. width: 54upx;
  1046. height: 54upx;
  1047. }
  1048. .qiun-padding {
  1049. padding: 2%;
  1050. width: 96%;
  1051. }
  1052. .qiun-wrap {
  1053. display: flex;
  1054. flex-wrap: wrap;
  1055. }
  1056. .qiun-rows {
  1057. display: flex;
  1058. flex-direction: row !important;
  1059. }
  1060. .qiun-columns {
  1061. display: flex;
  1062. flex-direction: column !important;
  1063. }
  1064. .qiun-common-mt {
  1065. margin-top: 0upx;
  1066. height: 160upx;
  1067. }
  1068. .qiun-bg-white {
  1069. background: #FFFFFF;
  1070. }
  1071. .qiun-title-bar {
  1072. width: 100%;
  1073. /* padding: 10upx 2%; */
  1074. flex-wrap: nowrap;
  1075. border-radius: 15upx;
  1076. }
  1077. .qiun-title-dot-light {
  1078. width: 92%;
  1079. border-left: 20upx;
  1080. border-left: 10upx solid #206DC3;
  1081. padding-left: 10upx;
  1082. height: 32upx;
  1083. /* padding-bottom: 40upx; */
  1084. font-family: "PingFang-SC-Bold";
  1085. font-weight: bold;
  1086. margin: auto;
  1087. font-size: 32upx;
  1088. color: #363D44;
  1089. transform: translateY(20upx);
  1090. }
  1091. .dis {
  1092. transform: translateY(-13upx);
  1093. font-size: 32upx;
  1094. font-family: "PingFang-SC-Bold";
  1095. color: #363D44;
  1096. }
  1097. .shijian {
  1098. transform: translateY(40upx);
  1099. padding-top: 30upx;
  1100. height: 80upx;
  1101. width: 690upx;
  1102. margin: auto;
  1103. box-shadow: 0upx 0upx 10upx #D3D3D3;
  1104. }
  1105. .line {
  1106. background: #ECECEC;
  1107. height: 20upx;
  1108. }
  1109. .qiun-charts {
  1110. width: 690upx;
  1111. height: 370upx;
  1112. padding-top: 50upx;
  1113. background-color: #FFFFFF;
  1114. margin: auto;
  1115. }
  1116. .charts {
  1117. width: 690upx;
  1118. height: 370upx;
  1119. background-color: #FFFFFF;
  1120. margin: auto;
  1121. }
  1122. .preImg {
  1123. position: absolute;
  1124. left: 30upx;
  1125. width: 71upx;
  1126. height: 57upx;
  1127. }
  1128. .nextImg {
  1129. position: absolute;
  1130. right: 30upx;
  1131. width: 71upx;
  1132. height: 57upx;
  1133. }
  1134. .fontLeft {
  1135. margin-right: 6upx;
  1136. }
  1137. .tr {
  1138. padding-top: 15upx;
  1139. display: flex;
  1140. flex-direction: row;
  1141. justify-content: flex-start;
  1142. font-size: 26upx;
  1143. font-family: "PingFang-SC-Bold";
  1144. }
  1145. .td-left {
  1146. font-family: "PingFang-SC-Bold";
  1147. margin: auto;
  1148. font-size: 26upx;
  1149. width: 30%;
  1150. text-align: right;
  1151. }
  1152. .td-right {
  1153. font-family: "PingFang-SC-Bold";
  1154. /* font-weight: bold; */
  1155. margin: auto;
  1156. /* font-size: 26upx; */
  1157. width: 70%;
  1158. text-align: left;
  1159. }
  1160. </style>