chooseProduct.vue 11 KB

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