<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span class="el-icon-document">任务详情</span>
        <el-button
          style="float: right"
          size="mini"
          type="danger"
          @click="goBack"
          >关闭</el-button
        >
      </div>
      <el-tabs
        tab-position="top"
        v-model="activeName"
        @tab-click="tabChangeHandler"
      >
        <!--表单信息-->
        <el-tab-pane label="表单信息" name="1">
          <el-col :span="16" :offset="4">
            <div class="test-form">
              <FormList></FormList>
            </div>
          </el-col>
        </el-tab-pane>
        <!-- 流程流转记录-->
        <el-tab-pane label="流转记录" name="2">
          <el-col :span="16" :offset="4">
            <RecordList></RecordList>
          </el-col>
        </el-tab-pane>
        <!--流程图 -->
        <el-tab-pane label="流程图" name="3">
          <FlowChart ref="flowChartRef" :flowData="flowData"></FlowChart>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import FormList from "./formList.vue";
import FlowChart from "@/views/bussiness/detail/FlowChart";
import RecordList from "@/views/bussiness/detail/RecordList";

// 模拟表单列表数据
import formList from "./formList.js";
import flowData from "./flowData.js";
export default {
  name: "Record",
  components: { FormList, FlowChart, RecordList },
  props: {},
  data() {
    return {
      activeName: "1",
    };
  },
  created() {},
  methods: {
    tabChangeHandler(val) {
      if (this.activeName == "3") {
        this.$nextTick(() => {
          this.$refs.flowChartRef.initViewer(this.flowData);
        });
      }
    },
    goBack() {
      this.$tab.closePage();
      this.$router.go(-1);
    },
  },
  computed: {
    flowData() {
      return flowData;
    },
  },
};
</script>
<style lang="scss" scoped>
.test-form {
  margin: 15px auto;
  width: 800px;
  padding: 15px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 100%;
  margin-bottom: 20px;
}

.el-tag + .el-tag {
  margin-left: 10px;
}

.my-label {
  background: #e1f3d8;
}
</style>
