statisticsMore.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="销售统计"></u-navbar>
  5. <view class="content">
  6. <view class="device-table" v-if="type=='device'">
  7. <view class="table">
  8. <view class="table-title flex justify-between align-center">
  9. <view class="title">
  10. 设备销售排行
  11. </view>
  12. <view class="sort-type flex">
  13. <view :class="[deviceSortType==0?'sort-type-item sort-type-show':'sort-type-item']" @click="deviceSort(0)">
  14. 销售额
  15. </view>
  16. <view :class="[deviceSortType==1?'sort-type-item sort-type-show':'sort-type-item']" @click="deviceSort(1)">
  17. 订单笔数
  18. </view>
  19. </view>
  20. </view>
  21. <uni-table :border="false" :stripe="false" emptyText="暂无更多数据">
  22. <!-- 表头行 -->
  23. <uni-tr>
  24. <uni-th align="center" width="52">排名</uni-th>
  25. <uni-th align="center" width="110">上榜设备</uni-th>
  26. <uni-th align="center" width="92">销售额</uni-th>
  27. <uni-th align="center" width="96">订单笔数</uni-th>
  28. </uni-tr>
  29. <!-- 表格数据行 -->
  30. <uni-tr v-for="(item,index) in list1" :key="item.deviceId">
  31. <uni-td v-if="index==0">
  32. <view class="table-td">
  33. <image class="table-img" src="../../static/images/global/first-class.png"
  34. mode="widthFix"></image>
  35. </view>
  36. </uni-td>
  37. <uni-td v-else-if="index==1">
  38. <view class="table-td">
  39. <image class="table-img" src="../../static/images/global/second-class.png"
  40. mode="widthFix"></image>
  41. </view>
  42. </uni-td>
  43. <uni-td v-else-if="index==2">
  44. <view class="table-td">
  45. <image class="table-img" src="../../static/images/global/third-class.png"
  46. mode="widthFix"></image>
  47. </view>
  48. </uni-td>
  49. <uni-td v-else>
  50. <view class="table-td">
  51. {{index+1}}
  52. </view>
  53. </uni-td>
  54. <uni-td>
  55. <view class="table-td table-td-name">{{item.deviceName||item.deviceId}}</view>
  56. </uni-td>
  57. <uni-td>
  58. <view class="table-td">¥{{$xy.delMoney(item.salesMoney)}}</view>
  59. </uni-td>
  60. <uni-td>
  61. <view class="table-td">{{item.salesCount}}笔</view>
  62. </uni-td>
  63. </uni-tr>
  64. </uni-table>
  65. </view>
  66. </view>
  67. <view class="goods-table" v-else>
  68. <view class="table">
  69. <view class="table-title flex justify-between align-center">
  70. <view class="title">
  71. 商品销售排行
  72. </view>
  73. <view class="sort-type flex">
  74. <view :class="[goodsSortType==0?'sort-type-item sort-type-show':'sort-type-item']" @click="goodsSort(0)">
  75. 销售额
  76. </view>
  77. <view :class="[goodsSortType==1?'sort-type-item sort-type-show':'sort-type-item']" @click="goodsSort(1)">
  78. 销量
  79. </view>
  80. </view>
  81. </view>
  82. <uni-table :border="false" :stripe="false" emptyText="暂无更多数据">
  83. <!-- 表头行 -->
  84. <uni-tr>
  85. <uni-th align="center" width="52">排名</uni-th>
  86. <uni-th align="center" width="110">上榜商品</uni-th>
  87. <uni-th align="center" width="92">销售额</uni-th>
  88. <uni-th align="center" width="92">销量</uni-th>
  89. </uni-tr>
  90. <!-- 表格数据行 -->
  91. <uni-tr v-for="(item,index) in list2" :key="item.goodsId">
  92. <uni-td v-if="index==0">
  93. <view class="table-td">
  94. <image class="table-img" src="../../static/images/global/first-class.png"
  95. mode="widthFix"></image>
  96. </view>
  97. </uni-td>
  98. <uni-td v-else-if="index==1">
  99. <view class="table-td">
  100. <image class="table-img" src="../../static/images/global/second-class.png"
  101. mode="widthFix"></image>
  102. </view>
  103. </uni-td>
  104. <uni-td v-else-if="index==2">
  105. <view class="table-td">
  106. <image class="table-img" src="../../static/images/global/third-class.png"
  107. mode="widthFix"></image>
  108. </view>
  109. </uni-td>
  110. <uni-td v-else>
  111. <view class="table-td">
  112. {{index+1}}
  113. </view>
  114. </uni-td>
  115. <uni-td>
  116. <view class="table-td table-td-name">{{item.goodsName}}</view>
  117. </uni-td>
  118. <uni-td>
  119. <view class="table-td">¥{{$xy.delMoney(item.salesMoney)}}</view>
  120. </uni-td>
  121. <uni-td>
  122. <view class="table-td">{{item.goodsCount}}件</view>
  123. </uni-td>
  124. </uni-tr>
  125. </uni-table>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. import {
  133. sumPage
  134. } from "@/api/commodity/goods.js"
  135. import {
  136. sumPage as deviceSumPage
  137. } from "@/api/device/device.js"
  138. export default {
  139. data() {
  140. return {
  141. timeStart: '',
  142. timeEnd: '',
  143. typeColumns: [
  144. ['销售额', '订单笔数']
  145. ],
  146. status: 'loadmore', //加载更多
  147. list1: [], //设备列表
  148. list2: [], //商品列表
  149. type:'device',
  150. deviceSortType: 0,
  151. goodsSortType: 0,
  152. }
  153. },
  154. onLoad(o) {
  155. let _this = this;
  156. const query = uni.createSelectorQuery().in(this);
  157. query.select(".list").boundingClientRect((data) => {
  158. uni.getSystemInfo({
  159. success(res) {
  160. _this.fullHeight = 2 * (res.windowHeight - data.top - 24) + 'rpx';
  161. },
  162. });
  163. }).exec();
  164. this.type=o.type
  165. this.timeStart=o.timeStart
  166. this.timeEnd=o.timeEnd
  167. if(this.type=='device'){
  168. this.deviceSortType=o.sortType
  169. }else{
  170. this.goodsSortType=o.sortType
  171. }
  172. },
  173. onShow() {
  174. this.getData()
  175. },
  176. methods: {
  177. getData() {
  178. if(this.type=='device'){
  179. this.getList1(this.deviceSortType)
  180. }else{
  181. this.getList2(this.goodsSortType)
  182. }
  183. },
  184. deviceSort(type){
  185. this.deviceSortType=type
  186. this.getList1(type)
  187. },
  188. goodsSort(type){
  189. this.goodsSortType=type
  190. this.getList2(type)
  191. },
  192. getParams(type) {
  193. let orderByKey = "";
  194. let orderBy = "";
  195. switch (type) {
  196. case '销售额':
  197. orderBy = 'desc';
  198. orderByKey = 'sales_money';
  199. break;
  200. case '订单笔数':
  201. orderBy = 'desc';
  202. orderByKey = 'sales_count';
  203. break;
  204. case '销量':
  205. orderBy = 'desc';
  206. orderByKey = 'goods_count';
  207. break;
  208. default:
  209. break;
  210. }
  211. let params = {
  212. type: 'day',
  213. orderByKey: orderByKey,
  214. orderBy: orderBy,
  215. beginDate: this.timeStart,
  216. endDate: this.timeEnd
  217. }
  218. return params
  219. },
  220. //获取设备排行
  221. getList1(e) {
  222. let type=e==0?'销售额':'订单笔数';
  223. let dataParams = this.getParams(type)
  224. let pageParams = {
  225. page: {
  226. current: 1,
  227. size: 1000
  228. }
  229. }
  230. let params = Object.assign(dataParams, pageParams)
  231. deviceSumPage(params).then(res => {
  232. if (res.data) {
  233. this.list1 = res.data.records;
  234. } else {
  235. this.list1 = []
  236. }
  237. })
  238. },
  239. //获取商品排行
  240. getList2(e) {
  241. let type=e==0?'销售额':'销量';
  242. let dataParams = this.getParams(type)
  243. let pageParams = {
  244. page: {
  245. current: 1,
  246. size: 1000
  247. }
  248. }
  249. let params = Object.assign(dataParams, pageParams)
  250. sumPage(params).then(res => {
  251. if (res.data) {
  252. this.list2 = res.data.records;
  253. } else {
  254. this.list2 = []
  255. }
  256. })
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .container {
  263. .content {
  264. .select {
  265. .time-tab {
  266. padding: 0 36rpx;
  267. .time-tab-item {
  268. padding: 0 24rpx;
  269. background-color: #fff;
  270. border: 1rpx solid #e0b4a2;
  271. text-align: center;
  272. line-height: 50rpx;
  273. color: #e0b4a2;
  274. border-radius: 40rpx;
  275. &.time-tab-show {
  276. background-color: #eab09a;
  277. color: #d98a6d;
  278. }
  279. }
  280. }
  281. .time-select {
  282. padding: 24rpx 36rpx;
  283. color: rgb(144, 144, 144);
  284. font-size: 28rpx;
  285. >view:nth-child(2) {
  286. width: 160rpx;
  287. text-align: right;
  288. }
  289. >view:nth-child(3) {
  290. width: 80rpx;
  291. padding: 0 24rpx;
  292. }
  293. }
  294. }
  295. .total {
  296. padding: 12rpx 0;
  297. background-color: #fff;
  298. .total-name {
  299. color: #333;
  300. font-size: 28rpx;
  301. line-height: 50rpx;
  302. }
  303. .total-num {
  304. color: #eab09a;
  305. font-size: 32rpx;
  306. font-weight: bold;
  307. line-height: 50rpx;
  308. }
  309. }
  310. .search {
  311. padding: 24rpx 24rpx;
  312. background-color: #fff;
  313. position: relative;
  314. font-size: 26rpx;
  315. .time-type {
  316. width: 180rpx;
  317. }
  318. .time-select {
  319. width: 340rpx;
  320. line-height: 64rpx;
  321. background-color: #eeeeef;
  322. border-radius: 6rpx;
  323. }
  324. }
  325. .table {
  326. width: 100%;
  327. background-color: #fff;
  328. color:#333;
  329. .table-title {
  330. line-height: 50rpx;
  331. padding: 24rpx;
  332. border-bottom: 1rpx solid #ebeef5;
  333. }
  334. .table-td {
  335. width: 100%;
  336. text-align: center;
  337. &.table-td-name{
  338. width:270rpx;
  339. white-space: wrap;
  340. }
  341. }
  342. .table-img {
  343. width: 40rpx;
  344. height: 40rpx;
  345. position: relative;
  346. }
  347. .sort-type {
  348. width: 250rpx;
  349. height: 50rpx;
  350. line-height: 48rpx;
  351. text-align: center;
  352. font-weight: normal;
  353. .sort-type-item {
  354. width: 50%;
  355. font-size: 26rpx;
  356. color: #555555;
  357. background-color: #fff;
  358. &.sort-type-item:nth-child(1) {
  359. border-top-left-radius: 6rpx;
  360. border-bottom-left-radius: 6rpx;
  361. border-top: 1rpx solid #CCCCCC;
  362. border-left: 1rpx solid #CCCCCC;
  363. border-bottom: 1rpx solid #CCCCCC;
  364. &.sort-type-show {
  365. color: #fff;
  366. border-top: 1rpx solid #2C6FF3;
  367. border-left: 1rpx solid #2C6FF3;
  368. border-bottom: 1rpx solid #2C6FF3;
  369. background-color: #2C6FF3;
  370. }
  371. }
  372. &.sort-type-item:nth-child(2) {
  373. border-top-right-radius: 6rpx;
  374. border-bottom-right-radius: 6rpx;
  375. border-top: 1rpx solid #CCCCCC;
  376. border-right: 1rpx solid #CCCCCC;
  377. border-bottom: 1rpx solid #CCCCCC;
  378. &.sort-type-show {
  379. color: #fff;
  380. border-top: 1rpx solid #2C6FF3;
  381. border-right: 1rpx solid #2C6FF3;
  382. border-bottom: 1rpx solid #2C6FF3;
  383. background-color: #2C6FF3;
  384. }
  385. }
  386. }
  387. }
  388. /deep/.uni-table-th {
  389. color: #333;
  390. font-weight: normal;
  391. }
  392. /deep/.uni-table-td{
  393. vertical-align: middle;
  394. }
  395. }
  396. .more{
  397. text-align: right;
  398. padding-right: 40rpx;
  399. position: relative;
  400. color:#333;
  401. line-height: 80rpx;
  402. background-color: #fff;
  403. >view{
  404. position: absolute;
  405. right:12rpx;
  406. top:50%;
  407. transform: translateY(-50%);
  408. }
  409. }
  410. }
  411. }
  412. </style>