chooseProduct.vue 11 KB

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