<template>
  <div class="page">
    <el-row :gutter="40">
        <el-col :span="6">
            <el-card shadow="always" @click.native="onOpen">
                <i class="el-icon-document-add"></i>
                <span class="card-text">OA发送</span>
            </el-card>
        </el-col>
    </el-row>
    <dia-add :visible="isVisible" ref="dia" @onSubmit="onSubmit" @cancel="onCancel" />
  </div>
</template>

<script>
  import diaAdd from './components/diaAdd.vue'
  import { oaReceive } from "@/api/preFiling/preArchiveManagement/preFileApp"
  import { message, clearObjValue } from "@/utils/common"

  export default {
      data(){
          return {
            isVisible: false,
          }
      },
      components: {
        diaAdd
      },
      methods: {
          onCancel(){
            this.isVisible = false;
            clearObjValue(this.$refs.dia.form)
          },
          onOpen(){
            this.isVisible = true;
          },
          onSubmit(val){
            this.$refs.dia.loading = true;
            oaReceive(val).then(res=>{
              this.$refs.dia.loading = false;
              if(res.code === '100'){
                message('success', '发送成功', 2000)
                this.onCancel()
              }
            }).catch(() => {
              this.$refs.dia.loading = false;
            })
          }
      }
  }
</script>

<style lang="scss" scoped>
  .page{
      padding: 20px 30px;
      .el-card{
        cursor: pointer;
        .el-icon-document-add{
            font-size: 50px;
            color: #40c9c6;
        }
        .card-text{
            line-height: 50px;
            vertical-align: top;
            color: rgba(0, 0, 0, 0.45);
            font-size: 16px;
            padding-left: 20px;
        }
      }
  }
</style>