shelfList.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入货架名称搜索"
  6. v-model="shelfName"
  7. :show-action="isGobleSearch"
  8. @input="change"
  9. @focus="isGobleSearch=true"
  10. @blur="isGobleSearch=false"
  11. @custom="search"
  12. @search="search"
  13. @clear="clearSearch"
  14. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  15. </u-search>
  16. </view>
  17. <view class="moreShelfPart-body">
  18. <scroll-view
  19. class="nav-right"
  20. scroll-y
  21. @scrolltolower="onreachBottom">
  22. <view class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id" @click="viewDetail(item)">
  23. <view class="item-info">
  24. <view class="item-name">
  25. <text>{{item.shelfName}}</text>
  26. </view>
  27. <view class="item-detail">
  28. <view>
  29. 货位数量:
  30. <text class="item-detail-text">{{item.shelfPlaceNum}}</text>
  31. </view>
  32. <view>
  33. 已绑定产品款数:
  34. <text class="item-detail-text">{{item.shelfPlaceBindNum}}</text>
  35. </view>
  36. <view>
  37. 设置完成:
  38. <text class="item-detail-text">{{item.finishFlag == 1 ? '是': '否'}}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="arrow">
  43. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  44. </view>
  45. </view>
  46. <view v-if="shelfList&&shelfList.length==0">
  47. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  48. </view>
  49. <view style="padding: 20upx;" v-else>
  50. <u-loadmore :status="status" />
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import { getShelfList, shelfSave } from '@/api/shelf'
  58. export default {
  59. data() {
  60. return {
  61. shelfName: '',
  62. isGobleSearch: false,
  63. shelfList: [],
  64. pageNo:1,
  65. pageSize: 15,
  66. total: 0, // 列表总数
  67. noDataText: '暂无货架',
  68. status: 'loading',
  69. tempData: null
  70. }
  71. },
  72. onLoad(opts) {
  73. uni.$on("setCustome",(data)=>{
  74. this.saveShelf(data)
  75. })
  76. },
  77. onUnload() {
  78. uni.$off("setCustome")
  79. },
  80. onShow() {
  81. this.search()
  82. },
  83. methods: {
  84. clearSearch(){
  85. this.shelfName = ''
  86. this.search()
  87. },
  88. change(v){
  89. if(v==''){
  90. this.clearSearch()
  91. }
  92. },
  93. search(){
  94. this.pageNo = 1
  95. this.shelfList = []
  96. this.getShelfList()
  97. },
  98. // 关联客户
  99. saveShelf(data){
  100. uni.showLoading({
  101. mask: true,
  102. title: '正在关联客户...'
  103. })
  104. shelfSave({
  105. shelfSn: this.tempData.shelfSn,
  106. customerSn: data.customerSn
  107. }).then(res => {
  108. if(res.status == 200){
  109. uni.navigateTo({
  110. url: "/pages/shelfSetting/shelfSet?shelfSn="+this.tempData.shelfSn
  111. })
  112. }
  113. uni.hideLoading()
  114. })
  115. },
  116. // 获取数字货架列表
  117. getShelfList(){
  118. const _this = this
  119. let params = {
  120. pageNo: this.pageNo,
  121. pageSize: this.pageSize,
  122. shelfName: this.shelfName
  123. }
  124. _this.status = 'loading'
  125. getShelfList(params).then(res => {
  126. uni.hideLoading()
  127. if(res.status == 200){
  128. let list = res.data.list
  129. if (list && list.length){
  130. // 分页 拼接数据
  131. if(_this.pageNo>1){
  132. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  133. }else{
  134. _this.shelfList = res.data.list
  135. }
  136. _this.total = res.data.count
  137. console.log(res.data.count)
  138. if (_this.shelfList.length == res.data.count) {
  139. _this.status = 'nomore'
  140. } else {
  141. _this.status = 'loadmore'
  142. }
  143. } else {
  144. _this.shelfList = list || []
  145. _this.total = 0
  146. _this.status = 'nomore'
  147. _this.noDataText = '没有查询到相关货架'
  148. }
  149. _this.noDataText = '暂无货架'
  150. }else{
  151. _this.status = 'loadmore'
  152. _this.shelfList = []
  153. _this.total = 0
  154. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  155. }
  156. })
  157. },
  158. // 加载更多
  159. onreachBottom () {
  160. if(this.shelfList.length < this.total ){
  161. if(this.isGobleSearch&&this.shelfName==''){
  162. return
  163. }
  164. this.pageNo++
  165. this.getShelfList()
  166. }else{
  167. this.status = "nomore"
  168. }
  169. },
  170. viewDetail(item){
  171. this.tempData = item
  172. // 又关联客户
  173. if(item.customerEntity){
  174. uni.navigateTo({
  175. url: "/pages/shelfSetting/shelfSet?shelfSn="+item.shelfSn
  176. })
  177. }else{
  178. uni.navigateTo({
  179. url: "/pages/sales/chooseCustomer?backPage=shelfSeting&shelfName="+item.shelfName
  180. })
  181. }
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="less">
  187. .moreShelfPart{
  188. width: 100%;
  189. height: 100vh;
  190. .moreShelfPart-search{
  191. padding: 20rpx;
  192. background-color: #FFFFFF;
  193. }
  194. .moreShelfPart-body{
  195. flex-grow: 1;
  196. background-color: #fff;
  197. }
  198. .nav-right{
  199. padding: 0 30upx;
  200. height: calc(100vh - 110rpx);
  201. box-sizing: border-box;
  202. .nav-right-item{
  203. padding:20upx 10upx;
  204. border-bottom: 2rpx solid #f5f5f5;
  205. display: flex;
  206. align-items: center;
  207. &:active{
  208. background: #f8f8f8;
  209. }
  210. .arrow{
  211. text-align: right;
  212. padding-left: 20rpx;
  213. }
  214. .item-info{
  215. flex:1;
  216. .item-name{
  217. font-size: 30upx;
  218. display: flex;
  219. align-items: center;
  220. }
  221. .item-detail{
  222. margin-top: 10rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: space-between;
  226. color: #9DA8B5;
  227. font-size: 26upx;
  228. .item-detail-text{
  229. font-size: 26upx;
  230. color: #333;
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. </style>