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 14KB

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