cartList.vue 14 KB

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