ruoyi学习
1、可选择的选择框
v-model:传入的参数
clearable:可以将选择的内容进行清除
@keyup.enter.native=“handleQuery”:相关联的函数名
获取dept具体的名称:
import { listDept } from "@/api/system/dept";
created() {this.getList();listDept(this.queryParams).then(response => {this.deptList = response.data;//this.deptList = this.handleTree(response.data, "");this.loading = false;});
},
效果:

2、将页面表格中的id转化为对应的名称
一、对应标签存在于字典数据内
export default {name: "Security",dicts: ['da_safe_facility'],//添加具体的字典类型data() {....}
}
options内添加的属于da_safe_facility类型的字典列表。
value对应具体的id。
最后需要添加一个dicts属性,具体的实现过程ruoyi已存在。
二、对应标签存在于其他表,需要进行联表查询
首先需要将实体类添加一个具体的名称字段
@Excel(name = "部门")
private String dept;
之后在Mapper的文件中,同样添加名称属性字段
<result property="dept" column="dept" />
对select查询语句进行重写,进行联表查询
<select id="selectDaFireFacilityList" parameterType="DaFireFacility" resultMap="DaFireFacilityResult">select id, name, place, type, buy_time, keep_time, count, manager, df.dept_id,group_concat(sd.dept_name) AS dept, year, df.create_by, df.create_time, df.update_by, df.update_time, df.remark from da_fire_facility df left join sys_dept sd on find_in_set(sd.dept_id,df.dept_id )<where><if test="deptId != null "> and df.dept_id = #{deptId}if><if test="year != null and year != ''"> and year = #{year}if>where>group by df.id order by year desc
select>
最后,在前端页面只需要添加下列语句就可以显示了。
界面:

3、判断是否为管理员
需要在controller层进行判断:
boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
ruoyi内部的实现代码为:
public static boolean isAdmin(Long userId)
{return userId != null && 1L == userId;
}
这里的逻辑是有些问题的,可以根据具体需求在这里进行修改。
4、雪花算法
雪花算法主要是用来生成不同的id,使用IdUtil工具类可以获取。
daFireFacility.setId(IdUtil.getSnowflake().nextId());
5、固定页面中的表格列
使用fixed属性确定固定在哪边。
6、使用弹出框查看图片
:visible.sync 这个dialog绑定的名称,用来判断是否可以看到。
在下面的js里面赋值给dialogVisible,让他可以展示出来。其中process.env.VUE_APP_BASE_API是前缀,后面获取的实URL
import {listTemplate} from "@/api/cdzq/template";
export default {name: "Security",data() {return {//url路径url:"",//是否显示图片弹出层dialogVisible : false,}},/** 展示模板按钮操作 */handleShow() {listTemplate().then(response => {for(var i=0;i<response.total;i++){if(response.rows[i].templatetype==6){this.url = process.env.VUE_APP_BASE_API+response.rows[i].templatevalue;}}this.dialogVisible = true;this.title = "安防设施情况登记表模板";});},/** 模板取消操作 */handleCancel() {this.dialogVisible = false;},
}
7、serialversionuid的作用
serialversionuid的作用是验证版本一致性。如果serialversionuid一致,说明他们的版本是一样的。反之,就说明版本不同,就无法运行或使用相关功能。
private static final long serialVersionUID = 1L;
8、大数据量插入sql语句(批处理)
在使用批处理指令时在连接串后面加上 rewriteBatchedStatements=true,代表允许重写批处理指令提交,以及此时的sql语句一定不能有分号,否则有【BatchUpdateException】异常.
private final String url ="jdbc:mysql://localhost:3306/database_sf?Shanghai&&rewriteBatchedStatements=true";ps = connection.prepareStatement(sql);for (int i = 1; i <= 10000; i++) {ps.setObject(1, i);ps.addBatch();if (i%100==0){ps.executeBatch();ps.clearBatch();}}
9、学习ruoyi的网站
ruoyi学习文档:http://doc.ruoyi.vip/ruoyi/
element学习文档:https://element.eleme.cn/#/zh-CN/component/installation
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
