<template>
  <el-dialog :title="addTitle" :visible.sync="dialogVisible" width="350px" :close-on-click-modal="false" lock-scroll  append-to-body>
    <el-form  ref="addFrom" label-position="left" label-width="70px"  :model="addform" class="order-add-form" size="small">
      <el-form-item label="审核模板">
        <el-select v-model="addform.auditTemplateId" placeholder="请选择审核模板">
          <el-option v-for="item in templateList" :key="item.id" :label="item.templateName" :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="addform-sub">
        <el-button @click="dialogVisible = false;addform.auditTemplateId = '';">关闭</el-button>
        <el-button type="primary" @click="addClick">提交</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import {post} from "@/api/common";
export default {
  props:['addTitle'],
  name: "addBox",
  data(){
    return{
      dialogVisible:true,
      templateList:[],
      addform:{
        auditTemplateId:'',
      }
    }
  },
  methods:{
    // 获取审核模板
    getTemplate (id) {
      this.dialogVisible = true
      post('/auditTemplate/page', { pageNum: 1, pageSize: 9999 }).then(res => {
        this.templateList = res.data.records
        this.$nextTick(()=>{
          if (id) this.addform.auditTemplateId = id
        })
      })
    },
    addClick(){
      if (this.addform.auditTemplateId){
        this.$emit('setFlow',this.addform)
      }else {
        this.$message.warning('请选择审核模板');
        return false;
      }
    },
  }
}
</script>

<style lang="scss" scoped>
.order-add-form{
  display: flex;
  flex-wrap: wrap;
  .addform-sub{
    width: 100%;
    text-align: center;
    ::v-deep .el-form-item__content{
      margin-left: 0 !important;
    }
    .el-button+.el-button{
      margin-left: 100px;
    }
  }
}
</style>
