<script src="../../../api/activiti/process/processtype.js"></script>
<template>
  <div class="box">
    <el-row>
      <el-button size="medium" type="primary" icon="el-icon-setting">设置常用流程</el-button>
    </el-row>
    <el-container v-for="actCategroy in acttype">
      <el-header>
        <!--流程类别-->
        {{actCategroy.categoryName}}
      </el-header>
      <el-row class="borx">
        <el-col class="aplr" v-for="actItem in actCategroy.actLists">
          <div class="dad">
            <!--流程名称-->
            <el-button type="text" @click="openactform(actItem.activitiKey)">{{actItem.activitiName}}</el-button>
          </div>
        </el-col>
      </el-row>
    </el-container>
    <el-dialog id="actform" title="流程起草" :visible.sync="actOpen" :before-close="cancel" append-to-body width="80%"
               top="10" height="90%">
      <!-- 动态引入组件-->
      <component :is="actForm" :data="detail" @transferUser="getUser"></component>

      <!--        <span slot="footer" class="dialog-footer">-->
      <!--    <el-button @click="actOpen = false">取 消</el-button>-->
      <!--    <el-button type="primary" @click="actOpen = false">确 定</el-button>-->
      <!--  </span>-->
    </el-dialog>
  </div>
</template>

<script>
  import { listCategoryGroup, getStartFormKey } from '@/api/activiti/process/startprocess'

  export default {
    name: 'ActToDraft',
    components: {},
    computed: {},
    data() {
      return {
        detail:{getactkey: '',
          formId:'',
        },
        // 遮罩层
        loading: true,
        // 是否显示弹出层
        actOpen: false,
        dialogVisible: false,
        title: '',
        acttype: [],
        dialogFormVisible: false,
        actopen: false,
        actForm: null,
        path: ''
      }
    },
    created() {
      this.getActList()//获取流程分类
      // this.openactform(actkey);
      //   this.openactform(actkey);
    },
    methods: {
      getUser(msg) {
        this.actOpen = msg
      },

      //通过流程key查询启动的表单fromkey
      openactform(actkey) {

        let vue = this
        this.detail.getactkey = actkey//动态传参到下面的页面
        getStartFormKey(actkey).then(response => {
          var path = response.msg
          this.actForm = () => Promise.resolve().then(() => require(`@/views/${path}`))
        })

        this.actOpen = true
        return vue.actForm = this.actForm
      },

      //返回流程分类
      getActList() {
        listCategoryGroup().then(response => {
          this.acttype = response.rows
          this.loading = false
        })
      },
      cancel() {
        this.actOpen = false
      }
    }
  }
</script>

<style scoped>
  .box {
    padding: 20px;
    margin: 12px;
    background: #fff;
  }

  .el-container {
    border-radius: 10px;
    margin-top: 20px;
  }

  .el-header {
    border-radius: 3px 3px 0 0;
    background: #eaeaea;
    height: 80px;
    line-height: 60px;
    font-size: 18px;
  }

  .borx {
    min-height: 75px;
    border: 1px solid #eaeaea;

  }

  .aplr {
    width: 20%;
    height: 75px;
    border-right: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
  }

  .aplr:hover {
    border: 0;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    transition: all .3s;

  }

  .dad {
    line-height: 80px;
    text-align: center;
  }

  .dad .el-button {
    font-size: 16px;
    color: rgba(0, 0, 0, .65);
  }

  .dad .el-button i {
    font-size: 18px !important;
    color: #000 !important;
  }

  .dad .el-button:hover {
    color: #2796ff !important;
  }

</style>
