Vue前端项目-用户管理-条件搜索界面
目录
1、用户管理页面
2、导入Element-UI相关组件
3、添加全局样式
4、全局挂载获取字典的方法
5、获取字典方法
6、全局挂载重置表单方法
7、重置表单方法
8、Controller层代码
9、Service接口层
10、Service接口实现类层
11、Mapper接口
12、Model实体类
13、常量类
14、映射描述文件
实现效果图:
1、用户管理页面
在 src / views / system / user / index.vue 中,将布局分成 2 列, 然后添加条件搜索表单
<template><div class="app-container"><el-row :gutter="20"><el-col :span="4" :xs="24">111</el-col><el-col :span="20" :xs="24"><el-form :model="queryParams" label-width="68px" ref="queryForm" :inline="true"><el-form-item label="用户名称" prop="userName"><el-input v-model="queryParams.userName" placeholder="请输入用户名称"clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" /></el-form-item><el-form-item label="手机号码" prop="phonenumber" ><el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码"clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" /></el-form-item><el-form-item label="状态" prop="status"><el-select v-model="queryParams.status" placeholder="用户状态" clearable size="small" style="width: 240px"><el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"/></el-select></el-form-item><el-form-item label="创建时间"><el-date-picker v-model="dateRange" size="small" 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><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-table :data="userList"><el-table-columntype="selection"width="40"align="center"/><el-table-columnlabel="用户编号"align="center"prop="userId"/><el-table-columnlabel="用户名称"align="center"prop="userName"/><el-table-columnlabel="用户昵称"align="center"prop="nickName"/><el-table-columnlabel="部门"align="center"prop="dept.deptName"/><el-table-columnlabel="手机号码"align="center"prop="phonenumber"width="120"/><el-table-columnlabel="状态"align="center"><!-- 通过 slot-scope="scope" 接收数据 --><template slot-scope="scope"><!-- scope.row 接收这一行数据 active-value: switch 打开时的值, inactive-value: switch 关闭时的值 --><el-switchv-model="scope.row.status"active-value="0"inactive-value="1"></el-switch></template></el-table-column><el-table-columnlabel="创建时间"align="center"prop="createTime"width="160"><template slot-scope="scope"><span>{{ parseTime(scope.row.createTime) }}</span></template></el-table-column><el-table-columnlabel="操作"align="center"width="180"class-name="small-padding fixed-width"><template slot-scope="scope"><el-buttonsize="mini"type="text"icon="el-icon-edit"@click="handleUpdate(scope.row)">修改</el-button><el-buttonv-if="scope.row.userId !== 1"size="mini"type="text"icon="el-icon-delete"@click="handleDelete(scope.row)">删除</el-button><el-buttonsize="mini"type="text"icon="el-icon-key"@click="handleResetPwd(scope.row)">重置</el-button></template></el-table-column></el-table><!-- 分页组件 --><paginationv-show="total>0":total="total":page.sync="queryParams.pageNum":limit.sync="queryParams.pageSize"@pagination="getList"/></el-col></el-row></div>
</template><script type="text/ecmascript-6">
import { listUser } from '@/api/system/user'
export default {name: '',data() {return {// 用户表格数据userList: null,// 总条数total: 0,// 查询参数queryParams: {pageNum: 1,pageSize: 10,userName: undefined,phonenumber: undefined,status: undefined,deptId: undefined},// 日期范围dateRange: [],// 状态数据字典statusOptions: []}},components: {},methods: {/** 查询用户列表 */getList() {// addDateRange 方法在 main.js中全局挂载listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {this.userList = response.rowsthis.total = response.total// this.loading = false;})},/** 搜索按钮操作 */handleQuery() {this.queryParams.page = 1this.getList()},/** 重置按钮操作 */resetQuery() {this.dateRange = []this.resetForm('queryForm')this.handleQuery()}},created() {this.getList()this.getDicts('sys_normal_disable').then(response => {this.statusOptions = response.data})}
}
</script><style lang="scss" scoped>
</style>
2、导入Element-UI相关组件
在 src / plugins / element.js 中添加相关组件
import { DatePicker, Select, Option, Row, Col } from 'element-ui'Vue.use(DatePicker)
Vue.use(Select)
Vue.use(Option)
Vue.use(Row)
Vue.use(Col)
3、添加全局样式
在 src / assets / styles / index.scss 中, 新增全局样式
label {font-weight: 700;
}
//main-container全局样式
.app-container {padding: 20px;
}
4、全局挂载获取字典的方法
在 src / veiws / system / user / index.vue 中的created方法 调用了 this.getDicts('sys_normal_disable') 来获取 用户状态数据(下拉框)
因此需要在 main.js 中全局挂载这个方法才能使用.
在 src / main.js 中
import { getDicts } from '@/api/system/dict/data'Vue.prototype.getDicts = getDicts
5、获取字典方法
创建 src / api / system / dict / data.js 文件 ,内容:
import request from '@/utils/request'// 根据字典类型查询字典数据信息
export function getDicts(dictType) {return request({url: '/system/dict/data/dictType/' + dictType,method: 'get'})
}
6、全局挂载重置表单方法
在 src / main.js 中,新增重置表单方法
import { addDateRange, parseTime, resetForm } from '@/utils/ruoyi'Vue.prototype.resetForm = resetForm
7、重置表单方法
在 src / utils / ruoyi.js 文件中,新增重置表单方法:
// 表单重置
export function resetForm(refName) {if (this.$refs[refName]) {this.$refs[refName].resetFields()}
}
8、Controller层代码
package com.ruoyi.project.system.controller;
/*** 数据字典信息** @author ruoyi*/
@RestController
@RequestMapping("/system/dict/data")
@CrossOrigin
public class SysDictDataController extends BaseController {@Resourceprivate ISysDictDataService dictDataService;/*** 根据字典类型查询字典数据信息*/@GetMapping(value = "/dictType/{dictType}")public AjaxResult dictType(@PathVariable String dictType){return AjaxResult.success(dictDataService.selectDictDataByType(dictType));}
}
9、Service接口层
package com.ruoyi.project.system.service;
/*** 字典 业务层** @author ruoyi*/
public interface ISysDictDataService {/*** 根据字典类型查询字典数据** @param dictType 字典类型* @return 字典数据集合信息*/public List<SysDictData> selectDictDataByType(String dictType);}
10、Service接口实现类层
package com.ruoyi.project.system.service.impl;
/*** 字典 业务层处理** @author ruoyi*/
@Service
public class SysDictDataServiceImpl implements ISysDictDataService {@Resourceprivate SysDictDataMapper dictDataMapper;/*** 根据字典类型查询字典数据** @param dictType 字典类型* @return 字典数据集合信息*/@Overridepublic List<SysDictData> selectDictDataByType(String dictType) {return dictDataMapper.selectDictDataByType(dictType);}}
11、Mapper接口
package com.ruoyi.project.system.mapper;
/*** 字典表 数据层** @author ruoyi*/
public interface SysDictDataMapper {/*** 根据字典类型查询字典数据** @param dictType 字典类型* @return 字典数据集合信息*/public List<SysDictData> selectDictDataByType(String dictType);}
12、Model实体类
package com.ruoyi.project.system.domain;
/*** 字典数据表 sys_dict_data** @author ruoyi*/
public class SysDictData extends BaseEntity
{private static final long serialVersionUID = 1L;/** 字典编码 */private Long dictCode;/** 字典排序 */private Long dictSort;/** 字典标签 */private String dictLabel;/** 字典键值 */private String dictValue;/** 字典类型 */private String dictType;/** 样式属性(其他样式扩展) */private String cssClass;/** 表格字典样式 */private String listClass;/** 是否默认(Y是 N否) */private String isDefault;/** 状态(0正常 1停用) */private String status;public Long getDictCode(){return dictCode;}public void setDictCode(Long dictCode){this.dictCode = dictCode;}public Long getDictSort(){return dictSort;}public void setDictSort(Long dictSort){this.dictSort = dictSort;}public String getDictLabel(){return dictLabel;}public void setDictLabel(String dictLabel){this.dictLabel = dictLabel;}public String getDictValue(){return dictValue;}public void setDictValue(String dictValue){this.dictValue = dictValue;}public String getDictType(){return dictType;}public void setDictType(String dictType){this.dictType = dictType;}public String getCssClass(){return cssClass;}public void setCssClass(String cssClass){this.cssClass = cssClass;}public String getListClass(){return listClass;}public void setListClass(String listClass){this.listClass = listClass;}public boolean getDefault(){return UserConstants.YES.equals(this.isDefault) ? true : false;}public String getIsDefault(){return isDefault;}public void setIsDefault(String isDefault){this.isDefault = isDefault;}public String getStatus(){return status;}public void setStatus(String status){this.status = status;}@Overridepublic String toString() {return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE).append("dictCode", getDictCode()).append("dictSort", getDictSort()).append("dictLabel", getDictLabel()).append("dictValue", getDictValue()).append("dictType", getDictType()).append("cssClass", getCssClass()).append("listClass", getListClass()).append("isDefault", getIsDefault()).append("status", getStatus()).append("createBy", getCreateBy()).append("createTime", getCreateTime()).append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime()).append("remark", getRemark()).toString();}
}
13、常量类
package com.ruoyi.common.constant;public class UserConstants {/** 是否为系统默认(是) */public static final String YES = "Y";}
14、映射描述文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.system.mapper.SysDictDataMapper"><resultMap type="SysDictData" id="SysDictDataResult"><id property="dictCode" column="dict_code" /><result property="dictSort" column="dict_sort" /><result property="dictLabel" column="dict_label" /><result property="dictValue" column="dict_value" /><result property="dictType" column="dict_type" /><result property="cssClass" column="css_class" /><result property="listClass" column="list_class" /><result property="isDefault" column="is_default" /><result property="status" column="status" /><result property="createBy" column="create_by" /><result property="createTime" column="create_time" /><result property="updateBy" column="update_by" /><result property="updateTime" column="update_time" /></resultMap><sql id="selectDictDataVo">select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remarkfrom sys_dict_data</sql><select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult"><include refid="selectDictDataVo"/>where status = '0' and dict_type = #{dictType} order by dict_sort asc</select></mapper>
Vue前端项目-用户管理-条件搜索界面相关推荐
- Vue前端项目图片管理
场景:项目中使用的图片icon,怎么管理才能更好的提高性能,简化代码,减少图片资源内存等问题. 方案一:雪碧图 方案二: icon font使用 本文重点讲一下icon font 一.制作SVG图片 ...
- Vue前端项目-登录组件-登录框界面
目录 1.登录框组件设计 1.1 表单元素组件注册 1.2 登录组件的结构和样式 2.Icon 图标 2.1 拷贝 font 文件夹到 asserts 目录 2.2 引入 font 的 css 样式 ...
- 为什么vue前端项目要使用nodejs
一.传统的JavaScript 传统的js是运行在浏览器上的,因为浏览器内核分为两个部分: 渲染引擎---渲染HTML和CSS, JavaScript 引擎---负责运行 JavaScript 随着技 ...
- 前端项目统一管理API接口
前端项目统一管理API接口 如今的前端框架层出不穷.应对的项目也是大小不一,微型的项目倒是无所谓文件结构,大多数项目我们都需要做到以下几点 规范文件目录,完善项目结构,以达到开发时思维清晰,错误定位准 ...
- VUE项目学习(一):搭建VUE前端项目
VUE项目学习(一):搭建VUE前端项目 1.安装node.js环境 (1)下载node.js,下载地址为:https://nodejs.org/en/ (2)按照默认选项安装node,检查安装版本 ...
- Vue前端项目【尚品汇】
Vue前端项目[尚品汇] 1. 说明 2. 对项目创建 3.结构 4. 项目运行起来时,浏览器自动打开 5.关闭ESLint校验功能 5.路由分析 6.路由元信息 7. 路由传参 7.1 路由的跳转方 ...
- 多个html如何套用套一个头部,Vue.js项目中管理每个页面的头部标签的两种方法...
在 Vue SPA 应用中,如果想要修改 HTML 的头部标签,如页面的 title ,我们只能去修改 index.html 模板文件,但是这个是全局的修改,如何为每个页面都设置不一样的 title ...
- vue 前端项目部署阿里云服务器
vue 前端项目部署阿里云服务器 one 前期准备 two 代码打包 扔服务器 one 前期准备 首先两个软件应该下载(Xftp Xshell),如果有其他类似的软件也可以. 打开xftp,新建一个会 ...
- cmd搭建vue前端项目详细过程
cmd 搭建vue前端项目 下载nods.js node.js下载(Windows版本) next 安装完毕! 配置node.js环境变量 进入找到Path进入 这里填你的node.js的安装路径 验 ...
最新文章
- Egret学习笔记 (Egret打飞机-3.实现背景循环滚动)
- 前台模板 海豚php_GitHub - cbw1820446/DolphinPHP: 海豚PHP——快速开发框架(基于ThinkPHP5.0.3)...
- MySQL的索引特性
- 以 B2C 和 B2B 方式启动 SAP Spartacus 的批处理文件
- 离散事件模拟(银行业务模拟。实现算法3.6、3.7的程序)
- treemap底层结构_HashMap面试必问的数据结构相关知识总结
- Head First设计模式(中文版)PDF
- 机器学习实验——回归预测算法
- 从0开始学java-day08:eclipse的使用和超市管理系统案例
- 计算机出现假桌面怎么解决办法,Win10系统下“AppHangXProcB1”导致桌面频繁假死如何解决?...
- 浅谈feature-based 和 fine-tune
- Dynamics 365 配置IFD的向导界面下一步按钮禁用的解决办法
- Win10 上切换至Administrator用户
- iPhone屏幕旋转机制详解
- 商务部关于网上交易的指导意见(暂行)
- 1837:Balance
- python pdf转图片 poppler_Python将PDF转成图片—PyMuPDF和pdf2image
- hadoop_hdfs命令
- MATLAB小技巧(20)矩阵分析--主成分回归
- Akka 进阶(二)Mailbox 邮箱