searchShelfHw.vue 6.6 KB

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