<template>
  <el-main class="base-main">
    <div style="width:1200px;margin: 32px auto 0;background-color: #fff;padding:20px;">
      <div class="form-container">
        <span>审批内容</span>
      </div>
      <div class="form-content">
        <form v-if="html" data-vv-scope="custom-form">
          <online-form
            class="custom-form"
            :html="html"
            :data="data"
            :permission="permission"
            :isView="isView"
          />
        </form>
      </div>
    </div>
  </el-main>
</template>
<script>
import OnlineForm from "@/components/flow/OnlineForm.vue";
import form from "@/api/formContent.js";

export default {
  name: "formContent",
  props: ["defId", "instId"],
  data() {
    return {
      dataInstId: "",
      html: null,
      data: null,
      permission: null,
      isView: true
    };
  },
  components: { OnlineForm },
  created() {
    var $ = require("jquery");
    let _me = this;
    let handlerJs = function(rep) {
      const currentUser = _me.$store.state.login.currentUser;

      let data = _me.data;
      let _this = _me;
      eval(rep.diyJs);
    };

    let handler = function(rep) {
      form.preview(rep.form.formId, handlerJs);
      _me.data = rep.data;
      if (rep.permission) {
        _me.permission = JSON.parse(rep.permission);
      }
      _me.html = rep.form.formHtml;
    };
    if (this.instId) {
      form.getInstFormAndBO(this.instId, handler);
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/css/element-variables.scss";

::v-deep .el-form-item {
    margin-bottom: 15px !important;
    margin-top: 10px !important;
    margin-right : 10px !important;
}
.base-main {
  background-color: #e9eef3;
}

::v-deep .form-table {
  width: 100%;
  border-top: 1px solid #ebeef5;
  border-left: 1px solid #ebeef5;
}

::v-deep .form-table > thead > tr > th, ::v-deep .form-table > tbody > tr > th {
  text-align: right;
  color: #666;
  font-weight: normal;
}

::v-deep .form-table > tbody > tr > th.group-th {
  text-align: left;
  background: #f9f9f9;
  font-weight: bold;
}

::v-deep .form-table > thead > tr.sub-table-header > th {
  text-align: center;
  background: #fafafa;
}

::v-deep .form-table > tbody > tr > th > span, ::v-deep .form-table > thead > tr > th > span {
  color: #f00;
}

::v-deep .form-table > tbody > tr > th, ::v-deep .form-table > tbody > tr > td, ::v-deep .form-table > tfoot > tr > td, ::v-deep .form-table > thead > tr > th {
  border-right: 1px solid #ebeef5;
  border-bottom: 1px solid #ebeef5;
  padding: 10px;
  min-width: 0;
  box-sizing: border-box;
  text-overflow: ellipsis;
  vertical-align: middle;
  position: relative;
}

::v-deep .form-table > tfoot > tr > td {
  padding: 5px 10px;
}

::v-deep .form-table-noBorder {
  border-top: 0px solid #ebeef5;
  border-left: 0px solid #ebeef5;
}

::v-deep .form-table-noBorder > tbody > tr > th, ::v-deep .form-table-noBorder > tbody > tr > td, ::v-deep .form-table-noBorder > tfoot > tr > td, ::v-deep .form-table-noBorder > thead > tr > th {
  border-right: 0px solid #ebeef5;
  border-bottom: 0px solid #ebeef5;
}

.form-container {
  border-bottom: 1px solid #ebeef5;
  padding-bottom: 10px;
}

.form-container > span {
  border-left: 3px solid $--theme-color;
  font-weight: bold;
  font-size: 14px;
  padding-left: 10px;
  color: #666;
}

.form-content {
  padding: 11px 0;
}

::v-deep div[aria-invalid='true'] + small, ::v-deep small.error-message {
  display: block;
  margin-top: 8px;
  color: #f56c6c;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}
</style>
