CustomerOrderReport.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view>
  3. <view class="home">
  4. <view class="search-icon" @click="openSearch"><text class="custom-icon custom-icon-shaixuan"></text></view>
  5. <view class="charts-box">
  6. <qiun-data-charts type="mix" :chartData="chartData" :echartsH5="true" :echartsApp="true"
  7. background="none" :animation="false" />
  8. </view>
  9. </view>
  10. <view class="top-view">
  11. <view class="thead">
  12. <view class="flex1 sort-li">客户</view>
  13. <view class="flex1 phone-li">登陆账号</view>
  14. <view class="flex1 staff-li">订单数</view>
  15. <view class="flex1 cutomer-li">订单金额</view>
  16. </view>
  17. <scroll-view class="cont-ul" scroll-y="true">
  18. <view class="flex" v-for="(item, index) in goods_list" :key="index">
  19. <view class="flex1 sort-li">{{ item.customerName }}</view>
  20. <view class="flex1 phone-li">{{ item.customerMobile }}</view>
  21. <view class="flex1 staff-li">{{ item.num }}</view>
  22. <view class="flex1 cutomer-li">{{ item.amount }}</view>
  23. </view>
  24. <u-loadmore :status="load_status" :load-text="loadText" @loadmore="loadmoreData" />
  25. </scroll-view>
  26. </view>
  27. <u-popup v-model="search_show" mode="right">
  28. <view class="search-pop">
  29. <view class="form-view">
  30. <u-form label-width="160rpx" label-position="left">
  31. <u-form-item label-position="top" label="下单日期">
  32. <view class="date-li">
  33. <picker mode="date" @change="bindDateStartChange">
  34. <text
  35. class="date-li">{{ search_data.start ? $u.timeFormat(search_data.start, 'yyyy-mm-dd') : '开始日期' }}</text>
  36. </picker>
  37. </view>
  38. <view class="date-line">-</view>
  39. <view class="date-li">
  40. <picker mode="date" @change="bindDateEndChange">
  41. <text
  42. class="date-li">{{ search_data.end ? $u.timeFormat(search_data.end, 'yyyy-mm-dd') : '结束日期' }}</text>
  43. </picker>
  44. </view>
  45. </u-form-item>
  46. <u-form-item label="订单状态">
  47. <view class="clearfix form-val" @click="openSel('month_show')">
  48. <text
  49. class="float_left ellipsis">{{ search_data.orderStatus_name ? search_data.orderStatus_name : '请选择' }}</text>
  50. <view class="float_right">
  51. <u-icon :name="!search_data.orderStatus ? 'arrow-right' : 'close-circle-fill'"
  52. size="28" color="#999999"></u-icon>
  53. </view>
  54. </view>
  55. </u-form-item>
  56. <!-- <u-form-item label="商品分类">
  57. <view class="clearfix form-val" @click="openSel('cate_show')">
  58. <text
  59. class="float_left ellipsis">{{ search_data.category_name ? search_data.category_name : '请选择' }}</text>
  60. <view class="float_right">
  61. <u-icon :name="!search_data.categoryId ? 'arrow-right' : 'close-circle-fill'"
  62. size="28" color="#999999"></u-icon>
  63. </view>
  64. </view>
  65. </u-form-item> -->
  66. </u-form>
  67. </view>
  68. <view class="search-btn">
  69. <view class="btn-li" @click="clearValue()">重置</view>
  70. <view class="btn-li" @click="searchConfirm">确定</view>
  71. </view>
  72. </view>
  73. </u-popup>
  74. <tki-tree style="z-index: 99;" ref="tkitree" :selectParent="true" :range="cate_list" rangeKey="title"
  75. @confirm="cateConfirm"></tki-tree>
  76. <u-select v-model="month_show" :list="tabs_list" @confirm="confirm"></u-select>
  77. </view>
  78. </template>
  79. <script>
  80. import tkiTree from '@/components/tki-tree/tki-tree.vue';
  81. export default {
  82. components: {
  83. tkiTree
  84. },
  85. data() {
  86. return {
  87. loadText: {
  88. loadmore: '点击加载更多',
  89. loading: '努力加载中',
  90. nomore: '没有更多了'
  91. },
  92. page: 1,
  93. pageSize: 10,
  94. total: 0,
  95. type: 1,
  96. chartData: {
  97. categories: [],
  98. series: []
  99. },
  100. goods_list: {},
  101. search_data: {
  102. start: '',
  103. end: '',
  104. category_name: '',
  105. categoryId: '',
  106. orderStatus: '',
  107. orderStatus_name: ''
  108. },
  109. search_show: false,
  110. month_show: false,
  111. tabs_list: [{
  112. label: '等待审核',
  113. value: 1
  114. },
  115. {
  116. label: '等待支付',
  117. value: 2
  118. },
  119. {
  120. label: '待发货',
  121. value: 3
  122. },
  123. {
  124. label: '待收货',
  125. value: 4
  126. },
  127. {
  128. label: '已完成',
  129. value: 5
  130. },
  131. {
  132. label: '已关闭',
  133. value: 6
  134. }
  135. ],
  136. cate_list: [],
  137. load_status: 'nomore'
  138. };
  139. },
  140. onLoad() {
  141. this.customerOrder();
  142. this.getAllCategory();
  143. },
  144. onPullDownRefresh() {
  145. this.page = 1;
  146. this.customerOrder();
  147. },
  148. methods: {
  149. loadmoreData() {
  150. if (this.total / this.pageSize > this.page) {
  151. this.page += 1;
  152. this.customerOrder();
  153. }
  154. },
  155. openSearch() {
  156. this.search_show = true;
  157. },
  158. customerOrder() {
  159. this.load_status = 'loading';
  160. this.$u.api
  161. .customerOrder({
  162. page: this.page,
  163. pageSize: this.pageSize,
  164. // categoryId: this.search_data.categoryId,
  165. startTime: this.search_data.start,
  166. endTime: this.search_data.end,
  167. type: this.type,
  168. orderStatus: this.search_data.orderStatus
  169. })
  170. .then(res => {
  171. uni.stopPullDownRefresh();
  172. if (this.page === 1) {
  173. this.goods_list = res.data;
  174. } else {
  175. this.goods_list = this.goods_list.concat(res.data);
  176. }
  177. this.total = res.pageTotal;
  178. this.load_status = this.$utils.loadStatus(this.page, this.pageSize, this.total);
  179. const customerName = [];
  180. const numArr = [];
  181. const amount = [];
  182. this.$nextTick(() => {
  183. res.data.forEach(value => {
  184. customerName.push(value.customerName);
  185. numArr.push(Number(value.num));
  186. amount.push(Number(value.amount));
  187. });
  188. this.setChartData(customerName, numArr, amount);
  189. })
  190. });
  191. },
  192. setChartData(customerName, numArr, amount) {
  193. this.chartData = {
  194. categories: customerName,
  195. series: [{
  196. name: '订单数',
  197. data: numArr,
  198. // #ifdef APP-PLUS
  199. type: 'bar',
  200. // #endif
  201. // #ifdef MP-WEIXIN
  202. type: 'column',
  203. // #endif
  204. index: 1
  205. },
  206. {
  207. name: '订单金额',
  208. data: amount,
  209. type: 'line',
  210. style: 'curve',
  211. // #ifdef APP-PLUS
  212. yAxisIndex: 1,
  213. smooth: true,
  214. // #endif
  215. disableLegend: true
  216. }
  217. ]
  218. };
  219. },
  220. bindDateStartChange(e) {
  221. this.search_data.start = this.$utils.timeByTimestamp(e.detail.value + ' 00:00:00');
  222. },
  223. bindDateEndChange(e) {
  224. this.search_data.end = this.$utils.timeByTimestamp(e.detail.value + ' 23:59:59');
  225. },
  226. cateConfirm(arr) {
  227. this.search_data.category_name = arr[0].title;
  228. this.search_data.categoryId = arr[0].id;
  229. },
  230. confirm(val) {
  231. this.search_data.orderStatus = val[0].value;
  232. this.search_data.orderStatus_name = val[0].label;
  233. },
  234. openSel(key) {
  235. if (key === 'cate_show') {
  236. this.$refs.tkitree._show();
  237. return;
  238. } else if (key === 'month_show') {
  239. this.month_show = true;
  240. }
  241. },
  242. // 获取所有商品分类
  243. getAllCategory() {
  244. this.$u.api
  245. .getAllCategory({
  246. enableStatus: 5
  247. })
  248. .then(res => {
  249. this.cate_list = res.data;
  250. });
  251. },
  252. clearValue() {
  253. this.search_data = {
  254. start: '',
  255. end: '',
  256. category_name: '',
  257. categoryId: '',
  258. orderStatus: '',
  259. orderStatus_name: ''
  260. };
  261. this.searchConfirm();
  262. },
  263. searchConfirm() {
  264. this.search_show = false;
  265. this.page = 1;
  266. this.customerOrder();
  267. }
  268. }
  269. };
  270. </script>
  271. <style lang="scss" scoped>
  272. .charts-box {
  273. width: 730rpx;
  274. /* #ifdef MP-WEIXIN */
  275. height: 480rpx;
  276. /* #endif */
  277. /* #ifdef APP-PLUS */
  278. height: 550rpx;
  279. /* #endif */
  280. margin: 0 auto;
  281. }
  282. .home {
  283. position: relative;
  284. /* #ifdef MP-WEIXIN */
  285. padding-top: 70rpx;
  286. /* #endif */
  287. .search-icon {
  288. position: absolute;
  289. right: 30rpx;
  290. top: 20rpx;
  291. width: 80rpx;
  292. height: 80rpx;
  293. text-align: center;
  294. z-index: 1;
  295. }
  296. }
  297. .top-view {
  298. width: 100%;
  299. z-index: 9;
  300. .thead {
  301. line-height: 60rpx;
  302. height: 60rpx;
  303. font-size: 24rpx;
  304. background-color: #f5f5f5;
  305. display: flex;
  306. width: 100%;
  307. }
  308. .search-view {
  309. width: 100%;
  310. }
  311. }
  312. .flex1 {
  313. display: table-cell;
  314. text-align: center;
  315. position: relative;
  316. height: 100%;
  317. vertical-align: middle;
  318. &.staff-li {
  319. width: 25%;
  320. }
  321. &.sort-li {
  322. width: 25%;
  323. }
  324. &.cutomer-li {
  325. width: 25%;
  326. }
  327. &.phone-li {
  328. width: 25%;
  329. }
  330. }
  331. .cont-ul {
  332. height: calc(100vh - 620rpx);
  333. background-color: #ffffff;
  334. .flex {
  335. height: 70rpx;
  336. }
  337. }
  338. .flex {
  339. display: table;
  340. width: 750rpx;
  341. font-size: 24rpx;
  342. }
  343. </style>