searchShelfHw.vue 9.0 KB

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