<template>
     <a-modal title="无效名单" :visible="childShow" @ok="invalidOk " @cancel="invalidCancel"
      :width=500 :body-style="{width:200}">
      <a-row>
        <a-col span="4">无效原因:</a-col>
        <a-col span="20">
        <a-radio-group @change="handleinvalidChange" v-model:value = "invalidParam.invalidReason">
          <a-radio v-for="(item, key) in invalidOptions" :key="key" :value="item.value">{{item.text}}</a-radio>
        </a-radio-group></a-col>
      </a-row>
    </a-modal>
</template>
<script>

import { postAction } from '@/api/manage'
import {ajaxGetDictItems} from '@/api/api'
export default {
    name: 'CustomerBusinessInvalid',
    data() {
        return {
            invalidParam: {
                invalidReason: "1"
            },
            invalidOptions: [],
        }
    },
    props: ['childShow', 'para'],
    watch: {
        immediate: true,
        childShow: {
            handler() {
                this.invalidParam = this.para;
                ajaxGetDictItems('customer_invalid_reason', null).then((res) => {
                    if (res.success) {
                    this.invalidOptions = res.result;
                    }
                });
                
            },
        }
    },
    methods: {
        invalidOk() {
        this.invalidParam.status = 5;
        postAction("/customer/customerBusiness/edit", this.invalidParam).then((res) => {
          if(res.success) {
            this.$message.success('编辑成功');
            this.invalidVisiable = false;
            this.$emit('childReturn',false);
          }
        });
      },
      invalidCancel(){
        this.$emit('childReturn',false);
      },
      handleinvalidChange(record) {
        this.invalidParam.invalidReason = record.target.value;
      },

    }
}
</script>
  