dayReport.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <el-scrollbar style="height:100%">
  3. <div>
  4. <div>
  5. <el-form
  6. :model="queryParams"
  7. style="margin-left: 20px;"
  8. ref="queryForm"
  9. :inline="true"
  10. v-show="showSearch"
  11. label-width="68px"
  12. >
  13. <el-form-item>
  14. <el-button size="mini" @click="dayDataSource">今天</el-button>
  15. <el-button size="mini" @click="yesDataSource">昨天</el-button>
  16. <el-button size="mini" @click="workDataSource">本周</el-button>
  17. <el-button size="mini" @click="monthDataSource">本月</el-button>
  18. <el-date-picker
  19. style="margin: 0px 10px;"
  20. size="mini"
  21. v-model="dateRangeCreatedDate"
  22. type="daterange"
  23. range-separator="至"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期"
  26. ></el-date-picker>
  27. <el-button size="mini" @click="queryDataSource">查询</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <span style="color:#ff9955;font-size:25px;">|</span>
  31. <span style="font-size:20px;">数据概览</span>
  32. <el-row :gutter="10" class="panel-group">
  33. <el-col :xs="12" :sm="12" :lg="6">
  34. <div class="flex xiaoliang">
  35. <div style="line-height: 62px;font-size: 44px;">{{ form.zongliters }}L</div>
  36. <div style="font-size: 28px;">总销量</div>
  37. </div>
  38. </el-col>
  39. <el-col :xs="12" :sm="12" :lg="6">
  40. <div class="flex xiaoe">
  41. <div style="line-height: 62px;font-size: 44px;">{{ form.zongAmt }}元</div>
  42. <div style="font-size: 28px;">总金额</div>
  43. </div>
  44. </el-col>
  45. <el-col :xs="12" :sm="12" :lg="6">
  46. <div class="flex xiaoliang">
  47. <div style="line-height: 62px;font-size: 44px;">{{ form.qyamt }}元</div>
  48. <div style="font-size: 28px;">汽油</div>
  49. </div>
  50. </el-col>
  51. <el-col :xs="12" :sm="12" :lg="6">
  52. <div class="flex xiaoliang">
  53. <div style="line-height: 62px;font-size: 44px;">{{ form.cyamt}}元</div>
  54. <div style="font-size: 28px;">柴油</div>
  55. </div>
  56. </el-col>
  57. </el-row>
  58. </div>
  59. <div style="width:100%; height: 360px;background: #FFFFFF;">
  60. <span style="color:#ff9955;font-size:25px;">|</span>
  61. <span style="font-size:20px;">销售情况</span>
  62. <div ref="myChart" style="width:100%; height: 350px;margin: 0px 25px;"></div>
  63. </div>
  64. <div style="width:100%; height: 181px;">
  65. <span style="color:#ff9955;font-size:25px;">|</span>
  66. <span style="font-size:20px;">详情:</span>
  67. <el-table v-loading="loading" :data="dayReportList">
  68. <el-table-column label="日期" align="center" prop="payDate">
  69. <template slot-scope="scope">
  70. <span>{{ parseTime(scope.row.createdDate, '{y}-{m}-{d}') }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="销额" align="center" prop="amt" />
  74. <el-table-column label="销量(L)" align="center" prop="orderLiters" v-if="false" />
  75. <el-table-column label="汽油" align="center" prop="qyAmt" />
  76. <el-table-column label="柴油" align="center" prop="cyAmt" />
  77. <el-table-column label="订单数" align="center" prop="orderNo" />
  78. <el-table-column label="应收" align="center" prop="receivableAmt" />
  79. <el-table-column label="到账" align="center" prop ="receivedAmt"/>
  80. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  81. <template slot-scope="scope">
  82. <el-button
  83. size="mini"
  84. type="text"
  85. icon="el-icon-edit"
  86. @click="handleLook(scope.row)"
  87. >详情</el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <pagination
  92. v-show="total>0"
  93. :total="total"
  94. :page.sync="queryParams.pageNum"
  95. :limit.sync="queryParams.pageSize"
  96. @pagination="dayReportDetail"
  97. />
  98. </div>
  99. <el-dialog :title="title" width="800px" :visible.sync="open" append-to-body>
  100. <el-table v-loading="loading" :data="dayReportDetailsList">
  101. <el-table-column label="油品" align="center" prop="oilName" />
  102. <el-table-column label="油枪号" align="center" prop="oilGun" />
  103. <el-table-column label="销量(L)" align="center" prop="orderLiters" />
  104. <el-table-column label="应收金额(元)" align="center" prop="receivableAmt" />
  105. <el-table-column label="实收金额(元)" align="center" prop="amt" />
  106. <el-table-column label="优惠金额(元)" align="center" prop="discountAmt" />
  107. <el-table-column label="优惠劵" align="center" prop="discountCouponAmt" v-if="false"/>
  108. <el-table-column label="会员支付" align="center" prop="menberAmt" v-if="false" />
  109. <el-table-column label="微信支付" align="center" prop="wxAmt" v-if="false" />
  110. <el-table-column label="支付宝支付" align="center" prop="zfbAmt"v-if="false" />
  111. <el-table-column label="会员充值" align="center" prop v-if="false" />
  112. <el-table-column label="积分消费" align="center" prop v-if="false" />
  113. </el-table>
  114. <pagination
  115. v-show="total1>0"
  116. :total="total1"
  117. :page.sync="queryInfo.pageNum"
  118. :limit.sync="queryInfo.pageSize"
  119. @pagination="getLookOrder"
  120. />
  121. </el-dialog>
  122. </div>
  123. </el-scrollbar>
  124. </template>
  125. <script>
  126. import echarts from "echarts";
  127. require("echarts/theme/macarons"); // echarts theme
  128. import {
  129. listSum,
  130. listOilType,
  131. listDayReport,
  132. selectDayReportDetail,
  133. getDetails,
  134. listXdata,
  135. listQydata92,
  136. listQydata95,
  137. listQydata97,
  138. listQydata0,
  139. listQydata10,
  140. listQydata20
  141. } from "@/api/dataSource/saleReport";
  142. export default {
  143. name: "source",
  144. data() {
  145. return {
  146. charts: null,
  147. // 遮罩层
  148. loading: true,
  149. // 选中数组
  150. ids: [],
  151. // 非单个禁用
  152. single: true,
  153. // 非多个禁用
  154. multiple: true,
  155. // 显示搜索条件
  156. showSearch: true,
  157. // 总条数
  158. total: 0,
  159. total1: 0,
  160. // 优惠劵管理表格数据
  161. couponList: [],
  162. dayReportDetailsList: [],
  163. dateRangeCreatedDate: [],
  164. //x轴数据
  165. xdata: [],
  166. //92#汽油数据
  167. qydata92: [],
  168. //95#汽油数据
  169. qydata95: [],
  170. //97#汽油数据
  171. qydata97: [],
  172. //0#柴油数据
  173. cydata0: [],
  174. //-10#柴油数据
  175. cydata10: [],
  176. //-20#柴油数据
  177. cydata20: [],
  178. // 弹出层标题
  179. title: "",
  180. // 是否显示弹出层
  181. open: false,
  182. // 查询参数
  183. queryParams: {
  184. createdDate: null,
  185. stationNo: null,
  186. stationName: null,
  187. beginTime: null,
  188. endTime: null,
  189. payDate: null,
  190. status:"1"
  191. },
  192. // 查询参数
  193. queryInfo: {
  194. pageNum: 1,
  195. pageSize: 10,
  196. payDate: null,
  197. status: null,
  198. createdDate: null,
  199. beginTime: null,
  200. endTime: null
  201. },
  202. //日报数据
  203. dayReportList: [],
  204. // 表单参数
  205. form: {
  206. zongAmt: 0,
  207. zongliters: 0,
  208. qyamt: 0,
  209. cyamt: 0
  210. },
  211. // 表单校验
  212. rules: {}
  213. };
  214. },
  215. mounted() {
  216. this.$nextTick(() => {
  217. this.queryParams.beginTime = this.getMonthDate();
  218. this.queryParams.endTime = this.getEndFormatDate(new Date());
  219. setTimeout(() => {
  220. this.initChart();
  221. }, 1000);
  222. });
  223. },
  224. created() {
  225. //获取折线图的数据
  226. this.reset();
  227. this.queryParams.beginTime = this.getMonthDate();
  228. this.queryParams.endTime = this.getEndFormatDate(new Date());
  229. this.getDatas();
  230. this.dayDataSource();
  231. },
  232. methods: {
  233. initChart() {
  234. // 初始化echarts
  235. this.charts = echarts.init(this.$refs.myChart, "macarons");
  236. this.charts.setOption(
  237. {
  238. xAxis: {
  239. data: this.xdata,
  240. boundaryGap: false,
  241. axisTick: {
  242. show: false
  243. }
  244. },
  245. tooltip: {
  246. trigger: "axis",
  247. axisPointer: {
  248. type: "cross"
  249. },
  250. padding: [5, 10]
  251. },
  252. yAxis: {
  253. axisTick: {
  254. show: false
  255. }
  256. },
  257. legend: {
  258. data: ["92#", "95#", "97#", "0#", "-10#", "-20#"]
  259. },
  260. animation: false,
  261. series: [
  262. {
  263. name: "92#",
  264. itemStyle: {
  265. normal: {
  266. color: "#FF005A",
  267. lineStyle: {
  268. color: "#FF005A",
  269. width: 2
  270. }
  271. }
  272. },
  273. smooth: true,
  274. type: "line",
  275. data: this.qydata92
  276. },
  277. {
  278. name: "95#",
  279. smooth: true,
  280. type: "line",
  281. itemStyle: {
  282. normal: {
  283. color: "#3888fa",
  284. lineStyle: {
  285. color: "#3888fa",
  286. width: 2
  287. }
  288. }
  289. },
  290. data: this.qydata95
  291. },
  292. {
  293. name: "97#",
  294. smooth: true,
  295. type: "line",
  296. itemStyle: {
  297. normal: {
  298. color: "#ffff00",
  299. lineStyle: {
  300. color: "#ffff00",
  301. width: 2
  302. }
  303. }
  304. },
  305. data: this.qydata97
  306. },
  307. {
  308. name: "0#",
  309. smooth: true,
  310. type: "line",
  311. itemStyle: {
  312. normal: {
  313. color: "#00ff00",
  314. lineStyle: {
  315. color: "#00ff00",
  316. width: 2
  317. }
  318. }
  319. },
  320. data: this.cydata0
  321. },
  322. {
  323. name: "-10#",
  324. smooth: true,
  325. type: "line",
  326. itemStyle: {
  327. normal: {
  328. color: "#00bfff",
  329. lineStyle: {
  330. color: "#00bfff",
  331. width: 2
  332. }
  333. }
  334. },
  335. data: this.cydata10
  336. },
  337. {
  338. name: "-20#",
  339. smooth: true,
  340. type: "line",
  341. itemStyle: {
  342. normal: {
  343. color: "#ffb6c1",
  344. lineStyle: {
  345. color: "#ffb6c1",
  346. width: 2
  347. }
  348. }
  349. },
  350. data: this.cydata20
  351. /* animationDuration: 2800,
  352. animationEasing: 'quadraticOut'*/
  353. }
  354. ]
  355. },
  356. true
  357. );
  358. },
  359. getXData() {
  360. return listXdata(this.queryParams).then(response => {
  361. this.xdata = [];
  362. if(response.hasOwnProperty('rows')){
  363. for (let i in response.rows) {
  364. this.xdata.push(response.rows[i].createdDate);
  365. }
  366. }
  367. });
  368. },
  369. getQyData92() {
  370. return listQydata92(this.queryParams).then(response => {
  371. this.qydata92 = [];
  372. if(response.hasOwnProperty('rows')){
  373. for (let i in response.rows) {
  374. let data = [];
  375. data.push(response.rows[i].createdDate);
  376. data.push(response.rows[i].amt);
  377. this.qydata92.push(data);
  378. }
  379. }
  380. });
  381. },
  382. getQydata95() {
  383. return listQydata95(this.queryParams).then(response => {
  384. this.qydata95 = [];
  385. if(response.hasOwnProperty('rows')){
  386. for (let i in response.rows) {
  387. let data = [];
  388. data.push(response.rows[i].createdDate);
  389. data.push(response.rows[i].amt);
  390. this.qydata95.push(data);
  391. }
  392. }
  393. });
  394. },
  395. getQydata97() {
  396. return listQydata97(this.queryParams).then(response => {
  397. this.qydata97 = [];
  398. if(response.hasOwnProperty('rows')){
  399. for (let i in response.rows) {
  400. let data = [];
  401. data.push(response.rows[i].createdDate);
  402. data.push(response.rows[i].amt);
  403. this.qydata97.push(data);
  404. }
  405. }
  406. });
  407. },
  408. getQydata0() {
  409. return listQydata0(this.queryParams).then(response => {
  410. this.cydata0 = [];
  411. if(response.hasOwnProperty('rows')){
  412. for (let i in response.rows) {
  413. let data = [];
  414. data.push(response.rows[i].createdDate);
  415. data.push(response.rows[i].amt);
  416. this.cydata0.push(data);
  417. }
  418. }
  419. });
  420. },
  421. getQydata10() {
  422. return listQydata10(this.queryParams).then(response => {
  423. this.cydata10 = [];
  424. if(response.hasOwnProperty('rows')){
  425. for (let i in response.rows) {
  426. let data = [];
  427. data.push(response.rows[i].createdDate);
  428. data.push(response.rows[i].amt);
  429. this.cydata10.push(data);
  430. }
  431. }
  432. });
  433. },
  434. getQydata20() {
  435. return listQydata20(this.queryParams).then(response => {
  436. this.cydata20 = [];
  437. if(response.hasOwnProperty('rows')){
  438. for (let i in response.rows) {
  439. let data = [];
  440. data.push(response.rows[i].createdDate);
  441. data.push(response.rows[i].amt);
  442. this.cydata20.push(data);
  443. }
  444. }
  445. });
  446. },
  447. //获取折线图用到的数据
  448. getDatas() {
  449. Promise.all([
  450. this.getXData(),
  451. this.getQyData92(),
  452. this.getQydata95(),
  453. this.getQydata97(),
  454. this.getQydata0(),
  455. this.getQydata10(),
  456. this.getQydata20()
  457. ]).then(res => {
  458. this.initChart();
  459. });
  460. },
  461. /** 查询优惠劵管理列表 */
  462. getList() {
  463. listSum(this.queryParams).then(response => {
  464. if (response.hasOwnProperty('data')) {
  465. this.form.zongAmt = response.data.amt;
  466. this.form.zongliters = response.data.orderLiters;
  467. }
  468. });
  469. listOilType(this.queryParams).then(response => {
  470. if(response.hasOwnProperty('rows')){
  471. for (let i in response.rows) {
  472. if (response.rows[i].oilType === "2") {
  473. this.form.qyamt = response.rows[i].amt;
  474. } else if (response.rows[i].oilType === "1") {
  475. this.form.cyamt = response.rows[i].amt;
  476. }
  477. }
  478. }
  479. });
  480. this.dayReportDetail();
  481. },
  482. dayReportDetail(){
  483. selectDayReportDetail(this.queryParams).then(response => {
  484. this.dayReportList = response.rows;
  485. console.log("response",response);
  486. this.total = response.total;
  487. this.loading = false;
  488. });
  489. },
  490. //本日的数据
  491. dayDataSource() {
  492. this.reset();
  493. this.queryParams.beginTime = this.getNowFormatDate(new Date());
  494. this.queryParams.endTime = this.getEndFormatDate(new Date());
  495. this.getList();
  496. },
  497. //昨天的数据
  498. yesDataSource() {
  499. this.reset();
  500. this.queryParams.beginTime = this.getFormatDate(new Date());
  501. this.queryParams.endTime = this.getNowFormatDate(new Date());
  502. this.getList();
  503. },
  504. //本周的数据
  505. workDataSource() {
  506. this.reset();
  507. this.queryParams.beginTime = this.getDates();
  508. this.queryParams.endTime = this.getEndFormatDate(new Date());
  509. //this.initChart();
  510. this.getDatas();
  511. this.getList();
  512. },
  513. //本月数据
  514. monthDataSource() {
  515. this.reset();
  516. this.queryParams.beginTime = this.getMonthDate();
  517. this.queryParams.endTime = this.getEndFormatDate(new Date());
  518. this.getDatas();
  519. this.getList();
  520. },
  521. //按照指定日期
  522. queryDataSource() {
  523. this.reset();
  524. this.queryParams.beginTime = this.dateRangeCreatedDate[0];
  525. this.queryParams.endTime = this.dateRangeCreatedDate[1];
  526. this.getDatas();
  527. this.getList();
  528. },
  529. //今天
  530. getNowFormatDate(date) {
  531. let seperator1 = "-";
  532. let month = date.getMonth() + 1;
  533. let strDate = date.getDate();
  534. if (month >= 1 && month <= 9) {
  535. month = "0" + month;
  536. }
  537. if (strDate >= 0 && strDate <= 9) {
  538. strDate = "0" + strDate;
  539. }
  540. let currentdate1 =
  541. date.getFullYear() + seperator1 + month + seperator1 + strDate;
  542. return currentdate1;
  543. },
  544. //明天
  545. getEndFormatDate(myDate) {
  546. let date = myDate.getDate();
  547. date = date + 1;
  548. myDate.setDate(date);
  549. let seperator2 = "-";
  550. let month = myDate.getMonth() + 1;
  551. let strDate = myDate.getDate();
  552. if (month >= 1 && month <= 9) {
  553. month = "0" + month;
  554. }
  555. if (strDate >= 0 && strDate <= 9) {
  556. strDate = "0" + strDate;
  557. }
  558. let currentdate2 =
  559. myDate.getFullYear() + seperator2 + month + seperator2 + strDate;
  560. return currentdate2;
  561. },
  562. //昨天
  563. getFormatDate(myDate) {
  564. let date = myDate.getDate();
  565. date = date - 1;
  566. myDate.setDate(date);
  567. let seperator3 = "-";
  568. let month = myDate.getMonth() + 1;
  569. let strDate = myDate.getDate();
  570. if (month >= 1 && month <= 9) {
  571. month = "0" + month;
  572. }
  573. if (strDate >= 0 && strDate <= 9) {
  574. strDate = "0" + strDate;
  575. }
  576. let currentdate3 =
  577. myDate.getFullYear() + seperator3 + month + seperator3 + strDate;
  578. return currentdate3;
  579. },
  580. getDates() {
  581. var new_Date = new Date();
  582. var timesStamp = new_Date.getTime();
  583. var currenDay = new_Date.getDay();
  584. var dates = new Date(
  585. timesStamp + 24 * 60 * 60 * 1000 * (0 - ((currenDay + 6) % 7))
  586. )
  587. .toLocaleDateString()
  588. .replace(/[年月]/g, "-")
  589. .replace(/[日上下午]/g, "");
  590. let s = dates.replace(/-/g, "/");
  591. var dt = new Date(s);
  592. var m = dt.getMonth() + 1;
  593. var d = dt.getDate();
  594. m = m < 10 ? "0" + m : m;
  595. d = d < 10 ? "0" + d : d;
  596. dates = dt.getFullYear() + "-" + m + "-" + d;
  597. return dates;
  598. },
  599. //本月第一天
  600. getMonthDate() {
  601. let date = new Date();
  602. let seperator1 = "-";
  603. let month = date.getMonth() + 1;
  604. if (month >= 1 && month <= 9) {
  605. month = "0" + month;
  606. }
  607. let currentdate =
  608. date.getFullYear() + seperator1 + month + seperator1 + "01";
  609. return currentdate;
  610. },
  611. // 表单重置
  612. reset() {
  613. this.queryParams = {
  614. createdDate: null,
  615. stationNo: null,
  616. stationName: null
  617. };
  618. this.form = {
  619. zongAmt: 0,
  620. zongliters: 0,
  621. qyamt: 0,
  622. cyamt: 0
  623. };
  624. },
  625. /** 查看详情按钮操作 */
  626. handleLook(row) {
  627. this.row =row;
  628. row.page= this.queryInfo.pageNum;
  629. row.limit= this.queryInfo.pageSize;
  630. this.getLookOrder(row);
  631. },
  632. getLookOrder(row) {
  633. const createdDate = this.row.createdDate;
  634. this.queryInfo.beginTime =createdDate.substring(0,10) +" 00:00:00";
  635. this.queryInfo.endTime =createdDate.substring(0,10) +" 23:59:59";
  636. this.queryInfo.status = "1";
  637. this.queryInfo.pageNum=row.page;
  638. this.queryInfo.pageSize =row.limit;
  639. getDetails(this.queryInfo).then(response => {
  640. this.dayReportDetailsList = response.rows;
  641. this.total1 = response.total;
  642. this.open = true;
  643. this.title = "日报详细信息";
  644. });
  645. }
  646. }
  647. };
  648. </script>
  649. <style lang="scss" scoped>
  650. .flex {
  651. display: flex;
  652. align-items: center;
  653. justify-content: center;
  654. width: 100%;
  655. height: 270px;
  656. flex-direction: column;
  657. }
  658. .flex-qy {
  659. display: flex;
  660. align-items: center;
  661. justify-content: center;
  662. }
  663. .flex-qy-sx {
  664. display: flex;
  665. align-items: center;
  666. justify-content: center;
  667. flex-direction: column;
  668. }
  669. .panel-group {
  670. padding-left: 10px;
  671. }
  672. .flex-sr {
  673. display: flex;
  674. align-items: center;
  675. justify-content: center;
  676. width: 100%;
  677. flex-direction: column;
  678. }
  679. .sr-font {
  680. font-size: 20px;
  681. color: #f4a645;
  682. }
  683. </style>