approvalPopup.vue 3.1 KB
<template>
  <van-popup round v-model="visible" position="bottom" :style="{ height: '68%' }" class="popup" :close-on-click-overlay="false" @close="onClose">
    <div class="title">{{ infoData.title }}</div>
    <div class="content">
      <div class="container">
        <div class="label">
          {{ infoData.label }}
          <span v-if="infoData.type == 2 && rejectRemarkRequired" class="required-label">*</span>
        </div>
        <div class="textarea-wrap">
          <van-field v-model="remark" type="textarea" placeholder="请输入" maxlength="200" rows="8" :autosize="{ maxHeight: 220 }" show-word-limit class="textarea-input" />
        </div>
        <div v-if="infoData.type == 1" class="tips">审核通过后将自动流转至线上运营审核</div>
      </div>
    </div>
    <div class="btn-group">
      <div class="btn cancel" @click="onCancel">取消</div>
      <div class="btn confirm" @click="onConfirm">确定</div>
    </div>
  </van-popup>
</template>

<script>
import { Toast } from 'vant'

export default {
  name: 'ApprovalPopup',
  props: {
    infoData: {
      type: Object,
      default: () => ({})
    },
    show: {
      type: Boolean,
      default: false
    },
    rejectRemarkRequired: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      remark: ''
    }
  },
  computed: {
    visible: {
      get() {
        return this.show
      },
      set(val) {
        if (!val) {
          this.$emit('cancel')
        }
      }
    }
  },
  watch: {
    show(val) {
      if (val) {
        this.remark = ''
      }
    }
  },
  methods: {
    onConfirm() {
      if (this.rejectRemarkRequired && this.infoData.type == 2 && !this.remark) {
        Toast('请输入驳回备注')
        return
      }
      this.$emit('confirm', this.remark)
    },
    onCancel() {
      this.$emit('cancel')
    },
    onClose() {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped lang="scss">
.popup {
  .title {
    height: 55px;
    line-height: 55px;
    color: #333333;
    font-size: 16px;
    text-align: center;
    border-bottom: 1px solid #eff0f2;
  }
  .content {
    height: calc(100% - 111px);
    overflow-y: auto;
  }
  .container {
    padding: 0 16px;
    .label {
      margin: 16px 0 8px;
      font-size: 14px;
      color: #222222;
      .required-label {
        color: #f24724;
      }
    }
    .textarea-wrap {
      .textarea-input {
        background: #f4f5f7;
        border-radius: 14px;
        padding: 4px 0;
        ::v-deep .van-field__control {
          padding: 12px;
        }
      }
    }
    .tips {
      color: #999999;
      font-size: 13px;
      margin: 8px 0;
    }
  }
  .btn-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 16px;
    .btn {
      flex: 1;
      border-radius: 6px;
      height: 41px;
      line-height: 41px;
      font-size: 16px;
      text-align: center;
    }
    .cancel {
      border: 1px solid #dee0e3;
      background: #f4f5f7;
      color: #292d33;
    }
    .confirm {
      background: #347bff;
      color: #ffffff;
      margin-left: 11px;
    }
  }
}
</style>