searchShelfHw.vue 9.2 KB

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