<template>
  <modal :show.sync="modalShow" backdrop="false" width="50%" title="提示信息">
    <article slot="modal-body">
      <div style="width:98%;margin: auto" v-show="showInformation">
        <p>{{ warninginfo.data.msgData }}</p>
        <div style="font-size: 15px;padding: 10px">
          <span style="float: right">
            <button class="button_search" v-show="!warninginfo.data.state.info" @click="operational('files_complete')"
                    style="width: max-content;">完善信息</button>
            <button class="button_search" v-show="warninginfo.data.state.blacklist&&!warninginfo.data.state.dibao"
                    @click="operational('basic-living')" style="width: max-content;">低保续保</button>
            <button class="button_search"
                    v-show="warninginfo.data.state.blacklist&&!warninginfo.data.state.dibao && warninginfo.data.state.dibaoend"
                    @click="operational('stop-basic-living')" style="width: max-content;">停止续保</button>
            <button class="button_search"
                    v-show="!(!warninginfo.data.state.dibao&&warninginfo.data.state.dibaoend) && warninginfo.data.canCharge"
                    @click="success()">确认</button>
          </span>
        </div>
        <p>{{ authorityInformation }}</p>
      </div>
      <div style="width:98%;margin: auto" v-show="!showInformation">
        <route v-ref:route @close="close" @success="success" v-show="!showInformation" :data="row"></route>
      </div>
    </article>
    <footer slot="modal-footer" class="modal-footer" style="text-align: center;border: 0">
      <!--如果想忽略到期信息，modal的值设为null-->
      <!--      <button class="button_clear" @click="ignore" v-if="basicLiving">忽略</button>-->
    </footer>
  </modal>
</template>
<script>
let initGen = async function (self) {
  if (self.warninginfo) {
    if (!self.warninginfo.data.state.info && !self.warninginfo.data.state.blacklist && !self.warninginfo.data.state.dibao) {
      self.authorityInformation = '您没有相关的业务操作权限, 请联系管理员！！'
    }
  }
}

export default {
  title: '收费弹出框',
  props: {
    // 动态属性表数据
    warninginfo: {
      type: Object
    },
    // 双击用户的数据
    row: {
      type: Object
    },
    modalShow: {
      type: Boolean
    }
  },
  data () {
    return {
      showInformation: true,
      informationtype: '',

      // 终止低保户 必选低保户到期
      stopBasicLiving: false,

      // 低保户到期提醒时间
      dibao_remind: this.$appdata.getSingleValue('低保快到期提醒') ? this.$appdata.getSingleValue('低保快到期提醒') : 0,
      // 低保户权限
      basicLivingAuthority: false,
      // 档案完善权限
      filesCompleteAuthority: true
    }
  },
  methods: {
    close () {
      this.$emit('close')
    },
    async success (val) {
      // 如果所有提示信息均处理，获取改户数据，进入收费操作
      if (!this.warninginfo.data.info && !this.warninginfo.data.blacklist && !this.warninginfo.data.dibao) {
        this.showInformation = false
        let data = await this.$resetpost('rs/sql/sale_getUser', {data: {condition: `1=1 and f_userinfo_code = '${this.row.f_userinfo_code}' and u.f_filialeid = '${this.row.f_filialeid}' `}}, {
          resolveMsg: '',
          rejectMsg: ''
        })
        this.$emit('modalsuccess', data.data[0])
      } else { // 没有处理完，显示提示信息
        this.showInformation = true
      }
    },
    operational (val) {
      this.showInformation = false
      this.$refs.route.init(val, {data: this.row})
    }
  },
  ready () {
    initGen(this)
  }
  // watch: {
  //   'modalShow' (val) {
  //     this.modal = val
  //   }
  // }
}
</script>
<style>
.basic-main {
  width: 79%;
}
</style>
