cartList.vue 16 KB

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