el-table表格排序(需要后端判别),el-table导出功能(向后端发送请求)

(1)表格排序

(2)简单的table导出功能(需要后台支撑)必须要有iframe

(3)页面所有代码:

<template>
  <div class="mainContainer">
    <el-form
      :model="form"
      ref="form"
      label-width="100px"
      label-position="left"
      class="scoreForm"
    >
      <el-form-item class="examTopdiv">
        <el-col :span="8">
          <el-form-item label="时间">
            <el-col :span="11">
              <el-form-item prop="startTime">
                <el-date-picker
                  size="small"
                  type="date"
                  placeholder="选择日期"
                  v-model="form.startTime"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col class="line" :span="2">-</el-col>
            <el-col :span="11">
              <el-form-item prop="endTime">
                <el-date-picker
                  size="small"
                  type="date"
                  placeholder="选择日期"
                  v-model="form.endTime"
                ></el-date-picker>
              </el-form-item>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="人员姓名" prop="userName" class="name">
            <el-input
              size="small"
              v-model="form.userName"
              placeholder="姓名"
              maxlength="20"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item style="display: inline-block">
            <el-form-item label="学号" prop="studentNo" class="name">
              <el-input
                size="small"
                v-model="form.studentNo"
                placeholder=""
                maxlength="20"
              ></el-input>
            </el-form-item>
          </el-form-item>
        </el-col>
        <el-col :span="8" class="colMain">
          <el-button size="small" @click="onSearch" class="operBtn">
            <i class="el-icon-query1 el-icon--left"></i>查询</el-button
          >
          <el-button size="small" @click="onResetForm" class="operBtn">
            <i class="el-icon-reset1 el-icon--left"></i>重置</el-button
          >
          <el-button class="exportButton" size="small" @click="onExportTable"
            ><i class="el-icon-expert1 el-icon--left"></i>导出</el-button
          >
        </el-col>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading"
      element-loading-background="transparent"
      :data="tableData"
      empty-text=" "
      border
      id="mainTable"
      stripe
      height="calc(100% - 90px)"
      style="width: 100%"
      @sort-change="sortChange"
    >
      <el-table-column
        type="index"
        align="center"
        label="序号"
        :index="indexMethod"
        width="80"
      >
      </el-table-column>
      <el-table-column
        prop="userName"
        align="center"
        label="姓名"
        sortable="custom"
      >
      </el-table-column>
      <el-table-column
        prop="studentNo"
        align="center"
        sortable="custom"
        label="学号"
      >
      </el-table-column>
      <el-table-column
        prop="duration"
        align="center"
        label="练习时长"
        sortable="custom"
      >
      </el-table-column>
      <el-table-column
        prop="avgScore"
        align="center"
        sortable="custom"
        label="平均分"
      >
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="form.pageIndex"
      :limit.sync="form.pageSize"
      @pagination="getAllExamData"
    />

    <!-- <PDFExport
      :dialogPDFExportFormVisible.sync="dialogPDFExportFormVisible"
      @handleFormVisible="setPDFExportFormVisible"
      :PDFExportData.sync="selectPDFExportData"
    ></PDFExport> -->
    <iframe id="export" style="display: none"></iframe> 
  </div>
</template>

<script>
// import PDFExport from "@/views/sim/score/pdfExport.vue";
import pagination from "@/components/Pagination";
import { pagePersonStat } from "@/api/sim/personnelStatistics.js";

export default {
  components: { pagination },
  data() {
    return {
      form: {
        startTime: this.$timeManage.days90Time().startTime,
        endTime: this.$timeManage.days90Time().endTime,
        studentNo: "",
        userName: "",
        trainType: "1",
        pageIndex: 0,
        pageSize: 20,
        sortField: "",
        sortOrder: "",
      },
      loading: true,
      examNames: [],
      total: 0,
      dialogFormVisible: false,
      dialogPDFExportFormVisible: false,
      manualScoreDlgVisible: false,
      selectData: "", //详情页面传递值
      manualSelectData: null,
      score: "",
      selectPDFExportData: "", //pdf导出页面传递值
      tableData: [],
    };
  },
  methods: {
    // 分页序号
    indexMethod(index) {
      index = index + 1 + this.form.pageIndex * this.form.pageSize;
      return index;
    },
    // 查询所有表格信息
    getAllExamData() {
      if (
        this.form.startTime > this.form.endTime &&
        this.form.startTime != null &&
        this.form.endTime != null
      ) {
        this.$message.error("开始时间不能大于结束时间");
        this.loading = false;
      } else {
        pagePersonStat(this.form).then((res) => {
          this.tableData = res.data.data;
          this.total = res.data.total;
          this.loading = false;
        });
      }
    },
    //分数详情页面
    detailScore(index, row) {
      this.dialogFormVisible = true;
      this.selectData = row.exerId;
      this.score = row.totalGrade;
    },
    // 导出pdf页面
    exportPdf(index, row) {
      // console.log("222222" + row.exerId)
      this.selectPDFExportData = row.exerId;
      this.dialogPDFExportFormVisible = true;
    },
    addManualScore(index, row) {
      this.manualSelectData = row.exerId;
      this.manualScoreDlgVisible = true;
    },
    //父组件事件
    setFormVisible(val) {
      //console.log("子组件的值======" + JSON.stringify(val));
      this.dialogFormVisible = val.dialogFormVisible;
      this.getAllExamData();
    },

    //父组件事件
    setPDFExportFormVisible(val) {
      this.dialogPDFExportFormVisible = val.dialogPDFExportFormVisible;
    },
    setManualFormVisible(val) {
      this.manualScoreDlgVisible = val.dialogFormVisible;
      this.getAllExamData();
    },
    // 重置
    onResetForm() {
      this.resetForm();
      this.getAllExamData();
    },

    resetForm() {
      this.$refs["form"].resetFields();
    },
    // 查询
    onSearch() {
      this.loading = true;
      var result = this.$timeManage.validate90Days(
        this.form.startTime,
        this.form.endTime
      );
      if (result != "true") {
        this.$message({
          type: "error",
          message: result,
        });
        this.loading = false;
      } else {
        this.getAllExamData();
      }
    },
    // 导出表格
    onExportTable() {
      if (this.tableData == null || this.tableData.length == 0) {
        this.$message({
          type: "warning",
          message: "数据为空,不能导出!",
        });
        return;
      }
      let tempForm = JSON.parse(JSON.stringify(this.form));
      let titleName = "人员统计";
      titleName = encodeURI(titleName);
      let dataStr = encodeURI(JSON.stringify(tempForm));
      document.getElementById("export").src =
        "/les/excel/back/export?serviceName=personStatExport&title=" +
        titleName +
        "&vars=" +
        dataStr;
    },

    //表头排序
    sortChange(param) {
      this.form.sortField = param.prop;
      var order = param.order;
      if (order == "ascending") {
        this.form.sortOrder = "asc";
      } else if (order == "descending") {
        this.form.sortOrder = "desc";
      }
      this.getAllExamData();
    },
  },
  created() {},
  mounted() {
    this.getAllExamData();
  },
};
</script>
    
<style scoped>
.examTopdiv {
  height: 40px;
  line-height: 40px;
  /* background: linear-gradient(to right,#88bfcf, #b6e0d7); */
  background: #3b424d;
  margin-bottom: 0px;
}

.examTopdiv >>> .el-form-item__content {
  line-height: 40px;
  margin-left: 0px;
}
/* .examTopdiv .el-input__inner{
  background: #e6e6e6;
  border-radius: 0px;
  border: 1px solid #B3B3B3;
} */
.examTopdiv > .el-form-item__content {
  margin-left: 0px !important;
}
.examTopdiv >>> .el-form-item__label {
  line-height: 40px;
  font-size: 14px;
  text-align: right;
}
.exportButton {
  margin-right: 16px;
}
.examHeader {
  height: 40px !important;
}
.examTopdiv >>> .line {
  text-align: center;
}

.formHeader {
  height: 40px !important;
}

/* .el-table th{
    background: #b4ded7;
    color: #606266;
  } */
/* #mainTable .el-table th>.cell{
     font-size: 18px;
  } */

.mainContainer {
  height: calc(100vh - 100px);
  overflow: hidden;
}

.colMain {
  text-align: right;
}

.examTopdiv >>> .el-date-editor.el-input,
.examTopdiv >>> .el-date-editor.el-input__inner {
  width: 100%;
}
.scoreForm {
  margin-bottom: 10px;
}

.el-icon-expert1 {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  background: url("../../../assets/target/expert.png") no-repeat;
}

.el-icon-reset1 {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  background: url("../../../assets/target/reset.png") no-repeat;
}

.el-icon-query1 {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  background: url("../../../assets/target/query.png") no-repeat;
}

/* .operBtn {
    font-Size:16px;
    width: 113px;
    height: 38px;
    vertical-align: middle;
    opacity: 1;
    border: none;
    background: url("../../../assets/menu/corner.png");
}

.operBtn:focus,.operBtn:hover{
    text-shadow: 0 0 10px rgb(58, 135, 235),0 0 20px rgb(58, 135, 235),0 0 30px rgb(58, 135, 235),0 0 40px rgb(58, 135, 235);
} */

.el-icon-check1 {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  background: url("../../../assets/target/check.png") no-repeat;
}

.el-icon-preview1 {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  background: url("../../../assets/target/preview.png") no-repeat;
}

.el-icon--left {
  padding-right: 6px;
  padding-bottom: 6px;
}

.el-icon--right {
  padding-right: 5px;
  padding-bottom: 6px;
}
</style>

<style>
.examTopdiv > .el-form-item__content {
  margin-left: 0px !important;
}

.el-input__inner {
  border: #2d3035 1px solid;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/180073.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

护眼台灯怎么样选择?口碑最好的五款护眼台灯推荐

7月13日&#xff0c;国家卫生健康委疾控局公布了一项覆盖了全国8604所学校&#xff0c;247.7万名学生的近视专项调查结果。结果显示&#xff0c;2020年&#xff0c;我国儿童青少年总体近视率为52.7%&#xff1b;其中6岁儿童为14.3%&#xff0c;小学生为35.6%&#xff0c;初中生…

Find My按摩仪|苹果Find My技术与按摩仪结合,智能防丢,全球定位

工作生活中&#xff0c;颈椎总会经常不舒服&#xff0c;尤其像我们这种低头族&#xff0c;上班用电脑&#xff0c;下班玩手机&#xff0c;每天的颈椎保持一个状态而得不到休息&#xff0c;从而让我们的颈椎不舒服&#xff0c;患上了颈椎病。颈椎僵硬&#xff0c;肌肉紧张&#…

win10底部任务栏无响应?试试这些方法!

win10的任务栏是一个关键的用户界面元素&#xff0c;允许您轻松访问应用程序和系统功能。然而&#xff0c;有时您可能会遇到win10底部任务栏无响应的问题&#xff0c;这会妨碍您的工作流程。本篇文章将介绍解决win 10底部任务栏无响应的问题的三种方法&#xff0c;每种方法都会…

比例减压阀放大器选型

控制阀型如比例插装阀、比例方向阀、比例压力阀、比例流量阀、比例叠加阀等&#xff0c;安装方式有插式及导轨卡槽式&#xff0c;输入指令可选0-10V、4-20mA、10V、0-5V&#xff0c;输出电流可选最大3A&#xff0c;适用各大品牌不带电反馈常规比例阀匹配度&#xff0c;控制比例…

Android项目更新依赖和打包步骤和问题汇总

目录 1、Android 项目打包&#xff0c;32位包升级到64位包问题一&#xff1a;ERROR: Conflicting configuration : armeabi-v7a,x86-64,arm64-v8a,x86 in ndk abiFilters cannot be present when splits abi filters are set : x86,armeabi-v7a,arm64-v8a 2、Android项目依赖升…

ubuntu22.04 git 安装

安装git&#xff1a;默认情况下&#xff0c;Git 在 ubuntu 22.04 基础存储库中可用。 现在运行以下命令在您的 Ubuntu 系统上安装最新版本的 Git&#xff1a; 查看当前版本号 git --version

第二证券:买国债逆回购的5个技巧?国债逆回购有什么技巧?

买国债逆回购存在以下五个技巧&#xff1a; 1、在周四买一天期的国债逆回购 出资者在周四购买1天期的国债逆回购&#xff0c;实践收益会按3天核算&#xff0c;一同&#xff0c;资金在周五依然可用于出资并获取收益。 2、节假日前买国债逆回购 国债逆回购收益率跟商场的资金…

Flink CDC -Sqlserver to Sqlserver java 模版编写

1.基本环境 <flink.version>1.17.0</flink.version> 2. 类文件 package com.flink.tablesql;import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.flink.streaming.api.environment.StreamExecutionEnviro…

oracle数据库巡检常见脚本-系列二

简介 作为数据库管理员&#xff08;DBA&#xff09;&#xff0c;定期进行数据库的日常巡检是非常重要的。以下是一些原因&#xff1a; 保证系统的稳定性&#xff1a;通过定期巡检&#xff0c;DBA可以发现并及时解决可能导致系统不稳定的问题&#xff0c;如性能瓶颈、资源利用率…

MEMS制造的基本工艺——晶圆键合工艺

晶圆键合是一种晶圆级封装技术&#xff0c;用于制造微机电系统 (MEMS)、纳米机电系统 (NEMS)、微电子学和光电子学&#xff0c;确保机械稳定和气密密封。用于 MEMS/NEMS 的晶圆直径范围为 100 毫米至 200 毫米&#xff08;4 英寸至 8 英寸&#xff09;&#xff0c;用于生产微电…

提升企业财务管理效率的首选软件——Manager for Mac

Manager for Mac作为一款功能强大且用户友好的企业会计软件&#xff0c;不仅能够提升企业的财务管理效率&#xff0c;还能够保护企业财务数据的安全性和稳定性。如果您正在寻找一款适合Mac平台的企业会计软件&#xff0c;不妨选择Manager for Mac&#xff0c;让您的企业财务管理…

企业微信身份验证

本篇主要是在上一篇获取第三方凭证基础上&#xff0c;用户通过三方网站自定义授权登录后获取用户信息&#xff0c;以实现用户绑定登录功能。 构造第三方应用授权链接 如果第三方应用需要在打开的网页里面携带用户的身份信息&#xff0c; 第一步需要构造如下的链接来获取授权c…

opencv-Hough 直线变换

Hough 直线变换是一种在图像中检测直线的技术。它通过在极坐标空间中表示图像中的直线&#xff0c;将直线检测问题转换为参数空间的累加问题。OpenCV 提供了 cv2.HoughLines() 和 cv2.HoughLinesP() 函数来执行 Hough 直线变换。 cv2.HoughLines() lines cv2.HoughLines(ima…

iOS APP包分析工具 | 京东云技术团队

介绍 分享一款用于分析iOSipa包的脚本工具&#xff0c;使用此工具可以自动扫描发现可修复的包体积问题&#xff0c;同时可以生成包体积数据用于查看。这块工具我们团队内部已经使用很长一段时间&#xff0c;希望可以帮助到更多的开发同学更加效率的优化包体积问题。 工具下载…

深度学习之六(自编码器--Autoencoder)

概念 自编码器(Autoencoder)是一种神经网络架构,用于无监督学习和数据的降维表示。它由两部分组成:编码器(Encoder)和解码器(Decoder)。 结构: 编码器(Encoder): 接收输入数据并将其压缩为潜在表示(latent representation),通常比输入数据的维度要低。编码器的…

探索结构体的奥秘

目录 &#x1f342;结构体 1&#xff0c;结构体的声明 1.1 结构的基础知识 1.2 结构的声明 1.3 特殊的声明 1.4 结构的自引用 1.5 结构体变量的定义和初始化 1.6 结构体内存对齐 1.6.1 如何计算 1.6.2 为什么存在内存对齐 1.7 修改默认对齐数 1.8 结构体传参 2&am…

小型内衣裤洗衣机哪个牌子好?性价比小型洗衣机推荐

内衣内裤应该如何清洗才能实现在不伤衣的同时有能够洗干净呢&#xff1f;其实除了使用温水搭配手洗以外&#xff0c;还有一些清洗方式&#xff0c;那就是选择一台专门为内衣定制的内衣洗衣机。目前内衣洗衣机由于精致小巧&#xff0c;方便安装&#xff0c;方便使用&#xff0c;…

常见网络安全防护

1 阻断服务攻击&#xff08;DOS&#xff09; 阻断服务攻击&#xff0c;想办法目标网络资源用尽变种&#xff1a;分布式阻断服务攻击 影响&#xff1a; 宽带消耗性&#xff08;消耗目标的带宽&#xff09;资源消耗型&#xff08;消耗目标的计算资源&#xff09; 解决方案&am…

【OpenCV+OCR】计算机视觉:识别图像验证码中指定颜色文字

文章目录 1. 写在前面2. 读取验证码图像3. 生成颜色掩码4. 生成黑白结果图5. OCR文字识别6. 测试结果 【作者主页】&#xff1a;吴秋霖 【作者介绍】&#xff1a;Python领域优质创作者、阿里云博客专家、华为云享专家。长期致力于Python与爬虫领域研究与开发工作&#xff01; 【…

易点易动设备管理系统提升设备能耗管理和设备状态监控效率

如今&#xff0c;能源效率和设备状态监控对于企业来说变得越发重要。传统的设备管理方式往往存在能耗浪费和难以实时监控设备状态的问题。为了解决这些问题&#xff0c;易点易动设备管理系统应运而生。本文将介绍易点易动设备管理系统的功能和优势&#xff0c;以及如何通过它提…
最新文章