._element 统计页">
当前位置:   article > 正文

elementui 搜索统计列表页_element 统计页

element 统计页
  • 列表
  • 点击设置时间区间
  • 多条件搜索(下拉列表,输入框,时间区间)
  • 清空搜索条件
  • 分页
  • 左侧树搜索条件
  • 树默认选中第一个

在这里插入图片描述

<template>
  <el-row style="padding: 0 !important">
    <el-col :span="5">
      <dtLine @line-click="lineClick" :deptTree="tree"></dtLine>
    </el-col>
    <el-col :span="19">
      <basic-container>
        <el-row class="dt-search">
          <el-col :span="24">
            <el-button
              size="small"
              class="width-but"
              :class="{ current: timeTab === 1 }"
              @click="setTime(1)"
              >今天</el-button
            >
            <el-button
              size="small"
              class="width-but"
              :class="{ current: timeTab === 2 }"
              @click="setTime(2)"
              >昨天</el-button
            >
            <el-button
              size="small"
              class="width-but"
              :class="{ current: timeTab === 3 }"
              @click="setTime(3)"
              >最近7天</el-button
            >
            <el-button
              size="small"
              class="width-but"
              :class="{ current: timeTab === 4 }"
              @click="setTime(4)"
              >最近15天</el-button
            >
            <el-button
              size="small"
              class="width-but"
              :class="{ current: timeTab === 5 }"
              @click="setTime(5)"
              >最近30天</el-button
            >
            <el-date-picker
              size="small"
              style="margin-left: 10px"
              v-model="time"
              type="daterange"
              @change="timeTab = 0"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-col>
          <el-col :span="24">
            <el-select
              v-model="postId"
              placeholder="请选择所属单位"
              class="search-post"
            >
              <el-option
                v-for="item in affiliatedUnitsay"
                :key="item.id"
                :label="item.postName"
                :value="item.id"
              >
              </el-option>
            </el-select>
            <el-input
              size="small"
              style="margin-left: 10px; width: 200px"
              v-model="keyword"
              placeholder="请输入姓名"
            ></el-input>
            <el-button
              size="small"
              style="margin-left: 10px"
              type="primary"
              icon="el-icon-search"
              @click="getList"
              >查询</el-button
            >
            <el-button size="small" icon="el-icon-delete" @click="searchReset"
              >清空</el-button
            >
          </el-col>
        </el-row>

        <el-table
          v-loading="loading"
          size="small"
          height="calc(100vh - 319px)"
          :data="data"
          style="width: 100%"
          border
          :header-cell-style="{
            background: '#fafafa',
            color: 'rgba(0,0,0,.85)',
            fontSize: '12px',
          }"
        >
          <el-table-column type="index" label="#" align="center">
          </el-table-column>
          <el-table-column prop="atteTime" label="日期"> </el-table-column>
          <el-table-column prop="userName" label="姓名"> </el-table-column>
          <el-table-column prop="typeName" label="人员分类"> </el-table-column>
          <el-table-column prop="department" label="所属单位">
          </el-table-column>
          <el-table-column prop="firstTime" label="首次识别时间">
          </el-table-column>
          <el-table-column prop="lastTime" label="最后识别时间">
          </el-table-column>
        </el-table>
        <div class="dt-page-box">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page.currentPage"
            :page-sizes="[10, 20, 30, 40, 50, 100]"
            :page-size="page.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page.total"
          >
          </el-pagination>
        </div>
      </basic-container>
    </el-col>
  </el-row>
</template>

<script>
import dtLine from "@/components/dt-line/main";
import { dayList, deptTree, postArray } from "@/api/attendance/record";
export default {
  name: "attendanceDay",
  data() {
    return {
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      time: "",
      timeTab: 0,
      tree: [],
      deptId: "",
      affiliatedUnitsay: [],
      keyword: "",
      data: [],
      query: {},
      postId: "",
    };
  },
  components: {
    dtLine,
  },
  beforeRouteEnter(to, from, next) {
    deptTree().then((res) => {
      let tree = res.data.data;
      const data = res.data.data;
      let firstDeptId = "";
      function loop(data) {
        data = data[0];
        if (data.hasChildren == true) {
          loop(data.children);
        } else {
          firstDeptId = data.id;
        }
      }
      loop(data);
      localStorage.setItem("deptId", firstDeptId);
      next((vm) => {
        vm.tree = tree;
      });
    });
  },
  watch: {
    timeTab(newVal) {
      const _startT = new Date();
      const _endT = new Date();
      switch (newVal) {
        case 1:
          break;
        case 2:
          _endT.setTime(_startT.getTime() - 3600 * 1000 * 24);
          _startT.setTime(_startT.getTime() - 3600 * 1000 * 24);
          break;
        case 3:
          _startT.setTime(_startT.getTime() - 3600 * 1000 * 24 * 7);
          break;
        case 4:
          _startT.setTime(_startT.getTime() - 3600 * 1000 * 24 * 15);
          break;
        case 5:
          _startT.setTime(_startT.getTime() - 3600 * 1000 * 24 * 30);
          break;
      }
      if (newVal !== 0) {
        this.time = [_startT, _endT];
      }
    },
  },
  created() {
    this.getList();
    this.postArray();
  },

  methods: {
    postArray() {
      const that = this;
      postArray().then((res) => {
        that.affiliatedUnitsay = res.data.data.records;
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    searchReset() {
      this.query = {};
      this.time = "";
      this.timeTab = 0;
      this.getList();
    },
    lineClick(data) {
      this.deptId = data.id;
      this.page.currentPage = 1;
      this.getList();
    },
    setTime(num) {
      this.timeTab = num;
    },
    getList(params = {}) {
      if (this.deptId == "") {
        this.deptId = localStorage.getItem("deptId");
      }
      this.query.deptId = this.deptId;
      this.query.timeFrom = this.time[0];
      this.query.timeTo = this.time[1];
      this.query.keyword = this.keyword;
      this.query.postId = this.postId;
      this.loading = true;
      dayList(
        this.page.currentPage,
        this.page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
    },
  },
};
</script>

<style scoped>
.search {
}
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267

子组件

<template>
  <div class="dt-line">
    <el-scrollbar>
      <basic-container>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>地铁线路</span>
          </div>
          <el-tree
            :data="deptTree"
            :props="defaultProps"
            node-key="id"
            :current-node-key="defaultId"
            default-expand-all="true"
            highlight-current
            @node-click="handleNodeClick"
          ></el-tree>
        </el-card>
      </basic-container>
    </el-scrollbar>
  </div>
</template>

<script>
export default {
  name: "dtLine",
  data() {
    return {
      data: [],
      defaultProps: {
        children: "children",
        label: "title",
      },
      defaultId: "",
    };
  },
  props: {
    deptTree: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  created() {
    this.defaultId = localStorage.getItem("deptId");
  },
  methods: {
    handleNodeClick(data) {
      this.$emit("line-click", data);
    },
  },
};
</script>

<style scoped>
.dt-line {
  height: 800px;
}
.dt-line .el-scrollbar__wrap {
  overflow: scroll;
}

.dt-line .box-card /deep/ .el-card__body {
  padding: 0 !important;
  margin-top: 15px;
}

.dt-line
  .el-tree--highlight-current
  .el-tree-node.is-current
  > .el-tree-node__content {
  color: #4d95fd;
  font-weight: bold;
}
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/641967
推荐阅读
相关标签
  

闽ICP备14008679号