ZhangXianQiang
2024-03-05 5300255dd40ac2ed67676da5568f0e4fd25a7078
src/views/daoAnOffice/right/danger/dataTable.vue
@@ -4,45 +4,51 @@
      <div class="top-title">安全事故列表</div>
      <div class="table-select flex">
        <div class="select-item mr-2 ml-2 cursor-pointer flex items-center"
          :class="{ 'item-active': selectItem.isActive }" v-for="selectItem in tableType" :key="selectItem.id">{{
          :class="{ 'item-active': selectItem.isActive }" v-for="selectItem in tableType" :key="selectItem.id"
          @click="changeSelect(selectItem)">{{
            selectItem.type }}</div>
      </div>
    </div>
    <div class="table-container flex-1">
      <el-table class="data-table" :data="tableData" :highlight-current-row="false" :stripe="true"
        :header-cell-style="{ backgroundColor: 'transparent', color: '#79A5E9', borderColor: '#29466A' }"
        :cell-style="{ color: '#79A5E9', borderColor: '#29466A', paddingTop: '10px', paddingBottom: '10px' }"
        :row-style="{ backgroundColor: 'transparent' }">
        <el-table-column prop="street" label="镇/街道" align="center" />
        <el-table-column label="发现数量" align="center">
          <template #default="scope">
            <div style="color: #6289E6;">
              {{ scope.row.num1 }}
            </div>
          </template>
        </el-table-column>
      <div class="table-content">
        <el-table class="data-table" ref="dataTable" :data="tableData" :highlight-current-row="false" :stripe="true"
          :header-cell-style="{ backgroundColor: 'transparent', color: '#79A5E9', borderColor: '#29466A' }"
          :cell-style="{ color: '#79A5E9', borderColor: '#29466A', paddingTop: '10px', paddingBottom: '10px' }"
          :row-style="{ backgroundColor: 'transparent' }">
          <el-table-column prop="street" label="镇/街道" align="center" />
          <el-table-column label="发现数量" align="center">
            <template #default="scope">
              <div style="color: #6289E6;">
                {{ scope.row.num1 }}
              </div>
            </template>
          </el-table-column>
        <el-table-column label="下发通知书" align="center">
          <template #default="scope">
            <div style="color: #CFB249;">
              {{ scope.row.num2 }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="处置数量" align="center">
          <template #default="scope">
            <div style="color: #2BB06D;">
              {{ scope.row.num3 }}
            </div>
          </template>
        </el-table-column>
      </el-table>
          <el-table-column label="下发通知书" align="center">
            <template #default="scope">
              <div style="color: #CFB249;">
                {{ scope.row.num2 }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="处置数量" align="center">
            <template #default="scope">
              <div style="color: #2BB06D;">
                {{ scope.row.num3 }}
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import { ref, onMounted, onUnmounted, nextTick, inject, watch } from 'vue';
const tableState = inject('tableState');
const tableType = ref([
  { id: 1, type: '本月', isActive: true },
@@ -86,12 +92,112 @@
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
  {
    street: '奎光塔街道',
    num1: 12,
    num2: 5,
    num3: 2
  },
];
const changeSelect = (selectItem) => {
  tableType.value.forEach((item) => {
    item.isActive = false;
  });
  selectItem.isActive = true;
}
// 处理表格滚动
let timer = null;
const dataTable = ref(null);
// const clearScroll = () => {
//   clearInterval(timer);
//   timer = null;
// }
// const createScroll = () => {
//   clearScroll();
//   const table = dataTable.value.layout.table.refs;
//   const tableWrapper = table.bodyWrapper.firstElementChild.firstElementChild;
//   console.log(tableWrapper);
//   timer = setInterval(() => {
//     tableWrapper.scrollTop += 1;
//     if (tableWrapper.clientHeight + tableWrapper.scrollTop >= tableWrapper.scrollHeight) {
//       tableWrapper.scrollTop = 0;
//     }
//   }, 100);
// }
// watch(tableState, (newValue) => {
//   console.log(newValue);
//   if (newValue) {
//     nextTick(() => {
//       setTimeout(() => {
//         createScroll();
//       }, 2000);
//     })
//   } else {
//     clearScroll();
//   }
// })
// onUnmounted(() => {
//   clearScroll();
// });
</script>
<style lang="scss" scoped>
.container {
  height: 360px;
}
.table-container {
  position: relative;
}
.table-content {
  width: 100%;
  position: absolute;
  top: 0;
  bottom: 0;
}
.table-top {
@@ -109,13 +215,17 @@
  font-size: 16px;
  color: #447ED6;
  margin-left: 20px;
  font-family: 'PingFang SC';
}
.select-item {
  padding: 0 14px;
  padding: 0 16px;
  height: 100%;
  border-bottom: 2px solid RGBA(98, 137, 230, 0);
  color: rgba(94, 134, 194, 1);
  font-family: 'PingFang SC';
}
.item-active {
@@ -124,16 +234,14 @@
}
.data-table {
  font-size: 14px;
  font-size: 16px;
  border: 1px solid #29466A;
  width: 100%;
  height: 100%;
  background: transparent;
  font-family: 'PingFang SC';
}
.table-color1 {}
::v-deep .el-table__inner-wrapper::before {
  background-color: transparent;