singleStatistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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}}</font>
  9. </view>
  10. <view class="company">
  11. <font style="color: #BDD6F3;font-size:28upx">{{$t('mainStatistics.company')}}</font>
  12. </view>
  13. </view>
  14. <view class="ri">
  15. <view class="riShell">
  16. <view class="riImg">
  17. <image style="width: 64upx;height: 64upx;padding-top: 20upx;" :src="$t('mainStatistics.dayImg')"></image>
  18. </view>
  19. <view class="riTitle">
  20. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  21. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalMoney')}}:</font>
  22. <font style="color: #ED341F;">{{dayRandomTimes}}</font>
  23. </view>
  24. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  25. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalNum')}}:</font>
  26. <font style="color: #ED341F;">{{dayRegularTimes}}</font>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="riqi">
  31. <view style="text-align:right" class="tody">
  32. <font style="color: #596D83;">{{today}}</font>
  33. </view>
  34. <view style="text-align:right" class="xingqi">
  35. <font style="color: #596D83;">{{week}}</font>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="fourTitle">
  40. <view class="four">
  41. <view class="fourImg">
  42. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.weekImg')" mode=""></image>
  43. </view>
  44. <view class="fourShell">
  45. <view class="one">
  46. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalMoney')}}:</font>
  47. <font style="color: #ED341F;">{{weekRandomTimes}}</font>
  48. </view>
  49. <view class="two">
  50. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalNum')}}:</font>
  51. <font style="color: #ED341F;">{{weekRegularTimes}}</font>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="four">
  56. <view class="fourImg">
  57. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.monthImg')" mode=""></image>
  58. </view>
  59. <view class="fourShell">
  60. <view class="one">
  61. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalMoney')}}:</font>
  62. <font style="color: #ED341F;">{{monthRandomTimes}}</font>
  63. </view>
  64. <view class="two">
  65. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalNum')}}:</font>
  66. <font style="color: #ED341F;">{{monthRegularTimes}}</font>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="four">
  71. <view class="fourImg">
  72. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.yearImg')" mode=""></image>
  73. </view>
  74. <view class="fourShell">
  75. <view class="one">
  76. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalMoney')}}:</font>
  77. <font style="color: #ED341F;">{{yearRandomTimes}}</font>
  78. </view>
  79. <view class="two">
  80. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalNum')}}:</font>
  81. <font style="color: #ED341F;">{{yearRegularTimes}}</font>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="four">
  86. <view class="fourImg">
  87. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.allImg')" mode=""></image>
  88. </view>
  89. <view class="fourShell">
  90. <view class="one">
  91. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineTotalNum')}}:</font>
  92. <font style="color: #ED341F;">{{machineTotalNum}}</font>
  93. </view>
  94. <view class="two">
  95. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineUseNum')}}:</font>
  96. <font style="color: #ED341F;">{{machineUseNum}}</font>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. mapState,
  106. mapActions,
  107. mapMutations
  108. } from 'vuex';
  109. import uCharts from '@/components/u-charts/u-charts.js';
  110. import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
  111. import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
  112. import uniList from '@/components/uni-list/uni-list.vue'
  113. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  114. import {
  115. dateUtils
  116. } from '@/common/util.js';
  117. var _self;
  118. export default {
  119. name: 'mainStatistics',
  120. props: {
  121. equipmentId: '',
  122. adminId: '',
  123. pname: '',
  124. },
  125. components: {
  126. uniCollapse,
  127. uniCollapseItem,
  128. uniList,
  129. uniListItem,
  130. },
  131. data() {
  132. return {
  133. machineTotalNum: 0,
  134. machineUseNum: 0,
  135. dayRandomTimes: 0,
  136. dayRegularTimes: 0,
  137. weekRandomTimes: 0,
  138. weekRegularTimes: 0,
  139. monthRandomTimes: 0,
  140. monthRegularTimes: 0,
  141. yearRandomTimes: 0,
  142. yearRegularTimes: 0,
  143. today: '',
  144. week: '',
  145. pnameData:''
  146. }
  147. },
  148. computed: {
  149. ...mapState(['loginUser']),
  150. // pnameData: {
  151. // get() {
  152. // return this.pname;
  153. // }
  154. // },
  155. },
  156. onShow() {
  157. var equipmentId = uni.getStorageSync("nowEquipmentId");
  158. if(equipmentId!=null||equipmentId!=''){
  159. this.equipmentId=equipmentId;
  160. }
  161. var equipmentName = uni.getStorageSync("nowEquipmentName");
  162. if(equipmentName!=null||equipmentName!=''){
  163. this.pnameData=equipmentName;
  164. }
  165. var token = uni.getStorageSync("token");
  166. if (token.toString().length > 1) {
  167. this.init();
  168. } else {
  169. uni.reLaunch({
  170. url: '../Login/Login',
  171. });
  172. }
  173. // this.input = this.input + 1;
  174. var test = uni.getStorageSync('test');
  175. var globalUser = uni.getStorageSync("globalUser");
  176. this.globalUser = globalUser;
  177. if (globalUser.toString().length > 1) {
  178. //判断是不是初次登陆
  179. if (test == 2) {
  180. this.init();
  181. }
  182. }
  183. var id = this.adminId;
  184. this.day();
  185. // this.equipmentStatus();
  186. },
  187. mounted() {
  188. var token = uni.getStorageSync("token");
  189. if (token.toString().length > 1) {
  190. this.init();
  191. } else {
  192. uni.reLaunch({
  193. url: '../Login/Login',
  194. });
  195. }
  196. // this.day();
  197. this.equipmentStatus();
  198. },
  199. methods: {
  200. ...mapActions('chart', ['getStatistics', 'getMainStatistics', 'getMachineNum', 'getEquipmentListByUser']),
  201. async init() {
  202. if (!this.pname) {
  203. this.pname = this.loginUser.name;
  204. }
  205. _self = this;
  206. await this.getMainStatisticsData();
  207. // await this.getEquipmentListData();
  208. //初次登陆跳转后,把test变成2
  209. uni.setStorageSync('test', '2');
  210. },
  211. day() {
  212. var date = new Date();
  213. // var daystr = dateUtils.formateDate(date, 'yyyy年MM月dd日');
  214. var daystr = dateUtils.formateDate(date, 'yyyy-MM-dd');
  215. this.today = daystr;
  216. // var str= '星期'+'日一二三四五六'.charAt(date.getDay());
  217. this.week = this.$t('mainStatistics.week' + date.getDay());
  218. },
  219. equipmentStatus() {
  220. var id = uni.getStorageSync("globalUser").id;
  221. var token = uni.getStorageSync("token");
  222. uni.request({
  223. url: this.serverurl + '/TEquipment/equipmentStatus',
  224. data: {
  225. "adminId": id
  226. },
  227. header: {
  228. 'token': token
  229. },
  230. method: "POST",
  231. success: (res) => {
  232. },
  233. });
  234. },
  235. getMainStatisticsData() {
  236. const param = {};
  237. if (this.adminId) { // 子组件,则拿传过来的参
  238. param['adminId'] = this.adminId;
  239. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  240. param['adminId'] = this.loginUser['id'];
  241. }
  242. var globalUser = uni.getStorageSync("globalUser");
  243. if (globalUser.id != 1) {
  244. if (param.adminId == null || param.adminId == undefined) {
  245. param['adminId'] = globalUser.id;
  246. }
  247. }
  248. if (this.equipmentId) {
  249. param['equipmentId'] = this.equipmentId;
  250. }
  251. // console.log('getMainStatisticsData:{}', param);
  252. var adminId = param.adminId;
  253. var equipmentId = this.equipmentId;
  254. var serverurl = this.serverurl;
  255. var token = uni.getStorageSync("token");
  256. uni.request({
  257. url: serverurl + '/TEquipment/getMachineNum',
  258. data: {
  259. "adminId": adminId,
  260. "equipmentId": equipmentId
  261. },
  262. method: "POST",
  263. header: {
  264. 'token': token
  265. },
  266. success: (res) => {
  267. var list = res.data.data;
  268. this.machineTotalNum = list[0];
  269. this.machineUseNum = list[1];
  270. }
  271. });
  272. return this.getMainStatistics(param)
  273. .then(data => {
  274. for (let bean of data) {
  275. if (bean['categorie'] === 'day') {
  276. if (bean['randomTimes'] != null) {
  277. this.dayRandomTimes = bean['randomTimes'];
  278. }
  279. if (bean['regularTimes'] != null) {
  280. this.dayRegularTimes = bean['regularTimes'];
  281. }
  282. }
  283. if (bean['categorie'] === 'week') {
  284. if (bean['randomTimes'] != null) {
  285. this.weekRandomTimes = bean['randomTimes'];
  286. }
  287. if (bean['regularTimes'] != null) {
  288. this.weekRegularTimes = bean['regularTimes'];
  289. }
  290. }
  291. if (bean['categorie'] === 'month') {
  292. if (bean['randomTimes'] != null) {
  293. this.monthRandomTimes = bean['randomTimes'];
  294. }
  295. if (bean['regularTimes'] != null) {
  296. this.monthRegularTimes = bean['regularTimes'];
  297. }
  298. }
  299. if (bean['categorie'] === 'year') {
  300. if (bean['randomTimes'] != null) {
  301. this.yearRandomTimes = bean['randomTimes'];
  302. }
  303. if (bean['regularTimes'] != null) {
  304. this.yearRegularTimes = bean['regularTimes'];
  305. }
  306. }
  307. }
  308. uni.stopPullDownRefresh();
  309. }, _ => void uni.stopPullDownRefresh());
  310. },
  311. }
  312. }
  313. </script>
  314. <style>
  315. page {
  316. /* background: #F2F2F2; */
  317. background: #FFFFFF;
  318. width: 750upx;
  319. overflow-x: hidden;
  320. }
  321. .head {
  322. display: flex;
  323. flex-direction: row;
  324. background: #206DC3;
  325. width: 750upx;
  326. height: 180upx;
  327. }
  328. .company {
  329. width: 48%;
  330. text-align: right;
  331. }
  332. .pname {
  333. display: flex;
  334. flex-direction: row;
  335. width: 40%;
  336. }
  337. .userFlagimg {
  338. padding-left: 30upx;
  339. padding-top: 10upx;
  340. width: 26upx;
  341. height: 28upx;
  342. }
  343. .wenzi {
  344. padding-left: 5upx;
  345. /* text-align:right; */
  346. white-space: nowrap;
  347. overflow: hidden;
  348. /* text-overflow: ellipsis; */
  349. }
  350. .ri {
  351. width: 690upx;
  352. height: 180upx;
  353. background: #FFFFFF;
  354. border-radius: 15upx;
  355. /* 上移 */
  356. transform: translateY(-90upx);
  357. text-align: center;
  358. margin: auto;
  359. display: flex;
  360. flex-direction: row;
  361. /* 阴影 */
  362. box-shadow: 0upx -1upx 20upx #D3D3D3;
  363. /* box-shadow:0px 0px 10px 5px #aaa; */
  364. }
  365. .riShell {
  366. display: flex;
  367. flex-direction: row;
  368. margin: auto;
  369. }
  370. .riTitle {
  371. display: flex;
  372. flex-direction: column;
  373. margin: auto;
  374. }
  375. .riqi {
  376. display: flex;
  377. flex-direction: column;
  378. margin: auto;
  379. }
  380. .fourTitle {
  381. width: 690upx;
  382. height: 294upx;
  383. display: flex;
  384. flex-direction: row;
  385. flex-wrap: wrap;
  386. background: #FFFFFF;
  387. box-shadow: 0upx 0upx 20upx #D3D3D3;
  388. margin: auto;
  389. border-radius: 15upx;
  390. transform: translateY(-60upx);
  391. }
  392. .four {
  393. display: flex;
  394. flex-direction: row;
  395. margin: auto;
  396. width: 48%;
  397. }
  398. .fourImg {
  399. width: 54upx;
  400. height: 54upx;
  401. }
  402. .qiun-padding {
  403. padding: 2%;
  404. width: 96%;
  405. }
  406. .qiun-wrap {
  407. display: flex;
  408. flex-wrap: wrap;
  409. }
  410. .qiun-rows {
  411. display: flex;
  412. flex-direction: row !important;
  413. }
  414. .fontLeft {
  415. margin-right: 6upx;
  416. }
  417. </style>