- 读取字典,返回数组
this.getDicts("sys_user_sex").then(response => {
console.log(response.data.values || [])
});
- 设置返回id name数组
this.getItems(listDemoGenClass,{pageSize:15}).then(res => {console.log(this.setItems(res, 'id', 'className')) [{key: '1', value: '一班'},{key: '2', value: '一班'}] console.log(res) res.data.list 返回[{id: 2, className: '二班'},{id: 3, className: '二班'}] })
- 配置参数获取
this.getConfigKey(“sys.uploadFile.imageSize”).then(res=>{console.log(res) 名称 res.data.configName 值res.data.configValue }) 没找到res.data=null
- 格式化日期,支持模板中
{{parseTime(new Date().getTime(), '{y}-{m}-{d} {h}:{i}:{s} {a}')}}
使用,不写参数是标准日期时间 以下带星期
let res= this.parseTime(new Date().getTime(), ‘{y}-{m}-{d} {h}:{i}:{s} {a}’)console.log(res)
- 重置表单,可以在模板中
<el-button @click=”resetForm(‘ruleForm’)”>重置
this.resetForm(“form”); form表单名- 添加时间范围
return {
dateRange: [],
queryParams: {
}pageNum: 1, pageSize: 10, roleName: undefined, roleKey: undefined, status: undefined
}
let res = this.addDateRange(this.queryParams, this.dateRange)
console.log(res)
- 添加时间范围
- 回显字典
this.getDicts(“sys_user_sex”).then(resp => {let res =this.selectDictLabel(resp.data.values, 1); console.log(resp,res) });
- 回显标签
this.getItems(listDemoGenClass, {pageSize:15}).then(res => {let rs= this.setItems(res, 'id', 'className') let rss= this.selectItemsLabel(rs, "2"); console.log(rs,rss) })
- 下载文件
this.download(“README.MD”) - 转换树形结构
this.handleTree(response.data.list||[], “id”, “parentId”); - 删除树形中空值
<treeselectv-model="form.deptId" :options="handleTreeRmEmpty(deptOptions)" :normalizer="normalizer" placeholder="请选择归属部门" />
- 获取上传文件地址
item.url = this.getUpFileUrl(this.apiUrl,item.url) - 接口地址
this.apiUrl //http://localhost:8887
this.msgSuccess(“成功”)
this.msgError(“错误”)
this.msgInfo(“提示”)
文档更新时间: 2021-10-31 01:35 作者:Yoby