shelfList.vue 6.1 KB

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