chooseProduct.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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().globalData.theme
  112. this.shelfInfo = {
  113. shelfSn: options.shelfSn,
  114. shelfName: options.shelfName
  115. }
  116. this.getpartList()
  117. this.getShelfPlace()
  118. },
  119. // 批量打印
  120. onNavigationBarButtonTap(e) {
  121. if(this.queryWord=='' && this.placeTab.length>1){
  122. if(this.curTab=='all'){
  123. uni.showToast({
  124. icon: 'none',
  125. title: '请先筛选层,按层批量打印!',
  126. duration: 5000
  127. })
  128. return
  129. }
  130. }
  131. const list = this.allList.filter(item => item.qty>0)
  132. this.$store.state.vuex_tempPrintList = list
  133. if(this.shelfInfo&&list.length){
  134. uni.navigateTo({
  135. url: "/pages/shelfSetting/batchPrint?page=bdtq&data="+encodeURIComponent(JSON.stringify(this.shelfInfo))
  136. })
  137. }else{
  138. uni.showToast({
  139. icon: 'none',
  140. title: '没有可打印的产品',
  141. duration: 5000
  142. })
  143. }
  144. },
  145. methods: {
  146. getShelfPlace(flag){
  147. getProductPlace({ shelfSn: this.shelfInfo.shelfSn }).then(res => {
  148. if (res.status == 200) {
  149. for(let a in res.data){
  150. this.placeTab.push(a)
  151. }
  152. if(!flag){
  153. this.curTab = 'all'
  154. }
  155. } else {
  156. this.placeTab = []
  157. }
  158. })
  159. },
  160. handleClear(){
  161. this.curTab = 'all'
  162. this.changeSearch()
  163. },
  164. // -------------------
  165. clearSearch(){
  166. this.queryWord = ''
  167. this.changeSearch()
  168. },
  169. changeSearch(v){
  170. this.pageNo = 1
  171. this.allList = []
  172. this.partList = []
  173. this.getpartList()
  174. },
  175. tabChange(item){
  176. this.curTab=item
  177. this.showTab = false
  178. this.changeSearch()
  179. },
  180. // 获取数字货架列表
  181. getpartList(){
  182. const _this = this
  183. let params = {
  184. shelfSn: this.shelfInfo.shelfSn,
  185. queryWord: this.queryWord,
  186. shelfPlaceCodeHead: this.curTab == 'all' ? '' : this.curTab
  187. }
  188. _this.status = 'loading'
  189. queryShelfProductList(params).then(res => {
  190. console.log(res)
  191. uni.hideLoading()
  192. if(res.status == 200){
  193. let list = res.data
  194. if (list && list.length){
  195. _this.allList = list
  196. _this.partList = list.slice(0,this.pageSize)
  197. _this.total = _this.allList.length
  198. _this.status = 'nomore'
  199. } else {
  200. _this.allList = []
  201. _this.partList = []
  202. _this.status = 'loadmore'
  203. }
  204. _this.noDataText = '没有搜索到产品'
  205. }else{
  206. _this.status = 'loadmore'
  207. _this.partList = []
  208. _this.total = 0
  209. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  210. }
  211. this.showTab = false
  212. })
  213. },
  214. // 加载更多
  215. onreachBottom () {
  216. if(this.partList.length < this.total ){
  217. this.pageNo = this.pageNo + 1
  218. this.partList = this.allList.slice(0,this.pageSize*this.pageNo)
  219. }else{
  220. this.status = "nomore"
  221. }
  222. },
  223. print(data){
  224. uni.navigateTo({ url: "/pages/common/printTag/printTag?page=bdtq&data="+JSON.stringify(data)})
  225. },
  226. // 扫描
  227. toScan(){
  228. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  229. this.mpaasScanModule.scan(
  230. {
  231. "scanMode":"Customized",
  232. "scanStyle":{
  233. "scanFrameSizePlus":{"width":250,"height":250},
  234. "scanFrameSize":200,
  235. "scanLight":"visible",
  236. "scanText":"对准条形码/二维码进行识别",
  237. "scanTitle":"扫码打印",
  238. }
  239. },
  240. (result) => {
  241. console.log(result)
  242. if(result.scanStatus == 1){
  243. this.scanResult(result)
  244. }
  245. })
  246. },
  247. // 扫描结果
  248. scanResult(data){
  249. const params = {
  250. shelfSn: this.shelfInfo.shelfSn,
  251. }
  252. // 二维码
  253. if(data.scanType == 'QRCODE'){
  254. const ret = data.scanValue.split("&")
  255. params.queryWord = ret[1] // 产品编码
  256. }else{
  257. params.qrCode = data.scanValue
  258. }
  259. queryShelfProductList(params).then(res => {
  260. console.log(res)
  261. if(res.status == 200){
  262. if(res.data&&res.data.length){
  263. if(res.data[0].qty){
  264. this.print(res.data[0])
  265. }else{
  266. uni.showToast({
  267. icon: "none",
  268. title: "产品库存不足,不能打印",
  269. duration: 5000
  270. })
  271. }
  272. }else{
  273. uni.showToast({
  274. icon: "none",
  275. title: "产品不属于此货架,请重新扫描",
  276. duration: 5000
  277. })
  278. }
  279. }
  280. })
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="less">
  286. .moreShelfPart{
  287. width: 100%;
  288. height: 100vh;
  289. .moreShelfPart-search{
  290. padding: 10rpx 20rpx;
  291. background-color: #FFFFFF;
  292. border-bottom: 2rpx solid #f5f5f5;
  293. .p-title{
  294. padding: 0 10rpx;
  295. display: flex;
  296. align-items: center;
  297. color: #222;
  298. font-size: 30rpx;
  299. > text{
  300. display: block;
  301. height: 30rpx;
  302. width: 6rpx;
  303. background: #0485F6;
  304. margin-right: 10rpx;
  305. border-radius: 10rpx;
  306. }
  307. .shelfName{
  308. flex-grow: 1;
  309. font-weight: bold;
  310. width: 60%;
  311. > view{
  312. overflow: hidden;
  313. white-space: nowrap;
  314. text-overflow: ellipsis;
  315. }
  316. }
  317. .btns{
  318. width:200rpx;
  319. text-align: right;
  320. font-size: 28rpx;
  321. color: #0485F6;
  322. }
  323. }
  324. .search{
  325. margin-top: 15upx;
  326. padding: 0.1rem;
  327. border-radius: 50rpx;
  328. border:1rpx solid #eee;
  329. .input{
  330. flex-grow: 1;
  331. padding: 4rpx;
  332. }
  333. .icon{
  334. width: 13%;
  335. text-align: center;
  336. font-size: 46rpx;
  337. color: #999;
  338. }
  339. }
  340. }
  341. .moreShelfPart-body{
  342. flex-grow: 1;
  343. background-color: #fff;
  344. }
  345. .nav-right{
  346. height: calc(100vh - 160rpx);
  347. box-sizing: border-box;
  348. .partList-list-box{
  349. padding: 20rpx 30rpx;
  350. border-bottom: 2rpx solid #f5f5f5;
  351. &:last-child{
  352. border:0;
  353. }
  354. .product{
  355. flex-grow: 1;
  356. .checkbox{
  357. width: 60rpx;
  358. }
  359. .pinfo{
  360. flex-grow: 1;
  361. padding-left: 20rpx;
  362. .pname{
  363. color: #191919;
  364. margin-bottom: 10rpx;
  365. text{
  366. font-weight: normal;
  367. margin-right: 6rpx;
  368. padding: 0 20rpx;
  369. background: rgba(3, 54, 146, 0.15);
  370. border-radius: 100rpx;
  371. color: #033692;
  372. font-size: 24rpx;
  373. }
  374. }
  375. .pname1{
  376. font-weight: bold;
  377. font-size: 32rpx;
  378. }
  379. .pno{
  380. background-color: rgba(3, 54, 146, 0.15);
  381. border-radius: 50rpx;
  382. padding: 2rpx 20rpx;
  383. color: #033692;
  384. font-size: 24rpx;
  385. margin-right: 10rpx;
  386. }
  387. .ptxt{
  388. font-size: 28rpx;
  389. color: #999;
  390. .pnums{
  391. color: #222;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. }
  398. // 筛选
  399. .tabBox{
  400. height: 100vh;
  401. .tabs{
  402. flex-grow: 1;
  403. overflow: auto;
  404. padding: 20rpx;
  405. > view{
  406. flex-wrap: wrap;
  407. justify-content: space-between;
  408. > view{
  409. width: 45%;
  410. border: 1rpx solid #eee;
  411. padding: 15rpx;
  412. border-radius: 50rpx;
  413. text-align: center;
  414. margin-bottom: 15rpx;
  415. }
  416. .active{
  417. border:0;
  418. background-color: #0485F6;
  419. color: #fff;
  420. }
  421. }
  422. }
  423. .btns{
  424. display: flex;
  425. padding: 20upx;
  426. justify-content: space-between;
  427. .handle-btn {
  428. font-size: 28upx;
  429. }
  430. }
  431. }
  432. }
  433. </style>