searchShelfHw.vue 9.2 KB

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