diff --git a/ZR.Vue/src/main.js b/ZR.Vue/src/main.js index 6328bcd..633ae62 100644 --- a/ZR.Vue/src/main.js +++ b/ZR.Vue/src/main.js @@ -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" }); diff --git a/ZR.Vue/src/utils/ruoyi.js b/ZR.Vue/src/utils/ruoyi.js index 55ad82a..206a468 100644 --- a/ZR.Vue/src/utils/ruoyi.js +++ b/ZR.Vue/src/utils/ruoyi.js @@ -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 { diff --git a/ZR.Vue/src/views/index.vue b/ZR.Vue/src/views/index.vue index 1d23113..aa363e8 100644 --- a/ZR.Vue/src/views/index.vue +++ b/ZR.Vue/src/views/index.vue @@ -62,6 +62,7 @@