字典新增批量查询

This commit is contained in:
不做码农
2021-12-12 21:03:28 +08:00
parent 4d373da260
commit ac22a0e922
12 changed files with 145 additions and 23 deletions

View File

@@ -25,6 +25,15 @@ export function getDicts(dictType) {
})
}
// 根据多个字典类型查询字典数据信息
export function getMoreDicts(dictType) {
return request({
url: '/system/dict/data/types',
data: dictType ,
method: 'post'
})
}
// 新增字典数据
export function addData(data) {
return request({
@@ -58,4 +67,4 @@ export function exportData(query) {
method: 'get',
params: query
})
}
}

View File

@@ -14,7 +14,7 @@ import permission from './directive/permission'
import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getDicts, getMoreDicts} from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, addDateRange2, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
//分页组件
@@ -34,6 +34,7 @@ import UploadFile from '@/components/FileUpload/index';
// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getMoreDicts = getMoreDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
@@ -44,15 +45,15 @@ Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.msgSuccess = function(msg) {
Vue.prototype.msgSuccess = function (msg) {
this.$message({ showClose: true, message: msg, type: "success" });
}
Vue.prototype.msgError = function(msg) {
Vue.prototype.msgError = function (msg) {
this.$message({ showClose: true, message: msg, type: "error" });
}
Vue.prototype.msgInfo = function(msg) {
Vue.prototype.msgInfo = function (msg) {
this.$message.info(msg);
}

View File

@@ -1,13 +1,10 @@
import axios from 'axios'
import {
MessageBox,
Message
} from 'element-ui'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import {
getToken
} from '@/utils/auth'
import { getToken } from '@/utils/auth'
// import { blobValidate } from "@/utils/ruoyi";
// import errorCode from '@/utils/errorCode'
// import { saveAs } from 'file-saver'
// 解决后端跨域获取不到cookie问题
axios.defaults.withCredentials = true
@@ -44,7 +41,10 @@ service.interceptors.response.use(res => {
}
// 未设置状态码则默认成功状态
const { code, msg } = res.data;
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data
}
if (code == 401) {
MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
confirmButtonText: '重新登录',
@@ -138,4 +138,32 @@ export function postForm(url, data, config) {
})
})
}
// 通用下载方法
// export function download(url, params, filename) {
// //downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
// return service.post(url, params, {
// //transformRequest: [(params) => { return tansParams(params) }],
// headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
// responseType: 'blob'
// }).then(async (data) => {
// const isLogin = await blobValidate(data);
// if (isLogin) {
// const blob = new Blob([data])
// saveAs(blob, filename)
// } else {
// const resText = await data.text();
// const rspObj = JSON.parse(resText);
// const errMsg = "出錯了";// errorCode[rspObj.code] || rspObj.msg || errorCode['default']
// Message.error(errMsg);
// }
// // downloadLoadingInstance.close();
// }).catch((r) => {
// console.error(r)
// Message.error('下载文件出现错误,请联系管理员!')
// // downloadLoadingInstance.close();
// })
// }
export default service

View File

@@ -69,8 +69,8 @@ export function addDateRange2(dateRange, index) {
var time = undefined;
if (null != dateRange && '' != dateRange) {
if (dateRange.length <= 2) {
time = dateRange[index];
}
time = dateRange[index];
}
}
return time;
}
@@ -119,7 +119,9 @@ export function download(fileName) {
// 字符串格式化(%s )
export function sprintf(str) {
var args = arguments, flag = true, i = 1;
var args = arguments,
flag = true,
i = 1;
str = str.replace(/%s/g, function () {
var arg = args[i++];
if (typeof arg === 'undefined') {
@@ -172,3 +174,14 @@ export function handleTree(data, id, parentId, children, rootId) {
});
return treeData != '' ? treeData : data;
}
// 验证是否为blob格式
export async function blobValidate(data) {
try {
const text = await data.text();
JSON.parse(text);
return false;
} catch (error) {
return true;
}
}

View File

@@ -229,7 +229,7 @@ export default {
if (code == 200) {
this.showGenerate = false;
this.msgSuccess("恭喜你,代码生成完成!");
this.download(data.fileName);
this.download(data.path);
} else {
this.msgError(res.msg);
}