modal-unstock.vue 2.08 KB
<template>
  <Modal class="ufo-font" :value="visiable" @input="onInput" ref="modal" :transfer="true" @on-sure="onSure" @on-cancel="onCancel">
    <div class="change-price-modal">
      <p class="modal-title">选择你要下架的数量</p>
      <Inputx v-model="unStockNum" :maxlength="8" :readonly="true" class="input-number">
        <i slot="prefix" class="iconfont icon-plus-minus" @touchend="onChangeNum(-1)"></i>
        <i slot="suffix" class="iconfont icon-i-add" @touchend="onChangeNum(1)"></i>
      </Inputx>
      <p class="stock-txt">
        目前还有 {{storageNum}} 个库存
      </p>
      <p class="tips">
        下架商品的保证金将会被释放
      </p>
    </div>
  </Modal>
</template>

<script>
import Inputx from '../../components/inputx.vue';
import Modal from '../../components/modal.vue';


export default {
  name: 'ModalPrice',
  data() {
    return {
      visiable: false,
      unStockNum: 1,
      storageNum: 6,
    };
  },
  methods: {
    show({storageNum}) {
      this.storageNum = storageNum;
      this.visiable = true;
    },
    onSure() {
      this.$emit('on-sure', this.unStockNum);
      this.visiable = false;
    },
    onCancel() {
      this.visiable = false;
    },
    onInput(val) {
      this.$emit('input', val);
    },
    onChangeNum(num) {
      const value = this.unStockNum + num;

      if (value <= 0 || value > this.storageNum) {
        return;
      }
      this.unStockNum = value;
    }
  },
  components: {Modal, Inputx}
};
</script>

<style lang="scss" scoped>
.change-price-modal {
  .stock-txt {
    margin-bottom: 10px;
  }

  .tips {
    margin-bottom: 10px;
    color: #999;
  }

  .input-number {
    margin-bottom: 10px;

    /deep/ .input-prefix,
    /deep/ .input-suffix {
      padding: 34px 40px;
      width: 112px;

      .iconfont {
        font-size: 32px;
        color: #999;
        font-weight: bold;
      }
    }

    /deep/ .input {
      font-weight: bold;
      padding-left: 112px;
      padding-right: 112px;
      text-align: center;
    }
  }

  .modal-title {
    line-height: 100px;
    text-align: center;
  }
}
</style>