searchShelfHw.vue 9.3 KB

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