dayReport.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div>
  3. <div>
  4. <el-form :model="queryParams" style="margin-left: 20px;" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item>
  6. <el-button size="mini" @click="dayDataSource">今天</el-button>
  7. <el-button size="mini" @click="yesDataSource">昨天</el-button>
  8. <el-button size="mini" @click="workDataSource">本周</el-button>
  9. <el-button size="mini" @click="monthDataSource">本月</el-button>
  10. <el-date-picker
  11. v-model="dateRangeCreatedDate"
  12. type="daterange"
  13. range-separator="至"
  14. start-placeholder="开始日期"
  15. end-placeholder="结束日期">
  16. </el-date-picker>
  17. <el-button size="mini" @click="queryDataSource">查询</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <span style="color:#ff9955;font-size:25px;" >|</span><span style="font-size:20px;">数据概览</span>
  21. <el-row :gutter="10" class="panel-group">
  22. <el-col :xs="12" :sm="12" :lg="6" >
  23. <div class="flex xiaoliang">
  24. <div style="line-height: 62px;font-size: 44px;">
  25. {{ form.zongliters }}L
  26. </div>
  27. <div style="font-size: 28px;">
  28. 总销量
  29. </div>
  30. </div>
  31. </el-col>
  32. <el-col :xs="12" :sm="12" :lg="6">
  33. <div class="flex xiaoe">
  34. <div style="line-height: 62px;font-size: 44px;">
  35. {{ form.zongAmt }}元
  36. </div>
  37. <div style="font-size: 28px;">
  38. 总金额
  39. </div>
  40. </div>
  41. </el-col>
  42. <el-col :xs="12" :sm="12" :lg="6" >
  43. <div class="flex xiaoliang">
  44. <div style="line-height: 62px;font-size: 44px;">
  45. {{ form.cyamt}}元
  46. </div>
  47. <div style="font-size: 28px;">
  48. 柴油
  49. </div>
  50. </div>
  51. </el-col>
  52. <el-col :xs="12" :sm="12" :lg="6" >
  53. <div class="flex xiaoliang">
  54. <div style="line-height: 62px;font-size: 44px;">
  55. {{ form.qyamt }}元
  56. </div>
  57. <div style="font-size: 28px;">
  58. 汽油
  59. </div>
  60. </div>
  61. </el-col>
  62. </el-row>
  63. </div>
  64. <div style="width:100%; height: 360px;margin: 0px 30px;background: #FFFFFF;">
  65. <span style="color:#ff9955;font-size:25px;" >|</span><span style="font-size:20px;">销售情况</span>
  66. <div ref="myChart" style="width:100%; height: 350px;" ></div>
  67. </div>
  68. <div style="width:100%; height: 181px;">
  69. <span style="color:#ff9955;font-size:25px;" >|</span><span style="font-size:20px;">详情:</span>
  70. <el-table v-loading="loading" :data="dayReportList">
  71. <el-table-column label="日期" align="center" prop="payDate" >
  72. <template slot-scope="scope">
  73. <span>{{ parseTime(scope.row.payDate, '{y}-{m}-{d}') }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="销额" align="center" prop="amt" />
  77. <el-table-column label="销量(L)" align="center" prop="orderLiters" v-if="false" />
  78. <el-table-column label="汽油" align="center" prop="qyAmt" />
  79. <el-table-column label="柴油" align="center" prop="cyAmt" />
  80. <el-table-column label="订单数" align="center" prop="orderNo" />
  81. <el-table-column label="营销费" align="center" prop="" />
  82. <el-table-column label="应收" align="center" prop="menberAmt" />
  83. <el-table-column label="到账" align="center" prop="" />
  84. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  85. <template slot-scope="scope">
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-edit"
  90. @click="handleLook(scope.row)"
  91. v-hasPermi="['station:gun:list']"
  92. >详情</el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </div>
  97. <el-dialog :title="title" :visible.sync="open" append-to-body>
  98. <el-table v-loading="loading" :data="dayReportDetailsList" >
  99. <el-table-column label="油品" align="center" prop="oilName" />
  100. <el-table-column label="油枪号" align="center" prop="oilGun" />
  101. <el-table-column label="销量(L)" align="center" prop="orderLiters"/>
  102. <el-table-column label="销额(元)" align="center" prop="amt" />
  103. <el-table-column label="优惠" align="center" prop="" v-if="false" />
  104. <el-table-column label="优惠卷" align="center" prop="" />
  105. <el-table-column label="实收" align="center" prop="" />
  106. <el-table-column label="会员支付" align="center" prop="menberAmt" />
  107. <el-table-column label="微信支付" align="center" prop="wxAmt" />
  108. <el-table-column label="支付宝支付" align="center" prop="zfbAmt" />
  109. <el-table-column label="会员充值" align="center" prop="" v-if="false"/>
  110. <el-table-column label="积分消费" align="center" prop="" v-if="false"/>
  111. </el-table>
  112. </el-dialog>
  113. </div>
  114. </template>
  115. <script>
  116. import echarts from 'echarts'
  117. require('echarts/theme/macarons') // echarts theme
  118. import { listSum,listOilType,listDayReport,getDetails,listXdata,listQydata92,listQydata95,listQydata97 } from "@/api/dataSource/saleReport";
  119. export default {
  120. name: "source",
  121. data() {
  122. return {
  123. charts: null,
  124. // 遮罩层
  125. loading: true,
  126. // 选中数组
  127. ids: [],
  128. // 非单个禁用
  129. single: true,
  130. // 非多个禁用
  131. multiple: true,
  132. // 显示搜索条件
  133. showSearch: true,
  134. // 总条数
  135. total: 0,
  136. // 优惠劵管理表格数据
  137. couponList: [],
  138. dayReportDetailsList: [],
  139. dateRangeCreatedDate:[],
  140. //x轴数据
  141. xdata:[],
  142. //92#汽油数据
  143. qydata92:[],
  144. //95#汽油数据
  145. qydata95:[],
  146. //97#汽油数据
  147. qydata97:[],
  148. // 弹出层标题
  149. title: "",
  150. // 是否显示弹出层
  151. open: false,
  152. // 查询参数
  153. queryParams: {
  154. createdDate: null,
  155. stationNo: null,
  156. stationName: null,
  157. beginTime:null,
  158. endTime:null,
  159. payDate:null
  160. },
  161. //日报数据
  162. dayReportList: [],
  163. // 表单参数
  164. form: {
  165. zongAmt:0,
  166. zongliters:0,
  167. qyamt:0,
  168. cyamt:0
  169. },
  170. // 表单校验
  171. rules: {
  172. }
  173. };
  174. },
  175. mounted() {
  176. this.$nextTick(() => {
  177. this.initChart();
  178. });
  179. },
  180. created() {
  181. //获取折线图的数据
  182. this.reset();
  183. this.queryParams.beginTime = this.getMonthDate();
  184. this.queryParams.endTime = this.getEndFormatDate(new Date());
  185. this.getDatas();
  186. this.dayDataSource();
  187. //不加等待时间的话,初始化了echarts,,getDatas的数据没有获取到。等待后数据获取到,重新加载就可以了。
  188. setTimeout(() =>{
  189. this.initChart();
  190. },1000);
  191. },
  192. methods: {
  193. initChart(){
  194. // 初始化echarts
  195. this.charts = echarts.init(this.$refs.myChart, 'macarons');
  196. console.log("xdata",this.xdata);
  197. this.charts.setOption({
  198. xAxis: {
  199. data: this.xdata,
  200. boundaryGap: false,
  201. axisTick: {
  202. show: false
  203. }
  204. },
  205. tooltip: {
  206. trigger: 'axis',
  207. axisPointer: {
  208. type: 'cross'
  209. },
  210. padding: [5, 10]
  211. },
  212. yAxis: {
  213. axisTick: {
  214. show: false
  215. }
  216. },
  217. legend: {
  218. data: ['92#', '95#','97#']
  219. },
  220. series: [{
  221. name: '92#', itemStyle: {
  222. normal: {
  223. color: '#FF005A',
  224. lineStyle: {
  225. color: '#FF005A',
  226. width: 2
  227. }
  228. }
  229. },
  230. smooth: true,
  231. type: 'line',
  232. data: this.qydata92,
  233. animationDuration: 2800,
  234. animationEasing: 'cubicInOut'
  235. },
  236. {
  237. name: '95#',
  238. smooth: true,
  239. type: 'line',
  240. itemStyle: {
  241. normal: {
  242. color: '#3888fa',
  243. lineStyle: {
  244. color: '#3888fa',
  245. width: 2
  246. },
  247. }
  248. },
  249. data: this.qydata95,
  250. animationDuration: 2800,
  251. animationEasing: 'quadraticOut'
  252. },
  253. {
  254. name: '97#',
  255. smooth: true,
  256. type: 'line',
  257. itemStyle: {
  258. normal: {
  259. color: '#ffff00',
  260. lineStyle: {
  261. color: '#ffff00',
  262. width: 2
  263. },
  264. }
  265. },
  266. data: this.qydata97,
  267. animationDuration: 2800,
  268. animationEasing: 'quadraticOut'
  269. }]
  270. });
  271. },
  272. //获取折线图用到的数据
  273. getDatas(){
  274. listXdata(this.queryParams).then(response => {
  275. this.xdata=[];
  276. console.log("查询到的xdata",response.rows);
  277. if (response.rows === "undefined") {
  278. } else {
  279. for (let i in response.rows){
  280. this.xdata.push(response.rows[i].createdDate);
  281. }
  282. }
  283. });
  284. listQydata92(this.queryParams).then(response => {
  285. this.qydata92=[];
  286. if (response.rows === "undefined") {
  287. } else {
  288. for (let i in response.rows){
  289. this.qydata92.push(response.rows[i].amt);
  290. }
  291. }
  292. });
  293. listQydata95(this.queryParams).then(response => {
  294. this.qydata95=[];
  295. if (response.rows === "undefined") {
  296. } else {
  297. for (let i in response.rows){
  298. this.qydata95.push(response.rows[i].amt);
  299. }
  300. }
  301. });
  302. listQydata97(this.queryParams).then(response => {
  303. this.qydata97=[];
  304. if (response.rows === "undefined") {
  305. } else {
  306. for (let i in response.rows){
  307. this.qydata97.push(response.rows[i].amt);
  308. }
  309. }
  310. });
  311. },
  312. /** 查询优惠劵管理列表 */
  313. getList() {
  314. listSum(this.queryParams).then(response => {
  315. if (response.data === "undefined") {
  316. } else {
  317. this.form.zongAmt = response.data.amt;
  318. this.form.zongliters = response.data.orderLiters;
  319. }
  320. });
  321. listOilType(this.queryParams).then(response => {
  322. if (response.rows === "undefined") {
  323. } else {
  324. for (let i in response.rows) {
  325. if (response.rows[i].oilType === "1") {
  326. this.form.qyamt = response.rows[i].amt;
  327. } else if (response.rows[i].oilType === "2") {
  328. this.form.cyamt = response.rows[i].amt;
  329. }
  330. }
  331. }
  332. });
  333. listDayReport(this.queryParams).then(response => {
  334. this.dayReportList = response.rows;
  335. this.total = response.total;
  336. this.loading = false;
  337. });
  338. },
  339. //本日的数据
  340. dayDataSource() {
  341. this.reset();
  342. this.queryParams.beginTime = this.getNowFormatDate(new Date());
  343. this.queryParams.endTime = this.getEndFormatDate(new Date());
  344. this.getList();
  345. },
  346. //昨天的数据
  347. yesDataSource() {
  348. this.reset();
  349. this.queryParams.beginTime = this.getFormatDate(new Date());
  350. this.queryParams.endTime = this.getNowFormatDate(new Date());
  351. this.getList();
  352. },
  353. //本周的数据
  354. workDataSource() {
  355. this.reset();
  356. this.queryParams.beginTime = this.getDates();
  357. this.queryParams.endTime = this.getEndFormatDate(new Date());
  358. this.getDatas();
  359. this.getList();
  360. setTimeout(() =>{
  361. this.initChart();
  362. },1000);
  363. },
  364. //本月数据
  365. monthDataSource() {
  366. this.reset();
  367. this.queryParams.beginTime = this.getMonthDate();
  368. this.queryParams.endTime = this.getEndFormatDate(new Date());
  369. this.getDatas();
  370. this.getList();
  371. this.initChart();
  372. },
  373. //按照指定日期
  374. queryDataSource() {
  375. this.reset();
  376. this.queryParams.beginTime = this.dateRangeCreatedDate[0];
  377. this.queryParams.endTime = this.dateRangeCreatedDate[1];
  378. this.getDatas();
  379. this.getList();
  380. setTimeout(() =>{
  381. this.initChart();
  382. },1000);
  383. },
  384. //今天
  385. getNowFormatDate(date) {
  386. let seperator1 = "-";
  387. let month = date.getMonth() + 1;
  388. let strDate = date.getDate();
  389. if (month >= 1 && month <= 9) {
  390. month = "0" + month;
  391. }
  392. if (strDate >= 0 && strDate <= 9) {
  393. strDate = "0" + strDate;
  394. }
  395. let currentdate1 = date.getFullYear() + seperator1 + month + seperator1 + strDate;
  396. return currentdate1;
  397. },
  398. //明天
  399. getEndFormatDate(myDate) {
  400. let date = myDate.getDate();
  401. date = date + 1;
  402. myDate.setDate(date);
  403. let seperator2 = "-";
  404. let month = myDate.getMonth() + 1;
  405. let strDate = myDate.getDate();
  406. if (month >= 1 && month <= 9) {
  407. month = "0" + month;
  408. }
  409. if (strDate >= 0 && strDate <= 9) {
  410. strDate = "0" + strDate;
  411. }
  412. let currentdate2 = myDate.getFullYear() + seperator2 + month + seperator2 + strDate;
  413. return currentdate2;
  414. },
  415. //昨天
  416. getFormatDate(myDate) {
  417. let date = myDate.getDate();
  418. date = date - 1;
  419. myDate.setDate(date);
  420. let seperator3 = "-";
  421. let month = myDate.getMonth() + 1;
  422. let strDate = myDate.getDate();
  423. if (month >= 1 && month <= 9) {
  424. month = "0" + month;
  425. }
  426. if (strDate >= 0 && strDate <= 9) {
  427. strDate = "0" + strDate;
  428. }
  429. let currentdate3 = myDate.getFullYear() + seperator3 + month + seperator3 + strDate;
  430. return currentdate3;
  431. },
  432. getDates() {
  433. var new_Date = new Date()
  434. var timesStamp = new_Date.getTime();
  435. var currenDay = new_Date.getDay();
  436. var dates = new Date(timesStamp + 24 * 60 * 60 * 1000 * (0 - (currenDay + 6) % 7)).toLocaleDateString().replace(/[年月]/g, '-').replace(/[日上下午]/g, '');
  437. let s = dates.replace(/-/g, "/");
  438. var dt = new Date(s);
  439. var m = dt.getMonth() + 1;
  440. var d = dt.getDate();
  441. m = m < 10 ? "0" + m : m;
  442. d = d < 10 ? "0" + d : d;
  443. dates = dt.getFullYear() + "-" + m + "-" + d
  444. return dates;
  445. },
  446. //本月第一天
  447. getMonthDate() {
  448. let date = new Date();
  449. let seperator1 = "-";
  450. let month = date.getMonth() + 1;
  451. if (month >= 1 && month <= 9) {
  452. month = "0" + month;
  453. }
  454. let currentdate = date.getFullYear() + seperator1 + month + seperator1 + "01";
  455. return currentdate;
  456. },
  457. // 表单重置
  458. reset() {
  459. this.queryParams = {
  460. createdDate: null,
  461. stationNo: null,
  462. stationName: null
  463. };
  464. this.form = {
  465. zongAmt: 0,
  466. zongliters: 0,
  467. qyamt: 0,
  468. cyamt: 0
  469. };
  470. },
  471. /** 修改按钮操作 */
  472. handleLook(row) {
  473. const payDate = row.payDate;
  474. getDetails(payDate).then(response => {
  475. this.dayReportDetailsList = response.rows;
  476. this.open = true;
  477. this.title = "";
  478. });
  479. }
  480. }
  481. };
  482. </script>
  483. <style lang="scss" scoped>
  484. .flex{
  485. display:flex;
  486. align-items:center;
  487. justify-content:center;
  488. width: 100%;
  489. height: 270px;
  490. flex-direction:column;
  491. }
  492. .flex-qy{
  493. display:flex;
  494. align-items:center;
  495. justify-content:center;
  496. }
  497. .flex-qy-sx{
  498. display:flex;
  499. align-items:center;
  500. justify-content:center;
  501. flex-direction:column;
  502. }
  503. .panel-group {
  504. padding-left: 10px;
  505. }
  506. .flex-sr{
  507. display:flex;
  508. align-items:center;
  509. justify-content:center;
  510. width: 100%;
  511. flex-direction:column;
  512. }
  513. .sr-font{
  514. font-size: 20px;
  515. color: #F4A645;
  516. }
  517. </style>