<template>
        <div class="dialog-content dialog-office-batch">
            <div class="p-16">
                <div class="flex-row align-items-center justify-content-between mb-16 case-batch-num">
                    <span>系统将对当前案件进行电子短信送达！</span>
                </div>
                <el-collapse-transition>
                    <el-row :gutter="56">
                        <el-col :span="24">
                            <div class="flex-row-center align-items-center height-40 mb-8">
                                <span class="tabs__search-criteria-title flex-shrink-0 pr-16 f18">选择文书类型（多选）</span>
                            </div>
                        </el-col>
                        <el-col :span="24">
                            <div class="mb-24 officelist">
                                <el-checkbox-group v-model="ObjectInfo.documentTypes">
                                    <el-checkbox border v-for="(item,index) in officeOptions" :label="item.type" :key="index" :disabled="(item.documentStaus.code == 2 && item.signStatus != null && item.signStatus.code == 3) ? false : true">{{ item.documentType.desc }}</el-checkbox>
                                </el-checkbox-group>
                            </div>
                        </el-col>
                    </el-row>
                </el-collapse-transition>
            </div>
            <span class="dialog-footer">
                <el-button size="small" @click="handleClose()">取消</el-button>
                <el-button size="small" type="primary" @click="handleSubmit()">发起送达</el-button>
            </span>
        </div>
</template>
<script>
import api from "@/services/caseManagement";
    export default {
        components: {
        },
        props: {
            caseId: {
                type: String,
                default: () => {},
            },
        },
        data() {
            return {
                officeOptions:[],
                ObjectInfo:{
                    // documentTypes: ['MEDIATE_NOTE', 'MEDIATE_APPLICATION', 'MEDIATE_RECORD', 'MEDIATE_AGREEMENT',
                    // 'JUDICATURE_APPLICATION', 'JUDICATURE_PROMISE' , 'CONFIRMATION_OF_ADDRESS', 'VERIFY_IDD'],
                    documentTypes:[],
                    servedType: 'SMS',
                    caseId:''
                },
            };
        },
        mounted () {
            this.getWritCaseList()
        },
        methods: {
            // 列表数据
            getWritCaseList() {
                let dataJson = {
                    id: this.caseId
                }
                api.getCaseGenerateList(dataJson).then(res => {
                    if (!res.code) {
                        this.officeOptions = res
                        this.officeOptions = this.officeOptions.filter(item=>{return item.type != 'VERIFY_IDD'})
                    }
                })
            },
            handleSubmit(){
                if(!this.$clickThrottle()) { return }//防止重复点击
                if (this.ObjectInfo.documentTypes.length == 0){
                    this.$message.warning("请选择文书类型！");
                    return
                }
                this.ObjectInfo.caseId = this.caseId
                api.traceServedCreate(this.ObjectInfo).then((res) => {
                    this.$message.success("发起文书电子送达成功");
                    this.handleClose()
                    this.$parent.getWritCaseList()
                });
            },

            handleClose() {
                this.$emit('update:singledeliveryvisible', false)
            },
        }
    };
</script>

<style scoped lang="scss">
.dialog-office-batch {
  width: 495px;
  max-height: 500px;

  .tabs__search-criteria-title {
    width: 100%;
  }

  .case-batch-num {
    background-color: rgba(236, 238, 241, 0.8196078431);
    padding: 15px 20px;
    border-radius: 4px;

    a {
      font-size: 16px;
      font-weight: 500;
      color: #C66A5B;
    }
  }

  .officelist {
    background-color: rgba(236, 238, 241, 0.8196078431);
    padding: 20px 20px;

    .el-checkbox {
      width: 180px;
      margin: 10px;
    }
  }
  .dialog-footer{
    display: inline-block;
    width: 500px;
    text-align: right;
    border-top: solid 1px #E5E6EB;
    padding: 10px;
  }
}
</style>