chooseProduct.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <view class="p-title flex align_center">
  5. <text></text>
  6. <view class="shelfName flex">
  7. <view>{{shelfInfo.shelfName}}</view>
  8. </view>
  9. <view class="btns" @click="showTab = true">
  10. 筛选:({{curTab!='all'?(curTab+'层'):'全部'}})
  11. <u-icon size="20" name="arrow-down"></u-icon>
  12. </view>
  13. </view>
  14. <view class="search flex align_center">
  15. <view class="input">
  16. <u-search
  17. v-model="queryWord"
  18. @custom="getpartList"
  19. @search="getpartList"
  20. @clear="clearSearch"
  21. @input="$u.debounce(changeSearch, 800)"
  22. bg-color="#fff"
  23. :show-action="false"
  24. placeholder="请输入货位号/产品编码/产品名称搜索"></u-search>
  25. </view>
  26. <view class="icon" @click="toScan">
  27. <u-icon name="scan"></u-icon>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="moreShelfPart-body">
  32. <scroll-view class="nav-right" scroll-y @scrolltolower="onreachBottom">
  33. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  34. <view class="product flex align_center">
  35. <view class="flex align_center flex_1">
  36. <view class="pimgs">
  37. <u-image :src="item.productEntity&&item.productEntity.images?item.productEntity.images:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  38. </view>
  39. <view class="pinfo">
  40. <view class="pname">
  41. <text>{{item.shelfPlaceCode}}</text>{{item.productCode}}
  42. </view>
  43. <view class="pname pname1">
  44. {{item.productName}}
  45. </view>
  46. <view class="ptxt flex align_center justify_between">
  47. <view>
  48. 最大库容:<text class="pnums">{{item.maxQty}}{{item.productEntity&&item.productEntity.unit}}</text>
  49. / 当前库存:<text class="pnums">{{item.qty}}{{item.productEntity&&item.productEntity.unit}}</text>
  50. </view>
  51. <view class="print" @click.stop="print(item)">
  52. <u-image :src="`/static/${$config('themePath')}/icon_printer@3x.png`" width="45" height="45"></u-image>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="partList&&partList.length==0">
  60. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="240" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  61. </view>
  62. <view style="padding: 20upx;" v-if="status!='loadmore'">
  63. <u-loadmore :status="status" />
  64. </view>
  65. </scroll-view>
  66. </view>
  67. <!-- 筛选项 -->
  68. <u-popup v-model="showTab" mode="right" width="70%">
  69. <view class="tabBox flex flex_column">
  70. <view class="tabs">
  71. <view class="flex">
  72. <view :class="curTab=='all'?'active':''" @click="tabChange('all')">全部层</view>
  73. <view :class="item==curTab?'active':'all'" v-for="item in placeTab" :key="item" @click="tabChange(item)">{{item}}层</view>
  74. </view>
  75. </view>
  76. </view>
  77. </u-popup>
  78. </view>
  79. </template>
  80. <script>
  81. import { queryShelfProductList,getProductPlace } from '@/api/shelf'
  82. export default {
  83. data() {
  84. return {
  85. queryWord: '',
  86. isGobleSearch: false,
  87. partList: [],
  88. allList: [],
  89. pageNo:1,
  90. pageSize: 15,
  91. total: 0, // 列表总数
  92. noDataText: '暂无数据',
  93. status: 'loading',
  94. vinstatus: 'loading',
  95. shelfInfo: {
  96. shelfSn: '',
  97. shelfName: ''
  98. },
  99. theme: '',
  100. showTab: false,
  101. placeTab: [],
  102. curTab: 'all',
  103. customBtnStyle: { // 自定义按钮样式
  104. borderColor: this.$config('primaryColor'),
  105. backgroundColor: this.$config('primaryColor'),
  106. color: '#fff'
  107. },
  108. }
  109. },
  110. onLoad(options) {
  111. this.theme = getApp({ allowDefault: true }).globalData.theme
  112. this.shelfInfo = {
  113. shelfSn: options.shelfSn,
  114. shelfName: options.shelfName
  115. }
  116. this.getpartList()
  117. this.getShelfPlace()
  118. },
  119. onBackPress() {
  120. if(this.showTab){
  121. this.showTab = false
  122. return true
  123. }
  124. },
  125. // 批量打印
  126. onNavigationBarButtonTap(e) {
  127. if(this.queryWord=='' && this.placeTab.length>1&&this.allList.length>50){
  128. if(this.curTab=='all'){
  129. uni.showToast({
  130. icon: 'none',
  131. title: '请先筛选层,按层批量打印!',
  132. duration: 5000
  133. })
  134. return
  135. }
  136. }
  137. // const list = this.allList.filter(item => item.qty>0)
  138. this.$store.state.vuex_tempPrintList = this.allList
  139. if(this.shelfInfo&&this.allList.length){
  140. uni.navigateTo({
  141. url: "/pages/shelfSetting/batchPrint?page=bdtq&data="+encodeURIComponent(JSON.stringify(this.shelfInfo))
  142. })
  143. }else{
  144. uni.showToast({
  145. icon: 'none',
  146. title: '没有可打印的产品',
  147. duration: 5000
  148. })
  149. }
  150. },
  151. methods: {
  152. getShelfPlace(flag){
  153. getProductPlace({ shelfSn: this.shelfInfo.shelfSn }).then(res => {
  154. if (res.status == 200) {
  155. for(let a in res.data){
  156. this.placeTab.push(a)
  157. }
  158. if(!flag){
  159. this.curTab = 'all'
  160. }
  161. } else {
  162. this.placeTab = []
  163. }
  164. })
  165. },
  166. handleClear(){
  167. this.curTab = 'all'
  168. this.changeSearch()
  169. },
  170. // -------------------
  171. clearSearch(){
  172. this.queryWord = ''
  173. this.changeSearch()
  174. },
  175. changeSearch(v){
  176. this.pageNo = 1
  177. this.allList = []
  178. this.partList = []
  179. this.getpartList()
  180. },
  181. tabChange(item){
  182. this.curTab=item
  183. this.showTab = false
  184. this.changeSearch()
  185. },
  186. // 获取数字货架列表
  187. getpartList(){
  188. const _this = this
  189. let params = {
  190. shelfSn: this.shelfInfo.shelfSn,
  191. queryWord: this.queryWord,
  192. shelfPlaceCodeHead: this.curTab == 'all' ? '' : this.curTab
  193. }
  194. _this.status = 'loading'
  195. queryShelfProductList(params).then(res => {
  196. console.log(res)
  197. uni.hideLoading()
  198. if(res.status == 200){
  199. let list = res.data
  200. if (list && list.length){
  201. _this.allList = list
  202. _this.partList = list.slice(0,this.pageSize)
  203. _this.total = _this.allList.length
  204. _this.status = 'nomore'
  205. } else {
  206. _this.allList = []
  207. _this.partList = []
  208. _this.status = 'loadmore'
  209. }
  210. _this.noDataText = '没有搜索到产品'
  211. }else{
  212. _this.status = 'loadmore'
  213. _this.partList = []
  214. _this.total = 0
  215. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  216. }
  217. this.showTab = false
  218. })
  219. },
  220. // 加载更多
  221. onreachBottom () {
  222. if(this.partList.length < this.total ){
  223. this.pageNo = this.pageNo + 1
  224. this.partList = this.allList.slice(0,this.pageSize*this.pageNo)
  225. }else{
  226. this.status = "nomore"
  227. }
  228. },
  229. print(data){
  230. uni.navigateTo({ url: "/pages/common/printTag/printTag?page=bdtq&data="+JSON.stringify(data)})
  231. },
  232. // 扫描
  233. toScan(){
  234. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  235. this.mpaasScanModule.scan(
  236. {
  237. "scanMode":"Customized",
  238. "scanStyle":{
  239. "scanFrameSizePlus":{"width":250,"height":250},
  240. "scanFrameSize":200,
  241. "scanLight":"visible",
  242. "scanText":"对准条形码/二维码进行识别",
  243. "scanTitle":"扫码打印",
  244. }
  245. },
  246. (result) => {
  247. console.log(result)
  248. if(result.scanStatus == 1){
  249. this.scanResult(result)
  250. }
  251. })
  252. },
  253. // 扫描结果
  254. scanResult(data){
  255. const params = {
  256. shelfSn: this.shelfInfo.shelfSn,
  257. }
  258. // 二维码
  259. if(data.scanType == 'QRCODE'){
  260. const ret = data.scanValue.split("&")
  261. params.queryWord = ret[1] // 产品编码
  262. }else{
  263. params.qrCode = data.scanValue
  264. }
  265. queryShelfProductList(params).then(res => {
  266. console.log(res)
  267. if(res.status == 200){
  268. if(res.data&&res.data.length){
  269. if(res.data[0].qty){
  270. this.print(res.data[0])
  271. }else{
  272. uni.showToast({
  273. icon: "none",
  274. title: "产品库存不足,不能打印",
  275. duration: 5000
  276. })
  277. }
  278. }else{
  279. uni.showToast({
  280. icon: "none",
  281. title: "产品不属于此货架,请重新扫描",
  282. duration: 5000
  283. })
  284. }
  285. }
  286. })
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="less">
  292. .moreShelfPart{
  293. width: 100%;
  294. height: 100vh;
  295. .moreShelfPart-search{
  296. padding: 10rpx 20rpx;
  297. background-color: #FFFFFF;
  298. border-bottom: 2rpx solid #f5f5f5;
  299. .p-title{
  300. padding: 0 10rpx;
  301. display: flex;
  302. align-items: center;
  303. color: #222;
  304. font-size: 30rpx;
  305. > text{
  306. display: block;
  307. height: 30rpx;
  308. width: 6rpx;
  309. background: #0485F6;
  310. margin-right: 10rpx;
  311. border-radius: 10rpx;
  312. }
  313. .shelfName{
  314. flex-grow: 1;
  315. font-weight: bold;
  316. width: 60%;
  317. > view{
  318. overflow: hidden;
  319. white-space: nowrap;
  320. text-overflow: ellipsis;
  321. }
  322. }
  323. .btns{
  324. width:200rpx;
  325. text-align: right;
  326. font-size: 28rpx;
  327. color: #0485F6;
  328. }
  329. }
  330. .search{
  331. margin-top: 15upx;
  332. padding: 0.1rem;
  333. border-radius: 50rpx;
  334. border:1rpx solid #eee;
  335. .input{
  336. flex-grow: 1;
  337. padding: 4rpx;
  338. }
  339. .icon{
  340. width: 13%;
  341. text-align: center;
  342. font-size: 46rpx;
  343. color: #999;
  344. }
  345. }
  346. }
  347. .moreShelfPart-body{
  348. flex-grow: 1;
  349. background-color: #fff;
  350. }
  351. .nav-right{
  352. height: calc(100vh - 160rpx);
  353. box-sizing: border-box;
  354. .partList-list-box{
  355. padding: 20rpx 30rpx;
  356. border-bottom: 2rpx solid #f5f5f5;
  357. &:last-child{
  358. border:0;
  359. }
  360. .product{
  361. flex-grow: 1;
  362. .checkbox{
  363. width: 60rpx;
  364. }
  365. .pinfo{
  366. flex-grow: 1;
  367. padding-left: 20rpx;
  368. .pname{
  369. color: #191919;
  370. margin-bottom: 10rpx;
  371. text{
  372. font-weight: normal;
  373. margin-right: 6rpx;
  374. padding: 0 20rpx;
  375. background: rgba(3, 54, 146, 0.15);
  376. border-radius: 100rpx;
  377. color: #033692;
  378. font-size: 24rpx;
  379. }
  380. }
  381. .pname1{
  382. font-weight: bold;
  383. font-size: 32rpx;
  384. }
  385. .pno{
  386. background-color: rgba(3, 54, 146, 0.15);
  387. border-radius: 50rpx;
  388. padding: 2rpx 20rpx;
  389. color: #033692;
  390. font-size: 24rpx;
  391. margin-right: 10rpx;
  392. }
  393. .ptxt{
  394. font-size: 28rpx;
  395. color: #999;
  396. .pnums{
  397. color: #222;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. }
  404. // 筛选
  405. .tabBox{
  406. height: 100vh;
  407. .tabs{
  408. flex-grow: 1;
  409. overflow: auto;
  410. padding: 20rpx;
  411. > view{
  412. flex-wrap: wrap;
  413. justify-content: space-between;
  414. > view{
  415. width: 45%;
  416. border: 1rpx solid #eee;
  417. padding: 15rpx;
  418. border-radius: 50rpx;
  419. text-align: center;
  420. margin-bottom: 15rpx;
  421. }
  422. .active{
  423. border:0;
  424. background-color: #0485F6;
  425. color: #fff;
  426. }
  427. }
  428. }
  429. .btns{
  430. display: flex;
  431. padding: 20upx;
  432. justify-content: space-between;
  433. .handle-btn {
  434. font-size: 28upx;
  435. }
  436. }
  437. }
  438. }
  439. </style>