cartList.vue 12 KB

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