searchShelfHw.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. enableFlag: 1
  159. }
  160. _this.status = 'loading'
  161. getShelfProductList(params).then(res => {
  162. uni.hideLoading()
  163. if(res.status == 200){
  164. let list = res.data.list
  165. console.log(list)
  166. if (list && list.length){
  167. // 分页 拼接数据
  168. if (_this.pageNo != 1) {
  169. _this.partList = _this.partList ? _this.partList.concat(list) : list
  170. } else {
  171. _this.partList = list
  172. }
  173. this.total = res.data.count
  174. if (_this.partList.length == res.data.count) {
  175. _this.status = 'nomore'
  176. } else {
  177. _this.status = 'loadmore'
  178. }
  179. } else {
  180. _this.partList = list || []
  181. this.total = 0
  182. _this.status = 'nomore'
  183. }
  184. _this.noDataText = '暂无匹配产品'
  185. }else{
  186. _this.status = 'loadmore'
  187. _this.partList = []
  188. _this.total = 0
  189. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  190. }
  191. this.showTab = false
  192. })
  193. },
  194. // 加载更多
  195. onreachBottom () {
  196. if(this.partList.length < this.total ){
  197. this.pageNo++
  198. this.getpartList()
  199. }else{
  200. this.status = "nomore"
  201. }
  202. },
  203. // 扫描
  204. toScan(){
  205. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  206. this.mpaasScanModule.scan(
  207. {
  208. "scanMode":"Customized",
  209. "scanStyle":{
  210. "scanFrameSizePlus":{"width":250,"height":250},
  211. "scanFrameSize":200,
  212. "scanLight":"visible",
  213. "scanText":"对准条形码/二维码进行识别",
  214. "scanTitle":"扫码搜索货位产品",
  215. }
  216. },
  217. (result) => {
  218. console.log(result)
  219. if(result.scanStatus == 1){
  220. this.scanResult(result)
  221. }
  222. })
  223. },
  224. // 扫描结果
  225. scanResult(data){
  226. const params = {
  227. pageNo: 1,
  228. pageSize:1,
  229. shelfSn: this.shelfSn
  230. }
  231. // 二维码
  232. if(data.scanType == 'QRCODE'){
  233. const ret = data.scanValue.split("&")
  234. params.queryWord = ret[1] // 产品编码
  235. }else{
  236. params.qrCode = data.scanValue
  237. }
  238. getShelfProductList(params).then(res => {
  239. console.log(res)
  240. if(res.status == 200){
  241. if(res.data&&res.data.list.length){
  242. this.toEdit(res.data.list[0])
  243. }else{
  244. uni.showToast({
  245. icon: "none",
  246. title: "产品不属于此货架,请重新扫描",
  247. duration: 5000
  248. })
  249. }
  250. }
  251. })
  252. }
  253. }
  254. }
  255. </script>
  256. <style lang="less">
  257. .content{
  258. height: 100vh;
  259. width: 100%;
  260. padding: 0 0.5rem;
  261. background: #fff;
  262. .searchBar{
  263. padding: 0 0.3rem 0.3rem;
  264. .p-title{
  265. padding: 0 10rpx;
  266. display: flex;
  267. align-items: center;
  268. color: #222;
  269. font-size: 30rpx;
  270. > text{
  271. display: block;
  272. height: 30rpx;
  273. width: 6rpx;
  274. background: #0485F6;
  275. margin-right: 10rpx;
  276. border-radius: 10rpx;
  277. }
  278. .shelfName{
  279. flex-grow: 1;
  280. font-weight: bold;
  281. width: 80%;
  282. > view{
  283. overflow: hidden;
  284. white-space: nowrap;
  285. text-overflow: ellipsis;
  286. }
  287. }
  288. .btns{
  289. width:100rpx;
  290. text-align: right;
  291. font-size: 28rpx;
  292. color: #0485F6;
  293. }
  294. }
  295. .search{
  296. margin-top: 15upx;
  297. padding: 0.1rem;
  298. border-radius: 50rpx;
  299. border:1rpx solid #eee;
  300. .input{
  301. flex-grow: 1;
  302. padding: 4rpx;
  303. }
  304. .icon{
  305. width: 13%;
  306. text-align: center;
  307. font-size: 46rpx;
  308. color: #999;
  309. }
  310. }
  311. }
  312. .check-list{
  313. flex-grow: 1;
  314. .scroll-view{
  315. height: calc(100vh - 150rpx);
  316. box-sizing: border-box;
  317. }
  318. .partList-list-box{
  319. padding: 20rpx 30rpx;
  320. border-bottom: 2rpx solid #f5f5f5;
  321. &:last-child{
  322. border:0;
  323. }
  324. .product{
  325. flex-grow: 1;
  326. &:active{
  327. opacity: 0.6;
  328. background-color: #f8f8f8;
  329. }
  330. .pinfo{
  331. flex-grow: 1;
  332. padding-left: 20rpx;
  333. .pname{
  334. font-size: 28rpx;
  335. color: #191919;
  336. margin-bottom: 10rpx;
  337. text{
  338. font-weight: normal;
  339. margin-right: 6rpx;
  340. padding: 0 10rpx;
  341. background: rgba(3, 54, 146, 0.15);
  342. border-radius: 100rpx;
  343. color: #033692;
  344. font-size: 24rpx;
  345. }
  346. }
  347. .ptxt{
  348. font-size: 28rpx;
  349. color: #333;
  350. font-weight: bold;
  351. .pnums{
  352. color: #222;
  353. }
  354. }
  355. }
  356. }
  357. }
  358. }
  359. // 筛选
  360. .tabBox{
  361. height: 100vh;
  362. .tabs{
  363. flex-grow: 1;
  364. overflow: auto;
  365. padding: 20rpx;
  366. > view{
  367. flex-wrap: wrap;
  368. justify-content: space-between;
  369. > view{
  370. width: 45%;
  371. border: 1rpx solid #ddd;
  372. padding: 15rpx;
  373. border-radius: 50rpx;
  374. text-align: center;
  375. margin-bottom: 15rpx;
  376. }
  377. .active{
  378. border:0;
  379. background-color: #0485F6;
  380. color: #fff;
  381. }
  382. }
  383. }
  384. .btns{
  385. display: flex;
  386. padding: 20upx;
  387. justify-content: space-between;
  388. .handle-btn {
  389. font-size: 28upx;
  390. }
  391. }
  392. }
  393. }
  394. </style>