searchShelfHw.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="searchBar">
  4. <view class="p-title">
  5. <text></text>
  6. <view class="shelfName flex align_center">
  7. <view>{{shelfName}}</view>
  8. </view>
  9. <view class="btns" @click="showTab = true">筛选<u-icon size="20" name="arrow-down"></u-icon></view>
  10. </view>
  11. <view class="search flex align_center">
  12. <view class="input">
  13. <u-search
  14. focus
  15. v-model="queryWord"
  16. @custom="getpartList"
  17. @search="getpartList"
  18. @clear="clearSearch"
  19. @input="$u.debounce(changeSearch, 800)"
  20. bg-color="#fff"
  21. :show-action="false"
  22. placeholder="请输入产品编码或名称搜索"></u-search>
  23. </view>
  24. <view class="icon" @click="toScan">
  25. <u-icon name="scan"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="check-list">
  30. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  31. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  32. <view class="product flex align_center" @click="toEdit(item)">
  33. <view class="flex align_center flex_1">
  34. <view class="pimgs">
  35. <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>
  36. </view>
  37. <view class="pinfo">
  38. <view class="pname">
  39. <text>{{item.shelfPlaceCode}}</text>{{item.productEntity&&item.productEntity.code}}
  40. </view>
  41. <view class="ptxt flex align_center justify_between">
  42. <view>
  43. <text class="pcode">{{item.productEntity&&item.productEntity.productName}}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view v-if="partList&&partList.length==0">
  51. <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>
  52. </view>
  53. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  54. <u-loadmore :status="status" />
  55. </view>
  56. </scroll-view>
  57. </view>
  58. <!-- 筛选项 -->
  59. <u-popup v-model="showTab" mode="right" width="70%">
  60. <view class="tabBox flex flex_column">
  61. <view class="tabs">
  62. <view class="flex">
  63. <view :class="item==curTab?'active':''" v-for="item in placeTab" :key="item" @click="curTab=curTab==item?'':item">{{item}}层</view>
  64. </view>
  65. </view>
  66. <view class="btns">
  67. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" @click="handleClear">重置</u-button>
  68. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="clearSearch">查询</u-button>
  69. </view>
  70. </view>
  71. </u-popup>
  72. </view>
  73. </template>
  74. <script>
  75. import { getShelfProductList,getProductPlace } from '@/api/shelf'
  76. export default {
  77. data() {
  78. return {
  79. queryWord: '',
  80. shelfName:'',
  81. shelfSn: '',
  82. pageNo:1,
  83. pageSize: 10,
  84. total: 0, // 列表总数
  85. noDataText: '暂无产品',
  86. status: 'loading',
  87. partList: [],
  88. showTab: false,
  89. placeTab: [],
  90. curTab: '',
  91. customBtnStyle: { // 自定义按钮样式
  92. borderColor: this.$config('primaryColor'),
  93. backgroundColor: this.$config('primaryColor'),
  94. color: '#fff'
  95. },
  96. }
  97. },
  98. onLoad(opts) {
  99. this.shelfName = opts.shelfName
  100. this.shelfSn = opts.shelfSn
  101. this.getpartList()
  102. this.getShelfPlace()
  103. },
  104. methods: {
  105. //编辑货位
  106. toEdit(item){
  107. const type = 'edit'
  108. const params = Object.assign({shelfSn: this.shelfSn,shelfName: this.shelfName},item)
  109. uni.navigateTo({
  110. url: "/pages/shelfSetting/editShelfHw?detailData="+encodeURIComponent(JSON.stringify(params))+"&type=" + type
  111. })
  112. },
  113. getShelfPlace(flag){
  114. getProductPlace({ shelfSn: this.shelfSn }).then(res => {
  115. if (res.status == 200) {
  116. for(let a in res.data){
  117. this.placeTab.push(a)
  118. }
  119. if(!flag){
  120. this.curTab = ''
  121. }
  122. } else {
  123. this.placeTab = []
  124. }
  125. })
  126. },
  127. handleClear(){
  128. this.curTab = ''
  129. this.clearSearch()
  130. },
  131. clearSearch(){
  132. this.queryWord = ''
  133. this.changeSearch()
  134. },
  135. changeSearch(){
  136. this.pageNo = 1
  137. this.partList = []
  138. this.getpartList()
  139. },
  140. // 获取数字货架列表
  141. getpartList(){
  142. const _this = this
  143. let params = {
  144. pageNo: this.pageNo,
  145. pageSize: this.pageSize,
  146. shelfSn: this.shelfSn,
  147. queryWord: this.queryWord,
  148. shelfPlaceCodeHead: this.curTab
  149. }
  150. _this.status = 'loading'
  151. getShelfProductList(params).then(res => {
  152. uni.hideLoading()
  153. if(res.status == 200){
  154. let list = res.data.list
  155. console.log(list)
  156. if (list && list.length){
  157. // 分页 拼接数据
  158. if (_this.pageNo != 1) {
  159. _this.partList = _this.partList ? _this.partList.concat(list) : list
  160. } else {
  161. _this.partList = list
  162. }
  163. this.total = res.data.count
  164. if (_this.partList.length == res.data.count) {
  165. _this.status = 'nomore'
  166. } else {
  167. _this.status = 'loadmore'
  168. }
  169. } else {
  170. _this.partList = list || []
  171. this.total = 0
  172. _this.status = 'nomore'
  173. }
  174. _this.noDataText = '暂无匹配产品'
  175. }else{
  176. _this.status = 'loadmore'
  177. _this.partList = []
  178. _this.total = 0
  179. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  180. }
  181. this.showTab = false
  182. })
  183. },
  184. // 加载更多
  185. onreachBottom () {
  186. if(this.partList.length < this.total ){
  187. this.pageNo++
  188. this.getpartList()
  189. }else{
  190. this.status = "nomore"
  191. }
  192. },
  193. // 扫描
  194. toScan(){
  195. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  196. this.mpaasScanModule.scan(
  197. {
  198. "scanMode":"Customized",
  199. "scanStyle":{
  200. "scanFrameSizePlus":{"width":250,"height":250},
  201. "scanFrameSize":200,
  202. "scanLight":"visible",
  203. "scanText":"对准条形码/二维码进行识别",
  204. "scanTitle":"扫码搜索货位产品",
  205. }
  206. },
  207. (result) => {
  208. console.log(result)
  209. if(result.scanStatus == 1){
  210. this.scanResult(result)
  211. }
  212. })
  213. },
  214. // 扫描结果
  215. scanResult(data){
  216. const params = {
  217. pageNo: 1,
  218. pageSize:1,
  219. shelfSn: this.shelfSn
  220. }
  221. // 二维码
  222. if(data.scanType == 'QRCODE'){
  223. const ret = data.scanValue.split("&")
  224. params.queryWord = ret[1] // 产品编码
  225. }else{
  226. params.qrCode = data.scanValue
  227. }
  228. getShelfProductList(params).then(res => {
  229. console.log(res)
  230. if(res.status == 200){
  231. if(res.data&&res.data.list.length){
  232. this.toEdit(res.data.list[0])
  233. }else{
  234. uni.showToast({
  235. icon: "none",
  236. title: "产品不属于此货架,请重新扫描",
  237. duration: 5000
  238. })
  239. }
  240. }
  241. })
  242. }
  243. }
  244. }
  245. </script>
  246. <style lang="less">
  247. .content{
  248. height: 100vh;
  249. width: 100%;
  250. padding: 0 0.5rem;
  251. background: #fff;
  252. .searchBar{
  253. padding: 0 0.3rem 0.3rem;
  254. .p-title{
  255. padding: 0 10rpx;
  256. display: flex;
  257. align-items: center;
  258. color: #222;
  259. font-size: 30rpx;
  260. > text{
  261. display: block;
  262. height: 30rpx;
  263. width: 6rpx;
  264. background: #0485F6;
  265. margin-right: 10rpx;
  266. border-radius: 10rpx;
  267. }
  268. .shelfName{
  269. flex-grow: 1;
  270. font-weight: bold;
  271. width: 80%;
  272. > view{
  273. overflow: hidden;
  274. white-space: nowrap;
  275. text-overflow: ellipsis;
  276. }
  277. }
  278. .btns{
  279. width:100rpx;
  280. text-align: right;
  281. font-size: 28rpx;
  282. color: #0485F6;
  283. }
  284. }
  285. .search{
  286. margin-top: 15upx;
  287. padding: 0.1rem;
  288. border-radius: 50rpx;
  289. border:0.1rpx solid #eee;
  290. .input{
  291. flex-grow: 1;
  292. padding: 0.1rpx;
  293. }
  294. .icon{
  295. width: 13%;
  296. text-align: center;
  297. font-size: 46rpx;
  298. color: #999;
  299. }
  300. }
  301. }
  302. .check-list{
  303. flex-grow: 1;
  304. .scroll-view{
  305. height: calc(100vh - 150rpx);
  306. box-sizing: border-box;
  307. }
  308. .partList-list-box{
  309. padding: 20rpx 30rpx;
  310. border-bottom: 2rpx solid #f5f5f5;
  311. &:last-child{
  312. border:0;
  313. }
  314. .product{
  315. flex-grow: 1;
  316. &:active{
  317. opacity: 0.6;
  318. background-color: #f8f8f8;
  319. }
  320. .pinfo{
  321. flex-grow: 1;
  322. padding-left: 20rpx;
  323. .pname{
  324. font-size: 28rpx;
  325. color: #191919;
  326. margin-bottom: 10rpx;
  327. text{
  328. font-weight: normal;
  329. margin-right: 6rpx;
  330. padding: 0 10rpx;
  331. background: rgba(3, 54, 146, 0.15);
  332. border-radius: 100rpx;
  333. color: #033692;
  334. font-size: 24rpx;
  335. }
  336. }
  337. .ptxt{
  338. font-size: 28rpx;
  339. color: #333;
  340. font-weight: bold;
  341. .pnums{
  342. color: #222;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. }
  349. // 筛选
  350. .tabBox{
  351. height: 100vh;
  352. .tabs{
  353. flex-grow: 1;
  354. overflow: auto;
  355. padding: 20rpx;
  356. > view{
  357. flex-wrap: wrap;
  358. justify-content: space-between;
  359. > view{
  360. width: 45%;
  361. border: 0.1rpx solid #ddd;
  362. padding: 15rpx;
  363. border-radius: 50rpx;
  364. text-align: center;
  365. margin-bottom: 15rpx;
  366. }
  367. .active{
  368. border:0;
  369. background-color: #0485F6;
  370. color: #fff;
  371. }
  372. }
  373. }
  374. .btns{
  375. display: flex;
  376. padding: 20upx;
  377. justify-content: space-between;
  378. .handle-btn {
  379. font-size: 28upx;
  380. }
  381. }
  382. }
  383. }
  384. </style>