salesRecord.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.buyerNameCurrent" @change="changeInput" @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.buyerNameCurrent}}</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. changeInput(v){
  110. if(v.length==0){
  111. this.tagClick()
  112. }
  113. },
  114. // 列表
  115. getList(pageNo){
  116. const _this = this
  117. if (pageNo) {
  118. if(pageNo==1){
  119. this.listData = []
  120. }
  121. this.pageNo = pageNo
  122. }
  123. let params = {
  124. pageNo: this.pageNo,
  125. pageSize: this.pageSize
  126. }
  127. this.status = "loading"
  128. salesRecordlList(Object.assign(params, this.queryparams)).then(res => {
  129. if (res.status == 200) {
  130. if(this.pageNo>1){
  131. this.listData = this.listData.concat(res.data.list || [])
  132. }else{
  133. this.listData = res.data.list || []
  134. }
  135. this.totalNum = res.data.count || 0
  136. } else {
  137. this.listData = []
  138. this.totalNum = 0
  139. this.noDataText = res.message
  140. }
  141. this.status = "loadmore"
  142. })
  143. },
  144. // scroll-view到底部加载更多
  145. onreachBottom() {
  146. if(this.listData.length < this.totalNum){
  147. this.pageNo += 1
  148. this.getList()
  149. }
  150. },
  151. }
  152. }
  153. </script>
  154. <style lang="less">
  155. .salesRecord-box{
  156. width: 100%;
  157. height: 100vh;
  158. .sales-productInfo{
  159. padding: 20upx 30upx;
  160. background: #fff;
  161. > view{
  162. padding: 5upx 0;
  163. }
  164. }
  165. .product-list{
  166. flex-grow: 1;
  167. .search-box{
  168. padding: 0 20upx 20upx;
  169. background: #fff;
  170. }
  171. .sales-list-con{
  172. height: 100%;
  173. .sales-list-main{
  174. height: 100%;
  175. .sales-list-item{
  176. background: #ffffff;
  177. padding: 20upx;
  178. margin: 25upx;
  179. border-radius: 25upx;
  180. box-shadow: 1px 1px 3px #EEEEEE;
  181. .list-item-tit{
  182. padding-bottom: 18upx;
  183. padding-top: 10upx;
  184. border-bottom: 1px solid #e4e7ed;
  185. .u-line{
  186. display: inline-block;
  187. width: 6upx;
  188. height: 30upx;
  189. vertical-align: bottom;
  190. margin: 0 10upx;
  191. border-radius: 5upx;
  192. }
  193. .buyer{
  194. flex-grow: 1;
  195. font-size: 30upx;
  196. font-weight: bold;
  197. }
  198. >view{
  199. &:last-child{
  200. width: 150upx;
  201. color: #666;
  202. }
  203. }
  204. }
  205. .list-item-con{
  206. padding: 10upx 0;
  207. .list-item-line{
  208. padding: 8upx 0;
  209. }
  210. text{
  211. color: #666;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. </style>