first_panku.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <view class="PanKuContainer">
  3. <!-- <view class="all">
  4. <view class="num">库存:总共<text class="spec">3532</text>套</view>
  5. </view> -->
  6. <view class="goodList">
  7. <view
  8. v-for="(item, i) in infoList"
  9. :key="i"
  10. class="goodItem"
  11. >
  12. <view class="top">
  13. <view
  14. class="avatar"
  15. :style="{ backgroundImage: `url(${item.imgurl})` }"
  16. ></view>
  17. <view class="info">
  18. <view class="name">{{ item.name }}</view>
  19. <view class="fixed">一年零一天不满意退钱</view>
  20. </view>
  21. </view>
  22. <view class="skuList">
  23. <view
  24. class="skuHeader"
  25. :class="item.toggle ? 'open' : ''"
  26. @click="item.toggle = !item.toggle"
  27. >
  28. <view class="type">规格</view>
  29. <view class="size">尺码</view>
  30. <view class="reviseNum">
  31. <view class="reviseNum-title">数量</view>
  32. </view>
  33. </view>
  34. <template v-if="item.toggle">
  35. <view
  36. v-for="(btem, bi) in item.skuList"
  37. :key="bi"
  38. >
  39. <template v-if="btem.type.includes(item.k)">
  40. <view class="skuItem">
  41. <view class="type">{{ +btem.sex ? '男款' : '女款' }}</view>
  42. <view class="size">{{ btem.size }}</view>
  43. <view class="reviseNum">
  44. <!-- <input
  45. v-model="btem.num"
  46. type="number"
  47. placeholder="输入数量"
  48. class="reviseInput"
  49. @change="inputNum(btem)"
  50. /> -->
  51. <count2 :count-num.sync="btem.num" />
  52. </view>
  53. </view>
  54. </template>
  55. </view>
  56. </template>
  57. </view>
  58. <view class="dataAll">
  59. <view class="sex">
  60. 男款:{{ item.skuList.filter(item => item.sex).reduce((a, b) => a + Number(b.num), 0) }}套
  61. /
  62. 女款:{{ item.skuList.filter(item => !item.sex).reduce((a, b) => a + Number(b.num), 0) }}套
  63. </view>
  64. <view class="num">
  65. <text>合计:</text>
  66. <text class="spec">
  67. {{ item.skuList.reduce((a, b) => a + Number(b.num), 0) }}套
  68. </text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="reviseBtn" @click="publishFirstPanKu">确认提交</view>
  74. </view>
  75. </template>
  76. <script>
  77. import Count2 from "./components/count2.vue"
  78. import { stockGoods, publishFirstPanKu } from "@/apis/stock.js"
  79. export default {
  80. components: {
  81. Count2
  82. },
  83. data() {
  84. return {
  85. count: 0,
  86. infoList: []
  87. }
  88. },
  89. onShow() {
  90. this.getStockGoods()
  91. },
  92. methods: {
  93. // 检查输入
  94. inputNum(data) {
  95. if(!(/^[+]{0,1}(\d+)$/.test(data.num))) {
  96. uni.showToast({
  97. icon: "none",
  98. title: '请填写正确的库存数量'
  99. })
  100. data.num = 0
  101. return false
  102. } else {
  103. data.num = Number(data.num)
  104. }
  105. },
  106. publishFirstPanKu() {
  107. let arr = {}
  108. let num = 0
  109. this.infoList.forEach((item) => {
  110. arr[item.k] = item.skuList.filter(btem => btem.type.includes(item.k))
  111. num += item.skuList.reduce((a, b) => a + Number(b.num), 0)
  112. })
  113. if(num === 0) {
  114. uni.showModal({
  115. content: "数量最少为1件",
  116. showCancel: false
  117. })
  118. return false
  119. }
  120. uni.showLoading()
  121. publishFirstPanKu(arr).then(res => {
  122. uni.hideLoading()
  123. if(res.code === 200) {
  124. uni.showModal({
  125. content: "一次性盘库成功,请返回上一个页面",
  126. showCancel: false,
  127. success(res) {
  128. if(res.confirm) {
  129. uni.reLaunch({
  130. url: '../stock/stock'
  131. })
  132. }
  133. }
  134. })
  135. } else {
  136. uni.showModal({
  137. content: res.message || "盘库失败",
  138. showCancel: false
  139. })
  140. }
  141. }).catch(()=> {
  142. uni.hideLoading()
  143. uni.showModal({
  144. content: "盘库失败",
  145. showCancel: false
  146. })
  147. })
  148. },
  149. getStockGoods() {
  150. uni.showLoading()
  151. stockGoods().then(res => {
  152. uni.hideLoading()
  153. if(res.code === 200) {
  154. this.infoList = Object.keys(res.data).map(k => ({
  155. imgurl: res.data[k].imgurl,
  156. name: res.data[k].name,
  157. k: k,
  158. toggle: false,
  159. skuList: [
  160. { size: 'L', sex: 1, num: 0, type: ['hard'] },
  161. { size: 'XL', sex: 1, num: 0, type: ['hard', 'simple', 'old', 'new_old', 'youth'] },
  162. { size: '2XL', sex: 1, num: 0, type: ['hard', 'simple', 'old', 'new_old', 'youth'] },
  163. { size: '3XL', sex: 1, num: 0, type: ['hard', 'simple', 'old', 'new_old', 'youth'] },
  164. { size: '4XL', sex: 1, num: 0, type: ['hard'] },
  165. { size: '5XL', sex: 1, num: 0, type: ['hard'] },
  166. { size: 'M', sex: 0, num: 0, type: ['hard', 'simple', 'youth'] },
  167. { size: 'L', sex: 0, num: 0, type: ['hard', 'simple', 'old', 'new_old', 'youth'] },
  168. { size: 'XL', sex: 0, num: 0, type: ['hard', 'simple', 'old', 'new_old', 'youth'] },
  169. { size: '2XL', sex: 0, num: 0, type: ['hard', 'simple', 'old', 'new_old', 'youth'] },
  170. { size: '3XL', sex: 0, num: 0, type: ['hard', 'old'] },
  171. { size: '4XL', sex: 0, num: 0, type: ['hard'] }
  172. ]
  173. }))
  174. } else {
  175. uni.showModal({
  176. content: res.message || "获取商品详情失败",
  177. showCancel: false
  178. })
  179. }
  180. }).catch(() => {
  181. uni.hideLoading()
  182. uni.showModal({
  183. content: "获取商品详情失败",
  184. showCancel: false
  185. })
  186. })
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. page{
  193. display: flex;
  194. flex-direction: column;
  195. }
  196. .PanKuContainer {
  197. width: 100%;
  198. flex: 1;
  199. background-color: #F9F9FB;
  200. .btn {
  201. width: 140rpx;
  202. height: 56rpx;
  203. border-radius: 8rpx;
  204. background-color: #EA4A41;
  205. color: #FFFFFF;
  206. font-size: 28rpx;
  207. line-height: 56rpx;
  208. text-align: center;
  209. text-align: center;
  210. }
  211. .reviseBtn {
  212. position: fixed;
  213. bottom: 0;
  214. left: 0;
  215. right: 0;
  216. height: 100rpx;
  217. text-align: center;
  218. line-height: 100rpx;
  219. background: linear-gradient(to right, #F97C55, #F44545);
  220. color: #FFFFFF;
  221. font-size: 32rpx;
  222. }
  223. .all {
  224. width: 100%;
  225. height: 116rpx;
  226. padding: 0 30rpx;
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-between;
  230. .num {
  231. color: #333333;
  232. font-size: 36rpx;
  233. line-height: 50rpx;
  234. font-weight: bold;
  235. .spec {
  236. color: #EA4A41 !important;
  237. }
  238. }
  239. }
  240. .goodList {
  241. width: 100%;
  242. padding-bottom: 100rpx;
  243. .goodItem {
  244. width: 100%;
  245. margin-bottom: 30rpx;
  246. padding: 30rpx;
  247. box-sizing: border-box;
  248. background-color: #ffffff;
  249. .top {
  250. width: 100%;
  251. display: flex;
  252. align-items: stretch;
  253. justify-content: space-between;
  254. margin-bottom: 40rpx;
  255. .avatar {
  256. width: 180rpx;
  257. height: 144rpx;
  258. background-color: #eeeeee;
  259. background-position: center;
  260. background-size: cover;
  261. background-repeat: no-repeat;
  262. border-radius: 8rpx;
  263. }
  264. .info {
  265. display: flex;
  266. justify-content: center;
  267. flex-direction: column;
  268. flex: 1;
  269. overflow: hidden;
  270. margin-left: 20rpx;
  271. .name {
  272. color: #333333;
  273. font-size: 32rpx;
  274. line-height: 44rpx;
  275. margin-bottom: 20rpx;
  276. font-weight: bold;
  277. }
  278. .fixed {
  279. color: #F76454;
  280. font-size: 28rpx;
  281. height: 40rpx;
  282. line-height: 40rpx;
  283. border: 1px solid #F76454;
  284. box-sizing: border-box;
  285. width: 328rpx;
  286. border-radius: 40rpx;
  287. color: #F76454;
  288. text-align: center;
  289. }
  290. }
  291. }
  292. .skuList{
  293. width: 100%;
  294. margin-bottom: 30rpx;
  295. .skuHeader, .skuItem {
  296. width: 100%;
  297. height: 100rpx;
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. border-bottom: 1px solid #EEEEEE;
  302. .type, .size, .num, .reviseNum {
  303. flex: 1;
  304. overflow: hidden;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. }
  309. .type {
  310. justify-content: flex-start;
  311. flex: none;
  312. width: 25%;
  313. font-weight: bold;
  314. }
  315. .size {
  316. font-weight: bold;
  317. }
  318. .reviseNum {
  319. justify-content: flex-end;
  320. width: 25%;
  321. // .reviseInput {
  322. // width: 168rpx;
  323. // height: 64rpx;
  324. // text-align: center;
  325. // line-height: 64rpx;
  326. // border-radius: 8rpx;
  327. // background-color: #F8F8F8;
  328. // color: #999999;
  329. // font-size: 28rpx;
  330. // }
  331. .reviseNum-title {
  332. width: 152rpx;
  333. height: 56rpx;
  334. border-radius: 56rpx;
  335. text-align: center;
  336. line-height: 56rpx;
  337. background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
  338. color: #FFFFFF;
  339. font-size: 28rpx;
  340. }
  341. }
  342. }
  343. .skuHeader {
  344. color: #999999;
  345. font-size: 28rpx;
  346. line-height: 40rpx;
  347. border-top: 1px solid #EEEEEE;
  348. .reviseNum {
  349. &::after {
  350. display: block;
  351. content: "";
  352. margin-left: 10rpx;
  353. width: 30rpx;
  354. height: 30rpx;
  355. background-image: url(../../static/new_my/arrow.png);
  356. background-size: cover;
  357. background-position: center;
  358. background-repeat: no-repeat;
  359. }
  360. }
  361. &.open {
  362. .reviseNum {
  363. &::after {
  364. transform: rotate(90deg) !important;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. .dataAll {
  371. width: 100%;
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. .sex {
  376. color: #333333;
  377. font-size: 28rpx;
  378. }
  379. .num {
  380. color: #999999;
  381. font-size: 28rpx;
  382. .spec {
  383. color: #EA4A41 !important;
  384. font-size: 40rpx !important;
  385. font-weight: bolder;
  386. }
  387. }
  388. }
  389. }
  390. }
  391. }
  392. </style>