chooseProduct.vue 10 KB

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