index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <view class="content flex flex_column">
  3. <div class="p-header" @click="openShlef">
  4. <text>{{curCustomerName||'全部客户'}}</text>
  5. <u-icon name="arrow-right"></u-icon>
  6. </div>
  7. <div class="e-chart">
  8. <div class="card-box" v-if="$hasPermissions('M_salesStatistics_mobile')">
  9. <div class="card-tits">
  10. 销售单
  11. </div>
  12. <div class="card-body">
  13. <div class="data-box flex">
  14. <div>
  15. <div class="data-amount">
  16. {{allData&&allData.salesTotalQty||0}}
  17. </div>
  18. <div class="data-label">销售产品数量(个)</div>
  19. </div>
  20. <div>
  21. <div class="data-amount">
  22. <u-count-to :end-val="allData&&allData.salesTotalAmount||0" separator="," :decimals="2"></u-count-to>
  23. </div>
  24. <div class="data-label">销售金额(元)</div>
  25. </div>
  26. </div>
  27. <qiun-data-charts
  28. type="line"
  29. :opts="opts"
  30. :ontouch="true"
  31. :chartData="chartData"
  32. />
  33. </div>
  34. </div>
  35. <div class="card-box" v-if="allData&&allData.xprhFlag&&$hasPermissions('M_shelfOrderTj_mobile')">
  36. <div class="card-tits">
  37. 货架订单
  38. </div>
  39. <div class="card-body">
  40. <div class="data-box flex">
  41. <div>
  42. <div class="data-amount">
  43. {{allData&&allData.orderTotalQty||0}}
  44. </div>
  45. <div class="data-label">取货产品数量(个)</div>
  46. </div>
  47. <div>
  48. <div class="data-amount">
  49. <u-count-to :end-val="allData&&allData.orderTotalAmount||0" separator="," :decimals="2"></u-count-to>
  50. </div>
  51. <div class="data-label">取货产品金额(元)</div>
  52. </div>
  53. </div>
  54. <qiun-data-charts
  55. type="line"
  56. :opts="opts1"
  57. :ontouch="true"
  58. :chartData="chartData1"
  59. />
  60. </div>
  61. </div>
  62. <div class="card-box" v-if="allData&&allData.xprhFlag&&$hasPermissions('M_tempOrderTj_mobile')">
  63. <div class="card-tits">
  64. 急送订单
  65. </div>
  66. <div class="card-body">
  67. <div class="data-box flex">
  68. <div>
  69. <div class="data-amount">
  70. {{allData&&allData.tempTotalQty||0}}
  71. </div>
  72. <div class="data-label">急送产品数量(个)</div>
  73. </div>
  74. <div>
  75. <div class="data-amount">
  76. <u-count-to :end-val="allData&&allData.tempTotalAmount||0" separator="," :decimals="2"></u-count-to>
  77. </div>
  78. <div class="data-label">急送产品金额(元)</div>
  79. </div>
  80. </div>
  81. <qiun-data-charts
  82. type="line"
  83. :opts="opts2"
  84. :ontouch="true"
  85. :chartData="chartData2"
  86. />
  87. </div>
  88. </div>
  89. </div>
  90. <!-- 筛选项 -->
  91. <u-popup v-model="showSearch" mode="right" width="70%">
  92. <view class="tabBox">
  93. <view class="tabs">
  94. <view class="flex">
  95. <view :class="item.val==curTab?'active':'all'" v-for="item in placeTab" :key="item.val" @click="tabChange(item)">{{item.name}}</view>
  96. </view>
  97. </view>
  98. <view class="flex align_center form-item-inp" style="padding: 0 30rpx;" v-if="curTab == 6">
  99. <u-input clearable v-model="dateArray" disabled placeholder="请选择时间段" @click="showDate=true" />
  100. <u-icon name="arrow-down" color="#999"></u-icon>
  101. </view>
  102. <view class="form-footer-btn">
  103. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" @click="handleClean">重置</u-button>
  104. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
  105. </view>
  106. </view>
  107. </u-popup>
  108. <!-- 选择日期范围 -->
  109. <u-calendar v-model="showDate" @change="dateChange" mode="range"></u-calendar>
  110. </view>
  111. </template>
  112. <script>
  113. import chooseShelf from './chooseShelf.vue'
  114. import { salesStatistics } from '@/api/sales.js'
  115. import getDate from '@/libs/getDate.js'
  116. export default {
  117. components: { chooseShelf },
  118. data() {
  119. return {
  120. customerSn: '',
  121. curCustomerName: '',
  122. chartData: {},
  123. chartData1: {},
  124. chartData2: {},
  125. opts: {},
  126. opts1:{},
  127. opts2:{},
  128. allData: null,
  129. showSearch: false,
  130. showDate: false,
  131. dateArray: '',
  132. customBtnStyle: { // 自定义按钮样式
  133. borderColor: this.$config('primaryColor'),
  134. backgroundColor: this.$config('primaryColor'),
  135. color: '#fff'
  136. },
  137. queryPramas:{
  138. beginDate: '',
  139. endDate: '',
  140. buyerSn: ''
  141. },
  142. placeTab: [
  143. {
  144. name:'今日',
  145. val: '0'
  146. },
  147. {
  148. name:'昨日',
  149. val: '1'
  150. },
  151. {
  152. name:'本周',
  153. val: '2'
  154. },
  155. {
  156. name:'上周',
  157. val: '3'
  158. },
  159. {
  160. name:'本月',
  161. val: '4'
  162. },
  163. {
  164. name:'上月',
  165. val: '5'
  166. },
  167. {
  168. name:'自定义',
  169. val: '6'
  170. }
  171. ],
  172. curTab: '4',
  173. webView: null
  174. }
  175. },
  176. onLoad() {
  177. uni.$on('chooseShelfOk',(data)=>{
  178. this.customerSn = data.customerSn
  179. this.curCustomerName = data.customerName
  180. this.queryPramas.buyerSn = data.customerSn
  181. })
  182. //#ifdef APP-PLUS
  183. this.webView = this.$mp.page.$getAppWebview();
  184. //#endif
  185. // 默认数据
  186. this.tabChange(this.placeTab[2])
  187. },
  188. onReady() {
  189. setTimeout(()=>{
  190. this.getServerData()
  191. },500)
  192. },
  193. onUnload() {
  194. uni.$off("chooseShelfOk")
  195. },
  196. onNavigationBarButtonTap() {
  197. this.showSearch = true
  198. },
  199. onBackPress() {
  200. if(this.showSearch){
  201. this.showSearch = false
  202. return true
  203. }
  204. },
  205. methods: {
  206. // 时间 change
  207. dateChange(date){
  208. this.dateArray = date.startDate + ' ~ ' + date.endDate
  209. this.queryPramas.beginDate = date.startDate + ' 00:00:00'
  210. this.queryPramas.endDate = date.endDate + ' 23:59:59'
  211. //#ifdef APP-PLUS
  212. this.webView.setTitleNViewButtonStyle(0, {
  213. "text":"\ue626 "+date.startDate+"~"+date.endDate,
  214. "color": "#00aaff",
  215. "width": "180px"
  216. });
  217. //#endif
  218. },
  219. tabChange(data){
  220. this.curTab = data.val
  221. if(data.val != 6){
  222. //#ifdef APP-PLUS
  223. this.webView.setTitleNViewButtonStyle(0, {
  224. "text":"\ue626 "+data.name,
  225. "color": "#00aaff",
  226. "width": "80px"
  227. });
  228. //#endif
  229. }else{
  230. this.dateArray = ''
  231. this.queryPramas.beginDate = ''
  232. this.queryPramas.endDate = ''
  233. }
  234. },
  235. // 重置
  236. handleClean(){
  237. this.tabChange(this.placeTab[2])
  238. this.showSearch = false
  239. this.getServerData()
  240. },
  241. // 查询
  242. handleSearch(){
  243. if(this.curTab == 6){
  244. if(this.queryPramas.beginDate&&this.queryPramas.endDate){
  245. this.getServerData()
  246. this.showSearch = false
  247. }else{
  248. uni.showToast({
  249. icon:'none',
  250. title: "请选择时间段"
  251. })
  252. }
  253. }else{
  254. this.getServerData()
  255. this.showSearch = false
  256. }
  257. },
  258. // 格式化折线图数据
  259. getFormatData(categories,data,name){
  260. if(data){
  261. data.map(item => Number(item))
  262. }
  263. return {
  264. categories: categories,
  265. series: [
  266. {
  267. name: name,
  268. data: data||[],
  269. label:{
  270. position: 'top'
  271. }
  272. },
  273. ]
  274. }
  275. },
  276. getOpts(data){
  277. return {
  278. enableScroll: true,
  279. xAxis: {
  280. disableGrid: true,
  281. itemCount: 4,
  282. scrollShow: data.length > 4,
  283. scrollAlign:'right'
  284. },
  285. yAxis: {
  286. gridType: "dash",
  287. dashLength: 2
  288. },
  289. }
  290. },
  291. getQueryDate(){
  292. const fun = [
  293. getDate.getToday,
  294. getDate.getYesterday,
  295. getDate.getCurrWeekDays,
  296. getDate.getLastWeekDays,
  297. getDate.getCurrLastMonthDays,
  298. getDate.getLastMonthDays
  299. ];
  300. return {
  301. beginDate: fun[this.curTab]().starttime,
  302. endDate: fun[this.curTab]().endtime
  303. }
  304. },
  305. getServerData() {
  306. let params = {}
  307. // 不是自定义时间段
  308. if(this.curTab != 6){
  309. params = this.getQueryDate()
  310. }
  311. salesStatistics(Object.assign(this.queryPramas,params)).then(res => {
  312. if(res.status == 200){
  313. this.allData = res.data
  314. this.chartData = this.getFormatData(res.data.salesDateList,res.data.salesAmountList,"销售金额")
  315. this.opts = this.getOpts(res.data.salesDateList)
  316. this.chartData1 = this.getFormatData(res.data.orderDateList,res.data.orderAmountList,"取货产品金额")
  317. this.opts1 = this.getOpts(res.data.orderDateList)
  318. this.chartData2 = this.getFormatData(res.data.tempDateList,res.data.tempAmountList,"急送产品金额")
  319. this.opts2 = this.getOpts(res.data.tempDateList)
  320. }
  321. })
  322. },
  323. openShlef(){
  324. uni.navigateTo({
  325. url: "/pages/statistics/chooseShelf?customerSn="+this.customerSn
  326. })
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="less">
  332. .content{
  333. height: 100vh;
  334. width: 100%;
  335. .p-header{
  336. background-color: #fff;
  337. text-align: center;
  338. padding-bottom: 20rpx;
  339. }
  340. .e-chart{
  341. flex-grow: 1;
  342. padding: 20rpx;
  343. font-size: 28rpx;
  344. overflow: auto;
  345. .card-box{
  346. background-color: #fff;
  347. margin-bottom: 20rpx;
  348. border-radius: 16rpx;
  349. overflow: hidden;
  350. > div{
  351. padding: 20rpx;
  352. &:first-child{
  353. padding-bottom: 0;
  354. }
  355. }
  356. .card-tits{
  357. font-weight: bold;
  358. }
  359. .data-box{
  360. padding-bottom: 20rpx;
  361. > div{
  362. width: 50%;
  363. text-align: center;
  364. border-right: 1rpx solid #eee;
  365. &:last-child{
  366. border:0;
  367. }
  368. .data-amount{
  369. font-size: 50rpx;
  370. }
  371. .data-label{
  372. color: #999;
  373. font-size: 24rpx;
  374. }
  375. }
  376. }
  377. }
  378. .card-body{
  379. overflow: auto;
  380. }
  381. }
  382. // 筛选
  383. .tabBox{
  384. height: 100vh;
  385. .tabs{
  386. flex-grow: 1;
  387. overflow: auto;
  388. padding: 20rpx;
  389. > view{
  390. flex-wrap: wrap;
  391. justify-content: space-between;
  392. > view{
  393. width: 45%;
  394. border: 1rpx solid #eee;
  395. padding: 15rpx;
  396. border-radius: 50rpx;
  397. text-align: center;
  398. margin-bottom: 15rpx;
  399. }
  400. .active{
  401. border:0;
  402. background-color: #0485F6;
  403. color: #fff;
  404. }
  405. }
  406. }
  407. .form-item-inp{
  408. border-bottom: 1rpx solid #eee;
  409. }
  410. .form-footer-btn{
  411. margin: 30upx;
  412. display: flex;
  413. justify-content: space-between;
  414. }
  415. .form-footer-btn {
  416. display: flex;
  417. .handle-btn {
  418. font-size: 28upx;
  419. margin: 0 10upx;
  420. flex: 1;
  421. }
  422. }
  423. }
  424. }
  425. </style>