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

<script>
import InputUfo from '../../components/input-ufo';
import Modal from '../../components/modal.vue';


export default {
  name: 'ModalPrice',
  data() {
    return {
      visiable: false,
      unStockNum: 1,
      storageNum: 1,
    };
  },
  methods: {
    show({storageNum}) {
      this.storageNum = storageNum;
      this.visiable = true;
    },
    hide() {
      this.storageNum = 1;
      this.visiable = false;
    },
    onSure() {
      this.$emit('on-no-sale', this.unStockNum);
    },
    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, InputUfo}
};
</script>

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

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

  .inp-unstock {
    margin-bottom: 10px;

    /deep/ .iconfont {
      padding: 34px 40px;
      width: 112px;
      font-size: 32px;
      color: #999;
      font-weight: bold;
    }

    /deep/ .cube-input-field {
      text-align: center;
    }
  }

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