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

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