salesRecord.vue 5.7 KB

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