<template>
    <div
      class="ResumeReasonDialog"
    >
        <div class="resumeReasonTip">
            {{ externalOptions.massage }}
        </div>
        <div class="useResumeReason">
            <Checkbox v-model="isUseResumeReason">按拦截原因取消拦截</Checkbox>
            <Select multiple chooseAll v-if='isUseResumeReason' v-model="choosedResumneReason" clearable class="input_box resumeReasonSelect" @on-change="checkchoosed">
                <Option v-for="d in externalOptions.INTERCEPTREASONLIST" :value="d.causeId" :key="d.causeId">{{ d.reasonVal }}</Option>
            </Select>
        </div>
        <div class="bottomBtnBox">
            <Button
                size="small"
                class="cancelBtn"
                ghost
                @click="close()"
            >
                取消
            </Button>
            <Button
                type="primary"
                size="small"
                class="sureBtn"
                @click="sureResume"
            >
                确定
            </Button>
        </div>
    </div>
  </template>
  
  
  <script>
    const R3 = window.R3;
  
    const { network } = R3;
    export default {
      props: {
        externalOptions: {
            type: Object,
            default: ()=>{}
        },
      },
      data() {
        return {
            isUseResumeReason: false,
            choosedResumneReason:[],
        };
      },
      created() {
        console.log(12345,this.externalOptions)
      },
      methods: {
        checkchoosed() {
            console.log(this.choosedResumneReason)
        },
        close() {
            // 成功关闭弹框
            this.$parent.close();
        },
        sureResume() {
            if(this.isUseResumeReason && this.choosedResumneReason.length == 0){
                return this.$Message.warning('请选择需要取消的拦截原因！');
            }
            let param = {
                isInterecpReason:this.isUseResumeReason?1:0,
                causeIds: this.choosedResumneReason,
                ids: this.externalOptions.idarray,
            }
            // console.log(param)
            network.post('/p/cs/intercept/reason/cancel', param).then((res)=>{
                if (res.data.code == 0) {
                    // this.$Message.success(res.data.message);
                    this.$Modal.fcWarning({
                        title: '提示',
                        content: res.data.message
                    });

                    this.$emit('closeActionDialog', true);
                    document.querySelector('#refresh').click(); // 标准列表刷新按钮
                } else if (res.data.code == 10) {
                    document.querySelector('#refresh').click(); // 标准列表刷新按钮
                    this.$emit('closeActionDialog', true);
                    let msg = res.data.message;
                    let refresh = this.searchClickData;
                    this.$R3Dialog({
                        dialogComponentName: 'ResumeInterception', // 自定义的弹框组件
                        title: '恢复拦截', // 弹框标题
                        footerHide: true,
                        externalOptions: {
                            massage: msg,
                            refresh
                        }
                    }, () => {});
                }
            })
        }
      }
    };
  </script>
  
  <style scoped lang='less'>
    .ResumeReasonDialog {
        width:400px;
    }
    .resumeReasonTip {
        line-height: 16px;
    }
    .useResumeReason {
        margin-top: 10px;
    }
    .resumeReasonSelect {
        margin-top: 8px;
        width: 350px;
    }
    .bottomBtnBox {
        width: calc(100% - 48px);
        margin: 16px auto 0px;
        text-align: center;
        .cancelBtn,.sureBtn {
        width: 72px;
        height: 32px;
        font-size: 12px;
        }
        .cancelBtn {
        color: #909399;
        border: 1px solid #DADADA;
        margin-right: 8px;
        }
    }
  </style>
  