salesRecord.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="salesRecord-box flex flex_column">
  3. <view class="sales-productInfo" v-if="baseData">
  4. <view>产品名称:{{ baseData.productName }}</view>
  5. <view>产品编码:{{ baseData.productCode }}</view>
  6. </view>
  7. <view class="product-list">
  8. <view class="search-box">
  9. <u-cell-group>
  10. <u-cell-item value="去选择" @click="toChooseCust">
  11. <view slot="title">
  12. 选择客户:
  13. <u-tag v-if="buyerName" :text="buyerName" closeable :show="show" @close="tagClick" shape="circle" />
  14. <u-tag v-else :text="'全部'" shape="circle" />
  15. </view>
  16. </u-cell-item>
  17. </u-cell-group>
  18. </view>
  19. <scroll-view class="sales-list-con" :style="{height: scrollH+'upx'}" scroll-y @scrolltolower="onreachBottom">
  20. <view class="sales-list-main">
  21. <view class="sales-list-item" v-for="(item, index) in listData" :key="item.id">
  22. <view class="list-item-tit flex align_center">
  23. <view class="u-line" :style="{background: $config('primaryColor')}"></view>
  24. <view class="buyer">{{item.salesBillEntity.buyerName}}</view>
  25. </view>
  26. <view class="list-item-con">
  27. <view class="list-item-line flex align_center justify_between">
  28. <view>销售时间:<text>{{item.salesBillEntity.createDate}}</text></view>
  29. </view>
  30. <view class="list-item-line flex align_center justify_between">
  31. <view>销售数量:<text>{{toThousands(item.qty||0)}}</text></view>
  32. <view>销售价:<text>¥{{toThousands(item.price||0, 2)}}</text></view>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-if="listData && listData.length == 0 && status!='loading'">
  37. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="150"></u-empty>
  38. </view>
  39. <view style="padding: 60upx;">
  40. <u-loadmore v-if="totalNum>listData.length || status=='loading'" :status="status" />
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {salesRecordlList} from "@/api/sales.js"
  49. import { toThousands } from '@/libs/tools'
  50. export default {
  51. data() {
  52. return {
  53. listData: [],
  54. pageNo: 1,
  55. pageSize: 10,
  56. totalNum: 0,
  57. status: 'loadmore',
  58. noDataText: '暂无销售记录',
  59. scrollH: 300,
  60. queryparams: {
  61. buyerSn: undefined,
  62. productSn: undefined
  63. },
  64. buyerName: '',
  65. baseData: null,
  66. show:false
  67. }
  68. },
  69. onLoad(opts) {
  70. this.queryparams.productSn = opts ? opts.productSn : undefined
  71. this.baseData ={productName:opts.productName,productCode:opts.productCode}
  72. uni.$on("searchSalesRecord",(data)=>{
  73. this.queryparams.buyerSn = data.customerSn
  74. this.buyerName = data.customerName
  75. this.show = true
  76. this.getList(1)
  77. })
  78. },
  79. onUnload() {
  80. uni.$off("searchSalesRecord")
  81. },
  82. onReady() {
  83. const sys = uni.getSystemInfoSync()
  84. if(sys.platform == 'android'){
  85. this.scrollH = (sys.windowHeight - sys.statusBarHeight - 120) * 2
  86. }else{
  87. if(sys.safeArea.top){
  88. this.scrollH = (sys.windowHeight - 120) * 2 + sys.statusBarHeight - 34
  89. }else{
  90. this.scrollH = (sys.windowHeight - 120) * 2 - 14
  91. }
  92. }
  93. this.getList()
  94. },
  95. methods: {
  96. toThousands:toThousands,
  97. toChooseCust(){
  98. uni.navigateTo({
  99. url:"/pages/sales/chooseCustomer?backPage=salesRecord"
  100. })
  101. },
  102. tagClick(){
  103. this.show = false
  104. this.buyerName = undefined
  105. this.queryparams.buyerSn = undefined
  106. this.getList(1)
  107. },
  108. // 列表
  109. getList(pageNo){
  110. const _this = this
  111. if (pageNo) {
  112. if(pageNo==1){
  113. this.listData = []
  114. }
  115. this.pageNo = pageNo
  116. }
  117. let params = {
  118. pageNo: this.pageNo,
  119. pageSize: this.pageSize
  120. }
  121. this.status = "loading"
  122. salesRecordlList(Object.assign(params, this.queryparams)).then(res => {
  123. if (res.status == 200) {
  124. if(this.pageNo>1){
  125. this.listData = this.listData.concat(res.data.list || [])
  126. }else{
  127. this.listData = res.data.list || []
  128. }
  129. this.totalNum = res.data.count || 0
  130. } else {
  131. this.listData = []
  132. this.totalNum = 0
  133. this.noDataText = res.message
  134. }
  135. this.status = "loadmore"
  136. })
  137. },
  138. // scroll-view到底部加载更多
  139. onreachBottom() {
  140. if(this.listData.length < this.totalNum){
  141. this.pageNo += 1
  142. this.getList()
  143. }
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="less">
  149. .salesRecord-box{
  150. width: 100%;
  151. height: 100vh;
  152. .sales-productInfo{
  153. padding: 20upx 30upx;
  154. background: #fff;
  155. > view{
  156. padding: 5upx 0;
  157. }
  158. }
  159. .product-list{
  160. flex-grow: 1;
  161. .search-box{
  162. background: #fff;
  163. }
  164. .sales-list-con{
  165. height: 100%;
  166. .sales-list-main{
  167. height: 100%;
  168. .sales-list-item{
  169. background: #ffffff;
  170. padding: 20upx;
  171. margin: 25upx;
  172. border-radius: 25upx;
  173. box-shadow: 1px 1px 3px #EEEEEE;
  174. .list-item-tit{
  175. padding-bottom: 18upx;
  176. padding-top: 10upx;
  177. border-bottom: 1px solid #e4e7ed;
  178. .u-line{
  179. display: inline-block;
  180. width: 6upx;
  181. height: 30upx;
  182. vertical-align: bottom;
  183. margin: 0 10upx;
  184. border-radius: 5upx;
  185. }
  186. .buyer{
  187. flex-grow: 1;
  188. font-size: 30upx;
  189. font-weight: bold;
  190. }
  191. >view{
  192. &:last-child{
  193. width: 150upx;
  194. color: #666;
  195. }
  196. }
  197. }
  198. .list-item-con{
  199. padding: 10upx 0;
  200. .list-item-line{
  201. padding: 8upx 0;
  202. }
  203. text{
  204. color: #666;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. </style>