<template>
  <div>
    <el-dialog title="批量文书送达" :visible="true" width="600px" append-to-body :close-on-click-modal="false"
               @close="handleClose">
      <div class="dialog-content dialog-office-batch">
        <div class="pt-8">
          <div class="flex-row align-items-center justify-content-between mb-16 case-batch-num">
            <span>选中<a>{{ eventTraDialog.caseids.length }}</a>个案件，系统将对您选择的案件进行批量电子短信送达！</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.value"
                                 :key="index">{{item.label}}</el-checkbox>
                  </el-checkbox-group>
                </div>
              </el-col>

            </el-row>
          </el-collapse-transition>
        </div>

      </div>
      <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose()">取消</el-button>
                <el-button type="primary" @click="handleSubmit()">批量送达</el-button>
            </span>
    </el-dialog>
  </div>
</template>
<script>
import caseManagement from "@/services/caseManagement";

export default {
  components: {},
  props: {
    eventTraDialog: {
      type: Object,
      default: () => {
        return {}
      },
    },
  },
  data() {
    return {
      officeOptions: [
        {label: '调解告知书', value: 'MEDIATE_NOTE'},
        {label: '调解申请书', value: 'MEDIATE_APPLICATION'},
        {label: '调解询问笔录', value: 'MEDIATE_RECORD'},
        {label: '调解协议', value: 'MEDIATE_AGREEMENT'},
        // {label: '司法申请书', value: 'JUDICATURE_APPLICATION'},
        // {label: '司法承诺书', value: 'JUDICATURE_PROMISE'},
        {label: '送达地址确认书', value: 'CONFIRMATION_OF_ADDRESS'},
        // {label: '身份识别报告', value: 'VERIFY_IDD'}
      ],
      ObjectInfo: {
        documentTypes: ['MEDIATE_NOTE', 'MEDIATE_APPLICATION', 'MEDIATE_RECORD', 'MEDIATE_AGREEMENT',
          'JUDICATURE_APPLICATION', 'JUDICATURE_PROMISE' , 'CONFIRMATION_OF_ADDRESS', 'VERIFY_IDD'],
        servedType: 'SMS'
      },
    };
  },
  mounted() {

  },
  methods: {
    // smsChange() {
    //   let jsonData = this.smsOptions.find(item => {
    //     return this.ObjectInfo.methodId == item.value
    //   })
    //   this.ObjectInfo.users = jsonData.users
    //   this.ObjectInfo.content = jsonData.content
    // },
    handleSubmit() {
      if (!this.ObjectInfo.documentTypes.length){
        this.$message.warning("请选择文书类型！");
        return
      }
      if(!this.$clickThrottle()) { return }//防止重复点击
      let caseIdList = this.eventTraDialog.caseids;
      caseManagement.traceServedBatchCreate({...this.ObjectInfo, caseIdList: caseIdList}).then(res => {
        this.$parent.getCaseInfoList(this.eventTraDialog.current)
        this.handleClose()
        this.$message.success("发送成功");
      })
    },
    handleClose() {
      this.$emit('update:eventTraDialog', null)
    },
  }
};
</script>

<style scoped lang="scss">
.dialog-office-batch {
  padding: 16px 30px;
  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: 230px;
      margin: 10px;
    }
  }

}
</style>