您的位置:首页 > 科技 > 能源 > app开发公司哪里做_网站logo是什么意思_文件关键词搜索工具_周口搜索引擎优化

app开发公司哪里做_网站logo是什么意思_文件关键词搜索工具_周口搜索引擎优化

2024/10/6 8:51:10 来源:https://blog.csdn.net/Leslie_Lei/article/details/142547150  浏览:    关键词:app开发公司哪里做_网站logo是什么意思_文件关键词搜索工具_周口搜索引擎优化
app开发公司哪里做_网站logo是什么意思_文件关键词搜索工具_周口搜索引擎优化

最简单页面

  1. 日期范围及字符搜索,监听器处理日期范围搜索控件清空重置问题
  2. 导出、导出文件文件名称带日期时间
  3. 表格日期指定格式显示
  4. 。。。
<template><div class="app-container"><el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px"><el-form-item label="申请日期"><el-date-pickerv-model="queryParams.queryDate"style="width: 240px"value-format="yyyy-MM-dd"type="daterange"range-separator="-"start-placeholder="开始日期"end-placeholder="结束日期"></el-date-picker></el-form-item><el-form-item label="姓名" prop="name"><el-inputv-model="queryParams.name"placeholder="请输入..."clearable@keyup.enter.native="handleQuery"/></el-form-item><el-form-item><el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button><el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button></el-form-item></el-form><el-row :gutter="10" class="mb8"><el-col :span="1.5"><el-buttontype="warning"plainicon="el-icon-download"size="mini"@click="handleExport"v-hasPermi="['Leslie:Lee:export']">导出</el-button></el-col><right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar></el-row><el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" border :max-height="tableMaxHeight"><el-table-column type="selection" width="55" align="center"/><el-table-column label="ID" align="center" prop="id" width="100" :show-overflow-tooltip='true' v-if="false"/><el-table-column label="姓名" align="center" prop="name" width="200" :show-overflow-tooltip="true"/><el-table-column label="申请日期" align="center" prop="applicationDate" width="100"><template slot-scope="scope"><span>{{ parseTime(scope.row.applicationDate, '{y}-{m}-{d}') }}</span></template></el-table-column></el-table><paginationv-show="total>0":total="total":page.sync="queryParams.pageNum":limit.sync="queryParams.pageSize"@pagination="getList"/></div>
</template><script>
import {queryDataList} from "@/api/leslie/lee.js";export default {name: "Leslie Lee",data() {return {// 遮罩层loading: true,// 选中数组ids: [],// 非单个禁用single: true,// 非多个禁用multiple: true,// 显示搜索条件showSearch: true,// 总条数total: 0,// 弹出层标题title: "",// 是否显示弹出层open: false,// 表单参数form: {},// 表单校验rules: {},// 数据集合dataList: [],// 查询参数queryParams: {// 页码、页显示量pageNum: 1,pageSize: 10,// 日期查询控件值集合queryDate: null,// 日期范围查询开始、结束startDate: null,endDate: null,// 其他查询参数id: null,name: null,applicationDate: null,},/** queryParams 范围 */};/** return 范围 */},/** data 范围 */created() {this.getList();},/** created 范围 */computed: {/** 页面适应 */tableMaxHeight() {const screenHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;return screenHeight - 230;}},/** computed 范围 */methods: {/** 数据查询 */getList() {this.loading = true;this.queryParams.params = {};if (this.queryParams.queryDate != null && this.queryParams.queryDate !== '') {this.queryParams.startDate = this.queryParams.queryDate[0];this.queryParams.endDate = this.queryParams.queryDate[1];}queryDataList(this.queryParams).then(response => {this.dataList = response.rows;this.total = response.total;this.loading = false;});},// 取消按钮cancel() {this.open = false;this.reset();},// 表单重置reset() {this.form = {};this.resetForm("form");},/** 搜索按钮操作 */handleQuery() {this.queryParams.pageNum = 1;this.getList();},/** 重置按钮操作 */resetQuery() {this.queryParams.queryDate = null;this.queryParams.startDate = null;this.queryParams.endDate = null;this.resetForm("queryForm");this.handleQuery();},// 多选框选中数据handleSelectionChange(selection) {this.ids = selection.map(item => item.oddNumbers)this.single = selection.length !== 1this.multiple = !selection.length},/** 导出按钮操作 */handleExport() {var date = new Date()var year = date.getFullYear().toString()var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString()var day = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate().toString()var h = date.getHours() < 10 ? '0' + date.getHours().toString() : date.getHours().toString()var m = date.getMinutes() < 10 ? '0' + date.getMinutes().toString() : date.getMinutes().toString()var s = date.getSeconds() < 10 ? '0' + date.getSeconds().toString() : date.getSeconds().toString()var dateTime = year + '-' + month + '-' + day + "_" + h + m + sthis.download('Leslie/Lee/export', {...this.queryParams}, `导出_${dateTime}.xlsx`)}},/** methods 范围 */watch: {// 监听日期清理后数据为null进行处理否则会报错'queryParams.queryDate'(newVal) {if (newVal == null) {this.queryParams.queryDate = ''this.queryParams.startDate = ''this.queryParams.endDate = ''}}},/** watch 范围 */};
</script>

 表头居中

el-table 中加入 :header-cell-style="headerCellStyle"

设置表头居中,使 align 属性生效不冲突表头格式

 函数写在 methods

    headerCellStyle({column, rowIndex, columnIndex, cellStyle}) {return {textAlign: 'center'};},

表格合计行

el-table 中加入:show-summary :summary-method="getSummaries"

表格最下方出现合计行,但不会随导出出现在导出文件中

可设置 显示千分位

 函数写在 methods

getSummaries(param) {const {columns, data} = param;const sums = [];columns.forEach((column, index) => {if (index === 0) {sums[index] = '合计';return;}const values = data.map(item => Number(item[column.property]));if (!values.every(value => isNaN(value))) {sums[index] = values.reduce((prev, curr) => {const value = Number(curr);if (!isNaN(value)) {return prev + curr;// 保留两位小数//return Math.round((prev + value) * 100) / 100;} else {return prev;}}, 0);sums[index] += '';//显示千分位//sums[index] = sums[index].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");} else {sums[index] = '';}});return sums;},

 合并行

设置哪几列符合什么条件后,值相等的行合并

仅写函数,不需要其他配置

函数写在 methods 中 

handleSpanMethod({row, // 行column, // 列rowIndex, // 行索引columnIndex, // 列索引}) {if (columnIndex === 1 || columnIndex === 2) {/**表格数据:this.dataList判断合并行数:this.mergeColumn()*/const _row = (this.mergeColumn(this.dataList).one)[rowIndex]const _col = _row > 0 ? 1 : 0return {rowspan: _row,colspan: _col}}},/**合并行配套方法*/mergeColumn(data) {const spanOneArr = []let concatOne = 0data.forEach((item, index) => {if (index === 0) {spanOneArr.push(1)} else {//条件if (item.name === data[index - 1].name) { //第一列需合并相同内容的字段spanOneArr[concatOne] += 1spanOneArr.push(0)} else {spanOneArr.push(1)concatOne = index}}})return {one: spanOneArr}},

获取当月第一天~最后一天

可用于设置日期范围搜索默认值

函数写在 methods 中  

    defaultDate() {var date = new Date()var year = date.getFullYear().toString()var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString()var da = new Date(date.getFullYear(), month, 0).getDate()da < 10 ? '0' + da.toString() : da.toString()var beg = year + '-' + month + '-01'var end = year + '-' + month + '-' + dathis.queryParams.queryDate = [beg, end] //将值设置给插件绑定的数据},

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com