shelfList.vue 5.3 KB

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