cartList.vue 13 KB

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