<template>
  <el-dialog title="单品改价" width="410px" v-model="show" @close="reset" :modal="modal">
    <div class="u-m-t-30 u-flex">
      <div class="no-wrap u-m-r-20">价格更改为</div>
      <el-input-number
        :min="min"
        :max="max"
        placeholder="请输入更改后的价格"
        v-model="price"
        @blur="checkPrice"
        type="number"
      ></el-input-number>
      <span class="u-m-l-10 u-font-14">元</span>
    </div>
    <div class="u-m-t-16">
      <span class="color-red">*</span>
      <span>当前单品单价：{{ originPrice }}元</span>
    </div>

    <template #footer>
      <div>
        <el-button size="medium" @click="close">取消</el-button>
        <el-button size="medium" type="primary" @click="confirm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>
    <script>
import { ElMessage } from "element-plus";
export default {
  props: {
    modal: {
      type: Boolean,
      default: true,
    },
    useVipPrice: {
      type: Boolean,
      default: false,
    },
    vipUser: {
      type: Object,
      default: () => {
        return {
          isVip: false,
        };
      },
    },
  },
  data() {
    return {
      max: 0,
      min: 0,
      originPrice: "",
      price: "",
      show: false,
      goods: {
        productId: -999,
      },
    };
  },
  computed: {
    isSeatFee() {
      return returnIsSeatFee(this.goods);
    },
  },
  methods: {
    checkPrice() {
      if (this.price < 0) {
        this.price = 0;
      }
    },
    changeSel(item) {
      item.checked = !item.checked;
    },
    reset() {
      this.price = "";
    },
    open(item) {
      console.log(item);
      const memberPrice = item.memberPrice || item.salePrice;
      this.max = this.useVipPrice ? memberPrice : item.salePrice;
      this.show = true;
      const price =
        item.discount_sale_amount * 1 || (this.useVipPrice ? memberPrice : item.salePrice);
      this.price = price;
      this.originPrice = price;
    },
    close() {
      this.show = false;
      this.price = "";
      this.originPrice = "";
    },
    async confirm() {
      if (this.price < 0) {
        return ElMessage.error("价格不能小于0");
      }
      this.$emit("confirm", this.price);
      this.close();
      // this.$emit("confirm", { note: note, num: this.number });
    },
  },
  mounted() {},
};
</script>
    
    <style lang="scss" scoped>
:deep(.el-dialog__body) {
  margin-bottom: 14px;
  margin-top: 14px;
  padding: 0 20px;
}
:deep(.el-tag) {
  margin-top: 10px;
  margin-right: 10px;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 15px;
  line-height: 35px;
  height: 35px;
}
.tags {
  .tag {
    margin: 10px 10px 0 0;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 10px 13px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    &.active {
      color: #1890ff;
      background: #e8f4ff;
      border-color: #a3d3ff;
    }
  }
}
:deep(.el-dialog__body) {
  color: #333;
}
:deep(input::-webkit-outer-spin-button) {
  -webkit-appearance: none !important;
}
:deep(input::-webkit-inner-spin-button) {
  -webkit-appearance: none !important;
}
</style>