123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649 |
- <template>
- <view class="ChuKuContainer">
- <view class="all">
- <view class="btn" @click="toUrlLink('stock/ruku_record')">入库记录</view>
- </view>
- <view class="goodList">
- <view v-for="(item, i) in list" :key="i" class="goodItem">
- <view class="top">
- <view class="avatar" :style="{ backgroundImage: `url(${item.imgurl})` }"></view>
- <view class="info">
- <view class="name">
- <text class="text">{{ item.name }}</text>
- <text class="text spec">(单位:{{ item.unitName }})</text>
- </view>
- <view class="fixed">一年零一天不满意退钱</view>
- </view>
- </view>
- <view class="skuList">
- <view v-for="(btem, bi) in item.skuList" :key="bi" class="skuItem">
- <picker mode="selector" :range="sexList" range-key="name"
- @change="toChangeSex($event, btem, item)">
- <view class="select">
- <view class="value">{{ btem.sex === '' ? '款式' : btem.sex ? '男款' : '女款' }}</view>
- </view>
- </picker>
- <template v-if="btem.sex === ''">
- <view class="select" @click="selectSizeTip">
- <view class="value">{{ btem.size === '' ? '尺码' : btem.size }}</view>
- </view>
- </template>
- <template v-else>
- <picker mode="selector" :range="item.pickerSizeList[String(btem.sex)]"
- @change="toChangeSize($event, btem, item)">
- <view class="select">
- <view class="value">{{ btem.size === '' ? '尺码' : btem.size }}</view>
- </view>
- </picker>
- </template>
- <view class="countBox">
- <count2 :countNum.sync="btem.num" />
- </view>
- <view class="addIcon" :class="bi ? 'delete' : ''" @click="toAddSku(item, bi)" />
- </view>
- </view>
- <view class="dataAll">
- <view class="sex">
- 男款:{{ item.skuList.filter(v => Number(v.sex)).reduce((a, b) => a + Number(b.num), 0) }}{{ item.unitName }}
- /
- 女款:{{ item.skuList.filter(v => !Number(v.sex)).reduce((a, b) => a + Number(b.num), 0) }}{{ item.unitName }}
- </view>
- <view class="num">
- <text>共计:</text>
- <text class="spec">
- {{ item.skuList.reduce((a, b) => a + Number(b.num), 0) }}{{ item.unitName }}
- </text>
- </view>
- </view>
- <view class="dataAll" style="margin-top: 20rpx;">
- <view class="unit" v-if="item.unitNum > 1">
- 1{{ item.unitName }} = {{ item.unitNum }}套
- </view>
- <view class="num">
- <text>合计:</text>
- <text class="spec">
- {{ item.skuList.reduce((a, b) => a + Number(b.num), 0) * item.unitNum }}套
- </text>
- </view>
- </view>
- </view>
- </view>
- <view class="reviseFooter">
- <view class="footer-right">
- <text class="text2">共计:</text>
- <text class="text3">
- {{ list.reduce((a, b) => a + (b.skuList.reduce((x,y) => x + Number(y.num), 0)), 0) }}
- </text>
- <text class="text4">件</text>
- </view>
- <view class="footer-right" style="margin-right: 0;">
- <text class="text2">合计:</text>
- <text class="text3">
- {{ list.reduce((a, b) => a + (b.skuList.reduce((x,y) => x + Number(y.num) * b.unitNum, 0)), 0) }}
- </text>
- <text class="text4">套</text>
- </view>
- <view class="footer-btn" @click="$noMultipleClicks(toSubmitRuku)">确认入库</view>
- </view>
- </view>
- </template>
- <script>
- const skuAllList = [{
- size: 'L',
- sex: 1,
- num: 0,
- type: ['hard']
- },
- {
- size: 'XL',
- sex: 1,
- num: 0,
- type: ['hard', 'simple', 'old', 'new_old', 'youth']
- },
- {
- size: '2XL',
- sex: 1,
- num: 0,
- type: ['hard', 'simple', 'old', 'new_old', 'youth']
- },
- {
- size: '3XL',
- sex: 1,
- num: 0,
- type: ['hard', 'simple', 'old', 'new_old', 'youth']
- },
- {
- size: '4XL',
- sex: 1,
- num: 0,
- type: ['hard']
- },
- {
- size: '5XL',
- sex: 1,
- num: 0,
- type: ['hard']
- },
- {
- size: 'M',
- sex: 0,
- num: 0,
- type: ['hard', 'simple', 'youth']
- },
- {
- size: 'L',
- sex: 0,
- num: 0,
- type: ['hard', 'simple', 'old', 'new_old', 'youth']
- },
- {
- size: 'XL',
- sex: 0,
- num: 0,
- type: ['hard', 'simple', 'old', 'new_old', 'youth']
- },
- {
- size: '2XL',
- sex: 0,
- num: 0,
- type: ['hard', 'simple', 'old', 'new_old', 'youth']
- },
- {
- size: '3XL',
- sex: 0,
- num: 0,
- type: ['hard', 'old']
- },
- {
- size: '4XL',
- sex: 0,
- num: 0,
- type: ['hard']
- }
- ]
- import Count2 from "./components/count2.vue"
- import {
- stockGoods,
- publishRuKuNew
- } from "@/apis/stock.js"
- export default {
- components: {
- Count2
- },
- data() {
- return {
- sexList: [{
- name: '男款',
- value: 1
- },
- {
- name: '女款',
- value: 0
- },
- ],
- list: [],
- noClick: true,
- }
- },
- onShow() {
- this.getStockGoods()
- },
- methods: {
- selectSizeTip() { // 尺码选择提醒
- uni.showModal({
- content: "请先选择款式",
- showCancel: false
- })
- },
- toSubmitRuku() { // 入库
- let arr = {}
- let num = 0,
- errorNum = 0
- this.list.forEach(v => {
- arr[v.k] = v.skuList
- errorNum += v.skuList.filter(item => (item.sex === '' || item.size === '') && item.num > 0)
- .length
- num += v.skuList.reduce((a, b) => a + Number(b.num), 0)
- })
- if (num === 0) {
- uni.showModal({
- content: '入库最少为1件',
- showCancel: false
- })
- return false
- }
- if (errorNum > 0) {
- uni.showModal({
- content: '请选择款式和尺码',
- showCancel: false
- })
- return false
- }
- let copy_arr = JSON.parse(JSON.stringify(arr))
- Object.keys(copy_arr).forEach(k => {
- copy_arr[k].forEach((item, i) => {
- if (i < copy_arr[k].length - 1) {
- if (item.size === copy_arr[k][i + 1].size && item.sex === copy_arr[k][i + 1]
- .sex) {
- item.num += copy_arr[k][i + 1].num
- copy_arr[k][i + 1].num = 0
- }
- }
- })
- copy_arr[k] = copy_arr[k].filter(item => Number(item.num) > 0)
- })
- uni.showLoading()
- publishRuKuNew({
- put_type: 0,
- data: copy_arr
- }).then(res => {
- uni.hideLoading()
- if (res.code === 200) {
- uni.showModal({
- content: "入库成功",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- uni.reLaunch({
- url: '../stock/stock'
- })
- }
- }
- })
- } else {
- uni.showModal({
- content: typeof res.message === "string" ? res.message : "入库失败",
- showCancel: false
- })
- }
- }).catch(() => {
- uni.hideLoading()
- uni.showModal({
- content: "入库失败",
- showCancel: false
- })
- })
- },
- toAddSku(parent, i) { // 添加尺码
- if (i) {
- parent.skuList.splice(i, 1)
- } else {
- parent.skuList.push({
- sex: '',
- size: '',
- num: 0
- })
- }
- },
- // 尺码选择
- toChangeSize(e, data, parent) {
- let i = e.detail.value
- data.size = parent.pickerSizeList[String(data.sex)][i]
- },
- // 男女款选择
- toChangeSex(e, data, parent) {
- let i = e.detail.value
- data.sex = this.sexList[i].value
- data.size = ''
- },
- // 获取图片
- getStockGoods() {
- const unitMap = new Map([
- ['hard', {
- name: '套',
- num: 1
- }],
- ['simple', {
- name: '件',
- num: 4
- }],
- ['old', {
- name: '件',
- num: 4
- }],
- ['new_old', {
- name: '件',
- num: 6
- }],
- ['youth', {
- name: '件',
- num: 4
- }]
- ])
- const _this = this
- stockGoods().then(res => {
- if (res.code === 200) {
- _this.list = Object.keys(res.data).map(k => ({
- k: k,
- imgurl: res.data[k].imgurl,
- name: res.data[k].name,
- unitName: unitMap.get(k).name,
- unitNum: unitMap.get(k).num,
- pickerSizeList: {
- '0': skuAllList.filter(stem => stem.type.includes(k) && Number(stem
- .sex) === 0).map(xtem => xtem.size),
- '1': skuAllList.filter(stem => stem.type.includes(k) && Number(stem
- .sex) === 1).map(xtem => xtem.size)
- },
- skuList: [{
- sex: '',
- size: '',
- num: 0,
- }]
- }))
- }
- })
- },
- toUrlLink(url) {
- if (!url) return false
- uni.navigateTo({
- url: `../${url}`
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- display: flex;
- flex-direction: column;
- }
- .ChuKuContainer {
- width: 100%;
- flex: 1;
- background-color: #F9F9FB;
- .btn {
- width: 140rpx;
- height: 56rpx;
- border-radius: 8rpx;
- background-color: #EA4A41;
- color: #FFFFFF;
- font-size: 28rpx;
- line-height: 56rpx;
- text-align: center;
- text-align: center;
- }
- .reviseFooter {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- height: 98rpx;
- background-color: #ffffff;
- border-top: 2rpx solid #EEEEEE;
- padding: 0 30rpx;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .footer-right {
- margin-right: auto;
- .text1 {
- color: #999999;
- font-size: 28rpx;
- line-height: 40rpx;
- }
- .text2 {
- color: #333333;
- font-size: 28rpx;
- line-height: 40rpx;
- margin-left: 10rpx;
- }
- .text3 {
- color: #EA4A41;
- font-size: 40rpx;
- line-height: 56rpx;
- }
- .text4 {
- color: #EA4A41;
- font-size: 28rpx;
- line-height: 40rpx;
- }
- }
- .footer-text {
- color: #999999;
- font-size: 28rpx;
- line-height: 40rpx;
- }
- .footer-btn {
- width: 192rpx;
- height: 68rpx;
- border-radius: 68rpx;
- text-align: center;
- line-height: 68rpx;
- background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
- color: #FFFFFF;
- font-size: 28rpx;
- margin-left: 12rpx;
- }
- }
- .all {
- width: 100%;
- height: 116rpx;
- padding: 0 30rpx;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .num {
- color: #333333;
- font-size: 36rpx;
- line-height: 50rpx;
- font-weight: bold;
- .spec {
- color: #EA4A41 !important;
- }
- }
- }
- .goodList {
- width: 100%;
- padding-bottom: 100rpx;
- .goodItem {
- width: 100%;
- margin-bottom: 30rpx;
- padding: 30rpx;
- box-sizing: border-box;
- background-color: #ffffff;
- .top {
- width: 100%;
- display: flex;
- align-items: stretch;
- justify-content: space-between;
- margin-bottom: 40rpx;
- .avatar {
- width: 180rpx;
- height: 144rpx;
- background-color: #eeeeee;
- background-position: center;
- background-size: cover;
- background-repeat: no-repeat;
- border-radius: 8rpx;
- }
- .info {
- display: flex;
- justify-content: center;
- flex-direction: column;
- flex: 1;
- overflow: hidden;
- margin-left: 20rpx;
- .name {
- .text {
- color: #333333;
- font-size: 32rpx;
- line-height: 44rpx;
- font-weight: bold;
- &.spec {
- color: #3394F8 !important;
- }
- }
- margin-bottom: 20rpx;
- }
- .fixed {
- color: #F76454;
- font-size: 28rpx;
- height: 40rpx;
- line-height: 40rpx;
- border: 1px solid #F76454;
- box-sizing: border-box;
- width: 328rpx;
- border-radius: 40rpx;
- color: #F76454;
- text-align: center;
- }
- }
- }
- .goodsAll {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 30rpx;
- padding-bottom: 36rpx;
- border-bottom: 1px solid #EEEEEE;
- .sex {
- color: #333333;
- font-size: 28rpx;
- line-height: 40rpx;
- }
- .num {
- color: #999999;
- font-size: 28rpx;
- .spec {
- color: #EA4A41 !important;
- font-size: 40rpx !important;
- font-weight: bold;
- }
- }
- }
- .skuList {
- width: 100%;
- border-top: 1px solid #EEEEEE;
- padding: 30rpx 0;
- .skuItem {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 30rpx;
- &:nth-last-of-type(1) {
- margin-bottom: 0;
- }
- .select {
- height: 72rpx;
- width: 156rpx;
- padding: 20rpx;
- box-sizing: 0 border-box;
- border-radius: 8rpx;
- background-color: #F5F5F5;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .value {
- color: #333333;
- font-size: 32rpx;
- line-height: 44rpx;
- text-align: center;
- flex: 1;
- overflow: hidden;
- }
- &::after {
- content: "";
- display: block;
- width: 30rpx;
- height: 30rpx;
- background-image: url(../../static/new_my/arrow.png);
- background-position: center;
- background-size: cover;
- background-repeat: no-repeat;
- margin-left: 10rpx;
- transform: rotate(90deg);
- }
- }
- .countBox {
- width: 192rpx;
- }
- .addIcon {
- width: 40rpx;
- height: 40rpx;
- background-image: url(../../static/new_stock/add.png);
- background-repeat: no-repeat;
- background-size: 100%;
- background-position: center;
- &.delete {
- background-image: url(../../static/new_stock/delete.png) !important;
- }
- }
- }
- }
- .dataAll {
- width: 100%;
- display: flex;
- align-items: baseline;
- justify-content: flex-end;
- .sex {
- color: #333333;
- font-size: 28rpx;
- margin-right: 30rpx;
- }
- .unit {
- color: #3394F8;
- font-size: 32rpx;
- margin-right: 30rpx;
- font-weight: bold;
- }
- .num {
- color: #999999;
- font-size: 28rpx;
- .spec {
- color: #EA4A41 !important;
- font-size: 40rpx !important;
- font-weight: bolder;
- }
- }
- }
- }
- }
- }
- </style>
|