index.vue 10 KB

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