shelfList.vue 6.2 KB

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