<!--
 * @Author: tengmingxue 1473375109@qq.com
 * @Date: 2023-06-05 17:46:54
 * @LastEditors: tengmingxue 1473375109@qq.com
 * @LastEditTime: 2023-06-08 19:17:16
 * @FilePath: \yx-big-screen\src\views\map\dialog\HistoryInfo\RowTable.vue
 * @Description: 表格
-->

<template>
  <div class="table-row-info">
    <a-row class="table-header">
      <a-col :span="1" class="title-col">序号</a-col>
      <a-col :span="6" class="title-col">评估时间</a-col>
      <a-col :span="5" class="title-col">评估结果</a-col>
      <a-col :span="5" class="title-col">巡查人员</a-col>
      <a-col :span="5" class="title-col">是否变化</a-col>
      <a-col :span="2" class="title-col">操作</a-col>
    </a-row>

    <div class="table-container" v-if="tableData.length > 0">
      <template v-for="(item, index) in tableData" :key="index">
        <a-row class="table-row" :class="{ active: currentRow === item.id }">
          <a-col :span="1" class="fields-col fields-style">
            <span class="defect-serial-p">
              <span class="defect-serial"> {{ index + 1 }}</span>
            </span>
          </a-col>
          <a-col :span="6" class="fields-col fields-style">{{ item.pgsj }}</a-col>
          <a-col :span="5" class="fields-col fields-style">{{ item.pgjg }}</a-col>
          <a-col :span="5" class="fields-col fields-style">{{ item.xcry }}</a-col>
          <a-col :span="5" class="fields-col fields-style">{{ item.ischange }}</a-col>
          <a-col :span="2" class="fields-col detail" @click="showDetailClick(item)">
            <span class="label">详情</span>
            <span :class="currentRow === item.id ? 'close-img img' : 'open-img img'"></span>
          </a-col>
        </a-row>
        <a-row class="table-detail" v-if="currentRow === item.id">
          <div class="title-label">设施及其建议：</div>
          <div class="continer">11111</div>

          <div class="title-label">现场分析与评价：</div>
          <div class="continer">2222</div>

          <div class="title-label">最新发生及危害情况：</div>
          <div class="continer">1111</div>
        </a-row>
      </template>
    </div>
    <div v-else class="no-table-container">
      <div class="nodata"></div>
    </div>
  </div>
</template>

<script>
import { defineComponent, reactive, toRefs, onMounted, ref, watch, getCurrentInstance } from 'vue';
import moment from 'moment';
import { queryInspectEvaluatePage } from '/@/api/map/geologicalApi';
const props = {
  /**
   * 地灾信息
   * */
  geologicalInfo: { type: Object, require: true },
};
export default defineComponent({
  name: 'TableRowInfo',
  components: {},
  props,
  setup() {
    const data = reactive({
      geologicalInfo: props.geologicalInfo,
      currentRow: '',
      condition: {
        dzdxid: Object.hasOwnProperty.call(props.geologicalInfo, 'id') ? props.geologicalInfo.id : null,
        current: 1,
        size: 10,
        startTime: moment(new Date()).subtract(7, 'days').format('YYYY-MM-DD HH:mm:ss'),
        endTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
      },
      tableData: [],
    });
    watch(
      () => props.geologicalInfo,
      (value) => {
        data.geologicalInfo = value;
      }
    );
    const showDetailClick = (row) => {
      data.currentRow = data.currentRow === row.id ? '' : row.id;
    };
    const queryDate = async (param) => {
      console.log('eventBus查询数据', param);
      const res = await queryInspectEvaluatePage(param);
      console.log('评估数据', res);
      if (res.code === 1) {
        data.tableData = res.result.records;
      }
    };
    onMounted(() => {
      eventBus.on('InspectEvaluateQueryEventBus', (param) => {
        queryDate(param);
      });
      queryDate(data.condition);
    });
    return {
      ...toRefs(data),
      showDetailClick,
      queryDate,
    };
  },
});
</script>
<style lang="less" scoped>
.table-row-info {
  position: relative;
  height: calc(100% - 58px);
  width: 100%;
  overflow: auto;

  .table-header {
    height: 40px;
    line-height: 40px;
    background: rgba(7, 178, 255, 0.18);
    .title-col {
      font-size: 14px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #16c0ff;
      text-align: center;
      border: 1px solid rgba(21, 186, 255, 0.3);
    }
  }
  .table-container {
    width: 100%;
    height: calc(100% - 70px);
    overflow: auto;
    .table-row {
      height: 40px;
      line-height: 40px;
      width: 100%;
      &:hover {
        background: rgba(255, 255, 255, 0.1);
      }
      .fields-col {
        display: flex;
        height: 100%;
        text-align: center;
        justify-content: center;
        align-items: center;
        border: 1px solid rgba(21, 186, 255, 0.3);
        .defect-serial-p {
          display: flex;
          width: 22px;
          height: 22px;
          .defect-serial {
            display: flex;
            width: 22px;
            height: 22px;
            padding: 0 5px;
            line-height: 22px;
            border-radius: 50%;
            font-size: 14px;
            font-family: Alimama ShuHeiTi;
            font-weight: bold;
            font-style: italic;
            color: #ffffff;
          }
        }
      }
      .fields-style {
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
      }
      .fields-style-red {
        color: #ff3535;
      }
      .fields-style-green {
        color: #0ae878;
      }
      .detail {
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 500;
        color: #08ba68;
        background: linear-gradient(46deg, #ffe87e 0%, #00e1e4 37%, #ffffff 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        cursor: pointer;
        display: flex;
        text-align: center;
        justify-content: center;
        align-items: center;
        .label {
          display: flex;
          margin-right: 6px;
        }
        .img {
          display: flex;
          width: 31px;
          height: 27px;
        }
        .close-img {
          background: url('/@/assets/images/dialog/pickup-on.png') no-repeat;
          background-size: 100% 100%;
        }
        .open-img {
          background: url('/@/assets/images/dialog/open-on.png') no-repeat;
          background-size: 100% 100%;
        }
      }
    }
    .active {
      background: rgba(255, 255, 255, 0.1);
    }
    .table-detail {
      border: 1px solid rgba(21, 186, 255, 0.3);
      height: auto;
      padding: 0 10px;
      .title-label {
        width: 100%;
        height: 28px;
        line-height: 28px;
        margin: 5px 0 2px 0;
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 500;
        color: #2ec6ff;
      }
      .container {
        height: auto;
        word-wrap: break-word;
        word-break: normal;
        margin-bottom: 6px;
      }
    }
  }
  .no-table-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: calc(100% - 70px);
    border: 1px solid rgba(21, 186, 255, 0.3);
    .nodata {
      width: 125px;
      height: 96px;
      background: url('/@/assets/images/dialog/nodata.png') no-repeat;
      background-size: 100% 100%;
    }
  }
}
</style>
