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

news2024/10/1 3:31:42

(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.coloradmin.cn/o/1241825.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Selenium安装WebDriver最新Chrome驱动(114以后的版本)

&#x1f4e2;专注于分享软件测试干货内容&#xff0c;欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1f4dd; 如有错误敬请指正&#xff01;&#x1f4e2;交流讨论&#xff1a;欢迎加入我们一起学习&#xff01;&#x1f4e2;资源分享&#xff1a;耗时200小时精选的「软件测试」资…

都被“锟斤拷”毒害过,那么究竟是为什么会出现这些奇怪的字符?

不管是在工作中还是生活中&#xff0c;都被“锟斤拷”毒害过&#xff0c;比如这样&#xff1a; 或者这样&#xff1a; 还有这样&#xff1a; 那么究竟是为什么会出现这些奇怪的字符&#xff1f; ASCII编码 在计算机底层都是用0和1进行存储的&#xff0c;ASCII编码将所有的字母…

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

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

Navicat 技术指引 | 适用于 GaussDB 的备份与还原功能

Navicat Premium&#xff08;16.2.8 Windows版或以上&#xff09; 已支持对 GaussDB 主备版的管理和开发功能。它不仅具备轻松、便捷的可视化数据查看和编辑功能&#xff0c;还提供强大的高阶功能&#xff08;如模型、结构同步、协同合作、数据迁移等&#xff09;&#xff0c;这…

Linux反弹SHell与检测思路

免责声明 文章仅做经验分享用途,利用本文章所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,作者不为此承担任何责任,一旦造成后果请自行承担!!! 反弹shell payload在线生成 https://www.chinabaiker.com/Hack-Tools/ Online - Reverse Shell G…

C++基础从0到1入门编程(四)类和对象

系统学习C 方便自己日后复习&#xff0c;错误的地方希望积极指正 往期文章&#xff1a; C基础从0到1入门编程&#xff08;一&#xff09; C基础从0到1入门编程&#xff08;二&#xff09; C基础从0到1入门编程&#xff08;三&#xff09; 参考视频&#xff1a; 1.黑马程序员匠心…

docker启动容器失败,然后查看日志,docker logs查看容器出现报错:

docker 启动容器失败&#xff0c;然后docker logs 查看容器出现报错&#xff1a; error from daemon in stream: Error grabbing logs: invalid character l after object key:value pair在网上看到的 解决方案&#xff1a; 找到你日志文件目录&#xff1a; docker inspect …

信用卡不在身上怎么查安全码

信用卡安全码是由3位数字组成的&#xff0c;一般位于信用卡背面签名栏旁边。如果信用卡不在身上&#xff0c;可以通过拨打发卡银行客服热线来查询安全码。但是&#xff0c;安全码是非常私密的信息&#xff0c;客服可能没有权限查询。因此&#xff0c;这个方法不一定有用。另外&…

Ocam——自由录屏工具~

当我们想要做一些混剪、恶搞类型的视频时&#xff0c;往往需要源影视作品中的诸多素材&#xff0c;虽然可以通过裁减mp4文件的方式来获取片段&#xff0c;但在高画质的条件下&#xff0c;mp4文件本身通常会非常大&#xff0c;长此以往&#xff0c;会给剪辑工作带来诸多不便&…

芯片的测试方法

半导体的生产流程包括晶圆制造和封装测试&#xff0c;在这两个环节中分别需要完成晶圆检测(CP, Circuit Probing)和成品测试(FT, Final Test)。无论哪个环节&#xff0c;要测试芯片的各项功能指标均须完成两个步骤&#xff1a;一是将芯片的引脚与测试机的功能模块连接起来&…

CCC联盟——UWB MAC(一)

本文在前面已经介绍了相关UWB的PHY之后&#xff0c;重点介绍数字钥匙&#xff08;Digital Key&#xff09;中关于MAC层的相关实现规范。由于MAC层相应涉及内容比较多&#xff0c;本文首先从介绍UWB MAC的整体框架&#xff0c;后续陆续介绍相关的网络、协议等内容。 1、UWB MAC架…

好用的团队协同办公软件推荐!企业办公必备!

有什么好用的团队协同办公软件可以推荐&#xff1f; 想要的办公软件需要满足“即时通讯”、“多端适配”、“项目管理”、“文件传输”这4大能力。 下面就给大家分享3大类能够满足题主需求的企业级办公软件&#xff0c;免费的付费的都有&#xff0c;也都是侧重的不同领域&…

基于命令行模式设计退款请求处理

前言 这篇文章的业务背景是基于我的另一篇文章: 对接苹果支付退款退单接口-CSDN博客 然后就是说设计模式是很开放的东西,可能我觉得合适,你可能觉得不合适,这里只是做下讨论,没有一定要各位同意的意思.... 相关图文件 这里我先把相关的图文件放上来,可能看着会比较清晰点 代码逻…

[UE4][C++]基于UUserWidget的一种序列图播放方法

最近在做一个大项目&#xff0c;鸽了几个月了....... 一、传统方法Flipbook 这种方法适合序列图较少的情况下、可以一个一个添加进来然后调整顺序。蓝图也比较友好可以直接设置很多属性和功能。这里简单了解一下即可&#xff0c;想要深入了解的同学可以自行搜索。 1.1创建Fli…

手把手云开发小程序-(四)-uniclould增删改查业务开发

一&#xff0c;导入uView 在开发小程序的时候&#xff0c;我习惯使用uView这个ui库。主要是直接用当然比自己写省时间。 它的官网&#xff1a;uView - 多平台快速开发的UI框架 - uni-app UI框架 (gitee.io) 导入&#xff1a; npm install uview-ui2.0.31然后按照官网进行配…

数据库基础入门 — SQL运算符

我是南城余&#xff01;阿里云开发者平台专家博士证书获得者&#xff01; 欢迎关注我的博客&#xff01;一同成长&#xff01; 一名从事运维开发的worker&#xff0c;记录分享学习。 专注于AI&#xff0c;运维开发&#xff0c;windows Linux 系统领域的分享&#xff01; 本…

Qt 软件开发框架(主要几个部分)

目录 1、 一个软件基本要素 &#xff08;1&#xff09;UI模块 &#xff08;2&#xff09;网络模块 &#xff08;3&#xff09;业务逻辑模块 &#xff08;4&#xff09;中间层 &#xff08;5&#xff09;独立模块&#xff08;守护进程、更新模块、日志收集模块…&#xff…

CodeWhisperer 体验总结

CodeWhisperer 体验总结 | CodeWhisperer 是一款亚马逊新推出的通用代码生成器 可以实时进行代码数据的提供 还可以定义安全问题 CodeWhisperer 对个人用户是免费使用 企业用户需要订阅使用 亚马逊云科技开发者社区为开发者们提供全球的开发技术资源。这里有技术文档、开发案例…

电商数据API接口接入|获取京东商品详情数据价格主图描述

企业前台研发部包含了企业业务大部分的对外前台系统&#xff0c;其中京东VOP平台(开放平台)适合于自建内网采购商城平台的企业客户。京东为这类客户专门开发API接口&#xff0c;对接到客户内网的网上商城&#xff0c;将产品SKU直接推送到客户内网&#xff0c;客户内部采购人员可…

华中科技大学李松课题组,利用机器学习预测多孔材料水吸附等温线

By 超神经 多孔材料的水吸附等温线是一个非常重要的参数&#xff0c;但这一参数的获得并不容易。这是因为多孔材料种类过多、结构多元&#xff0c;通过实验和计算的方式获得水吸附等温线数据成本过高&#xff0c;耗时过长。 华中科技大学的李松课题组&#xff0c;建立了一个两步…