You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <view class="content">
  3. <view v-if="pieDataAll.length>0">
  4. <!-- <view v-if="pieDataAll.length>0"> -->
  5. <view class="title_name">{{dealDateTime[0]}}年{{dealDateTime[1]}}月{{dealDateTime[2]}}日黔通智联ETC事业部全国发行日报表
  6. </view>
  7. <view class="table_wrap" v-if="dataAll">
  8. <t-table>
  9. <t-tr font-size="12">
  10. <t-td>车型</t-td>
  11. <t-td>记账副卡当日开卡数</t-td>
  12. <t-td>记账卡累计发卡数</t-td>
  13. </t-tr>
  14. <t-tr v-if="dataAll.vehicleData" v-for="(item,index) in dataAll.vehicleData.vehicleDataDetails"
  15. :key="index" fontSize="12">
  16. <t-td>{{ item.vehicleType }}</t-td>
  17. <t-td>{{ item.dayCardCount }}</t-td>
  18. <t-td>{{ item.cardCount }}</t-td>
  19. </t-tr>
  20. <t-tr font-size="12">
  21. <t-td>合计</t-td>
  22. <t-td>{{ dataAll.vehicleData? dataAll.vehicleData.vehicleDataCount.dayCardCount:null }}</t-td>
  23. <t-td>{{ dataAll.vehicleData? dataAll.vehicleData.vehicleDataCount.cardCount:null }}</t-td>
  24. </t-tr>
  25. </t-table>
  26. </view>
  27. <!-- 改变类型和时间 -->
  28. <view class="change_type">
  29. <uni-data-select v-if="!isAli" v-model="selectTypeName" :localdata="typeRange" @change="changeType"
  30. :clear="false"></uni-data-select>
  31. <view class='time'>
  32. <uni-datetime-picker v-if="!isAli" type="date" :clear-icon="false" v-model="dateTime"
  33. @change="change" @show="showTan" @close="closeTan" />
  34. <!-- <button class="page-body-button" v-if="isAli" type="primary" @click="aliDate()">选择日期:yyyy-MM-dd</button> -->
  35. <view v-if="isAli" class="info_plate">
  36. <text>日期</text>
  37. <u-input v-model="dateTime" @click="aliDate" class="input" disabled placeholder="请选择日期" />
  38. <!-- <u-icon name="arrow-right" @click="aliDate" style="margin-left: 10px;display: flex;"></u-icon> -->
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="pieData !={} || chartData !={} || lineData !={} ">
  43. <view v-if=" isShow===0 ">
  44. <view class=" title title_pie">
  45. <view class="choice_item1"><uni-data-select v-if="!isAli" v-model="selectPieValue"
  46. :localdata="pieRange" @change="changePie" :clear="false">
  47. </uni-data-select></view>
  48. </view>
  49. <view class="charts-box" v-if="hideCanvas">
  50. <qiun type="pie" :opts="opts" :chartData="pieData" />
  51. </view>
  52. </view>
  53. <view v-else-if="isShow === 1">
  54. <view class="title title_pie">
  55. <view class="choice_item1"><uni-data-select v-model="selectLineValue" :localdata="lineRange"
  56. @change="changeLine" :clear="false"></uni-data-select></view>
  57. </view>
  58. <view class="charts-box" v-if="hideCanvas">
  59. <qiun type="line" :opts="optsLine" :chartData="lineData" :ontouch="true" />
  60. </view>
  61. </view>
  62. <view v-else>
  63. <view class="title title_pie">
  64. <view class="choice_item"><uni-data-select v-model="selectColValue" :localdata="colRange"
  65. @change="changeCol" :clear="false"></uni-data-select></view>
  66. </view>
  67. <view class="charts-box" v-if="hideCanvas">
  68. <qiun type="column" :opts="optsCol" :chartData="chartData" :ontouch="true" />
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="no" v-else>暂无数据统计信息</view>
  74. <u-select v-model="selectTypeName" :list="typeRange" @confirm="selectConfirm"></u-select>
  75. </view>
  76. </template>
  77. <script>
  78. import * as IFCODE from "@/utils/network/api.js";
  79. import {
  80. request
  81. } from "@/utils/network/request.js";
  82. const tools = require("../../../static/etcUtil/tools.js");
  83. import {
  84. stringToJson
  85. } from "@/utils/network/encryption";
  86. import {
  87. nowDate
  88. } from "@/utils/utils";
  89. import {
  90. getItem
  91. } from "@/utils/storage";
  92. // 表格
  93. import tTable from "@/components/t-table/t-table.vue"
  94. import tTh from '@/components/t-table/t-th.vue'
  95. import tTr from '@/components/t-table/t-tr.vue'
  96. import tTd from '@/components/t-table/t-td.vue'
  97. // import qiun from "@/subpackage/service/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue";
  98. import qiun from "../qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue";
  99. export default {
  100. data() {
  101. return {
  102. isAli: false,
  103. hideCanvas: false,
  104. canvasShow: false,
  105. dateTime: "", //日期
  106. noDealDateTime: '', //没有处理过的时间,传给后端
  107. dealDateTime: [], //处理过后的时间,前端展示
  108. dataAll: '', //总的数据
  109. //标题名称
  110. titleArr: {
  111. 'dayCardCount': '当日开户数',
  112. 'monthCardCount': '当月开户数',
  113. "monthCancelCount": "当月注销",
  114. 'yearCardCount': '当年累积开户数',
  115. 'cardCount': '总计开户数',
  116. 'dayCancelCount': '当日注销',
  117. 'yearCancelCount': '当年注销数',
  118. 'cancelCount': '总计注销数'
  119. },
  120. isShow: 0,
  121. pieData: {},
  122. chartData: {},
  123. lineData: {},
  124. opts: {
  125. fontSize: 11,
  126. },
  127. optsLine: {
  128. fontSize: 11,
  129. enableScroll: true,
  130. xAxis: {
  131. disableGrid: true,
  132. scrollShow: true,
  133. itemCount: 3
  134. },
  135. extra: {
  136. line: {
  137. type: "straight",
  138. width: 2,
  139. activeType: "hollow"
  140. }
  141. }
  142. },
  143. optsCol: {
  144. fontSize: 11,
  145. enableScroll: true,
  146. xAxis: {
  147. disableGrid: true,
  148. scrollShow: true,
  149. itemCount: 3.5
  150. },
  151. yAxis: {
  152. data: [{
  153. min: 0
  154. }]
  155. },
  156. extra: {
  157. column: {
  158. type: "group",
  159. width: 25,
  160. }
  161. }
  162. },
  163. selectPieValue: 0,
  164. pieRange: [],
  165. pieDataAll: [],
  166. selectLineValue: 0,
  167. lineRange: [{
  168. value: 0,
  169. text: "全部"
  170. },
  171. {
  172. value: 1,
  173. text: "记账卡"
  174. },
  175. {
  176. value: 2,
  177. text: "储值卡"
  178. },
  179. ],
  180. lineDataAll: [],
  181. selectColValue: 0,
  182. colRange: [],
  183. colData: {
  184. xData: ["当日开户数", "当月开户数", "当年累积开户数", "总计开户数", "当日注销", "当年注销数", "总计注销数"],
  185. yData: {}
  186. },
  187. selectTypeValue: 0,
  188. typeRange: [{
  189. value: 0,
  190. text: "饼状图"
  191. },
  192. {
  193. value: 1,
  194. text: "折线图"
  195. },
  196. {
  197. value: 2,
  198. text: "柱状图"
  199. },
  200. ],
  201. };
  202. },
  203. components: {
  204. tTable,
  205. tTh,
  206. tTr,
  207. tTd,
  208. qiun
  209. },
  210. onLoad() {
  211. // #ifdef MP-ALIPAY
  212. this.isAli = true
  213. // #endif
  214. // #ifdef MP-WEIXIN
  215. this.isAli = false
  216. // #endif
  217. this.noDealDateTime = nowDate(new Date());
  218. this.dateTime = nowDate(new Date());
  219. // this.noDealDateTime='2023-04-17';
  220. this.dealDateTime = nowDate(new Date()).split('-');
  221. this.reqPie(); //饼状图数据请求
  222. window.addEventListener('setItem', () => {
  223. console.log("此处发生变化")
  224. })
  225. },
  226. methods: {
  227. showTan() {
  228. console.log("展示")
  229. this.hideCanvas = false;
  230. },
  231. closeTan() {
  232. console.log("隐藏")
  233. this.hideCanvas = true;
  234. },
  235. getPieData(data) {
  236. //模拟从服务器获取数据时的延时
  237. setTimeout(() => {
  238. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  239. let res = {
  240. series: [{
  241. data: data
  242. }]
  243. };
  244. this.pieData = JSON.parse(JSON.stringify(res));
  245. }, 500);
  246. },
  247. getColumnData(xData, yData) {
  248. //模拟从服务器获取数据时的延时
  249. setTimeout(() => {
  250. let res = {
  251. categories: xData,
  252. series: [yData]
  253. };
  254. this.chartData = JSON.parse(JSON.stringify(res));
  255. }, 500);
  256. },
  257. getLineData(data) {
  258. //模拟从服务器获取数据时的延时
  259. setTimeout(() => {
  260. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  261. let res = {
  262. categories: data.xData,
  263. series: data.yData
  264. };
  265. this.lineData = JSON.parse(JSON.stringify(res));
  266. }, 500);
  267. },
  268. selectitem(index, item) {
  269. if (index >= 0) {
  270. this.tval = item.value;
  271. } else {
  272. this.tval = ""
  273. }
  274. },
  275. //饼状图改变
  276. changePie(e) {
  277. this.getPieData(this.pieDataAll[e]);
  278. },
  279. // 折线图改变类型
  280. changeLine(e) {
  281. this.getLineData(this.lineDataAll[e]);
  282. },
  283. // 柱状图改变
  284. changeCol(e) {
  285. this.getColumnData(this.colData.xData, this.colData.yData[e]);
  286. },
  287. // 改变类型
  288. changeType(e) {
  289. this.isShow = e;
  290. },
  291. reqPie() {
  292. tools.showLoadingAlert("加载中");
  293. let options = {
  294. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  295. data: {
  296. accountDate: this.noDealDateTime, //统计日期
  297. agencyId: [], //渠道编号
  298. cardType: [], //卡类型 1-记账卡,0-储值卡
  299. vehicleType: '', //车辆类型 0-客车,1-货车,2-专项作业车
  300. }, //请求参数
  301. method: "POST", //提交方式(默认POST)
  302. showLoading: true, //是否显示加载中(默认显示)
  303. };
  304. // 调用方式
  305. request(IFCODE.dataStatistics, options)
  306. .then((res) => {
  307. tools.hideLoadingAlert();
  308. this.dataAll = stringToJson(res.bizContent);
  309. try {
  310. if (this.dataAll.cardData) {
  311. console.log("this.dataAll", this.dataAll)
  312. this.dealPieData(stringToJson(res.bizContent)); //处理饼状图数据
  313. this.getPieData(this.pieDataAll[0]); //饼状图展示
  314. this.dealLineData(stringToJson(res.bizContent)); //处理折线图数据
  315. this.getLineData(this.lineDataAll[0]); //折线图展示
  316. this.dealColData(stringToJson(res.bizContent)) //处理柱状图数据
  317. this.getColumnData(this.colData.xData, this.colData.yData[0]); //柱状图
  318. }
  319. } catch (error) {
  320. console.log(error.name + ":" + error.message)
  321. }
  322. })
  323. },
  324. dealPieData(data) {
  325. // 记账卡合计
  326. this.pieRange = []; //清空一遍数据
  327. this.pieDataAll = []; //清空一遍数据
  328. var pieDataItem = []
  329. if (data.cardData.accountCardData.accountCardDataCount) {
  330. var list = {
  331. value: 0,
  332. text: "记账卡合计"
  333. };
  334. this.pieRange.push(list);
  335. for (var i in data.cardData.accountCardData.accountCardDataCount) {
  336. if (this.titleArr[i]) {
  337. var obj = {};
  338. obj.name = this.titleArr[i];
  339. obj.value = (data.cardData.accountCardData.accountCardDataCount)[i];
  340. }
  341. pieDataItem.push(obj);
  342. }
  343. this.pieDataAll.push(pieDataItem);
  344. }
  345. // 储值卡合计
  346. var pieDataItem1 = []
  347. if (data.cardData.valueCardData.valueCardDataCount) {
  348. var list = {
  349. value: 1,
  350. text: "储值卡合计"
  351. };
  352. this.pieRange.push(list);
  353. for (var i in data.cardData.valueCardData.valueCardDataCount) {
  354. if (this.titleArr[i]) {
  355. var obj = {};
  356. obj.name = this.titleArr[i];
  357. obj.value = (data.cardData.valueCardData.valueCardDataCount)[i];
  358. }
  359. pieDataItem1.push(obj);
  360. }
  361. this.pieDataAll.push(pieDataItem1);
  362. }
  363. // ETC卡合计
  364. var pieDataItem2 = []
  365. if (data.cardData.cardDataCount) {
  366. var list = {
  367. value: 2,
  368. text: "ETC卡合计"
  369. };
  370. this.pieRange.push(list);
  371. for (var i in data.cardData.cardDataCount) {
  372. if (this.titleArr[i]) {
  373. var obj = {};
  374. obj.name = this.titleArr[i];
  375. obj.value = (data.cardData.cardDataCount)[i];
  376. }
  377. pieDataItem2.push(obj);
  378. }
  379. this.pieDataAll.push(pieDataItem2);
  380. }
  381. console.log("this.pieDataAll", this.pieDataAll)
  382. },
  383. dealLineData(data) {
  384. this.lineDataAll = [];
  385. // 全部
  386. var lineItem = {
  387. xData: ["当日开户数", "当月开户数", "当年累积开户数", "总计开户数", "当日注销", "当年注销数", "总计注销数"],
  388. yData: []
  389. }
  390. var allData = data.cardData.accountCardData.accountCardDataDetail.concat(data.cardData.valueCardData
  391. .valueCardDataDetail)
  392. for (var i = 0; i < allData.length; i++) {
  393. if (allData[i].agencyName) {
  394. var obj = {};
  395. obj.name = allData[i].agencyName
  396. obj.data = [];
  397. for (var n in this.titleArr) {
  398. obj.data.push(allData[i][n])
  399. }
  400. lineItem.yData.push(obj)
  401. }
  402. }
  403. this.lineDataAll.push(lineItem)
  404. // 记账卡
  405. var lineItem1 = {
  406. xData: ["当日开户数", "当月开户数", "当年累积开户数", "总计开户数", "当日注销", "当年注销数", "总计注销数"],
  407. yData: []
  408. }
  409. for (var i = 0; i < data.cardData.accountCardData.accountCardDataDetail.length; i++) {
  410. if (data.cardData.accountCardData.accountCardDataDetail[i].agencyName) {
  411. var obj = {};
  412. obj.name = data.cardData.accountCardData.accountCardDataDetail[i].agencyName
  413. obj.data = [];
  414. for (var n in this.titleArr) {
  415. obj.data.push(data.cardData.accountCardData.accountCardDataDetail[i][n])
  416. }
  417. lineItem1.yData.push(obj)
  418. }
  419. }
  420. this.lineDataAll.push(lineItem1)
  421. var lineItem2 = {
  422. xData: ["当日开户数", "当月开户数", "当年累积开户数", "总计开户数", "当日注销", "当年注销数", "总计注销数"],
  423. yData: []
  424. }
  425. for (var i = 0; i < data.cardData.valueCardData.valueCardDataDetail.length; i++) {
  426. if (data.cardData.valueCardData.valueCardDataDetail[i].agencyName) {
  427. var obj = {};
  428. obj.name = data.cardData.valueCardData.valueCardDataDetail[i].agencyName
  429. obj.data = [];
  430. for (var n in this.titleArr) {
  431. obj.data.push(data.cardData.valueCardData.valueCardDataDetail[i][n])
  432. }
  433. lineItem2.yData.push(obj)
  434. }
  435. }
  436. this.lineDataAll.push(lineItem2)
  437. },
  438. dealColData(data) {
  439. this.colRange = [];
  440. var allData = data.cardData.accountCardData.accountCardDataDetail.concat(data.cardData.valueCardData
  441. .valueCardDataDetail)
  442. for (var i = 0; i < allData.length; i++) {
  443. if (allData[i].agencyName) {
  444. var obj = {};
  445. obj.value = i;
  446. obj.text = allData[i].agencyName;
  447. this.colRange.push(obj); //获得选择类表
  448. this.colData.yData[i] = {};
  449. this.colData.yData[i]['name'] = allData[i].agencyName;
  450. this.colData.yData[i]['data'] = [];
  451. for (var n in this.titleArr) {
  452. this.colData.yData[i]['data'].push(allData[i][n])
  453. }
  454. }
  455. }
  456. },
  457. // 日期事件
  458. change(e) {
  459. this.dealDateTime = e.split('-');
  460. this.dateTime = e;
  461. this.noDealDateTime = e;
  462. this.reqPie(); //饼状图数据请求
  463. // window.addEventListener("show", () => {
  464. // console.log('它发生变化了')
  465. // });
  466. // this.canvasShow = getItem("show")
  467. },
  468. aliDate() {
  469. my.datePicker({
  470. success: (res) => {
  471. console.log("您选择的日期为:" + res.date)
  472. this.dateTime = res.date;
  473. console.log("您选择的日期为:" + this.dateTime)
  474. this.dealDateTime = res.date.split('-');
  475. console.log("您选择的日期为:" + this.dealDateTime)
  476. this.noDealDateTime = res.date;
  477. console.log("您选择的日期为:" + this.noDealDateTime)
  478. this.reqPie();
  479. },
  480. });
  481. }
  482. },
  483. };
  484. </script>
  485. <style scoped>
  486. ::v-deep .uni-date-x {
  487. background-color: #EEF7F7 !important;
  488. }
  489. .content {
  490. background-color: #EEF7F7;
  491. overflow: hidden;
  492. min-height: 100vh;
  493. }
  494. .charts-box {
  495. width: 100%;
  496. height: 300px;
  497. }
  498. .title {
  499. border-left: 10rpx solid rgb(24, 144, 255);
  500. font-size: 32rpx;
  501. margin: 6px 10px;
  502. border-radius: 8rpx;
  503. }
  504. .table_wrap {
  505. font-size: 14rpx;
  506. margin: 40rpx auto;
  507. width: 700rpx;
  508. height: auto
  509. }
  510. t-tr t-td:nth-child(1) {
  511. width: 20% !important;
  512. }
  513. t-tr t-td:nth-child(2) {
  514. width: 43% !important;
  515. }
  516. t-tr t-td:nth-child(3) {
  517. width: 37% !important;
  518. }
  519. .uni-stat__select {
  520. width: 40% !important;
  521. }
  522. .info_plate {
  523. display: flex;
  524. flex-direction: row;
  525. width: 94%;
  526. height: 100rpx;
  527. margin: 0 auto;
  528. border-bottom: 2rpx solid #f2f2f2;
  529. }
  530. .title_pie {
  531. display: flex;
  532. justify-content: flex-end;
  533. align-items: center;
  534. }
  535. .uni-select {
  536. font-size: 13px !important;
  537. height: 30px !important;
  538. }
  539. .change_type {
  540. padding: 0 3%;
  541. display: flex;
  542. justify-content: space-between;
  543. margin-bottom: 36rpx;
  544. margin-top: 16rpx;
  545. }
  546. .change_type>uni-data-select {
  547. width: 40%;
  548. }
  549. .time {
  550. width: 40%;
  551. }
  552. .title_name {
  553. width: 95%;
  554. font-weight: 600;
  555. text-align: center;
  556. margin: auto;
  557. }
  558. .choice_item {
  559. width: 50%;
  560. }
  561. .choice_item1 {
  562. width: 35%;
  563. }
  564. /deep/.uni-date__x-input,
  565. /deep/.uni-select {
  566. height: 32px;
  567. line-height: 32px !important;
  568. font-size: 13px !important;
  569. }
  570. .no {
  571. text-align: center;
  572. margin: 50rpx auto;
  573. }
  574. </style>