shelfList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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="getShelfList"
  12. @search="getShelfList"
  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-if="total>pageSize || status=='loading'">
  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. this.getShelfList()
  74. uni.$on("setCustome",(data)=>{
  75. this.pageNo = 1
  76. this.shelfList = []
  77. this.getShelfList()
  78. this.saveShelf(data)
  79. })
  80. },
  81. onUnload() {
  82. uni.$off("setCustome")
  83. },
  84. methods: {
  85. clearSearch(){
  86. this.shelfName = ''
  87. this.pageNo = 1
  88. this.shelfList = []
  89. this.getShelfList()
  90. },
  91. change(v){
  92. if(v==''){
  93. this.clearSearch()
  94. }
  95. },
  96. // 关联客户
  97. saveShelf(data){
  98. shelfSave({
  99. shelfSn: this.tempData.shelfSn,
  100. customerSn: data.customerSn
  101. }).then(res => {
  102. uni.navigateTo({
  103. url: "/pages/shelfSetting/shelfSet?shelfSn="+this.tempData.shelfSn
  104. })
  105. })
  106. },
  107. // 获取数字货架列表
  108. getShelfList(){
  109. const _this = this
  110. let params = {
  111. pageNo: this.pageNo,
  112. pageSize: this.pageSize,
  113. shelfName: this.shelfName
  114. }
  115. _this.status = 'loading'
  116. getShelfList(params).then(res => {
  117. uni.hideLoading()
  118. if(res.status == 200){
  119. let list = res.data.list
  120. if (list && list.length){
  121. // 分页 拼接数据
  122. if (_this.pageNo != 1) {
  123. _this.shelfList = _this.shelfList ? _this.shelfList.concat(list) : list
  124. } else {
  125. _this.shelfList = list
  126. }
  127. this.total = res.data.count
  128. console.log(res.data.count)
  129. if (_this.shelfList.length == res.data.count) {
  130. _this.status = 'nomore'
  131. } else {
  132. _this.status = 'loadmore'
  133. }
  134. } else {
  135. _this.shelfList = list || []
  136. this.total = 0
  137. _this.status = 'nomore'
  138. _this.noDataText = '没有查询到相关货架'
  139. }
  140. _this.noDataText = '暂无货架'
  141. }else{
  142. _this.status = 'loadmore'
  143. _this.shelfList = []
  144. _this.total = 0
  145. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  146. }
  147. })
  148. },
  149. // 加载更多
  150. onreachBottom () {
  151. if(this.shelfList.length < this.total ){
  152. if(this.isGobleSearch&&this.shelfName==''){
  153. return
  154. }
  155. this.pageNo++
  156. this.getShelfList()
  157. }else{
  158. this.status = "nomore"
  159. }
  160. },
  161. viewDetail(item){
  162. this.tempData = item
  163. // 又关联客户
  164. if(item.customerEntity){
  165. uni.navigateTo({
  166. url: "/pages/shelfSetting/shelfSet?shelfSn="+item.shelfSn
  167. })
  168. }else{
  169. uni.navigateTo({
  170. url: "/pages/sales/chooseCustomer?backPage=shelfSeting&shelfName="+item.shelfName
  171. })
  172. }
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="less">
  178. .moreShelfPart{
  179. width: 100%;
  180. height: 100vh;
  181. .moreShelfPart-search{
  182. padding: 20rpx;
  183. background-color: #FFFFFF;
  184. }
  185. .moreShelfPart-body{
  186. flex-grow: 1;
  187. background-color: #fff;
  188. }
  189. .nav-right{
  190. padding: 0 30upx;
  191. height: calc(100vh - 110rpx);
  192. box-sizing: border-box;
  193. .nav-right-item{
  194. padding:20upx 10upx;
  195. border-bottom: 2rpx solid #f5f5f5;
  196. display: flex;
  197. align-items: center;
  198. &:active{
  199. background: #f8f8f8;
  200. }
  201. .arrow{
  202. text-align: right;
  203. padding-left: 20rpx;
  204. }
  205. .item-info{
  206. flex:1;
  207. .item-name{
  208. font-size: 30upx;
  209. display: flex;
  210. align-items: center;
  211. }
  212. .item-detail{
  213. margin-top: 10rpx;
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. color: #9DA8B5;
  218. font-size: 26upx;
  219. .item-detail-text{
  220. font-size: 26upx;
  221. color: #333;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. </style>