<template>
  <!-- 全流程管理组件 -->
  <div class="StepsMyBox">
    <el-dialog
      custom-class="myMission"
      title="详细信息"
      :append-to-body="true"
      :modal="true"
      :visible.sync="dialogVisible"
      width="70%"
      height="60%"
      :before-close="handleClose"
    >
      <div>
        <div class="dialog_title_info">
          <div>立项年度：{{ formData && formData.c_lxndwt ? formData.c_lxndwt : "--" }}</div>
          <div>被审计镇：{{ clickData.c_owning_street_town_str ? clickData.c_owning_street_town_str : "--" }}</div>
        </div>
        <div class="dialog_title_info">问题金额（万元）：{{ formData && formData.c_wtjewt ? formData.c_wtjewt : "--" }}</div>
        <div class="dialog_title">审计报告中的问题反映情况</div>
        <div v-for="(item, index) in dialogData" :key="index" class="dialog_table">
          <div>{{ item.title }}</div>
          <div>{{ formData && formData[item.columnName] ? formData[item.columnName] : "--" }}</div>
        </div>
        <div class="dialog_title3">
          <el-button size="mini" type="primary" class="infoBut" @click="gotoView(formData)">查看疑点图斑</el-button>
        </div>
      </div>
    </el-dialog>
    <div style="padding: 10px">
      <el-button type="primary" icon="el-icon-arrow-left" @click="backEvent()">返回上级</el-button>
    </div>
    <!-- 全流程管理主题 -->
    <div class="StepsMyBox_main">
      <!-- 左侧项目明细 -->
      <div class="StepsMyBox_main_left">
        <div class="StepsMyBox_main_left_main">
          <div class="StepsMyBox_main_left_main_title">{{ clickData.c_project_name ? clickData.c_project_name : "--" }}</div>
          <div class="StepsMyBox_main_left_main_info">基本信息</div>
          <div class="StepsMyBox_main_left_main_info">
            <div>立项日期:</div>
            <div>{{ clickData.c_create_date ? $dayjs(clickData.c_create_date).format("YYYY-MM-DD") : "--" }}</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>项目类型:</div>
            <div>{{ clickData.c_task_type_str ? clickData.c_task_type_str : "--" }}</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>涉及街镇:</div>
            <div>{{ clickData.c_owning_street_town_str ? clickData.c_owning_street_town_str : "--" }}</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>牵头部门:</div>
            <div>资环处</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>项目组长:</div>
            <div>谢康</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>项目主审:</div>
            <div>庞杰</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>参与人员:</div>
            <div>李同</div>
          </div>
          <div class="StepsMyBox_main_left_main_info">
            <div>追踪问题:</div>
            <div>29个</div>
          </div>
        </div>
      </div>
      <!-- 右侧流程明细 -->
      <div class="StepsMyBox_main_right">
        <div>
          <el-steps :active="stepsIndexNow" style="margin: 40px 40px 40px 80px">
            <el-step v-for="(item, index) in stepsList" :key="index">
              <template slot="icon">
                <el-image
                  style="width: 20px; height: 20px"
                  :src="'/static/images/stepsIcon/' + item.status + '.png'"
                  fit="cover"
                ></el-image>
              </template>
              <template slot="title">
                <div
                  class="stepsTitle"
                  :style="{ background: stepsIndex == index + 1 ? '#00aaff' : '' }"
                  @click="changeStepsIndex(index + 1)"
                >
                  {{ item.title }}
                </div>
              </template>
              <template slot="description">
                <div class="stepsDescription">
                  {{ item.time ? item.time : "" }}
                </div>
              </template>
            </el-step>
          </el-steps>
        </div>
        <div class="stepsInfoBox">
          <!-- 流程明细文字描述 -->
          <div>
            {{ stepsList[stepsIndex - 1].info.text ? clickData.c_project_name + stepsList[stepsIndex - 1].info.text : "" }}
          </div>
          <!-- 流程明细文件预览（通知和报告会用到文件预览） -->
          <FilePreView ref="filePreview" v-show="fileView" style="height: calc(100% - 30px)" />
          <!-- 流程明细-实施列表 -->
          <div v-if="stepsList[stepsIndex - 1].info.infos">
            <div v-for="(item, index) in stepsList[stepsIndex - 1].info.infos" :key="item.index" style="padding-bottom: 1rem">
              <span
                :style="{ fontWeight: index != 0 ? 'none' : 'bold', paddingLeft: index != 0 ? '1rem' : '0px' }"
                class="infoTitle"
                ><div v-if="index != 0" class="infoIcon"></div>
                {{ item.title }}</span
              ><el-button
                v-if="item.id"
                size="mini"
                type="primary"
                class="infoBut"
                style="margin-left: 2rem"
                @click="getInfoById(item.id)"
                >查看详情</el-button
              >
            </div>
          </div>
          <!-- 流程明细-整改表格 -->
          <div v-if="stepsList[stepsIndex - 1].info.tableData">
            <div class="flexBox">
              <div v-for="(value, key) in stepsList[stepsIndex - 1].info.props" :key="key">
                <div class="tableTitle">{{ value }}</div>
              </div>
            </div>
            <div
              v-for="(item, index) in stepsList[stepsIndex - 1].info.tableData"
              :key="item.id"
              class="flexBox"
              style="padding: 0.5rem 0"
            >
              <div v-for="(value, key) in stepsList[stepsIndex - 1].info.props" :key="key">
                <span v-if="key != 'opt'">{{ stepsList[stepsIndex - 1].info.tableData[index][key] }}</span>
                <el-button
                  v-else
                  size="mini"
                  type="primary"
                  class="infoBut"
                  @click="getInfoById(stepsList[stepsIndex - 1].info.tableData[index])"
                >
                  查看详情
                </el-button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
/**
 * 头部菜单（全流程管理）组件
 * @author: LiuMengxiang
 * @Date: 2022年11月21-25日
 */
import FilePreView from "./FilePreView.vue";
export default {
  name: "StepsMyBox",
  components: { FilePreView },
  data() {
    return {
      // 当前或默认选中的步骤条下标加一
      stepsIndex: 6,
      stepsIndexNow: 6,
      // 是否显示在线文档预览
      fileView: false,
      // 整改中的查看详情弹窗状态
      dialogVisible: false,
      // 该项目关联任务列表
      tableData: [],
      // 暂存对象
      formData: {},
      // 参与人员
      countUser: 0,
      dialogData: [
        { title: "问题分类", columnName: "c_wtflwt", info: "--" },
        { title: "问题定性一级", columnName: "c_wtdx1wt", info: "--" },
        { title: "问题定性二级", columnName: "c_wtdx2wt", info: "--" },
        { title: "问题事项", columnName: "c_wtsxwt", info: "--" },
        { title: "使用法条", columnName: "c_syftwt", info: "--" },
        { title: "边审边改情况", columnName: "c_bsbgqkwt", info: "--" }
      ],
      // 步骤条列表
      stepsList: [
        {
          title: "立项",
          info: {
            tableData: [
              {
                desc: "报审计委员会审计",
                date: ""
              },
              {
                desc: "区府常务会",
                date: "2023-02-22"
              },
              {
                desc: "区委常务会",
                date: ""
              },
              {
                desc: "区府常务会批示",
                date: ""
              },
              {
                desc: "区府网站公示",
                date: ""
              }
            ],
            props: { desc: "节点", date: "日期" }
          },
          status: 200,
          time: "2022-02-22"
        },
        {
          title: "通知",
          info: { text: "项目审计通知书.pdf", filePath: "./static/word/审计通知书.pdf" },
          status: 200,
          time: "2022-08-30"
        },
        {
          title: "方案",
          info: { text: "项目实施方案.pdf", filePath: "./static/word/实施方案.pdf" },
          status: 200,
          time: "2022-09-07"
        },
        {
          title: "实施",
          info: {
            infos: [
              { title: "李同 共完成了248处疑点审计" },
              { title: "2022.09.13 12:00 创建任务" },
              { title: "2022.09.14 12:00 登录系统" },
              { title: "2022.09.14 15:23 完成了疑点标记（打开图层：永久基本农田、2020年森林 底图：2022年一季度卫星影像图）" },
              { title: "2022.09.14 15:24 完成了疑点标记（打开图层：永久基本农田，2020年森林 底图：2021年四季度卫星影像图）" },
              { title: "2022.09.15 15:24 完成了疑点标记（打开图层：永久基本农田，2020年森林 底图：2021年四季度卫星影像图）" },
              { title: "2022.09.15 16:00 完成了疑点审计（打开图层：永久基本农田、2018年森林）" },
              { title: "2022.09.15 16:34 对2022年一季度及2019年四季度卫星影像图进行同屏比对，并打印结果" },
              { title: "2022.09.15 09:34 对2022年一季度及2019年四季度卫星影像图进行卷帘比对" },
              { title: "2022.09.16 15:34 发送了标记疑点给用户23452dddy的手机端" },
              { title: "2022.09.16 08:45 上传了泥潭数据.geojson" }
            ]
          },
          status: 200,
          time: ""
        },
        {
          title: "报告",
          info: { text: "项目审计意见.docx", filePath: "./static/word/审计意见.pdf" },
          status: 200,
          time: "2022-12-15"
        },
        {
          title: "整改",
          info: {
            tableData: [
              {
                desc: "基本农田非粮化",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "一般耕地非粮化",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "河长巡河流于形式",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分河道监管不到位",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "个别生态环境督察事项整改机制落实不到位",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分监测不合格地块用作水稻种植等",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分地块抛荒闲置",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "复垦新增耕地地块面积较小，难以耕种",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "复垦新增耕地零碎化，难以耕种",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "复垦地块覆土质量不高",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "个别地块拆除整治不到位",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分地块拆后堆物等，环境效益低",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分已拆除复垦地块荒置",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分重大环保事项集体决策程序履行不到位",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "垃圾中转站选址决策不合理",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "工业节能目标任务未完成",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "个别单位建筑能耗超标",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "机关办公建筑能耗申报不完整",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "违规占用设置堆点",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "垃圾违规堆放、导致多支付处置费用",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "备案堆点监管不到位",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分泥库在基本农田内实施",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分泥库重复列入土地平整项目",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "拆分项目，规避公开招标",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "过程监管缺失，底泥来源及处置去向不明。",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "部分设施农用地备案过期",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "对项目招投标工作监管不到位，个别项目串通投标",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "建设程序管理不到位，部分项目先实施后签合同",
                status: "整改中",
                endTime: "2023-03-15"
              },
              {
                desc: "个别地块公益林建后管理养护不到位",
                status: "整改中",
                endTime: "2023-03-15"
              }
            ],
            props: { desc: "问题描述", status: "当前状态", endTime: "整改期限", opt: "操作" }
          },
          status: 400,
          time: "进行中"
        }
      ]
    };
  },
  props: ["clickData"],
  mounted() {},
  watch: {
    clickData: {
      handler(newValue, oldValue) {
        if (newValue != oldValue) {
          // this.$nextTick(() => {
          //   // 获取项目基本信息
          //   this.stepsList[0].info.text =
          //     this.$dayjs(this.clickData.check_time).format("YYYY-MM-DD") +
          //     ": " +
          //     this.clickData.c_project_name +
          //     "（通过立项！）";
          //   // 获取项目关联任务信息
          //   this.getAllTasks();
          //   // 获取项目流程数据
          //   // console.log("全流程管理详情", newValue, oldValue);
          // });
          this.changeStepsIndex(6);
        }
      },
      deep: true,
      immediate: false
    }
  },
  methods: {
    gotoView(fromData) {
      // 调用全局事件总线中的指定事件
      this.$bus.$emit("openMyView", [fromData.c_sjlbwt, fromData.c_bsjzwt]);
      this.dialogVisible = false;
      this.$store.commit("changeNavSelect", {
        index: "3",
        name: "综合分析"
      });
    },
    // 流程管理【实施】节点，根据id查看详情
    getInfoById(val) {
      let searchParam = [];
      // 立项年度
      if (val.desc) {
        let paramTime = {
          field: "c_wtdx2wt",
          // 等值查询
          searchType: "1",
          content: {
            value: val.desc
          }
        };
        searchParam.push(paramTime);
      }
      let params = new FormData();
      params = {
        columnId: 1127,
        states: "0,1,2,3",
        pageSize: 1,
        page: 0,
        search: JSON.stringify(searchParam)
      };

      this.$Post(this.urlsCollection.selectContentList, params).then(res => {
        if (res.code === 200 && res.content.data.length > 0) {
          this.formData = res.content.data[0];
          this.dialogVisible = true;
        }
      });
    },
    // 返回上级
    backEvent() {
      this.$emit("hideStepsMyBoxState");
    },
    // 切换步骤条
    changeStepsIndex(index) {
      this.stepsIndex = index;
      if (this.fileView) {
        this.$refs.filePreview.cancel();
        this.fileView = false;
      }
      // 判断流程明细是否存在文件，存在的话自动请求文件并渲染
      if (this.stepsList[this.stepsIndex - 1].info.filePath) {
        this.fileView = true;
        this.$refs.filePreview.showView(this.stepsList[this.stepsIndex - 1].info.filePath);
      }
    },
    handleClose() {
      this.dialogVisible = false;
    },
    // 查询事件
    getAllTasks() {
      let params = new FormData();
      this.countUser = 0;
      params.append("columnId", "48");
      params.append("states", "2,3");
      params.append("pageSize", 999);
      params.append("page", 0);
      let searchParam = [];
      if (this.clickData.id) {
        let param1 = {
          field: "c_associated_item_ids",
          searchType: "2",
          content: {
            value: this.clickData.id
          }
        };
        searchParam.push(param1);
      }
      params.append("search", JSON.stringify(searchParam));
      this.$Post(this.urlsCollection.selectContentList, params).then(
        res => {
          if (res.code === 200 && res.content.data.length > 0) {
            this.tableData = res.content.data;
            if (this.tableData.length > 0) {
              let usersList = [];
              this.tableData.forEach(item => {
                if (usersList.indexOf(item.author_id) < 0) {
                  usersList.push(item.author_id);
                  this.countUser++;
                }
              });
            }
          } else {
            this.tableData = [];
            this.countUser = 0;
          }
        },
        error => {
          this.tableData = [];
          this.countUser = 0;
        }
      );
    }
  }
};
</script>
<style lang="less" scoped>
.StepsMyBox {
  padding: 0;
  position: absolute;
  display: flex;
  background: #001220 !important;
  z-index: 999;
  width: 100%;
  height: 100%;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -khtml-user-select: none;
  user-select: none;
  overflow: hidden;
  flex-direction: column;
  &_main {
    padding: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 80px);
    display: flex;
    justify-content: space-between;
    &_left {
      width: calc(25% - 5px);
      height: 100%;
      background: #001d3c !important;
      &_main {
        margin: 20px 30px;
        display: flex;
        flex-direction: column;
        &_title {
          font-size: 20px;
          font-family: pingfangSC;
          font-weight: 400;
          color: #4dc3ff;
          line-height: 58px;
        }
        &_info {
          display: flex;
          padding: 10px 0;
          font-size: 18px;
          font-family: pingfangSC;
          font-weight: bold;
          color: #ffffff;
          line-height: 60px;
          div {
            font-size: 16px;
            font-family: pingfangSC;
            font-weight: 400;
            color: #ffffff;
            line-height: 50px;
            width: 50%;
          }
        }
      }
    }
    &_right {
      width: calc(75% - 5px);
      height: 100%;
      background: #001d3c !important;
      .stepsTitle {
        margin-top: 10px;
        transform: translate(-30%, 0%);
        width: 2rem;
        cursor: pointer;
        padding: 0px 20px;
        // border: 1px solid #00aaff;
        border-radius: 3px;
        color: #ffffff;
        font-weight: bold;
      }
      .stepsDescription {
        margin-top: 10px;
        transform: translateX(-40px);
        padding: 0px 20px;
        font-size: 16px;
        color: #375787;
        font-weight: bold;
      }
      .stepsInfoBox {
        width: calc(100% - 80px);
        height: calc(100% - 220px);
        margin: 40px;
        margin-top: 0px;
        font-size: 18px;
        overflow-y: auto;
        // font-weight: bold;
        font-family: pingfangSC;
        line-height: 30px;
        color: #ffffff;
        .flexBox {
          display: flex;
          width: 100%;
          justify-content: space-evenly;
          align-items: center;
          align-content: space-around;
          flex-wrap: nowrap;
          flex-direction: row;
          .tableTitle {
            font-size: 20px;
            font-family: pingfangSC;
            font-weight: 400;
            color: #4dc3ff;
            padding-bottom: 0.5rem;
          }
          & > div {
            width: 100%;
          }
        }
      }
    }
  }
}

.infoTitle {
  position: relative;
  .infoIcon {
    position: absolute;
    left: 2px;
    top: 10px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
  }
}
.dialog_title {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  padding-bottom: 1.5rem;
  &2 {
    font-weight: 100;
    font-size: 18px;
    color: #fff;
    padding-top: 1.5rem;
  }
  &3 {
    display: flex;
    justify-content: center;
    padding-top: 1.5rem;
  }
  &_info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 400px;
    color: #dcdfe6;
    padding: 1rem 0;
  }
}
.dialog_table {
  display: flex;
  justify-content: space-between;
  div {
    width: 50%;
    text-align: center;
    background-color: #00000064 !important;
    margin: 1px;
    padding: 5px 10px;
    display: flex;
    justify-content: center;
    color: #dcdfe6;
    border: 1px solid #001d3c00;
  }
}
div {
  .flexBox:nth-child(1) {
    background: #37578799;
  }
  .flexBox:nth-child(odd) {
    background: #37578732;
  }
}
</style>
