salesRecord.vue 5.6 KB

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