searchShelfHw.vue 9.2 KB

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