searchShelfHw.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="searchBar">
  4. <view class="shelfName">{{shelfName}}</view>
  5. <view class="search flex align_center">
  6. <view class="input">
  7. <u-search
  8. v-model="queryWord"
  9. @custom="getpartList"
  10. @search="getpartList"
  11. @clear="clearSearch"
  12. bg-color="#fff"
  13. :action-style="{border:'0.1rpx solid #00aaff',borderRadius:'50rpx',color:'#00aaff'}"
  14. placeholder="请输入产品编码或名称搜索"></u-search>
  15. </view>
  16. <view class="icon" @click="toScan">
  17. <u-icon name="scan"></u-icon>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="check-list">
  22. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  23. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  24. <view class="product flex align_center" @click="toEdit(item)">
  25. <view class="flex align_center flex_1">
  26. <view class="pimgs">
  27. <u-image :src="item.productEntity&&item.productEntity.images?item.productEntity.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  28. </view>
  29. <view class="pinfo">
  30. <view class="pname">
  31. <text>{{item.shelfPlaceCode}}</text>{{item.productEntity&&item.productEntity.code}}
  32. </view>
  33. <view class="ptxt flex align_center justify_between">
  34. <view>
  35. <text class="pcode">{{item.productEntity&&item.productEntity.productName}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="partList&&partList.length==0">
  43. <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>
  44. </view>
  45. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  46. <u-loadmore :status="status" />
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { getShelfProductList } from '@/api/shelf'
  54. export default {
  55. data() {
  56. return {
  57. queryWord: '',
  58. shelfName:'',
  59. shelfSn: '',
  60. pageNo:1,
  61. pageSize: 10,
  62. total: 0, // 列表总数
  63. noDataText: '暂无产品',
  64. status: 'loading',
  65. partList: []
  66. }
  67. },
  68. onLoad(opts) {
  69. this.shelfName = opts.shelfName
  70. this.shelfSn = opts.shelfSn
  71. this.getpartList()
  72. },
  73. methods: {
  74. //编辑货位
  75. toEdit(row){
  76. uni.navigateTo({
  77. url: "/pages/shelfSetting/editShelfHw?shelfSn="+this.shelfSn
  78. })
  79. },
  80. clearSearch(){
  81. this.queryWord = ''
  82. this.pageNo = 1
  83. this.partList = []
  84. this.getpartList()
  85. },
  86. // 获取数字货架列表
  87. getpartList(){
  88. const _this = this
  89. let params = {
  90. pageNo: this.pageNo,
  91. pageSize: this.pageSize,
  92. shelfSn: this.shelfSn,
  93. queryWord: this.queryWord
  94. }
  95. _this.status = 'loading'
  96. getShelfProductList(params).then(res => {
  97. uni.hideLoading()
  98. if(res.status == 200){
  99. let list = res.data.list
  100. console.log(list)
  101. if (list && list.length){
  102. // 分页 拼接数据
  103. if (_this.pageNo != 1) {
  104. _this.partList = _this.partList ? _this.partList.concat(list) : list
  105. } else {
  106. _this.partList = list
  107. }
  108. this.total = res.data.count
  109. if (_this.partList.length == res.data.count) {
  110. _this.status = 'nomore'
  111. } else {
  112. _this.status = 'loadmore'
  113. }
  114. } else {
  115. _this.partList = list || []
  116. this.total = 0
  117. _this.status = 'nomore'
  118. }
  119. _this.noDataText = '暂无匹配产品'
  120. }else{
  121. _this.status = 'loadmore'
  122. _this.partList = []
  123. _this.total = 0
  124. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  125. }
  126. })
  127. },
  128. // 加载更多
  129. onreachBottom () {
  130. if(this.partList.length < this.total ){
  131. this.pageNo++
  132. this.getpartList()
  133. }else{
  134. this.status = "nomore"
  135. }
  136. },
  137. // 扫描
  138. toScan(){
  139. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  140. this.mpaasScanModule.scan(
  141. {
  142. "scanMode":"Customized",
  143. "scanStyle":{
  144. "scanFrameSizePlus":{"width":250,"height":250},
  145. "scanFrameSize":200,
  146. "scanLight":"visible",
  147. "scanText":"对准条形码/二维码进行识别",
  148. "scanTitle":"扫码搜索货位产品",
  149. }
  150. },
  151. (result) => {
  152. console.log(result)
  153. if(result.scanStatus == 1){
  154. this.scanResult(result)
  155. }
  156. })
  157. },
  158. // 扫描结果
  159. scanResult(data){
  160. // this.toEdit()
  161. // 二维码
  162. if(data.scanType == 'QRCODE'){
  163. }else{
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="less">
  170. .content{
  171. height: 100vh;
  172. width: 100%;
  173. padding: 0 0.5rem;
  174. background: #fff;
  175. .searchBar{
  176. padding: 0.5rem 0;
  177. .shelfName{
  178. font-weight: bold;
  179. }
  180. .search{
  181. padding: 0.5rem;
  182. .input{
  183. flex-grow: 1;
  184. border:0.1rpx solid #eee;
  185. padding: 0.1rpx;
  186. border-radius: 50rpx;
  187. padding-right: 10rpx;
  188. }
  189. .icon{
  190. width: 10%;
  191. text-align: center;
  192. font-size: 50rpx;
  193. color: #999;
  194. }
  195. }
  196. }
  197. .check-list{
  198. flex-grow: 1;
  199. .scroll-view{
  200. height: calc(100vh - 180rpx);
  201. box-sizing: border-box;
  202. }
  203. .partList-list-box{
  204. padding: 20rpx 30rpx;
  205. border-bottom: 2rpx solid #f5f5f5;
  206. &:last-child{
  207. border:0;
  208. }
  209. .product{
  210. flex-grow: 1;
  211. .checkbox{
  212. width: 60rpx;
  213. }
  214. .pinfo{
  215. flex-grow: 1;
  216. padding-left: 20rpx;
  217. .pname{
  218. font-size: 28rpx;
  219. color: #191919;
  220. margin-bottom: 10rpx;
  221. text{
  222. font-weight: normal;
  223. margin-right: 6rpx;
  224. padding: 0 10rpx;
  225. background: rgba(3, 54, 146, 0.15);
  226. border-radius: 100rpx;
  227. color: #033692;
  228. font-size: 24rpx;
  229. }
  230. }
  231. .ptxt{
  232. font-size: 28rpx;
  233. color: #666;
  234. .pnums{
  235. color: #222;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>