chooseProduct.vue 10 KB

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