| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
- <view class="edit-price rd-t-40rpx" v-if="goodsInfo.attr_value">
- <view class="title">{{goodsInfo.spec_type?'批量修改库存':'修改库存'}}
- <view class="close acea-row row-center-wrapper" @tap="closeDrawer">
- <text class="iconfont icon-ic_close"></text>
- </view>
- </view>
- <view class="list">
- <view class="item acea-row row-between-wrapper" v-if="!goodsInfo.spec_type">
- <view>剩余库存</view>
- <view class="stock">{{goodsInfo.attr_value.stock}}</view>
- </view>
- <view class="item acea-row row-between-wrapper pr-20">
- <view>修改库存</view>
- <view class="acea-row row-middle">
- <view class="itemn acea-row row-middle" :class="current == index?'on':''" v-for="(item, index) in navList" :key="index" @click="navTap(index)">
- <text class="iconfont" :class="current == index?'icon-ic_Selected':'icon-ic_unselect'"></text>
- <text>{{item}}</text>
- </view>
- </view>
- </view>
- <view class="item acea-row row-between-wrapper">
- <view>库存</view>
- <input type="number" placeholder="请填写库存" placeholder-class="placeholder" v-model="currentStock" @input="stockTap"/>
- </view>
- </view>
- <view v-if="goodsInfo.spec_type" class="bnt acea-row row-center-wrapper" @tap="defineSpec">确定</view>
- <view v-else class="bnt acea-row row-center-wrapper" @tap="define">保存</view>
- </view>
- </base-drawer>
- </template>
- <script>
- import {
- postStoreUpdateAttrs
- } from "@/api/admin";
- export default {
- props:{
- visible: {
- type: Boolean,
- default: false,
- },
- goodsInfo: {
- type: Object,
- default: () => {}
- }
- },
- data: function() {
- return {
- navList:['入库','出库'],
- current:0,
- currentStock:0
- };
- },
- mounted() {
- },
- methods:{
- navTap(index){
- this.current = index
- },
- stockTap(e){
- this.currentStock = parseInt(e.detail.value);
- },
- defineSpec(){
- if(this.currentStock<=0){
- this.$util.Tips({
- title: '请填写库存'
- });
- return
- }
- let data = {
- currentStock:this.currentStock,
- current: this.current
- }
- this.$emit('successChange',data);
- },
- define(){
- if(this.currentStock<=0){
- this.$util.Tips({
- title: '请填写库存'
- });
- return
- }
- let data = {
- attr_value:[]
- }
- let obj = {
- product_id:this.goodsInfo.attr_value.product_id,
- unique:this.goodsInfo.attr_value.unique,
- stock: this.current? parseInt(this.goodsInfo.attr_value.stock)-this.currentStock : this.currentStock + parseInt(this.goodsInfo.attr_value.stock)
- }
- data.type = 'stock';
- data.attr_value.push(obj)
- postStoreUpdateAttrs(this.goodsInfo.id,data).then(res=>{
- this.$util.Tips({
- title: res.msg
- });
- this.current = 0;
- this.currentStock = 0;
- this.$emit('successChange');
- }).catch(err=>{
- this.$util.Tips({
- title: err
- });
- })
- },
- closeDrawer() {
- this.$emit('closeDrawer');
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .edit-price{
- background-color: #fff;
- padding-bottom: 60rpx;
- .title{
- text-align: center;
- height: 108rpx;
- line-height: 108rpx;
- font-size: 32rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 600;
- color: #333333;
- position: relative;
- padding: 0 30rpx;
- .close{
- width: 36rpx;
- height: 36rpx;
- line-height: 36rpx;
- background: #EEEEEE;
- border-radius: 50%;
- position: absolute;
- right: 30rpx;
- top:38rpx;
- .iconfont {
- font-weight: 300;
- font-size: 20rpx;
- }
- }
- }
- .list{
- padding: 0 10rpx 0 30rpx;
- .item{
- font-size: 28rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- color: #333333;
- height: 72rpx;
- margin-bottom: 32rpx;
- box-sizing: border-box;
- .stock{
- color: #999;
- padding-right: 20rpx;
- }
- .itemn{
- margin-left: 50rpx;
- color: #999999;
- .iconfont {
- margin-top: 4rpx;
- color: #CCCCCC;
- margin-right: 14rpx;
- }
- &.on {
- color: #333333;
- .iconfont {
- color: #2A7EFB;
- }
- }
- }
- input {
- text-align: right;
- font-size: 28rpx;
- height: 100%;
- padding-right: 20rpx;
- }
- .placeholder{
- font-size: 28rpx;
- padding-right: 20rpx;
- }
- }
- }
- .bnt{
- font-size: 26rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- width: 710rpx;
- height: 72rpx;
- background: #2A7EFB;
- border-radius: 50rpx;
- margin: 72rpx auto 0 auto;
- }
- }
- </style>
|