优化代码,新增自定义字典方法封装
This commit is contained in:
parent
e9b249c7ad
commit
ef6ad49cec
@ -18,7 +18,7 @@ import './assets/icons' // icon
|
||||
import './permission' // permission control
|
||||
import { getDicts} from "@/api/system/dict/data";
|
||||
import { getConfigKey } from "@/api/system/config";
|
||||
import { parseTime, resetForm, addDateRange, addDateRange2, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
|
||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree, handleDict } from "@/utils/ruoyi";
|
||||
//分页组件
|
||||
import Pagination from "@/components/Pagination";
|
||||
//自定义表格工具扩展
|
||||
@ -38,11 +38,11 @@ Vue.prototype.getConfigKey = getConfigKey
|
||||
Vue.prototype.parseTime = parseTime
|
||||
Vue.prototype.resetForm = resetForm
|
||||
Vue.prototype.addDateRange = addDateRange
|
||||
Vue.prototype.addDateRange2 = addDateRange2
|
||||
Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.handleDict = handleDict
|
||||
|
||||
Vue.prototype.msgSuccess = function (msg) {
|
||||
this.$message({ showClose: true, message: msg, type: "success" });
|
||||
|
||||
@ -53,18 +53,6 @@ export function resetForm(refName) {
|
||||
}
|
||||
}
|
||||
|
||||
// // 添加日期范围
|
||||
// export function addDateRange(params, dateRange) {
|
||||
// var search = params;
|
||||
// search.beginTime = "";
|
||||
// search.endTime = "";
|
||||
// if (null != dateRange && '' != dateRange) {
|
||||
// search.beginTime = dateRange[0];
|
||||
// search.endTime = dateRange[1];
|
||||
// }
|
||||
// return search;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 添加日期范围
|
||||
* @param { beginTime: '', endTime: '', page: 1} params
|
||||
@ -211,6 +199,29 @@ export function handleTree(data, id, parentId, children, rootId) {
|
||||
return treeData != '' ? treeData : data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造自定义字典数据
|
||||
* @param {*} data 数据源
|
||||
* @param {*} lableId id字段 默认 'lableId'
|
||||
* @param {*} labelName 名称 默认 'labelName'
|
||||
*/
|
||||
export function handleDict(data, lableId, labelName) {
|
||||
lableId = lableId || 'id'
|
||||
labelName = labelName || 'name'
|
||||
//循环所有项
|
||||
var dictList = [];
|
||||
if (!Array.isArray(data)) {
|
||||
return [];
|
||||
}
|
||||
data.forEach((element) => {
|
||||
dictList.push({
|
||||
dictLabel: element[labelName],
|
||||
dictValue: element[lableId].toString(),
|
||||
});
|
||||
});
|
||||
return dictList;
|
||||
}
|
||||
|
||||
// 验证是否为blob格式
|
||||
export async function blobValidate(data) {
|
||||
try {
|
||||
|
||||
@ -62,6 +62,7 @@
|
||||
<li>MySql</li>
|
||||
<li>Mapster</li>
|
||||
<li>Epplus</li>
|
||||
<li>Signalr</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
</el-col>
|
||||
|
||||
@ -234,14 +234,7 @@ export default {
|
||||
methods: {
|
||||
// 查询数据
|
||||
getList() {
|
||||
this.queryParams["beginCreate_time"] = this.addDateRange2(
|
||||
this.dateRangeCreate_time,
|
||||
0
|
||||
);
|
||||
this.queryParams["endCreate_time"] = this.addDateRange2(
|
||||
this.dateRangeCreate_time,
|
||||
1
|
||||
);
|
||||
this.addDateRange(this.queryParams, this.dateRangeCreate_time, 'Create_time');
|
||||
this.loading = true;
|
||||
listSysfile(this.queryParams).then((res) => {
|
||||
if (res.code == 200) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user