cartList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="product-list flex" v-if="placeTab.length">
  4. <view class="leftTabs">
  5. <view v-for="item in placeTab" :key="item" :class="curTab==item?'active':''" @click="curTab = item">{{item}}层</view>
  6. </view>
  7. <scroll-view scroll-y class="rightCons" v-if="shelfPlaceList">
  8. <view
  9. class="partList-list-box"
  10. v-for="item in shelfPlaceList[curTab]"
  11. :key="item.shelfCartSn"
  12. @click="editRow(item)"
  13. >
  14. <view class="flex align_center flex_1">
  15. <view class="pimgs">
  16. <u-image :src="item.product&&item.product.images?item.product.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="120" height="120" border-radius="10"></u-image>
  17. </view>
  18. <view class="pinfo">
  19. <view class="ptxt">
  20. <text>{{item.shelfPlaceCode}}</text>
  21. {{item.productCode}}
  22. </view>
  23. <view class="pname">
  24. {{item.product.productName}}
  25. </view>
  26. </view>
  27. </view>
  28. <view class="ptools flex align_center justify_between">
  29. <view></view>
  30. <view class="pcurnums flex align_center">
  31. <view class="u-ninput">
  32. <u-number-box :index="item.id" :input-height="60" @blur="updateNums" @minus="updateNums" @plus="updateNums" color="#000" bg-color="#fff" v-model="item.qty" :min="0"></u-number-box>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. </view>
  39. <view class="product-list" v-else>
  40. <view style="padding: 200upx 0 0;">
  41. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" text="暂无货位产品,请录入" img-width="150" mode="list"></u-empty>
  42. </view>
  43. <view style="text-align: center;margin-top: 50upx;" v-if="!loading">
  44. <u-button @click="showLayer=true" type='primary' shape="circle" size="medium">点击录入产品</u-button>
  45. </view>
  46. </view>
  47. <view class="footer-bar flex align_center justify_between" v-if="placeTab.length">
  48. <view class="heji flex align_center" @click="showPop=!showPop">
  49. 所有层合计款数:<text>{{totalKs}}</text>;数量:<text>{{totalNums}}</text>;
  50. <u-icon name="arrow-up"></u-icon>
  51. </view>
  52. <view class="btns">
  53. <u-button @click="showLayer=true" type='primary' shape="circle" size="medium">继续录入产品</u-button>
  54. </view>
  55. </view>
  56. <!-- 合计弹框 -->
  57. <u-popup mode="bottom" :mask="false" closeable v-model="showPop" :z-index="100">
  58. <view class="heji-content">
  59. <scroll-view scroll-y="true" style="height: 400rpx;">
  60. <view class="heji-con-list">
  61. <view class="flex align_center" v-for="item in countData" :key="item.shelfTierCode">
  62. <view>{{item.shelfTierCode}}层</view>
  63. <view class="flex align_center">
  64. <text>款数:{{item.category}}</text>
  65. <text>数量:{{item.qty}}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </scroll-view>
  70. </view>
  71. </u-popup>
  72. <!-- 选中层 -->
  73. <u-popup mode="center" width="80%" :mask-close-able="false" closeable @close="curLayer=''" v-model="showLayer" border-radius="15">
  74. <view class="layer-content">
  75. <view class="tits">请选择产品的货架层号</view>
  76. <view class="tagbox flex">
  77. <view>
  78. <view class="tag" :class="curLayer==item?'active':''" v-for="item in layerList" :key="item" @click="curLayer=curLayer==item?'':item">
  79. {{item}}层
  80. </view>
  81. </view>
  82. </view>
  83. <view class="newbtn flex justify_between" v-if="curLayer">
  84. <u-button shape="circle" @click="searchProduct()" size="medium">按产品编码搜索</u-button>
  85. <u-button @click="scanProduct()" type='primary' shape="circle" size="medium">扫描条形码匹配</u-button>
  86. </view>
  87. </view>
  88. </u-popup>
  89. <!-- 上架确认 -->
  90. <choose-type-modal v-if="chooseModal" :totalKs="totalKs" :totalNums="totalNums" :openModal="chooseModal" @confirm="confirmPut" @close="chooseModal = false" />
  91. <printStickerModal v-if="showPrintModal" :layer="curTab" :openModal="showPrintModal" @confirm="confirmPrint" @close="showPrintModal = false"></printStickerModal>
  92. </view>
  93. </template>
  94. <script>
  95. import { clzConfirm, numberToFixed } from '@/libs/tools';
  96. import {queryMapList, queryCountList, shelfCartSave, shelfCartDelete, queryEmptyCostList, shelfCartConfirm} from '@/api/shelfCart.js'
  97. import chooseTypeModal from './chooseTypeModal'
  98. import printStickerModal from './printStickerModal'
  99. export default {
  100. components: {
  101. chooseTypeModal,
  102. printStickerModal
  103. },
  104. data() {
  105. return {
  106. loading: false,
  107. showPop: false,
  108. chooseModal: false,
  109. showPrintModal: false,
  110. shelfSn: '',
  111. shelfName: '',
  112. shelfPlaceList: null,
  113. placeTab: [],
  114. curTab: '',
  115. totalKs: 0,
  116. totalNums: 0,
  117. countData: [],
  118. layerList: [],
  119. showLayer: false,
  120. curLayer: ''
  121. }
  122. },
  123. onShow() {
  124. this.curLayer = ''
  125. },
  126. onLoad(opts) {
  127. this.layerList = 'A、B、C、D、E、F、G、H、I、J、K、L、M、N、O、P、Q、R、S、T、U、V、W、X、Y、Z'.split('、');
  128. this.shelfSn = opts.shelfSn
  129. this.shelfName = opts.shelfName
  130. this.customerSn = opts.customerSn
  131. this.pageInit()
  132. uni.$on("updateTempHw",()=>{
  133. this.pageInit(true)
  134. })
  135. uni.$on("setCostOk",()=>{
  136. this.chooseModal = true
  137. })
  138. },
  139. onUnload() {
  140. uni.$off("updateTempHw")
  141. },
  142. onNavigationBarButtonTap(e) {
  143. console.log(e)
  144. // 上架入库
  145. if(e.index == 0){
  146. this.toPutaway()
  147. }
  148. // 打印贴签
  149. if(e.index == 1){
  150. this.showPrintModal = true
  151. }
  152. },
  153. methods: {
  154. pageInit(flag){
  155. this.placeTab = []
  156. this.shelfPlaceList = null
  157. this.countData = []
  158. this.getList(flag)
  159. this.getCount()
  160. },
  161. scanProduct(){
  162. this.showLayer = false
  163. uni.navigateTo({
  164. url: "/pages/batchShelves/scanProduct?shelfSn="+this.shelfSn+'&layer='+this.curLayer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn+'&from=cartList'
  165. })
  166. },
  167. searchProduct(){
  168. this.showLayer = false
  169. uni.navigateTo({
  170. url: "/pages/batchShelves/searchProduct?shelfSn="+this.shelfSn+'&layer='+this.curLayer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn+'&from=cartList'
  171. })
  172. },
  173. // 上架入库
  174. toPutaway(){
  175. uni.showLoading({
  176. title: '正在查询...',
  177. mask: true
  178. })
  179. queryEmptyCostList({shelfSn: this.shelfSn}).then(res => {
  180. console.log(res)
  181. uni.hideLoading()
  182. if(res.data&&res.data.length){
  183. this.$store.state.vuex_tempData = res.data
  184. // 去设置价格
  185. uni.navigateTo({
  186. url: "/pages/batchShelves/setProductCost?shelfSn="+this.shelfSn+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  187. })
  188. }else{
  189. this.chooseModal = true
  190. }
  191. })
  192. },
  193. //确认上架
  194. confirmPut(data){
  195. uni.showLoading({
  196. mask: true,
  197. title: '正在上架...'
  198. })
  199. shelfCartConfirm({
  200. shelfSn: this.shelfSn,
  201. ...data
  202. }).then(res => {
  203. uni.hideLoading()
  204. if(res.status == 200){
  205. uni.navigateBack()
  206. }
  207. })
  208. },
  209. // 打印
  210. confirmPrint(type){
  211. this.showPrintModal = false
  212. const shelfInfo = {
  213. shelfSn: this.shelfSn,
  214. shelfName: this.shelfName,
  215. layer: this.curTab
  216. }
  217. // 打印当前层
  218. if(type == 'manual'){
  219. const list = this.shelfPlaceList[this.curTab]
  220. this.$store.state.vuex_tempPrintList = list
  221. if(shelfInfo&&list.length){
  222. uni.navigateTo({
  223. url: "/pages/batchShelves/batchPrint/batchPrint?type=manual&data="+encodeURIComponent(JSON.stringify(shelfInfo))
  224. })
  225. }else{
  226. uni.showToast({
  227. icon: 'none',
  228. title: '没有可打印的产品',
  229. duration: 5000
  230. })
  231. }
  232. }else{
  233. // 搜索打印
  234. this.$store.state.vuex_tempPrintList = this.shelfPlaceList
  235. uni.navigateTo({
  236. url: "/pages/batchShelves/batchPrint/batchPrint?type=search&data="+encodeURIComponent(JSON.stringify(shelfInfo))
  237. })
  238. }
  239. },
  240. // 编辑
  241. editRow(item){
  242. this.$store.state.vuex_tempData = item
  243. uni.navigateTo({
  244. url: "/pages/batchShelves/editShelfHw?shelfSn="+this.shelfSn+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  245. })
  246. },
  247. // 获取产品列表
  248. getList(flag){
  249. uni.showLoading({
  250. mask: true,
  251. title: '正在加载...'
  252. })
  253. this.loading = true
  254. queryMapList({ shelfSn: this.shelfSn }).then(res => {
  255. console.log(res.data)
  256. if (res.status == 200 && res.data) {
  257. this.shelfPlaceList = JSON.stringify(res.data) == '{}' ? null : res.data
  258. for(let a in res.data){
  259. this.placeTab.push(a)
  260. }
  261. if(!flag || this.placeTab.length==1){
  262. this.curTab = this.placeTab[0]
  263. }else{
  264. if(!this.shelfPlaceList[this.curTab]){
  265. this.curTab = this.placeTab[0]
  266. }
  267. }
  268. if(this.placeTab.length == 0){
  269. this.shelfPlaceList = null
  270. }
  271. } else {
  272. this.shelfPlaceList = null
  273. this.placeTab = []
  274. }
  275. uni.hideLoading()
  276. this.loading = false
  277. })
  278. },
  279. // 获取统计数据
  280. getCount(){
  281. this.totalKs = 0
  282. this.totalNums = 0
  283. queryCountList({shelfSn: this.shelfSn}).then(res => {
  284. if(res.status == 200){
  285. this.countData = res.data
  286. // 计算合计
  287. this.countData.map(item => {
  288. this.totalKs += item.category||0
  289. this.totalNums += item.qty||0
  290. })
  291. }
  292. })
  293. },
  294. // 删除
  295. shelfCartDelete(row){
  296. const _this = this
  297. clzConfirm({
  298. title: '提示',
  299. content: '确认删除此货位和产品吗?',
  300. success (ret) {
  301. if (ret.confirm || ret.index == 0) {
  302. uni.showLoading({
  303. mask: true,
  304. title: '正在删除...'
  305. })
  306. shelfCartDelete({ shelfCartSn: row.shelfCartSn }).then(res => {
  307. if (res.status == 200) {
  308. _this.toashMsg(res.message)
  309. _this.pageInit(true)
  310. }
  311. uni.hideLoading()
  312. })
  313. }else{
  314. _this.pageInit(true)
  315. }
  316. }
  317. })
  318. },
  319. // 修改数量
  320. updateNums(e){
  321. console.log(e)
  322. const row = this.shelfPlaceList[this.curTab].find(item => item.id == e.index)
  323. const nums = e.value
  324. // 如果小于1,提示是否删除
  325. if(nums<1){
  326. this.shelfCartDelete(row)
  327. return
  328. }
  329. // 继续修改数量
  330. uni.showLoading({
  331. mask: true,
  332. title: '正在保存...'
  333. })
  334. const params = {
  335. shelfSn: row.shelfSn,
  336. shelfName: this.shelfName,
  337. shelfTierCode: row.shelfTierCode,
  338. shelfPlaceSn: row.shelfPlaceSn||undefined,
  339. shelfPlaceCode: row.shelfPlaceCode,
  340. productSn: row.productSn,
  341. productCode: row.productCode,
  342. qty: nums,
  343. price: row.price,
  344. cost: row.cost,
  345. shelfCartSn: row.shelfCartSn
  346. }
  347. console.log(params)
  348. shelfCartSave(params).then(res => {
  349. if(res.status == 200){
  350. this.toashMsg(res.message)
  351. this.getCount()
  352. }
  353. uni.hideLoading()
  354. })
  355. },
  356. }
  357. }
  358. </script>
  359. <style lang="less">
  360. .content{
  361. width: 100%;
  362. height: 100vh;
  363. .product-list{
  364. flex-grow: 1;
  365. .leftTabs{
  366. width: 20%;
  367. overflow: auto;
  368. > view{
  369. padding: 0.8rem 0.5rem;
  370. border-left: 0.2rem solid #f8f8f8;
  371. text-align: center;
  372. }
  373. .active{
  374. border-color: rgb(47, 126, 209);
  375. background-color: #fff;
  376. }
  377. }
  378. .rightCons{
  379. width: 80%;
  380. background-color: #fff;
  381. position: relative;
  382. padding: 0 20upx;
  383. height: calc(100vh - 110rpx);
  384. .partList-list-box{
  385. padding: 10px 0;
  386. border-bottom: 2rpx solid #f5f5f5;
  387. .pinfo{
  388. flex-grow: 1;
  389. padding-left: 20rpx;
  390. .ptxt{
  391. color: #666;
  392. font-size: 26rpx;
  393. text{
  394. font-weight: normal;
  395. margin-right: 10rpx;
  396. padding: 0 10rpx;
  397. background: rgba(3, 54, 146, 0.15);
  398. border-radius: 30rpx;
  399. color: #033692;
  400. font-size: 24rpx;
  401. }
  402. margin-bottom: 15upx;
  403. }
  404. .pname{
  405. color: #666;
  406. font-size: 30rpx;
  407. font-weight: bold;
  408. }
  409. }
  410. .ptools{
  411. color: #666;
  412. font-size: 26rpx;
  413. margin-top: 20rpx;
  414. .u-ninput{
  415. border: 2rpx solid #eee;
  416. border-radius: 50rpx;
  417. padding: 0 6rpx;
  418. }
  419. /deep/ .u-icon-disabled{
  420. background: #fff!important;
  421. }
  422. /deep/ .u-number-input{
  423. margin: 0 0;
  424. border: 2rpx solid #eee;
  425. border-top: 0;
  426. border-bottom: 0;
  427. }
  428. /deep/ .u-icon-plus, /deep/ .u-icon-minus{
  429. border-radius: 50rpx;
  430. }
  431. }
  432. }
  433. }
  434. }
  435. .footer-bar{
  436. padding: 20rpx;
  437. position: relative;
  438. z-index: 200;
  439. background-color: #fff;
  440. .heji{
  441. flex-grow: 1;
  442. color: #999;
  443. text{
  444. color: #333;
  445. }
  446. font-size: 26rpx;
  447. padding-right: 30upx;
  448. }
  449. .btns{
  450. button{
  451. width: 200rpx;
  452. background-color: rgb(51, 95, 182);
  453. color: #fff;
  454. }
  455. }
  456. }
  457. .heji-content{
  458. padding: 60upx 30upx 30upx;
  459. }
  460. .heji-con-list{
  461. > view{
  462. display: flex;
  463. align-items: center;
  464. border-bottom: 2rpx solid #eee;
  465. padding: 18rpx 0;
  466. > view{
  467. &:first-child{
  468. font-weight: normal;
  469. padding: 4rpx 15rpx;
  470. background: rgba(3, 54, 146, 0.15);
  471. border-radius: 10rpx;
  472. color: #033692;
  473. font-size: 24rpx;
  474. margin-right: 30upx;
  475. }
  476. &:last-child{
  477. flex-grow: 1;
  478. text{
  479. margin-right: 20upx;
  480. }
  481. }
  482. }
  483. }
  484. }
  485. .layer-content{
  486. padding: 30upx;
  487. .tits{
  488. padding: 10upx 0 20upx;
  489. text-align: center;
  490. }
  491. .tagbox{
  492. flex-grow: 1;
  493. > view{
  494. margin: 0 auto;
  495. overflow: hidden;
  496. width: 100%;
  497. .tag{
  498. width: 16%;
  499. background-color: #fff;
  500. border:1rpx solid #aeaeae;
  501. box-shadow: 2rpx 4rpx 6rpx #eee;
  502. border-radius: 15rpx;
  503. text-align: center;
  504. padding: 10rpx 0;
  505. float: left;
  506. margin: 10rpx 2%;
  507. }
  508. .active{
  509. background-color: #55aaff;
  510. border-color: #55aaff;
  511. color: #fff;
  512. }
  513. }
  514. }
  515. .newbtn{
  516. padding: 40upx 0 10upx;
  517. button{
  518. width: 45%;
  519. }
  520. }
  521. }
  522. }
  523. </style>