shelfList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. <u-tag size='mini' type="info" shape="circle" v-if="item.state=='SUSPEND'" text="已暂停"></u-tag>
  29. </view>
  30. <view class="item-detail">
  31. <view>
  32. 货位数量:
  33. <text class="item-detail-text">{{item.shelfPlaceNum}}</text>
  34. </view>
  35. <view>
  36. 已绑定产品款数:
  37. <text class="item-detail-text">{{item.shelfPlaceBindNum}}</text>
  38. </view>
  39. <view>
  40. 设置完成:
  41. <text class="item-detail-text">{{item.finishFlag == 1 ? '是': '否'}}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="arrow" v-if="item.state!='WRITE_OFF'&&item.state!='SUSPEND'">
  46. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  47. </view>
  48. </view>
  49. <view v-if="shelfList&&shelfList.length==0">
  50. <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>
  51. </view>
  52. <view style="padding: 20upx;" v-else>
  53. <u-loadmore :status="status" />
  54. </view>
  55. </scroll-view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import { getShelfList, shelfSave } from '@/api/shelf'
  61. export default {
  62. data() {
  63. return {
  64. shelfName: '',
  65. isGobleSearch: false,
  66. shelfList: [],
  67. pageNo:1,
  68. pageSize: 15,
  69. total: 0, // 列表总数
  70. noDataText: '暂无货架',
  71. status: 'loading',
  72. tempData: null
  73. }
  74. },
  75. onLoad(opts) {
  76. uni.$on("setCustome",(data)=>{
  77. this.saveShelf(data)
  78. })
  79. uni.setNavigationBarColor({
  80. frontColor: '#ffffff',
  81. backgroundColor: this.$config('primaryColor')
  82. })
  83. },
  84. onUnload() {
  85. uni.$off("setCustome")
  86. },
  87. onShow() {
  88. this.search()
  89. },
  90. methods: {
  91. clearSearch(){
  92. this.shelfName = ''
  93. this.search()
  94. },
  95. change(v){
  96. if(v==''){
  97. this.clearSearch()
  98. }
  99. },
  100. search(){
  101. this.pageNo = 1
  102. this.shelfList = []
  103. this.getShelfList()
  104. },
  105. // 关联客户
  106. saveShelf(data){
  107. uni.showLoading({
  108. mask: true,
  109. title: '正在关联客户...'
  110. })
  111. shelfSave({
  112. shelfSn: this.tempData.shelfSn,
  113. customerSn: data.customerSn
  114. }).then(res => {
  115. if(res.status == 200){
  116. uni.navigateTo({
  117. url: "/pages/shelfSetting/shelfSet?shelfSn="+this.tempData.shelfSn
  118. })
  119. }
  120. uni.hideLoading()
  121. })
  122. },
  123. // 获取数字货架列表
  124. getShelfList(){
  125. const _this = this
  126. let params = {
  127. pageNo: this.pageNo,
  128. pageSize: this.pageSize,
  129. shelfName: this.shelfName,
  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. uni.showToast({
  187. icon: 'none',
  188. title: "此货架已暂停"
  189. })
  190. return
  191. }
  192. this.tempData = item
  193. // 又关联客户
  194. if(item.customerEntity){
  195. uni.navigateTo({
  196. url: "/pages/shelfSetting/shelfSet?shelfSn="+item.shelfSn
  197. })
  198. }else{
  199. uni.navigateTo({
  200. url: "/pages/sales/chooseCustomer?backPage=shelfSeting&shelfName="+item.shelfName
  201. })
  202. }
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="less">
  208. .moreShelfPart{
  209. width: 100%;
  210. height: 100vh;
  211. .moreShelfPart-search{
  212. padding: 20rpx;
  213. background-color: #FFFFFF;
  214. }
  215. .moreShelfPart-body{
  216. flex-grow: 1;
  217. background-color: #fff;
  218. }
  219. .nav-right{
  220. padding: 0 30upx;
  221. height: calc(100vh - 110rpx);
  222. box-sizing: border-box;
  223. .nav-right-item{
  224. padding:20upx 10upx;
  225. border-bottom: 2rpx solid #f5f5f5;
  226. display: flex;
  227. align-items: center;
  228. &:active{
  229. background: #f8f8f8;
  230. }
  231. .arrow{
  232. text-align: right;
  233. padding-left: 20rpx;
  234. }
  235. .item-info{
  236. flex:1;
  237. .item-name{
  238. font-size: 30upx;
  239. display: flex;
  240. align-items: center;
  241. }
  242. .item-detail{
  243. margin-top: 10rpx;
  244. display: flex;
  245. align-items: center;
  246. justify-content: space-between;
  247. color: #9DA8B5;
  248. font-size: 26upx;
  249. .item-detail-text{
  250. font-size: 26upx;
  251. color: #333;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. </style>