MerchandiseSalesStatement.vue 9.8 KB

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