shelfList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. }
  130. _this.status = 'loading'
  131. getShelfList(params).then(res => {
  132. uni.hideLoading()
  133. if(res.status == 200){
  134. let list = res.data.list
  135. if (list && list.length){
  136. // 分页 拼接数据
  137. if(_this.pageNo>1){
  138. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  139. }else{
  140. _this.shelfList = res.data.list
  141. }
  142. _this.total = res.data.count
  143. console.log(res.data.count)
  144. if (_this.shelfList.length == res.data.count) {
  145. _this.status = 'nomore'
  146. } else {
  147. _this.status = 'loadmore'
  148. }
  149. } else {
  150. _this.shelfList = list || []
  151. _this.total = 0
  152. _this.status = 'nomore'
  153. _this.noDataText = '没有查询到相关货架'
  154. }
  155. _this.noDataText = '暂无货架'
  156. }else{
  157. _this.status = 'loadmore'
  158. _this.shelfList = []
  159. _this.total = 0
  160. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  161. }
  162. })
  163. },
  164. // 加载更多
  165. onreachBottom () {
  166. if(this.shelfList.length < this.total ){
  167. if(this.isGobleSearch&&this.shelfName==''){
  168. return
  169. }
  170. this.pageNo++
  171. this.getShelfList()
  172. }else{
  173. this.status = "nomore"
  174. }
  175. },
  176. viewDetail(item){
  177. if(item.state=='WRITE_OFF'){
  178. uni.showToast({
  179. icon: 'none',
  180. title: "此货架已注销"
  181. })
  182. return
  183. }
  184. if(item.state=='SUSPEND'){
  185. return
  186. }
  187. this.tempData = item
  188. // 又关联客户
  189. if(item.customerEntity){
  190. uni.navigateTo({
  191. url: "/pages/shelfSetting/shelfSet?shelfSn="+item.shelfSn
  192. })
  193. }else{
  194. uni.navigateTo({
  195. url: "/pages/sales/chooseCustomer?backPage=shelfSeting&shelfName="+item.shelfName
  196. })
  197. }
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="less">
  203. .moreShelfPart{
  204. width: 100%;
  205. height: 100vh;
  206. .moreShelfPart-search{
  207. padding: 20rpx;
  208. background-color: #FFFFFF;
  209. }
  210. .moreShelfPart-body{
  211. flex-grow: 1;
  212. background-color: #fff;
  213. }
  214. .nav-right{
  215. padding: 0 30upx;
  216. height: calc(100vh - 110rpx);
  217. box-sizing: border-box;
  218. .nav-right-item{
  219. padding:20upx 10upx;
  220. border-bottom: 2rpx solid #f5f5f5;
  221. display: flex;
  222. align-items: center;
  223. &:active{
  224. background: #f8f8f8;
  225. }
  226. .arrow{
  227. text-align: right;
  228. padding-left: 20rpx;
  229. }
  230. .item-info{
  231. flex:1;
  232. .item-name{
  233. font-size: 30upx;
  234. display: flex;
  235. align-items: center;
  236. }
  237. .item-detail{
  238. margin-top: 10rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. color: #9DA8B5;
  243. font-size: 26upx;
  244. .item-detail-text{
  245. font-size: 26upx;
  246. color: #333;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>