cartList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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" 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. if(this.placeTab.length){
  145. // 上架入库
  146. if(e.index == 0){
  147. this.toPutaway()
  148. }
  149. // 打印贴签
  150. if(e.index == 1){
  151. this.showPrintModal = true
  152. }
  153. }else{
  154. uni.showToast({
  155. icon: 'none',
  156. title: '还未录入产品,不能操作',
  157. duration: 4000
  158. })
  159. }
  160. },
  161. methods: {
  162. pageInit(flag){
  163. this.placeTab = []
  164. this.shelfPlaceList = null
  165. this.countData = []
  166. this.getList(flag)
  167. this.getCount()
  168. },
  169. scanProduct(){
  170. this.showLayer = false
  171. uni.navigateTo({
  172. url: "/pages/batchShelves/scanProduct?shelfSn="+this.shelfSn+'&layer='+this.curLayer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn+'&from=cartList'
  173. })
  174. },
  175. searchProduct(){
  176. this.showLayer = false
  177. uni.navigateTo({
  178. url: "/pages/batchShelves/searchProduct?shelfSn="+this.shelfSn+'&layer='+this.curLayer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn+'&from=cartList'
  179. })
  180. },
  181. // 上架入库
  182. toPutaway(){
  183. uni.showLoading({
  184. title: '正在查询...',
  185. mask: true
  186. })
  187. queryEmptyCostList({shelfSn: this.shelfSn}).then(res => {
  188. console.log(res)
  189. uni.hideLoading()
  190. if(res.data&&res.data.length){
  191. this.$store.state.vuex_tempData = res.data
  192. // 去设置价格
  193. uni.navigateTo({
  194. url: "/pages/batchShelves/setProductCost?shelfSn="+this.shelfSn+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  195. })
  196. }else{
  197. this.chooseModal = true
  198. }
  199. })
  200. },
  201. //确认上架
  202. confirmPut(data){
  203. uni.showLoading({
  204. mask: true,
  205. title: '正在上架...'
  206. })
  207. shelfCartConfirm({
  208. shelfSn: this.shelfSn,
  209. ...data
  210. }).then(res => {
  211. uni.hideLoading()
  212. if(res.status == 200){
  213. uni.navigateBack()
  214. }
  215. })
  216. },
  217. // 打印
  218. confirmPrint(type){
  219. this.showPrintModal = false
  220. const shelfInfo = {
  221. shelfSn: this.shelfSn,
  222. shelfName: this.shelfName,
  223. layer: this.curTab
  224. }
  225. // 打印当前层
  226. if(type == 'manual'){
  227. const list = this.shelfPlaceList[this.curTab]
  228. this.$store.state.vuex_tempPrintList = list
  229. if(shelfInfo&&list.length){
  230. uni.navigateTo({
  231. url: "/pages/batchShelves/batchPrint/batchPrint?type=manual&data="+encodeURIComponent(JSON.stringify(shelfInfo))
  232. })
  233. }else{
  234. uni.showToast({
  235. icon: 'none',
  236. title: '没有可打印的产品',
  237. duration: 5000
  238. })
  239. }
  240. }else{
  241. // 搜索打印
  242. this.$store.state.vuex_tempPrintList = this.shelfPlaceList
  243. uni.navigateTo({
  244. url: "/pages/batchShelves/batchPrint/batchPrint?type=search&data="+encodeURIComponent(JSON.stringify(shelfInfo))
  245. })
  246. }
  247. },
  248. // 编辑
  249. editRow(item){
  250. this.$store.state.vuex_tempData = item
  251. uni.navigateTo({
  252. url: "/pages/batchShelves/editShelfHw?shelfSn="+this.shelfSn+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  253. })
  254. },
  255. // 获取产品列表
  256. getList(flag){
  257. uni.showLoading({
  258. mask: true,
  259. title: '正在加载...'
  260. })
  261. this.loading = true
  262. queryMapList({ shelfSn: this.shelfSn }).then(res => {
  263. console.log(res.data)
  264. this.loading = false
  265. if (res.status == 200 && res.data) {
  266. this.shelfPlaceList = JSON.stringify(res.data) == '{}' ? null : res.data
  267. for(let a in res.data){
  268. this.placeTab.push(a)
  269. }
  270. if(!flag || this.placeTab.length==1){
  271. this.curTab = this.placeTab[0]
  272. }else{
  273. if(!this.shelfPlaceList[this.curTab]){
  274. this.curTab = this.placeTab[0]
  275. }
  276. }
  277. if(this.placeTab.length == 0){
  278. this.shelfPlaceList = null
  279. this.curTab = ''
  280. }
  281. } else {
  282. this.shelfPlaceList = null
  283. this.placeTab = []
  284. this.curTab = ''
  285. }
  286. uni.hideLoading()
  287. })
  288. },
  289. // 获取统计数据
  290. getCount(){
  291. this.totalKs = 0
  292. this.totalNums = 0
  293. queryCountList({shelfSn: this.shelfSn}).then(res => {
  294. if(res.status == 200){
  295. this.countData = res.data
  296. // 计算合计
  297. this.countData.map(item => {
  298. this.totalKs += item.category||0
  299. this.totalNums += item.qty||0
  300. })
  301. }
  302. })
  303. },
  304. // 删除
  305. shelfCartDelete(row){
  306. const _this = this
  307. clzConfirm({
  308. title: '提示',
  309. content: '确认删除此货位和产品吗?',
  310. success (ret) {
  311. if (ret.confirm || ret.index == 0) {
  312. uni.showLoading({
  313. mask: true,
  314. title: '正在删除...'
  315. })
  316. shelfCartDelete({ shelfCartSn: row.shelfCartSn }).then(res => {
  317. if (res.status == 200) {
  318. _this.toashMsg(res.message)
  319. _this.pageInit(true)
  320. }
  321. uni.hideLoading()
  322. })
  323. }else{
  324. _this.pageInit(true)
  325. }
  326. }
  327. })
  328. },
  329. // 修改数量
  330. updateNums(e){
  331. console.log(e)
  332. const row = this.shelfPlaceList[this.curTab].find(item => item.id == e.index)
  333. const nums = e.value
  334. // 如果小于1,提示是否删除
  335. if(nums<1){
  336. this.shelfCartDelete(row)
  337. return
  338. }
  339. // 继续修改数量
  340. uni.showLoading({
  341. mask: true,
  342. title: '正在保存...'
  343. })
  344. const params = {
  345. shelfSn: row.shelfSn,
  346. shelfName: this.shelfName,
  347. shelfTierCode: row.shelfTierCode,
  348. shelfPlaceSn: row.shelfPlaceSn||undefined,
  349. shelfPlaceCode: row.shelfPlaceCode,
  350. productSn: row.productSn,
  351. productCode: row.productCode,
  352. qty: nums,
  353. price: row.price,
  354. cost: row.terminalPrice,
  355. shelfCartSn: row.shelfCartSn
  356. }
  357. console.log(params)
  358. shelfCartSave(params).then(res => {
  359. if(res.status == 200){
  360. this.toashMsg(res.message)
  361. this.getCount()
  362. }
  363. uni.hideLoading()
  364. })
  365. },
  366. }
  367. }
  368. </script>
  369. <style lang="less">
  370. .content{
  371. width: 100%;
  372. height: 100vh;
  373. .product-list{
  374. flex-grow: 1;
  375. .leftTabs{
  376. width: 20%;
  377. overflow: auto;
  378. > view{
  379. padding: 0.8rem 0.5rem;
  380. border-left: 0.2rem solid #f8f8f8;
  381. text-align: center;
  382. }
  383. .active{
  384. border-color: rgb(47, 126, 209);
  385. background-color: #fff;
  386. }
  387. }
  388. .rightCons{
  389. width: 80%;
  390. background-color: #fff;
  391. position: relative;
  392. padding: 0 20upx;
  393. height: calc(100vh - 110rpx);
  394. .partList-list-box{
  395. padding: 10px 0;
  396. border-bottom: 2rpx solid #f5f5f5;
  397. .pinfo{
  398. flex-grow: 1;
  399. padding-left: 20rpx;
  400. .ptxt{
  401. color: #666;
  402. font-size: 26rpx;
  403. text{
  404. font-weight: normal;
  405. margin-right: 10rpx;
  406. padding: 0 10rpx;
  407. background: rgba(3, 54, 146, 0.15);
  408. border-radius: 30rpx;
  409. color: #033692;
  410. font-size: 24rpx;
  411. }
  412. margin-bottom: 15upx;
  413. }
  414. .pname{
  415. color: #666;
  416. font-size: 30rpx;
  417. font-weight: bold;
  418. }
  419. }
  420. .ptools{
  421. color: #666;
  422. font-size: 26rpx;
  423. margin-top: 20rpx;
  424. .u-ninput{
  425. border: 2rpx solid #eee;
  426. border-radius: 50rpx;
  427. padding: 0 6rpx;
  428. }
  429. /deep/ .u-icon-disabled{
  430. background: #fff!important;
  431. }
  432. /deep/ .u-number-input{
  433. margin: 0 0;
  434. border: 2rpx solid #eee;
  435. border-top: 0;
  436. border-bottom: 0;
  437. }
  438. /deep/ .u-icon-plus, /deep/ .u-icon-minus{
  439. border-radius: 50rpx;
  440. }
  441. }
  442. }
  443. }
  444. }
  445. .footer-bar{
  446. padding: 20rpx;
  447. position: relative;
  448. z-index: 200;
  449. background-color: #fff;
  450. .heji{
  451. flex-grow: 1;
  452. color: #999;
  453. text{
  454. color: #333;
  455. }
  456. font-size: 26rpx;
  457. padding-right: 30upx;
  458. }
  459. .btns{
  460. button{
  461. width: 200rpx;
  462. background-color: rgb(51, 95, 182);
  463. color: #fff;
  464. }
  465. }
  466. }
  467. .heji-content{
  468. padding: 60upx 30upx 100upx;
  469. }
  470. .heji-con-list{
  471. > view{
  472. display: flex;
  473. align-items: center;
  474. border-bottom: 2rpx solid #eee;
  475. padding: 18rpx 0;
  476. > view{
  477. &:first-child{
  478. font-weight: normal;
  479. padding: 4rpx 15rpx;
  480. background: rgba(3, 54, 146, 0.15);
  481. border-radius: 10rpx;
  482. color: #033692;
  483. font-size: 24rpx;
  484. margin-right: 30upx;
  485. }
  486. &:last-child{
  487. flex-grow: 1;
  488. text{
  489. margin-right: 20upx;
  490. }
  491. }
  492. }
  493. }
  494. }
  495. .layer-content{
  496. padding: 30upx;
  497. .tits{
  498. padding: 10upx 0 20upx;
  499. text-align: center;
  500. }
  501. .tagbox{
  502. flex-grow: 1;
  503. > view{
  504. margin: 0 auto;
  505. overflow: hidden;
  506. width: 100%;
  507. .tag{
  508. width: 16%;
  509. background-color: #fff;
  510. border:1rpx solid #aeaeae;
  511. box-shadow: 2rpx 4rpx 6rpx #eee;
  512. border-radius: 15rpx;
  513. text-align: center;
  514. padding: 10rpx 0;
  515. float: left;
  516. margin: 10rpx 2%;
  517. }
  518. .active{
  519. background-color: #55aaff;
  520. border-color: #55aaff;
  521. color: #fff;
  522. }
  523. }
  524. }
  525. .newbtn{
  526. padding: 40upx 0 10upx;
  527. button{
  528. width: 45%;
  529. }
  530. }
  531. }
  532. }
  533. </style>