<template>
  <div class="big_box">
    <!-- 标题 -->
    <div class="headBox" style="justify-content: space-between">
      <div class="title">隐患详情</div>
    </div>
    <div class="bigBox" :style="{ height: bigHeight }">
      <div class="big_from">
        <div class="left">
          <el-collapse v-model="activeNames">
            <el-collapse-item title="隐患信息:" name="1">
              <div style="
                  display: flex;
                  justify-content: center;
                  width: calc(100%-40px);
                  margin-left: 20px;
                ">
                <el-form v-show="collapse1" :model="ruleForm.value" :rules="rules" label-width="120px"
                  class="demo-ruleForm.value" status-icon>
                  <el-form-item label="检查部门:">
                    <el-input v-model="ruleForm.founderDeptname" clearable style="width: 100%"></el-input>
                  </el-form-item>
                  <el-form-item label="检查人员:">
                    <el-input v-model="ruleForm.founderName" clearable style="width: 100%"></el-input>
                  </el-form-item>
                  <el-form-item label="被检查单位:">
                    <el-input v-model="ruleForm.becheckedOrgname" clearable style="width: 100%"></el-input>
                  </el-form-item>
                  <el-form-item label="被检查对象:">
                    <el-input v-model="ruleForm.objname" clearable style="width: 100%"></el-input>
                  </el-form-item>
                  <el-form-item label="所属部位:">
                    <el-input v-model="ruleForm.partName" clearable style="width: 100%"></el-input>
                  </el-form-item>
                  <el-form-item label="所属场所:">
                    <el-input v-model="ruleForm.siteName" clearable style="width: 100%"></el-input>
                  </el-form-item>
                  <el-form-item label="检查类型:">
                    <el-select v-model="ruleForm.sourcetype" clearable>
                      <el-option v-for="item in D_BZ_YHLX" :key="item" :label="item.label" :value="item.value" />
                    </el-select>
                    <!-- <el-input clearable v-model="ruleForm.sourcetype" style="width: 100%">
                                        <dict-tag :options="D_BZ_YHLX" :value="ruleForm.sourcetype" :tag="false" />
                                    </el-input> -->
                  </el-form-item>
                  <el-form-item label="隐患描述:" style="width: 1100px">
                    <el-input v-model="ruleForm.pitfallDescribe" type="textarea" style="width: 100%" />
                  </el-form-item>
                  <el-form-item label="隐患级别:" style="width: 1100px">
                    <dict-tag :options="D_DBZ_YHDJ" :value="ruleForm.pitfallLevel" :tag="false" />
                  </el-form-item>
                </el-form>
              </div>
            </el-collapse-item>
            <el-collapse-item title="整改措施(方案)信息" name="2">
              <el-form v-show="collapse2" :model="ruleForm.value" :rules="rules" label-width="120px"
                class="demo-ruleForm.value" status-icon>
                <div class="lin">
                  <span>隐患分析</span>
                </div>
                <el-form-item label="原因分析:" style="width: 100%">
                  <el-input v-model="ruleForm.reason" type="textarea" style="width: 100%" />
                </el-form-item>
                <div class="lin">
                  <span>制定方案</span>
                </div>
                <el-form-item label="整改负责人:">
                  <el-input v-model="ruleForm.dutyUsername" clearable style="width: 100%"></el-input>
                </el-form-item>
                <el-form-item label="整改期限:">
                  <el-input v-model="ruleForm.planOvertime" clearable style="width: 100%"></el-input>
                </el-form-item>
                <el-form-item label="整改措施:" style="width: 1100px">
                  <el-input v-model="ruleForm.reformMeasure" type="textarea" style="width: 100%" />
                </el-form-item>
                <el-form-item label="临时控制措施:" style="width: 1100px">
                  <el-input v-model="ruleForm.existingControls" type="textarea" style="width: 100%" />
                </el-form-item>
                <el-form-item label="投入预算:">
                  <el-input v-model="ruleForm.budgetAmount" clearable style="width: 100%">
                  </el-input>
                </el-form-item>
                <el-form-item label="附件:" style="width: 100%">
                  <span>{{ ruleForm.reformFilename }}</span>
                </el-form-item>
              </el-form>
            </el-collapse-item>
            <!-- <el-collapse-item title="整改措施(方案)审查" name="3">
              <el-form v-show="collapse3" label-width="120px" class="demo-dynamic">
                <div class="lin">
                  <span>整改方案审核</span>
                </div>
                <el-form-item label="审核结果：" style="width: 100%">
                  <span>{{ ruleForm.checkResult }}</span>
                </el-form-item>
                <el-form-item label="审核意见：" style="width: 100%">
                  <el-input v-model="ruleForm.checkOpinion" type="textarea" style="width: 100%" />
                </el-form-item>
                <el-form-item label="审核人：">
                  <el-input v-model="ruleForm.checkUsername" clearable style="width: 100%"></el-input>
                </el-form-item>
                <el-form-item label="审核部门：">
                  <el-input v-model="ruleForm.checkDeptname" clearable style="width: 100%"></el-input>
                </el-form-item>
              </el-form>
            </el-collapse-item> -->
            <el-collapse-item title="整改落实信息" name="4">
              <el-form v-show="collapse4" label-width="120px" class="demo-dynamic">
                <el-form-item label="整改说明" style="width: 100%">
                  <el-input v-model="ruleForm.verifyContent" clearable style="width: 100%"></el-input>
                </el-form-item>
              </el-form>
            </el-collapse-item>
            <el-collapse-item title="整改落实验证" name="5">
              <el-form v-show="collapse5" label-width="120px" class="demo-dynamic">
                <el-form-item label="验证人：" style="width: 100%">
                  <span>{{ ruleForm.signUsername }}</span>
                </el-form-item>
                <el-form-item label="是否通过：" style="width: 100%">
                  <span v-if="ruleForm.signResult == 'Y'"> 通过</span>
                  <span v-if="ruleForm.signResult == 'N'"> 不通过</span>
                </el-form-item>
                <el-form-item label="整改说明：" style="width: 100%">
                  <el-input v-model="ruleForm.signOpinion" clearable style="width: 100%"></el-input>
                </el-form-item>
              </el-form>
            </el-collapse-item>
          </el-collapse>
        </div>

        <div class="right">
          <el-timeline>
            <el-timeline-item center placement="top" v-for="(activity, index) in activities" :key="index"
              :color="activity.color" :timestamp="activity.timestamp">
              <el-card>
                <p>{{ activity.content }}</p>
              </el-card>
            </el-timeline-item>
            <el-timeline-item center placement="top" color="#0bbd87">
              <p style="color: #fff">
                {{ ruleForm.finishFlag === "3" ? "已完成" : "" }}
                <el-icon size="20px" color="rgb(11,189,135)">
                  <Flag />
                </el-icon>
              </p>
            </el-timeline-item>
          </el-timeline>
        </div>
      </div>

      <el-button class="closes" @click="handleClose" type="primary">
        <el-icon>
          <DocumentDelete />
        </el-icon>
        <span>关闭</span>
      </el-button>
    </div>
  </div>
</template>

<script setup>
// 引入
import { MoreFilled } from "@element-plus/icons-vue";
import { useStore } from "vuex";
import { reactive, onMounted, ref, getCurrentInstance } from "vue";
import { getApi, deleteApi, putApi } from "@/api/tobAcco_api.js";
import { useRouter, useRoute } from "vue-router";
const store = useStore();
const route = useRoute();
const router = useRouter();
const { proxy } = getCurrentInstance();
// 数据
const { D_DBZ_YHDJ, D_BZ_YHLX } = proxy.$dict("D_DBZ_YHDJ", "D_BZ_YHLX");
const bigHeight = ref(); //整个高度
const params = {
  cityId: route.query.cityId
};
const activities = ref([]);
// 控制按钮展开与折叠
const collapse1 = ref(true);
const collapse2 = ref(true);
const collapse3 = ref(true);
const collapse4 = ref(true);
const collapse5 = ref(true);
const activeNames = ref(1);
const ruleForm = ref({});
//当前列的id

// 方法
//获取详情数据
function getyhJdxq() {
  let pifallid = localStorage.getItem("pifallid");
  getApi({ pifallid: pifallid }, "/mosty-jcgl/zhjc/getPageCountDetailsJd").then(
    (res) => {
      if (res) {
        ruleForm.value = res;
      }
    }
  );
}

const bigHeightFn = () => {
  bigHeight.value = window.innerHeight - 147 + "px";
};
//右边流程tu
const getRightList = () => {
  let pifallid = localStorage.getItem("pifallid");
  getApi(
    { pifallid: pifallid },
    "/mosty-jcgl/zhjc/getPageCountDetailsJdLc"
  ).then((res) => {
    activities.value = res.rlist.map((item) => {
      return {
        content: item.title,
        timestamp: item.date + " " + item.time,
        color: "#0bbd87"
      };
    });
  });
};
//关闭
function handleClose() {
  let arr = store.getters.tagsViewList;
  for (let i = 0; i < arr.length; i++) {
    const e = arr[i];
    if (e.fullPath == "/fxgk/jcss/yhtjckjd") {
      arr.splice(i, 1);
    }
  }
  router.push("/fxgk/jcss/zhjc");
}
onMounted(() => {
  bigHeightFn();
  getyhJdxq();
  getRightList();
});
</script>

<style lang="scss" scoped>
.big_from {
  display: flex;
  justify-content: space-between;
  height: calc(100% - 120px);

  .left {
    width: 70%;
    margin-left: 10px;
    height: calc(100% - 100px);
    overflow-y: scroll;
    padding: 0 20px;
  }
}

.headBox {
  width: 100%;
  height: 80;

  .title {
    font-size: 18px;
    line-height: 80px;
    padding: 0 20px;
  }
}

.el-form {
  padding: 20px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.el-form-item {
  text-align: center;
  width: 350px;
}

.el-input {
  width: 350px;
}

.lable_span {
  color: red;
}

.lin {
  width: 100%;
  border-bottom: 1px dashed #1ada4a;
  margin-bottom: 20px;

  >span {
    color: #1ada4a;
    font-size: 16px;
  }
}

.right {
  width: 25%;
  height: calc(100% - 100px);
  overflow-y: scroll;
}

.bottom {
  margin-top: 10px;
  width: 100%;
  text-align: right;
}

.closes {
  float: right;
}
</style>