chuku.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <template>
  2. <view class="ChuKuContainer">
  3. <!-- <view class="nav">
  4. <view
  5. v-for="(nav, ni) in navList"
  6. :key="ni"
  7. class="nav-item"
  8. :class="navIndex === ni ? 'active' : ''"
  9. @click="navIndex = ni"
  10. >
  11. {{ nav }}
  12. </view>
  13. </view> -->
  14. <view class="all">
  15. <view class="num">
  16. <text>待出库:总共</text>
  17. <text
  18. class="spec">{{ list.reduce((a, b) => a + b.children.reduce((x, y) => x + Number(y.num), 0), 0) }}</text>
  19. <text>套</text>
  20. </view>
  21. <view class="flexS">
  22. <!-- <view class="btn1" @click="toUrlLink('stock/code_record')">扫码记录</view> -->
  23. <view class="btn" @click="toUrlLink('stock/chuku_record')">出库记录</view>
  24. </view>
  25. </view>
  26. <view class="goodList">
  27. <view v-for="(item, i) in list" :key="i" class="goodItem">
  28. <view class="top">
  29. <view class="avatar" :style="{ backgroundImage: `url(${item.imgurl})` }"></view>
  30. <view class="info">
  31. <view class="name">{{ item.name }}</view>
  32. <view class="fixed">一年零一天不满意退钱</view>
  33. </view>
  34. </view>
  35. <view class="goodsAll">
  36. <view class="sex">
  37. 男款:{{ item.children.filter(v => Number(v.sex)).reduce((a, b) => a + Number(b.num), 0) }}套 /
  38. 女款:{{
  39. item.children.filter(v => !Number(v.sex)).reduce((a, b) => a + Number(b.num), 0)
  40. }}套
  41. </view>
  42. <view class="num">
  43. <text>合计:</text>
  44. <text class="spec">{{ item.children.reduce((a, b) => a + Number(b.num), 0) }}套</text>
  45. </view>
  46. </view>
  47. <view class="skuList">
  48. <view v-for="(btem, bi) in item.skuList" :key="bi" class="skuItem">
  49. <view class="type">{{ +btem.sex ? '男款' : '女款' }}</view>
  50. <view class="size">{{ btem.size }}</view>
  51. <view class="num">
  52. <count2 :countNum.sync="btem.num" />
  53. </view>
  54. </view>
  55. </view>
  56. <view class="dataAll">
  57. <view class="sex">
  58. 男款:{{ item.skuList.filter(v => Number(v.sex)).reduce((a, b) => a + Number(b.num), 0) }}套 / 女款:{{
  59. item.skuList.filter(v => !Number(v.sex)).reduce((a, b) => a + Number(b.num), 0)
  60. }}套
  61. </view>
  62. <view class="num">
  63. <text>出库:</text>
  64. <text class="spec">{{ item.skuList.reduce((a, b) => a + Number(b.num), 0) }}套</text>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="reviseFooter">
  70. <view class="footer-right">
  71. <text
  72. class="text1">{{ list.filter(item => item.skuList.reduce((x, y) => x + Number(y.num), 0) > 0).length }}类</text>
  73. <text class="text2">共计:</text>
  74. <text
  75. class="text3">{{ list.reduce((a, b) => a + b.skuList.reduce((x, y) => x + Number(y.num), 0), 0) }}</text>
  76. <text class="text4">套</text>
  77. </view>
  78. <!-- <view class="footer-text">
  79. 剩余:
  80. {{ list.reduce((a, b) => a + (b.children.reduce((x,y) => x + Number(y.num), 0)), 0) - list.reduce((a, b) => a + (b.skuList.reduce((x,y) => x + Number(y.num), 0)), 0) }}
  81. </view> -->
  82. <view class="footer-btn" @click="toSubmitChuku">确认出库</view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. const skuAllList = [{
  88. size: 'L',
  89. sex: 1,
  90. num: 0,
  91. type: ['hard']
  92. },
  93. {
  94. size: 'XL',
  95. sex: 1,
  96. num: 0,
  97. type: ['hard', 'simple', 'old', 'new_old', 'youth']
  98. },
  99. {
  100. size: '2XL',
  101. sex: 1,
  102. num: 0,
  103. type: ['hard', 'simple', 'old', 'new_old', 'youth']
  104. },
  105. {
  106. size: '3XL',
  107. sex: 1,
  108. num: 0,
  109. type: ['hard', 'simple', 'old', 'new_old', 'youth']
  110. },
  111. {
  112. size: '4XL',
  113. sex: 1,
  114. num: 0,
  115. type: ['hard']
  116. },
  117. {
  118. size: '5XL',
  119. sex: 1,
  120. num: 0,
  121. type: ['hard']
  122. },
  123. {
  124. size: 'M',
  125. sex: 0,
  126. num: 0,
  127. type: ['hard', 'simple', 'youth']
  128. },
  129. {
  130. size: 'L',
  131. sex: 0,
  132. num: 0,
  133. type: ['hard', 'simple', 'old', 'new_old', 'youth']
  134. },
  135. {
  136. size: 'XL',
  137. sex: 0,
  138. num: 0,
  139. type: ['hard', 'simple', 'old', 'new_old', 'youth']
  140. },
  141. {
  142. size: '2XL',
  143. sex: 0,
  144. num: 0,
  145. type: ['hard', 'simple', 'old', 'new_old', 'youth']
  146. },
  147. {
  148. size: '3XL',
  149. sex: 0,
  150. num: 0,
  151. type: ['hard', 'old']
  152. },
  153. {
  154. size: '4XL',
  155. sex: 0,
  156. num: 0,
  157. type: ['hard']
  158. }
  159. ]
  160. import Count2 from '../stock/components/count2.vue';
  161. import {
  162. stockGoods,
  163. getPanKuStock,
  164. publishChuKu
  165. } from '@/apis/stock.js';
  166. export default {
  167. components: {
  168. Count2
  169. },
  170. data() {
  171. return {
  172. sexList: [{
  173. name: '男款',
  174. value: 1
  175. }, {
  176. name: '女款',
  177. value: 0
  178. }],
  179. list: [],
  180. navList: ['零售', '出货', '其他'],
  181. navIndex: 0
  182. };
  183. },
  184. onShow() {
  185. this.init();
  186. },
  187. methods: {
  188. selectSizeTip() {
  189. // 尺码选择提醒
  190. uni.showModal({
  191. content: '请先选择款式',
  192. showCancel: false
  193. });
  194. },
  195. // 出库
  196. toSubmitChuku() {
  197. let arr = {};
  198. let num = 0,
  199. errorNum = 0;
  200. this.list.forEach(v => {
  201. arr[v.k] = v.skuList;
  202. errorNum += v.skuList.filter(item => (item.sex === '' || item.size === '') && item.num > 0)
  203. .length;
  204. num += v.skuList.reduce((a, b) => a + Number(b.num), 0);
  205. });
  206. if (num === 0) {
  207. uni.showModal({
  208. content: '出库最少为1件',
  209. showCancel: false
  210. });
  211. return false;
  212. }
  213. if (errorNum > 0) {
  214. uni.showModal({
  215. content: '请选择款式和尺码',
  216. showCancel: false
  217. });
  218. return false;
  219. }
  220. let copy_arr = JSON.parse(JSON.stringify(arr));
  221. Object.keys(copy_arr).forEach(k => {
  222. copy_arr[k].forEach((item, i) => {
  223. if (i < copy_arr[k].length - 1) {
  224. if (item.size === copy_arr[k][i + 1].size && item.sex === copy_arr[k][i + 1]
  225. .sex) {
  226. item.num += copy_arr[k][i + 1].num;
  227. copy_arr[k][i + 1].num = 0;
  228. }
  229. }
  230. });
  231. copy_arr[k] = copy_arr[k].filter(item => Number(item.num) > 0);
  232. });
  233. uni.showLoading();
  234. publishChuKu({
  235. type: this.navIndex,
  236. arr: copy_arr
  237. })
  238. .then(res => {
  239. uni.hideLoading();
  240. if (res.code === 200) {
  241. uni.showModal({
  242. content: '出库成功',
  243. showCancel: false,
  244. success(res) {
  245. if (res.confirm) {
  246. uni.reLaunch({
  247. url: '../stock/stock'
  248. });
  249. }
  250. }
  251. });
  252. } else {
  253. uni.showModal({
  254. content: typeof res.message === 'string' ? res.message : '出库失败',
  255. showCancel: false
  256. });
  257. }
  258. })
  259. .catch(() => {
  260. uni.hideLoading();
  261. uni.showModal({
  262. content: '出库失败',
  263. showCancel: false
  264. });
  265. });
  266. },
  267. // 添加尺码
  268. toAddSku(parent, i) {
  269. if (i) {
  270. parent.skuList.splice(i, 1);
  271. } else {
  272. parent.skuList.push({
  273. sex: '',
  274. size: '',
  275. num: 0
  276. });
  277. }
  278. },
  279. // 尺码选择
  280. toChangeSize(e, data, parent) {
  281. let i = e.detail.value;
  282. data.size = parent.pickerSizeList[String(data.sex)][i];
  283. },
  284. // 男女款选择
  285. toChangeSex(e, data, parent) {
  286. let i = e.detail.value;
  287. data.sex = this.sexList[i].value;
  288. data.size = '';
  289. },
  290. deepClone2(obj) {
  291. var _obj = JSON.stringify(obj),
  292. objClone = JSON.parse(_obj);
  293. return objClone;
  294. },
  295. // 初始化
  296. init() {
  297. uni.showLoading();
  298. const _this = this;
  299. Promise.all([this.getStockGoods(), this.getPanKuStock()])
  300. .then(res => {
  301. uni.hideLoading();
  302. let goodsList = res[0];
  303. let stockList = res[1];
  304. _this.list = Object.keys(stockList).map(k => ({
  305. k: k,
  306. children: stockList[k],
  307. imgurl: goodsList[k].imgurl,
  308. name: goodsList[k].name,
  309. skuList: this.deepClone2(skuAllList.slice(0).filter(xtem => xtem.type.includes(
  310. k)))
  311. }));
  312. })
  313. .catch(() => {
  314. uni.hideLoading();
  315. uni.showModal({
  316. content: '获取出库信息失败',
  317. showCancel: false
  318. });
  319. });
  320. },
  321. // 获取图片
  322. getStockGoods() {
  323. return new Promise(resolve => {
  324. stockGoods().then(res => {
  325. if (res.code === 200) {
  326. resolve(res.data);
  327. }
  328. });
  329. });
  330. },
  331. // 获取盘库历史
  332. getPanKuStock() {
  333. return new Promise(resolve => {
  334. getPanKuStock().then(res => {
  335. if (res.code === 200) {
  336. resolve(res.data);
  337. }
  338. });
  339. });
  340. },
  341. toUrlLink(url) {
  342. if (!url) return false;
  343. uni.navigateTo({
  344. url: `../${url}`
  345. });
  346. }
  347. }
  348. };
  349. </script>
  350. <style lang="scss" scoped>
  351. page {
  352. display: flex;
  353. flex-direction: column;
  354. }
  355. .ChuKuContainer {
  356. width: 100%;
  357. flex: 1;
  358. background-color: #f9f9fb;
  359. .nav {
  360. width: 100%;
  361. height: 104rpx;
  362. padding: 0 60rpx;
  363. box-sizing: border-box;
  364. background-color: #ffffff;
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. &-item {
  369. position: relative;
  370. color: #333333;
  371. font-size: 32rpx;
  372. line-height: 44rpx;
  373. &.active {
  374. color: #ea4a41 !important;
  375. &::after {
  376. content: '';
  377. display: block;
  378. position: absolute;
  379. bottom: 0;
  380. left: 50%;
  381. transform: translateX(-50%);
  382. width: 30rpx;
  383. height: 4rpx;
  384. border-radius: 4rpx;
  385. background: linear-gradient(97deg, #f97c55 0%, #f44545 100%);
  386. }
  387. }
  388. }
  389. }
  390. .btn {
  391. width: 140rpx;
  392. height: 56rpx;
  393. border-radius: 8rpx;
  394. background-color: #ea4a41;
  395. color: #ffffff;
  396. font-size: 28rpx;
  397. line-height: 56rpx;
  398. text-align: center;
  399. text-align: center;
  400. }
  401. .reviseFooter {
  402. position: fixed;
  403. bottom: 0;
  404. left: 0;
  405. right: 0;
  406. height: 98rpx;
  407. background-color: #ffffff;
  408. border-top: 2rpx solid #eeeeee;
  409. padding: 0 30rpx;
  410. box-sizing: border-box;
  411. display: flex;
  412. align-items: center;
  413. justify-content: flex-end;
  414. .footer-right {
  415. margin-right: auto;
  416. .text1 {
  417. color: #999999;
  418. font-size: 28rpx;
  419. line-height: 40rpx;
  420. }
  421. .text2 {
  422. color: #333333;
  423. font-size: 28rpx;
  424. line-height: 40rpx;
  425. margin-left: 10rpx;
  426. }
  427. .text3 {
  428. color: #ea4a41;
  429. font-size: 40rpx;
  430. line-height: 56rpx;
  431. }
  432. .text4 {
  433. color: #ea4a41;
  434. font-size: 28rpx;
  435. line-height: 40rpx;
  436. }
  437. }
  438. .footer-text {
  439. color: #999999;
  440. font-size: 28rpx;
  441. line-height: 40rpx;
  442. }
  443. .footer-btn {
  444. width: 192rpx;
  445. height: 68rpx;
  446. border-radius: 68rpx;
  447. text-align: center;
  448. line-height: 68rpx;
  449. background: linear-gradient(141deg, #f97c55 0%, #f44545 100%);
  450. color: #ffffff;
  451. font-size: 28rpx;
  452. margin-left: 12rpx;
  453. }
  454. }
  455. .all {
  456. width: 100%;
  457. height: 116rpx;
  458. padding: 0 30rpx;
  459. display: flex;
  460. align-items: center;
  461. justify-content: space-between;
  462. .num {
  463. color: #333333;
  464. font-size: 36rpx;
  465. line-height: 50rpx;
  466. font-weight: bold;
  467. .spec {
  468. color: #ea4a41 !important;
  469. }
  470. }
  471. .btn,
  472. .btn1 {
  473. width: 140rpx;
  474. height: 56rpx;
  475. border-radius: 8rpx;
  476. background-color: #ea4a41;
  477. color: #ffffff;
  478. font-size: 28rpx;
  479. line-height: 56rpx;
  480. text-align: center;
  481. text-align: center;
  482. }
  483. .btn1 {
  484. background: linear-gradient(180deg, #FFBB00 0%, #FF9100 100%);
  485. margin-right: 24rpx;
  486. }
  487. }
  488. .goodList {
  489. width: 100%;
  490. padding-bottom: 100rpx;
  491. .goodItem {
  492. width: 100%;
  493. margin-bottom: 30rpx;
  494. padding: 30rpx;
  495. box-sizing: border-box;
  496. background-color: #ffffff;
  497. .top {
  498. width: 100%;
  499. display: flex;
  500. align-items: stretch;
  501. justify-content: space-between;
  502. margin-bottom: 40rpx;
  503. .avatar {
  504. width: 180rpx;
  505. height: 144rpx;
  506. background-color: #eeeeee;
  507. background-position: center;
  508. background-size: cover;
  509. background-repeat: no-repeat;
  510. border-radius: 8rpx;
  511. }
  512. .info {
  513. display: flex;
  514. justify-content: center;
  515. flex-direction: column;
  516. flex: 1;
  517. overflow: hidden;
  518. margin-left: 20rpx;
  519. .name {
  520. color: #333333;
  521. font-size: 32rpx;
  522. line-height: 44rpx;
  523. margin-bottom: 20rpx;
  524. }
  525. .fixed {
  526. color: #f76454;
  527. font-size: 28rpx;
  528. height: 40rpx;
  529. line-height: 40rpx;
  530. border: 1px solid #f76454;
  531. box-sizing: border-box;
  532. width: 328rpx;
  533. border-radius: 40rpx;
  534. color: #f76454;
  535. text-align: center;
  536. }
  537. }
  538. }
  539. .goodsAll {
  540. width: 100%;
  541. display: flex;
  542. align-items: center;
  543. justify-content: space-between;
  544. margin-bottom: 30rpx;
  545. padding-bottom: 36rpx;
  546. border-bottom: 1px solid #eeeeee;
  547. .sex {
  548. color: #333333;
  549. font-size: 28rpx;
  550. line-height: 40rpx;
  551. }
  552. .num {
  553. color: #999999;
  554. font-size: 28rpx;
  555. .spec {
  556. color: #ea4a41 !important;
  557. font-size: 40rpx !important;
  558. font-weight: bold;
  559. }
  560. }
  561. }
  562. .skuList {
  563. width: 100%;
  564. margin-bottom: 30rpx;
  565. .skuItem {
  566. width: 100%;
  567. display: flex;
  568. align-items: center;
  569. justify-content: space-between;
  570. margin-bottom: 30rpx;
  571. &:nth-last-of-type(1) {
  572. margin-bottom: 0;
  573. }
  574. .type,
  575. .size,
  576. .num,
  577. .reviseNum {
  578. flex: 1;
  579. overflow: hidden;
  580. display: flex;
  581. align-items: center;
  582. justify-content: center;
  583. }
  584. .type {
  585. justify-content: flex-start;
  586. flex: none;
  587. width: 18%;
  588. }
  589. .reviseNum {
  590. justify-content: flex-end;
  591. }
  592. .select {
  593. height: 72rpx;
  594. width: 156rpx;
  595. padding: 20rpx;
  596. box-sizing: 0 border-box;
  597. border-radius: 8rpx;
  598. background-color: #f5f5f5;
  599. display: flex;
  600. align-items: center;
  601. justify-content: flex-end;
  602. .value {
  603. color: #333333;
  604. font-size: 32rpx;
  605. line-height: 44rpx;
  606. text-align: center;
  607. flex: 1;
  608. overflow: hidden;
  609. }
  610. &::after {
  611. content: '';
  612. display: block;
  613. width: 30rpx;
  614. height: 30rpx;
  615. background-image: url(../../static/new_my/arrow.png);
  616. background-position: center;
  617. background-size: cover;
  618. background-repeat: no-repeat;
  619. margin-left: 10rpx;
  620. transform: rotate(90deg);
  621. }
  622. }
  623. .countBox {
  624. width: 192rpx;
  625. }
  626. .addIcon {
  627. width: 40rpx;
  628. height: 40rpx;
  629. background-image: url(../../static/new_stock/add.png);
  630. background-repeat: no-repeat;
  631. background-size: 100%;
  632. background-position: center;
  633. &.delete {
  634. background-image: url(../../static/new_stock/delete.png) !important;
  635. }
  636. }
  637. }
  638. }
  639. .dataAll {
  640. width: 100%;
  641. display: flex;
  642. align-items: baseline;
  643. justify-content: flex-end;
  644. .sex {
  645. color: #333333;
  646. font-size: 28rpx;
  647. margin-right: 30rpx;
  648. }
  649. .num {
  650. color: #999999;
  651. font-size: 28rpx;
  652. .spec {
  653. color: #ea4a41 !important;
  654. font-size: 40rpx !important;
  655. font-weight: bolder;
  656. }
  657. }
  658. }
  659. }
  660. }
  661. }
  662. </style>