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