mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-22 12:58:55 +08:00
♻️ Refactoring code. 重构代码
This commit is contained in:
parent
ad2306d39d
commit
b03696ad78
@ -1,5 +1,4 @@
|
||||
import request from '/@/utils/request';
|
||||
import { getObjDetails } from '/@/api/admin/param';
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
|
@ -39,10 +39,11 @@ export function getObj(id?: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function delObj(id?: string) {
|
||||
export function delObj(ids?: Object) {
|
||||
return request({
|
||||
url: '/gen/dsconf/' + id,
|
||||
url: '/gen/dsconf',
|
||||
method: 'delete',
|
||||
data: ids,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,11 @@
|
||||
<div>
|
||||
<template v-for="(item, index) in props.options">
|
||||
<template v-if="values.includes(item.value)">
|
||||
<span v-if="item.elTagType == 'default' || item.elTagType == ''" :key="item.value" :index="index" :class="item.elTagClass">{{
|
||||
item.label
|
||||
}}</span>
|
||||
<span v-if="item.elTagType == 'default' || item.elTagType == ''" :key="index" :index="index" :class="item.elTagClass">{{ item.label }}</span>
|
||||
<el-tag
|
||||
v-else
|
||||
:disable-transitions="true"
|
||||
:key="item.value"
|
||||
:key="index * 2"
|
||||
:index="index"
|
||||
:type="item.elTagType === 'primary' ? '' : item.elTagType"
|
||||
:class="item.elTagClass"
|
||||
@ -25,7 +23,7 @@ import { computed } from 'vue';
|
||||
const props = defineProps({
|
||||
// 数据
|
||||
options: {
|
||||
type: Array,
|
||||
type: Array as any,
|
||||
default: null,
|
||||
},
|
||||
// 当前的值
|
||||
|
@ -31,7 +31,7 @@ const props = defineProps({
|
||||
default: 0,
|
||||
},
|
||||
pageSizes: {
|
||||
type: Array,
|
||||
type: Array as () => number[],
|
||||
default: () => {
|
||||
return [1, 10, 20, 50, 100, 200];
|
||||
},
|
||||
|
@ -61,6 +61,9 @@ const handleNodeClick = (item: any) => {
|
||||
emit('nodeClick', item);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取部门树形结构数据。
|
||||
*/
|
||||
const getDeptTree = () => {
|
||||
if (props.query instanceof Function) {
|
||||
state.localLoading = true;
|
||||
|
@ -78,6 +78,9 @@ const valueId = computed({
|
||||
const valueTitle = ref('');
|
||||
const defaultExpandedKey = ref([]);
|
||||
|
||||
/**
|
||||
* 初始化下拉菜单选择器的默认值,并设置默认选中和默认展开。
|
||||
*/
|
||||
function initHandle() {
|
||||
nextTick(() => {
|
||||
const selectedValue = valueId.value;
|
||||
@ -93,6 +96,11 @@ function initHandle() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击某一节点时触发的事件,更新当前的选中值和展开状态。
|
||||
* @param {Object} node - 被点击的节点对象
|
||||
*/
|
||||
function handleNodeClick(node) {
|
||||
valueTitle.value = node[props.objMap.label];
|
||||
valueId.value = node[props.objMap.value];
|
||||
@ -100,19 +108,37 @@ function handleNodeClick(node) {
|
||||
proxy.$refs.treeSelect.blur();
|
||||
selectFilterData('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索过滤函数,根据输入的值来过滤显示的节点。
|
||||
* @param {String} val - 输入框内的搜索关键字
|
||||
*/
|
||||
function selectFilterData(val) {
|
||||
proxy.$refs.selectTree.filter(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据输入的值来判断节点是否需要显示。
|
||||
* @param {String} value - 输入框内的搜索关键字
|
||||
* @param {Object} data - 当前处理的节点数据
|
||||
* @returns {Boolean} - 是否需要显示此节点
|
||||
*/
|
||||
function filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data[props.objMap['label']].indexOf(value) !== -1;
|
||||
}
|
||||
/**
|
||||
* 清空当前的选中状态,并重置展开状态。
|
||||
*/
|
||||
function clearHandle() {
|
||||
valueTitle.value = '';
|
||||
valueId.value = '';
|
||||
defaultExpandedKey.value = [];
|
||||
clearSelected();
|
||||
}
|
||||
/**
|
||||
* 删除所有选中状态的节点。
|
||||
*/
|
||||
function clearSelected() {
|
||||
const allNode = document.querySelectorAll('#tree-option .el-tree-node');
|
||||
allNode.forEach((element) => element.classList.remove('is-current'));
|
||||
|
@ -80,18 +80,32 @@ const state = reactive({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*/
|
||||
const downExcelTemp = () => {
|
||||
other.downBlobFile(other.adaptationUrl(prop.tempUrl), {}, 'temp.xlsx');
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传进度条变化事件
|
||||
*/
|
||||
const handleFileUploadProgress = () => {
|
||||
state.upload.isUploading = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传失败事件处理
|
||||
*/
|
||||
const handleFileError = () => {
|
||||
useMessage().error('上传失败,数据格式不合法!');
|
||||
state.upload.open = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传成功事件处理
|
||||
* @param {any} response - 上传成功的响应结果
|
||||
*/
|
||||
const handleFileSuccess = (response: any) => {
|
||||
state.upload.isUploading = false;
|
||||
state.upload.open = false;
|
||||
@ -104,21 +118,32 @@ const handleFileSuccess = (response: any) => {
|
||||
state.errorData = response.data;
|
||||
uploadRef.value.clearFiles();
|
||||
// 刷新表格
|
||||
emit('refreshDataList');
|
||||
emit?.('refreshDataList');
|
||||
} else {
|
||||
useMessage().success(response.msg ? response.msg : '导入成功');
|
||||
// 刷新表格
|
||||
emit('refreshDataList');
|
||||
emit?.('refreshDataList');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 提交表单,触发上传
|
||||
*/
|
||||
const submitFileForm = () => {
|
||||
uploadRef.value.submit();
|
||||
};
|
||||
|
||||
/**
|
||||
* 显示上传文件对话框,并清除上传信息
|
||||
*/
|
||||
const show = () => {
|
||||
state.upload.isUploading = false;
|
||||
state.upload.open = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 计算请求头部信息
|
||||
*/
|
||||
const headers = computed(() => {
|
||||
return {
|
||||
Authorization: 'Bearer ' + Session.getToken(),
|
||||
|
@ -49,9 +49,10 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
// 监听 modelValue 的变化,使 imageUrl 与 modelValue 同步
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
(val: string) => {
|
||||
if (val) {
|
||||
imageUrl.value = val;
|
||||
}
|
||||
@ -59,6 +60,7 @@ watch(
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
|
||||
// 上传成功事件处理
|
||||
const handleAvatarSuccess = (res, file) => {
|
||||
if (res.code === 0) {
|
||||
imageUrl.value = res.data.url;
|
||||
@ -69,7 +71,9 @@ const handleAvatarSuccess = (res, file) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 上传前校验
|
||||
const beforeAvatarUpload = (rawFile: any) => {
|
||||
// 校检文件格式
|
||||
if (rawFile.type !== 'image/jpeg' && rawFile.type !== 'image/png') {
|
||||
useMessage().error(`文件格式不正确, 请上传 jpeg/png格式文件!`);
|
||||
return false;
|
||||
@ -85,6 +89,7 @@ const beforeAvatarUpload = (rawFile: any) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
// 计算请求头部信息
|
||||
const headers = computed(() => {
|
||||
const tenantId = Session.getTenant();
|
||||
return {
|
||||
|
@ -171,8 +171,13 @@ const handleRemove = (file: any) => {
|
||||
emit('update:modelValue', listToString(fileList.value));
|
||||
};
|
||||
|
||||
// 对象转成指定字符串分隔
|
||||
const listToString = (list, separator = ',') => {
|
||||
/**
|
||||
* 将对象数组转为字符串,以逗号分隔。
|
||||
* @param list 待转换的对象数组。
|
||||
* @param separator 分隔符,默认为逗号。
|
||||
* @returns {string} 返回转换后的字符串。
|
||||
*/
|
||||
const listToString = (list: { url: string }[], separator = ','): string => {
|
||||
let strs = '';
|
||||
separator = separator || ',';
|
||||
for (let i in list) {
|
||||
@ -180,13 +185,16 @@ const listToString = (list, separator = ',') => {
|
||||
strs += list[i].url + separator;
|
||||
}
|
||||
}
|
||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||
return strs !== '' ? strs.substr(0, strs.length - 1) : '';
|
||||
};
|
||||
|
||||
const handleUploadError = () => {
|
||||
useMessage().error('上传文件失败');
|
||||
};
|
||||
|
||||
/**
|
||||
* 监听 props 中的 modelValue 值变化,更新 fileList。
|
||||
*/
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
|
@ -1,55 +1,67 @@
|
||||
import { ElMessage } from 'element-plus';
|
||||
import other from '../utils/other';
|
||||
import other from '/@/utils/other';
|
||||
|
||||
/**
|
||||
* 表格组件基础配置属性
|
||||
*/
|
||||
export interface BasicTableProps {
|
||||
// 是否在创建页面时,调用数据列表接口
|
||||
// 是否在创建页面时即调用数据列表接口,默认为true
|
||||
createdIsNeed?: boolean;
|
||||
// 是否需要分页
|
||||
// 是否需要分页,默认为true
|
||||
isPage?: boolean;
|
||||
// 查询条件
|
||||
// 查询条件表单对象,类型为any
|
||||
queryForm?: any;
|
||||
// 数据列表
|
||||
// 数据列表数组
|
||||
dataList?: any[];
|
||||
// 分页属性
|
||||
// 分页属性对象
|
||||
pagination?: Pagination;
|
||||
// 数据列表,loading状态
|
||||
// 数据列表,loading状态标志,默认为false
|
||||
dataListLoading?: boolean;
|
||||
// 数据列表,多选项
|
||||
// 数据列表多选项数组
|
||||
dataListSelections?: any[];
|
||||
// 接口api
|
||||
// 数据列表查询接口api方法,接收任意数量参数,返回Promise
|
||||
pageList?: (...arg: any) => Promise<any>;
|
||||
// loading
|
||||
// loading标志,默认为false
|
||||
loading?: Boolean;
|
||||
|
||||
// 多选结果数组
|
||||
selectObjs?: any[];
|
||||
|
||||
// 排序字段数组
|
||||
descs?: string[];
|
||||
|
||||
// 排序方式数组
|
||||
ascs?: string[];
|
||||
|
||||
// props属性对象,类型为any
|
||||
props?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页属性配置接口
|
||||
*/
|
||||
export interface Pagination {
|
||||
// 当前页码
|
||||
// 当前页码,默认为1
|
||||
current?: number;
|
||||
// 每页数
|
||||
// 每页显示条数,默认为10
|
||||
size?: number;
|
||||
// 总条数
|
||||
// 总条数,默认为0
|
||||
total?: number;
|
||||
|
||||
// 每页显示条数选择器的选项数组,默认为[10,20,30,40]
|
||||
pageSizes?: any[];
|
||||
|
||||
// 分页组件布局方式,可选值有 total,sizes,prev,jump,next,默认为'total,sizes,prev,jump,next'
|
||||
layout?: String;
|
||||
}
|
||||
|
||||
export function useTable(options?: BasicTableProps) {
|
||||
const defaultOptions: BasicTableProps = {
|
||||
// 列表数据是否正在加载中,默认为false
|
||||
dataListLoading: false,
|
||||
// 是否需要自动请求创建接口来获取表格数据,默认为true
|
||||
createdIsNeed: true,
|
||||
// 是否展示分页组件,默认为true
|
||||
isPage: true,
|
||||
// 查询表单对象,用于提交条件查询时的参数传递,默认为空对象
|
||||
queryForm: {},
|
||||
// 表格展示的数据数组,默认为空数组
|
||||
dataList: [],
|
||||
// 分页组件属性配置,如当前页码、每页展示数据条数等,默认值为 {current:1, size:10,total:0,pageSizes:[1, 10, 20, 50, 100, 200],layout:'total, sizes, prev, pager, next, jumper'}
|
||||
pagination: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
@ -57,17 +69,29 @@ export function useTable(options?: BasicTableProps) {
|
||||
pageSizes: [1, 10, 20, 50, 100, 200],
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
} as Pagination,
|
||||
// 当前选中的数据项,默认为空数组
|
||||
dataListSelections: [],
|
||||
// 是否正在从服务器加载数据,默认为false
|
||||
loading: false,
|
||||
// 表格数据项的选择数据,默认为空数组
|
||||
selectObjs: [],
|
||||
// 排序时使用的字段名数组,如 ['id','name'],默认为空数组
|
||||
descs: [],
|
||||
// 排序方向数组,如 ['asc', 'desc'],默认为空数组
|
||||
ascs: [],
|
||||
// props属性配置对象,用于自定义数据属性,默认值为 {item:'records',totalCount:'total'}
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 合并默认属性配置和自定义属性配置
|
||||
* @param options 默认属性配置对象
|
||||
* @param props 自定义属性配置对象
|
||||
* @returns 合并后的属性配置对象
|
||||
*/
|
||||
const mergeDefaultOptions = (options: any, props: any): BasicTableProps => {
|
||||
for (const key in options) {
|
||||
if (!Object.getOwnPropertyDescriptor(props, key)) {
|
||||
@ -80,27 +104,36 @@ export function useTable(options?: BasicTableProps) {
|
||||
// 覆盖默认值
|
||||
const state = mergeDefaultOptions(defaultOptions, options);
|
||||
|
||||
const query = () => {
|
||||
/**
|
||||
* 发起分页查询,并设置表格数据和分页信息
|
||||
*/
|
||||
const query = async () => {
|
||||
// 判断是否存在state.pageList属性
|
||||
if (state.pageList) {
|
||||
state.loading = true;
|
||||
state
|
||||
.pageList({
|
||||
try {
|
||||
// 开始加载数据,设置state.loading为true
|
||||
state.loading = true;
|
||||
|
||||
// 调用state.pageList方法发起分页查询
|
||||
const res = await state.pageList({
|
||||
...state.queryForm,
|
||||
current: state.pagination?.current,
|
||||
size: state.pagination?.size,
|
||||
descs: state.descs,
|
||||
ascs: state.ascs,
|
||||
})
|
||||
.then((res: any) => {
|
||||
state.dataList = state.isPage ? res.data[state.props.item] : res.data;
|
||||
state.pagination!.total = state.isPage ? res.data[state.props.totalCount] : 0;
|
||||
})
|
||||
.catch((err: any) => {
|
||||
ElMessage.error(err.msg || err.data.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
state.loading = false;
|
||||
});
|
||||
|
||||
// 设置表格展示的数据数组
|
||||
state.dataList = state.isPage ? res.data[state.props.item] : res.data;
|
||||
// 设置分页信息中的总数据条数
|
||||
state.pagination!.total = state.isPage ? res.data[state.props.totalCount] : 0;
|
||||
} catch (err: any) {
|
||||
// 捕获异常并显示错误提示
|
||||
ElMessage.error(err.msg || err.data.msg);
|
||||
} finally {
|
||||
// 结束加载数据,设置state.loading为false
|
||||
state.loading = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -110,14 +143,25 @@ export function useTable(options?: BasicTableProps) {
|
||||
}
|
||||
});
|
||||
|
||||
// 分页改变
|
||||
/**
|
||||
* 分页大小改变事件处理函数
|
||||
* @param val 新的分页大小
|
||||
*/
|
||||
const sizeChangeHandle = (val: number) => {
|
||||
// 修改state.pagination中的size属性
|
||||
state.pagination!.size = val;
|
||||
// 再次发起查询操作
|
||||
query();
|
||||
};
|
||||
// 分页改变
|
||||
|
||||
/**
|
||||
* 当前页码改变事件处理函数
|
||||
* @param val 新的页码
|
||||
*/
|
||||
const currentChangeHandle = (val: number) => {
|
||||
// 修改state.pagination中的current属性
|
||||
state.pagination!.current = val;
|
||||
// 再次发起查询操作
|
||||
query();
|
||||
};
|
||||
|
||||
@ -145,14 +189,27 @@ export function useTable(options?: BasicTableProps) {
|
||||
query();
|
||||
};
|
||||
|
||||
const getDataList = (refresh: boolean = true) => {
|
||||
if (refresh) {
|
||||
/**
|
||||
* 获取数据列表,并可选择是否刷新当前页码
|
||||
* 刷新后不跳转第一页,则入参 getDataList(false)
|
||||
* @param refresh 是否刷新当前页码
|
||||
*/
|
||||
const getDataList = (refresh?: any) => {
|
||||
// 如果需要刷新,则将state.pagination.current重置为1
|
||||
if (refresh !== false) {
|
||||
state.pagination!.current = 1;
|
||||
}
|
||||
// 再次发起查询操作
|
||||
query();
|
||||
};
|
||||
|
||||
// 下载文件
|
||||
/**
|
||||
* 下载文件
|
||||
* @param url 文件下载地址
|
||||
* @param query 请求参数(可能包含token)
|
||||
* @param fileName 文件名
|
||||
* @returns 返回一个Promise对象,用于异步处理结果
|
||||
*/
|
||||
const downBlobFile = (url: string, query: any, fileName: string) => {
|
||||
return other.downBlobFile(url, query, fileName);
|
||||
};
|
||||
|
@ -32,11 +32,13 @@ for (const path in modules) {
|
||||
if (itemize[key![2]]) itemize[key![2]].push(modules[path].default);
|
||||
else itemize[key![2]] = modules[path];
|
||||
}
|
||||
|
||||
for (const path in pages) {
|
||||
const key = path.match(/(\S+)\/(\S+).ts/);
|
||||
if (itemize[key![2]]) itemize[key![2]].push(pages[path].default);
|
||||
else itemize[key![2]] = pages[path];
|
||||
}
|
||||
|
||||
// 合并数组对象(非标准数组对象,数组中对象的每项 key、value 都不同)
|
||||
function mergeArrObj<T>(list: T, key: string) {
|
||||
let obj = {};
|
||||
@ -59,7 +61,6 @@ const stores = useThemeConfig(pinia);
|
||||
const { themeConfig } = storeToRefs(stores);
|
||||
|
||||
// 导出语言国际化
|
||||
// https://vue-i18n.intlify.dev/guide/essentials/fallback.html#explicit-fallback-with-one-locale
|
||||
export const i18n = createI18n({
|
||||
legacy: false,
|
||||
silentTranslationWarn: true,
|
||||
@ -75,7 +76,9 @@ const messageLocal = {};
|
||||
|
||||
const itemizeLocal = { en: [] as any[], 'zh-cn': [] as any[] };
|
||||
|
||||
// 远程获取i18n
|
||||
/**
|
||||
* 异步请求数据并更新 i18n 相关的信息。
|
||||
*/
|
||||
try {
|
||||
setTimeout(async () => {
|
||||
const infoI18n = await info();
|
||||
|
@ -159,7 +159,10 @@ const initSetTime = () => {
|
||||
initTime();
|
||||
}, 1000);
|
||||
};
|
||||
// 锁屏时间定时器
|
||||
|
||||
/**
|
||||
* 初始化锁屏相关信息
|
||||
*/
|
||||
const initLockScreen = () => {
|
||||
if (themeConfig.value.isLockScreen) {
|
||||
state.isShowLockScreenIntervalTime = window.setInterval(() => {
|
||||
@ -174,6 +177,7 @@ const initLockScreen = () => {
|
||||
clearInterval(state.isShowLockScreenIntervalTime);
|
||||
}
|
||||
};
|
||||
|
||||
// 存储布局配置
|
||||
const setLocalThemeConfig = () => {
|
||||
themeConfig.value.isDrawer = false;
|
||||
@ -181,17 +185,22 @@ const setLocalThemeConfig = () => {
|
||||
};
|
||||
const mes = ref();
|
||||
|
||||
// 密码输入点击事件
|
||||
const onLockScreenSubmit = () => {
|
||||
checkPassword(state.lockScreenPassword)
|
||||
.then(() => {
|
||||
themeConfig.value.isLockScreen = false;
|
||||
themeConfig.value.lockScreenTime = 30;
|
||||
setLocalThemeConfig();
|
||||
})
|
||||
.catch((err) => {
|
||||
mes.value = err.msg;
|
||||
});
|
||||
/**
|
||||
* 处理密码输入事件,验证密码正确性并解锁
|
||||
*/
|
||||
const onLockScreenSubmit = async () => {
|
||||
try {
|
||||
// 调用checkPassword方法验证密码
|
||||
await checkPassword(state.lockScreenPassword);
|
||||
// 更新全局主题配置中的isLockScreen和lockScreenTime属性
|
||||
themeConfig.value.isLockScreen = false;
|
||||
themeConfig.value.lockScreenTime = 30;
|
||||
// 将最新的主题配置保存到本地存储中
|
||||
setLocalThemeConfig();
|
||||
} catch (err: any) {
|
||||
// 捕获异常并将错误提示信息赋值给mes变量
|
||||
mes.value = err.msg;
|
||||
}
|
||||
};
|
||||
|
||||
const formData = reactive({});
|
||||
|
@ -1,47 +1,60 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
/**
|
||||
* 创建并导出字典存储的 Vue3 store 对象
|
||||
* @function
|
||||
* @returns {DictionaryStore} - 返回创建的字典存储对象
|
||||
*/
|
||||
export const dict = defineStore('dict', {
|
||||
state: () => ({
|
||||
dict: [] as any[],
|
||||
}),
|
||||
actions: {
|
||||
getDict(_key: String) {
|
||||
if (_key == null && _key == '') {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 获取指定键的值
|
||||
* @function
|
||||
* @param {string} key - 需要获取的键
|
||||
* @returns {Object|null} - 返回指定键对应的值,如果找不到则返回 null
|
||||
*/
|
||||
getDict(key) {
|
||||
try {
|
||||
for (let i = 0; i < this.dict.length; i++) {
|
||||
if (this.dict[i].key == _key) {
|
||||
return this.dict[i].value;
|
||||
}
|
||||
}
|
||||
const item = this.dict.find((item) => item.key === key);
|
||||
return item ? item.value : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
// 设置字典
|
||||
setDict(_key: String, value: Object) {
|
||||
if (_key !== null && _key !== '') {
|
||||
this.dict.push({
|
||||
key: _key,
|
||||
value: value,
|
||||
});
|
||||
|
||||
/**
|
||||
* 设置一个键值对
|
||||
* @function
|
||||
* @param {string} key - 需要设置的键
|
||||
* @param {Object} value - 需要设置的值
|
||||
*/
|
||||
setDict(key, value) {
|
||||
if (!key || typeof key !== 'string') {
|
||||
return;
|
||||
}
|
||||
this.dict.push({ key, value });
|
||||
},
|
||||
// 删除字典
|
||||
removeDict(_key: string) {
|
||||
var bln = false;
|
||||
|
||||
/**
|
||||
* 删除指定键值对
|
||||
* @function
|
||||
* @param {string} key - 需要删除的键
|
||||
* @returns {boolean} - 返回删除操作是否成功
|
||||
*/
|
||||
removeDict(key) {
|
||||
try {
|
||||
for (let i = 0; i < this.dict.length; i++) {
|
||||
if (this.dict[i].key == _key) {
|
||||
this.dict.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
const index = this.dict.findIndex((item) => item.key === key);
|
||||
if (index !== -1) {
|
||||
this.dict.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
bln = false;
|
||||
return false;
|
||||
}
|
||||
return bln;
|
||||
return false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -8,11 +8,9 @@ export const useMsg = defineStore('msg', {
|
||||
getAllMsg() {
|
||||
return this.msgArray;
|
||||
},
|
||||
// 设置字典
|
||||
setMsg(value: Object) {
|
||||
this.msgArray.push(value);
|
||||
},
|
||||
// 删除字典
|
||||
removeAll() {
|
||||
this.msgArray = [];
|
||||
},
|
||||
|
@ -5,8 +5,8 @@ import other from '/@/utils/other';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
* @methods setUserInfos 设置用户信息
|
||||
* @function useUserInfo
|
||||
* @returns {UserInfosStore}
|
||||
*/
|
||||
export const useUserInfo = defineStore('userInfo', {
|
||||
state: (): UserInfosState => ({
|
||||
@ -18,16 +18,26 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
authBtnList: [],
|
||||
},
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async login(data: any) {
|
||||
/**
|
||||
* 登录方法
|
||||
* @function login
|
||||
* @async
|
||||
* @param {Object} data - 登录数据
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async login(data) {
|
||||
data.grant_type = 'password';
|
||||
data.scope = 'server';
|
||||
|
||||
// 密码加密
|
||||
const user = other.encryption({
|
||||
data: data,
|
||||
key: import.meta.env.VITE_PWD_ENC_KEY,
|
||||
param: ['password'],
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
login(user)
|
||||
.then((res) => {
|
||||
@ -42,6 +52,14 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 手机登录方法
|
||||
* @function loginByMobile
|
||||
* @async
|
||||
* @param {Object} data - 登录数据
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async loginByMobile(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
loginByMobile(data.mobile, data.code)
|
||||
@ -57,7 +75,16 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
});
|
||||
});
|
||||
},
|
||||
async loginBySocial(state: string, code: string) {
|
||||
|
||||
/**
|
||||
* 社交账号登录方法
|
||||
* @function loginBySocial
|
||||
* @async
|
||||
* @param {string} state - 状态
|
||||
* @param {string} code - 代码
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async loginBySocial(state, code) {
|
||||
return new Promise((resolve, reject) => {
|
||||
loginBySocial(state, code)
|
||||
.then((res) => {
|
||||
@ -72,24 +99,37 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 刷新token方法
|
||||
* @function refreshToken
|
||||
* @async
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
async refreshToken() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const refreshToken = Session.get('refresh_token');
|
||||
refreshTokenApi(refreshToken)
|
||||
.then((res: any) => {
|
||||
.then((res) => {
|
||||
// 存储token 信息
|
||||
Session.set('token', res.access_token);
|
||||
Session.set('refresh_token', res.refresh_token);
|
||||
resolve(res);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户信息方法
|
||||
* @function setUserInfos
|
||||
* @async
|
||||
*/
|
||||
async setUserInfos() {
|
||||
getUserInfo().then((res: any) => {
|
||||
getUserInfo().then((res) => {
|
||||
const userInfo: any = {
|
||||
user: res.data.sysUser,
|
||||
time: new Date().getTime(),
|
||||
|
@ -57,7 +57,7 @@ export function useTitle() {
|
||||
*/
|
||||
export function setTagsViewNameI18n(item: any) {
|
||||
let tagsViewName: string = '';
|
||||
const { query, params, meta } = item;
|
||||
const { query, params } = item;
|
||||
//修复tagsViewName匹配到其他含下列单词的路由
|
||||
const pattern = /^\{("(zh-cn|en|zh-tw)":"[^,]+",?){1,3}}$/;
|
||||
if (query?.tagsViewName || params?.tagsViewName) {
|
||||
@ -339,6 +339,9 @@ const other = {
|
||||
adaptationUrl: (url?: string) => {
|
||||
return adaptationUrl(url);
|
||||
},
|
||||
resolveAllEunuchNodeId: (json: any[], idArr: any[], temp: any[] = []) => {
|
||||
return resolveAllEunuchNodeId(json, idArr, temp);
|
||||
},
|
||||
};
|
||||
|
||||
export function getQueryString(url: string, paraName: string) {
|
||||
@ -396,6 +399,21 @@ export function handleTree(data, id, parentId, children, rootId) {
|
||||
return treeData !== '' ? treeData : data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析所有太监节点ID
|
||||
* @returns
|
||||
*/
|
||||
const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[] = []) => {
|
||||
for (const item of json) {
|
||||
if (item.children && item.children.length !== 0) {
|
||||
resolveAllEunuchNodeId(item.children, idArr, temp);
|
||||
} else {
|
||||
temp.push(...idArr.filter((id) => id === item.id));
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param str 驼峰转下划线
|
||||
|
@ -1,75 +1,87 @@
|
||||
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { Session, Local } from '/@/utils/storage';
|
||||
import { useMessageBox } from '/@/hooks/message';
|
||||
import qs from 'qs';
|
||||
import other from './other';
|
||||
|
||||
// 配置新建一个 axios 实例
|
||||
/**
|
||||
* 创建并配置一个 Axios 实例对象
|
||||
*/
|
||||
const service: AxiosInstance = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_URL,
|
||||
timeout: 50000, // 全局超时时间
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
paramsSerializer: {
|
||||
serialize(params) {
|
||||
return qs.stringify(params, { allowDots: true });
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// 添加请求拦截器
|
||||
/**
|
||||
* Axios请求拦截器,对请求进行处理
|
||||
* 1. 序列化get请求参数
|
||||
* 2. 统一增加Authorization和TENANT-ID请求头
|
||||
* 3. 自动适配单体、微服务架构不同的URL
|
||||
* @param config AxiosRequestConfig对象,包含请求配置信息
|
||||
*/
|
||||
service.interceptors.request.use(
|
||||
(config: AxiosRequestConfig) => {
|
||||
// get查询参数序列化
|
||||
// 对get请求参数进行序列化
|
||||
if (config.method === 'get') {
|
||||
// @ts-ignore
|
||||
// @ts-ignore 使用qs库来序列化查询参数
|
||||
config.paramsSerializer = (params: any) => {
|
||||
return qs.stringify(params, { arrayFormat: 'repeat' });
|
||||
};
|
||||
}
|
||||
// 统一增加 token
|
||||
const isToken = (config.headers || {}).isToken === false;
|
||||
|
||||
// 统一增加Authorization请求头
|
||||
const token = Session.getToken();
|
||||
if (token && !isToken) {
|
||||
if (token && !config.headers?.isToken) {
|
||||
config.headers!['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
// 统一增加租户信息
|
||||
if (Local.get('tenantId')) {
|
||||
config.headers!['TENANT-ID'] = Local.get('tenantId');
|
||||
// 统一增加TENANT-ID请求头
|
||||
const tenantId = Local.get('tenantId');
|
||||
if (tenantId && !config.headers?.skipTenant) {
|
||||
config.headers!['TENANT-ID'] = tenantId;
|
||||
}
|
||||
|
||||
//自动适配单体、微服务架构不同的URL
|
||||
// 自动适配单体和微服务架构不同的URL
|
||||
config.url = other.adaptationUrl(config.url);
|
||||
|
||||
// 处理完毕,返回config对象
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
// 对请求错误做些什么
|
||||
// 对请求错误进行处理
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
// 添加响应拦截器
|
||||
service.interceptors.response.use(
|
||||
(res: any) => {
|
||||
if (res.data.code === 1) {
|
||||
throw res.data;
|
||||
}
|
||||
return res.data;
|
||||
},
|
||||
(error) => {
|
||||
const status = Number(error.response.status) || 200;
|
||||
if (status === 424) {
|
||||
useMessageBox()
|
||||
.confirm('令牌状态已过期,请点击重新登录')
|
||||
.then(() => {
|
||||
Session.clear(); // 清除浏览器全部临时缓存
|
||||
window.location.href = '/'; // 去登录页
|
||||
return;
|
||||
});
|
||||
}
|
||||
return Promise.reject(error.response.data);
|
||||
/**
|
||||
* 响应拦截器处理函数
|
||||
* @param response 响应结果
|
||||
* @returns 如果响应成功,则返回响应的data属性;否则,抛出错误或者执行其他操作
|
||||
*/
|
||||
const handleResponse = (response: AxiosResponse<any>) => {
|
||||
if (response.data.code === 1) {
|
||||
throw response.data;
|
||||
}
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
/**
|
||||
* 添加 Axios 的响应拦截器,用于全局响应结果处理
|
||||
*/
|
||||
service.interceptors.response.use(handleResponse, (error) => {
|
||||
const status = Number(error.response.status) || 200;
|
||||
if (status === 424) {
|
||||
useMessageBox()
|
||||
.confirm('令牌状态已过期,请点击重新登录')
|
||||
.then(() => {
|
||||
Session.clear(); // 清除浏览器全部临时缓存
|
||||
window.location.href = '/'; // 去登录页
|
||||
return;
|
||||
});
|
||||
}
|
||||
return Promise.reject(error.response.data);
|
||||
});
|
||||
|
||||
// 导出 axios 实例
|
||||
export default service;
|
||||
|
@ -95,7 +95,7 @@ const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, do
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value.resetFields();
|
||||
queryRef.value?.resetFields();
|
||||
// 清空多选
|
||||
selectObjs.value = [];
|
||||
getDataList();
|
||||
@ -108,25 +108,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -197,7 +197,9 @@ const openDialog = (id: string) => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
// 重置表单数据
|
||||
dataFormRef.value?.resetFields();
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取sysOauthClientDetails信息
|
||||
if (id) {
|
||||
|
@ -122,26 +122,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -40,11 +40,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemDeptDialog">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getObj, depttree, addObj, putObj } from '/@/api/admin/dept';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh']);
|
||||
const { t } = useI18n();
|
||||
// 定义变量内容
|
||||
const deptDialogFormRef = ref();
|
||||
const dataForm = reactive({
|
||||
@ -86,31 +88,18 @@ const openDialog = (type: string, id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
deptDialogFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
if (dataForm.deptId) {
|
||||
putObj(dataForm)
|
||||
.then(() => {
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
} else {
|
||||
addObj(dataForm)
|
||||
.then(() => {
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await deptDialogFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
dataForm.deptId ? await putObj(dataForm) : await addObj(dataForm);
|
||||
useMessage().success(t(dataForm.deptId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 从后端获取菜单信息
|
||||
|
@ -35,9 +35,13 @@
|
||||
<el-table-column prop="createTime" :label="$t('sysdept.createTime')" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column :label="$t('common.action')" show-overflow-tooltip width="200">
|
||||
<template #default="scope">
|
||||
<el-button text type="primary" @click="onOpenAddDept('add', scope.row)" v-auth="'sys_dept_add'"> {{ $t('common.addBtn') }}</el-button>
|
||||
<el-button text type="primary" @click="onOpenEditDept('edit', scope.row)" v-auth="'sys_dept_edit'">{{ $t('common.editBtn') }}</el-button>
|
||||
<el-button text type="primary" @click="onTabelRowDel(scope.row)" v-auth="'sys_dept_del'"> {{ $t('common.delBtn') }}</el-button>
|
||||
<el-button text type="primary" @click="deptDialogRef.openDialog('add', scope.row?.id)" v-auth="'sys_dept_add'">
|
||||
{{ $t('common.addBtn') }}</el-button
|
||||
>
|
||||
<el-button text type="primary" @click="deptDialogRef.openDialog('edit', scope.row?.id)" v-auth="'sys_dept_edit'">{{
|
||||
$t('common.editBtn')
|
||||
}}</el-button>
|
||||
<el-button text type="primary" @click="handleDelete(scope.row)" v-auth="'sys_dept_del'"> {{ $t('common.delBtn') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -63,10 +67,8 @@ import { downBlobFile } from '/@/utils/other';
|
||||
// 引入组件
|
||||
const DeptForm = defineAsyncComponent(() => import('./form.vue'));
|
||||
const { t } = useI18n();
|
||||
|
||||
// 定义变量内容
|
||||
const deptDialogRef = ref();
|
||||
|
||||
const excelUploadRef = ref();
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
@ -80,32 +82,25 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
|
||||
const { getDataList } = useTable(state);
|
||||
|
||||
// 打开新增菜单弹窗
|
||||
const onOpenAddDept = (type: string, row: any) => {
|
||||
deptDialogRef.value.openDialog(type, row?.id);
|
||||
};
|
||||
// 打开编辑菜单弹窗
|
||||
const onOpenEditDept = (type: string, row: any) => {
|
||||
deptDialogRef.value.openDialog(type, row.id);
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/admin/dept/export', state.queryForm, 'dept.xlsx');
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const onTabelRowDel = (row: any) => {
|
||||
useMessageBox()
|
||||
.confirm(`${t('common.delConfirmText')}:${row.name} ?`)
|
||||
.then(() => {
|
||||
delObj(row.id)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success('删除成功');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (row: any) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(row.id);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -53,21 +53,21 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
});
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle } = useTable(state);
|
||||
|
||||
const handleDelete = (row: any) => {
|
||||
useMessageBox()
|
||||
.confirm(`${t('common.delConfirmText')} ?`)
|
||||
.then(() => {
|
||||
delItemObj(row.id)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleDelete = async (row: any) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delItemObj(row.id);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
const open = (row: any) => {
|
||||
state.queryForm.dictId = row.id;
|
||||
state.queryForm.dictType = row.dictType;
|
||||
|
@ -109,7 +109,7 @@ const { getDataList, currentChangeHandle, sizeChangeHandle } = useTable(state);
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
queryRef.value.resetFields();
|
||||
queryRef.value?.resetFields();
|
||||
state.queryForm = {};
|
||||
getDataList();
|
||||
};
|
||||
@ -123,14 +123,6 @@ const handleSelectable = (row: any) => {
|
||||
return row.systemFlag !== '1';
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
//刷新缓存
|
||||
const handleRefreshCache = () => {
|
||||
refreshCache().then(() => {
|
||||
@ -138,19 +130,26 @@ const handleRefreshCache = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -11,12 +11,10 @@
|
||||
|
||||
<script setup lang="ts" name="SysFileDialog">
|
||||
const Upload = defineAsyncComponent(() => import('/@/components/Upload/index.vue'));
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 定义变量内容
|
||||
const visible = ref(false);
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
visible.value = true;
|
||||
|
@ -99,25 +99,24 @@ const download = (row: any) => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -141,25 +141,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<el-descriptions-item :label="$t('syslog.requestUri')">{{ data.requestUri }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('syslog.createBy')">{{ data.createBy }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('syslog.exception')">
|
||||
<highlightjs v-if="data.exception" autodetect :code="data.exception" />
|
||||
<highlightjs ref="highlight" v-if="data.exception" autodetect :code="data.exception" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-drawer>
|
||||
@ -20,6 +20,7 @@
|
||||
const visible = ref(false);
|
||||
|
||||
const data = reactive({} as any);
|
||||
const highlight = ref();
|
||||
|
||||
const openDialog = (row: any) => {
|
||||
visible.value = true;
|
||||
|
@ -19,7 +19,7 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList(true)" icon="Search" type="primary">{{ $t('common.queryBtn') }} </el-button>
|
||||
<el-button @click="getDataList" icon="Search" type="primary">{{ $t('common.queryBtn') }} </el-button>
|
||||
<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -117,37 +117,35 @@ const { downBlobFile, getDataList, currentChangeHandle, sortChangeHandle, sizeCh
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
queryRef.value.resetFields();
|
||||
queryRef.value?.resetFields();
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/admin/log/export', state.queryForm, 'log.xlsx');
|
||||
};
|
||||
|
||||
// 删除数据
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(`${t('common.delConfirmText')}?`)
|
||||
.then(() => {
|
||||
// 删除用户的接口
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
<el-tooltip :content="$t('sysmenu.deleteDisabledTip')" :disabled="!deleteMenuDisabled(scope.row)" placement="top">
|
||||
<span style="margin-left: 12px">
|
||||
<el-button :disabled="deleteMenuDisabled(scope.row)" @click="onTabelRowDel(scope.row)" text type="primary" v-auth="'sys_menu_del'">
|
||||
<el-button :disabled="deleteMenuDisabled(scope.row)" @click="handleDelete(scope.row)" text type="primary" v-auth="'sys_menu_del'">
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
</span>
|
||||
@ -71,9 +71,10 @@
|
||||
import { delObj, pageList } from '/@/api/admin/menu';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
// 引入组件
|
||||
const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
|
||||
const { t } = useI18n();
|
||||
// 定义变量内容
|
||||
const menuDialogRef = ref();
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
@ -100,19 +101,20 @@ const deleteMenuDisabled = (row: any) => {
|
||||
return (row.children || []).length > 0;
|
||||
};
|
||||
|
||||
// 删除当前菜单
|
||||
const onTabelRowDel = (row: any) => {
|
||||
useMessageBox()
|
||||
.confirm(`此操作将永久删除:${row.name}`)
|
||||
.then(() => {
|
||||
delObj(row.id)
|
||||
.then(() => {
|
||||
useMessage().success('删除成功');
|
||||
getDataList();
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
// 删除操作
|
||||
const handleDelete = async (row: any) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(row.id);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -133,32 +133,32 @@ const exportExcel = () => {
|
||||
downBlobFile('/admin/param/export', state.queryForm, 'param.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.publicId);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
const handleRefreshCache = () => {
|
||||
refreshCache().then(() => {
|
||||
useMessage().success('同步成功');
|
||||
});
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.publicId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -110,25 +110,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.postId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.postId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -156,25 +156,24 @@ const handleSelectable = (row: any) => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.roleId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.roleId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -31,6 +31,7 @@ import { pageList } from '/@/api/admin/menu';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { Ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import other from '/@/utils/other';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@ -68,7 +69,7 @@ const openDialog = (row: any) => {
|
||||
})
|
||||
.then((r) => {
|
||||
state.treeData = r.data;
|
||||
state.checkedKeys = resolveAllEunuchNodeId(state.treeData, checkedKeys.value, []);
|
||||
state.checkedKeys = other.resolveAllEunuchNodeId(state.treeData, checkedKeys.value, []);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
@ -90,22 +91,6 @@ const onSubmit = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 遍历节点
|
||||
const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[]) => {
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
const item = json[i];
|
||||
// 国际化
|
||||
item.name = t(item.name);
|
||||
// 存在子节点,递归遍历;不存在子节点,将json的id添加到临时数组中
|
||||
if (item.children && item.children.length !== 0) {
|
||||
resolveAllEunuchNodeId(item.children, idArr, temp);
|
||||
} else {
|
||||
temp.push(idArr.filter((id) => id === item.id));
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
|
@ -94,9 +94,9 @@ const openDialog = (id: string) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取appSocialDetails信息
|
||||
if (id) {
|
||||
@ -106,43 +106,27 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
if (form.appSecret && form.appSecret.indexOf('******') >= 0) {
|
||||
form.appSecret = undefined;
|
||||
}
|
||||
// 隐藏敏感信息
|
||||
form.appSecret = form.appSecret?.includes('******') ? undefined : form.appSecret;
|
||||
form.appId = form.appId?.includes('******') ? undefined : form.appId;
|
||||
|
||||
if (form.appId && form.appId.indexOf('******') >= 0) {
|
||||
form.appId = undefined;
|
||||
}
|
||||
|
||||
// 更新
|
||||
try {
|
||||
if (form.id) {
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
await putObj(form);
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
await addObj(form);
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
}
|
||||
});
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
|
@ -117,25 +117,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -118,16 +118,15 @@ const dataRules = ref({
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
const openDialog = (id: string): void => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields?.();
|
||||
});
|
||||
|
||||
// 获取Tenant信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getTenantData(id);
|
||||
@ -136,35 +135,18 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
// 更新
|
||||
if (form.id) {
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表格数据
|
||||
|
@ -146,26 +146,25 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTenantMenu = () => {
|
||||
|
@ -47,6 +47,7 @@ import { useMessage } from '/@/hooks/message';
|
||||
import { getObj } from '/@/api/admin/tenant-menu';
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import other from '/@/utils/other';
|
||||
const { status_type } = useDict('status_type');
|
||||
const { t } = useI18n();
|
||||
|
||||
@ -93,56 +94,36 @@ const checkedMenu = ref<any[]>([]);
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
checkedMenu.value = [];
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
checkedMenu.value = [];
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取Tenant信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getTenantMenuData(id);
|
||||
}
|
||||
|
||||
getMenuData();
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const onSubmit = () => {
|
||||
loading.value = true;
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
loading.value = false;
|
||||
return false;
|
||||
}
|
||||
form.menuIds = [...menuTreeRef.value.getCheckedKeys(), ...menuTreeRef.value.getHalfCheckedKeys()].join(',');
|
||||
if (form.id) {
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
loading.value = false;
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
loading.value = false;
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
const treeLoading = ref(false);
|
||||
@ -151,27 +132,13 @@ const getMenuData = () => {
|
||||
treemenu().then((res) => {
|
||||
menuData.value = res.data;
|
||||
if (form.menuIds) {
|
||||
checkedMenu.value = resolveAllEunuchNodeId(menuData.value, form.menuIds.split(','), []);
|
||||
checkedMenu.value = other.resolveAllEunuchNodeId(menuData.value, form.menuIds.split(','), []);
|
||||
} else {
|
||||
checkedMenu.value = [];
|
||||
}
|
||||
treeLoading.value = false;
|
||||
});
|
||||
};
|
||||
const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[]) => {
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
const item = json[i];
|
||||
// 国际化
|
||||
item.name = t(item.name);
|
||||
// 存在子节点,递归遍历;不存在子节点,将json的id添加到临时数组中
|
||||
if (item.children && item.children.length !== 0) {
|
||||
resolveAllEunuchNodeId(item.children, idArr, temp);
|
||||
} else {
|
||||
temp.push(idArr.filter((id) => id === item.id));
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
const getTenantMenuData = (id: string) => {
|
||||
// 获取部门数据
|
||||
|
@ -53,20 +53,21 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
});
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle } = useTable(state);
|
||||
|
||||
const handleDelete = (row: any) => {
|
||||
useMessageBox()
|
||||
.confirm(`${t('common.delConfirmText')}:${row.name} ?`)
|
||||
.then(() => {
|
||||
// 删除用户的接口
|
||||
delObj(row.id)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
|
||||
const handleDelete = async (row: any) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(row.id);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
const open = () => {
|
||||
|
@ -8,5 +8,7 @@ export default {
|
||||
expiresAt: 'expiresAt',
|
||||
inputUsernameTip: 'input Username',
|
||||
offlineBtn: 'offline',
|
||||
offlineConfirmText: 'offline confirm',
|
||||
offlineSuccessText: 'offline success',
|
||||
},
|
||||
};
|
||||
|
@ -8,5 +8,7 @@ export default {
|
||||
expiresAt: '过期时间',
|
||||
inputUsernameTip: '请输入用户名',
|
||||
offlineBtn: '下线',
|
||||
offlineConfirmText: '确认下线',
|
||||
offlineSuccessText: '下线成功',
|
||||
},
|
||||
};
|
||||
|
@ -69,50 +69,47 @@ const { t } = useI18n();
|
||||
// 定义变量内容
|
||||
const queryRef = ref();
|
||||
const showSearch = ref(true);
|
||||
|
||||
// 多选rows
|
||||
const selectObjs = ref([]) as any;
|
||||
// 是否可以多选
|
||||
const multiple = ref(true);
|
||||
|
||||
// table hook
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {
|
||||
username: '',
|
||||
},
|
||||
pageList: fetchList,
|
||||
});
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sortChangeHandle, sizeChangeHandle } = useTable(state);
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
queryRef.value.resetFields();
|
||||
queryRef.value?.resetFields();
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.accessToken);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.accessToken));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (accessTokens: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(accessTokens)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (accessTokens: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('systoken.offlineConfirmText'));
|
||||
} catch {
|
||||
return; // 取消删除则直接跳过此方法
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(accessTokens);
|
||||
getDataList();
|
||||
useMessage().success(t('systoken.offlineSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 判断当前token 是否和登录token一致
|
||||
|
@ -38,7 +38,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="$t('sysuser.dept')" prop="dept">
|
||||
<el-form-item :label="$t('sysuser.dept')" prop="deptId">
|
||||
<el-tree-select
|
||||
:data="deptData"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
@ -151,7 +151,7 @@ const dataRules = ref({
|
||||
{ required: true, message: '姓名不能为空', trigger: 'blur' },
|
||||
{ validator: rule.chinese, trigger: 'blur' },
|
||||
],
|
||||
dept: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
|
||||
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
|
||||
role: [{ required: true, message: '角色不能为空', trigger: 'blur' }],
|
||||
post: [{ required: true, message: '岗位不能为空', trigger: 'blur' }],
|
||||
// 手机号校验,不能为空、新增的时不能重复校验
|
||||
@ -197,41 +197,30 @@ const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
if (dataForm.userId) {
|
||||
// 清除*占位符,避免误提交错误的数据
|
||||
if (dataForm.phone && dataForm.phone.includes('*')) {
|
||||
dataForm.phone = undefined;
|
||||
try {
|
||||
const { userId, phone, password } = dataForm;
|
||||
|
||||
if (userId) {
|
||||
// 清除占位符,避免提交错误的数据
|
||||
if (phone?.includes('*')) dataForm.phone = undefined;
|
||||
if (password?.includes('******')) dataForm.password = undefined;
|
||||
|
||||
loading.value = true;
|
||||
await putObj(dataForm);
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
} else {
|
||||
loading.value = true;
|
||||
await addObj(dataForm);
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
}
|
||||
if (dataForm.password && dataForm.password.includes('******')) {
|
||||
dataForm.password = undefined;
|
||||
}
|
||||
loading.value = true;
|
||||
putObj(dataForm)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(dataForm)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,6 +17,7 @@ export default {
|
||||
inputNameTip: 'input name',
|
||||
importUserTip: 'user import',
|
||||
deleteDisabledTip: 'admin are not allowed to delete',
|
||||
noDataScopeTip: 'no data permissions',
|
||||
},
|
||||
personal: {
|
||||
name: 'personal info',
|
||||
|
@ -1,26 +1,27 @@
|
||||
export default {
|
||||
sysuser: {
|
||||
index: '序号',
|
||||
username: '用户名',
|
||||
name: '姓名',
|
||||
phone: '手机号',
|
||||
post: '岗位',
|
||||
role: '角色',
|
||||
lockFlag: '状态',
|
||||
createTime: '创建时间',
|
||||
password: '密码',
|
||||
dept: '部门',
|
||||
email: '邮箱',
|
||||
nickname: '昵称',
|
||||
inputUsernameTip: '请输入用户名',
|
||||
inputPhoneTip: '请输入手机号',
|
||||
inputNameTip: '请输入姓名',
|
||||
importUserTip: '用户导入',
|
||||
deleteDisabledTip: 'admin 不允许被删除',
|
||||
},
|
||||
personal: {
|
||||
name: '个人信息',
|
||||
passwordRule: '两次输入密码不一致',
|
||||
passwordScore: '密码等级太低',
|
||||
},
|
||||
sysuser: {
|
||||
index: '序号',
|
||||
username: '用户名',
|
||||
name: '姓名',
|
||||
phone: '手机号',
|
||||
post: '岗位',
|
||||
role: '角色',
|
||||
lockFlag: '状态',
|
||||
createTime: '创建时间',
|
||||
password: '密码',
|
||||
dept: '部门',
|
||||
email: '邮箱',
|
||||
nickname: '昵称',
|
||||
inputUsernameTip: '请输入用户名',
|
||||
inputPhoneTip: '请输入手机号',
|
||||
inputNameTip: '请输入姓名',
|
||||
importUserTip: '用户导入',
|
||||
deleteDisabledTip: 'admin 不允许被删除',
|
||||
noDataScopeTip: '没有数据权限'
|
||||
},
|
||||
personal: {
|
||||
name: '个人信息',
|
||||
passwordRule: '两次输入密码不一致',
|
||||
passwordScore: '密码等级太低',
|
||||
},
|
||||
};
|
||||
|
@ -3,7 +3,15 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="4" :xs="24">
|
||||
<el-card class="layout-padding-auto" shadow="hover">
|
||||
<query-tree :placeholder="$t('common.queryDeptTip')" :query="deptData.queryList" @node-click="handleNodeClick" />
|
||||
<query-tree :placeholder="$t('common.queryDeptTip')" :query="deptData.queryList" @node-click="handleNodeClick">
|
||||
<!-- 没有数据权限提示 -->
|
||||
<template #default="{ node, data }">
|
||||
<el-tooltip v-if="data.isLock" class="item" effect="dark" :content="$t('sysuser.noDataScopeTip')" placement="right-start">
|
||||
<span>{{ node.label }} <SvgIcon name="ele-Lock" /></span>
|
||||
</el-tooltip>
|
||||
<span v-if="!data.isLock">{{ node.label }}</span>
|
||||
</template>
|
||||
</query-tree>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="20" :xs="24">
|
||||
@ -17,7 +25,7 @@
|
||||
<el-input v-model="state.queryForm.phone" :placeholder="$t('sysuser.inputPhoneTip')" clearable style="width: 240px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="Search" type="primary" @click="getDataList">{{ $t('common.queryBtn') }} </el-button>
|
||||
<el-button icon="Search" type="primary" @click="getDataList">{{ $t('common.queryBtn') }}</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -87,7 +95,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle"> </pagination>
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle"></pagination>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -139,6 +147,7 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
},
|
||||
pageList: pageList,
|
||||
});
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile } = useTable(state);
|
||||
|
||||
// 部门树使用的数据
|
||||
const deptData = reactive({
|
||||
@ -149,12 +158,9 @@ const deptData = reactive({
|
||||
},
|
||||
});
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile } = useTable(state);
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
queryRef.value.resetFields();
|
||||
queryRef.value?.resetFields();
|
||||
state.queryForm.deptId = '';
|
||||
getDataList();
|
||||
};
|
||||
@ -177,29 +183,24 @@ const handleSelectable = (row: any) => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.userId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.userId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
state.dataList;
|
||||
});
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -65,6 +65,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="systemMenuDialog" setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { addObj, info, pageList, update, validateByName, validatePermission } from '/@/api/app/appmenu';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { rule } from '/@/utils/validate';
|
||||
@ -72,7 +73,7 @@ import { rule } from '/@/utils/validate';
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh']);
|
||||
// 引入组件
|
||||
|
||||
const { t } = useI18n();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
// 定义变量内容
|
||||
@ -95,38 +96,6 @@ const state = reactive({
|
||||
parentData: [] as any[], // 上级菜单数据
|
||||
});
|
||||
|
||||
// 从后端获取菜单信息
|
||||
const getMenuData = () => {
|
||||
state.parentData = [];
|
||||
loading.value = true;
|
||||
pageList()
|
||||
.then((res) => {
|
||||
let menu = {
|
||||
createBy: '',
|
||||
createTime: '',
|
||||
delFlag: '',
|
||||
icon: '',
|
||||
keepAlive: '',
|
||||
menuId: '',
|
||||
menuType: '',
|
||||
parentId: '',
|
||||
path: '',
|
||||
sortOrder: 0,
|
||||
updateBy: '',
|
||||
updateTime: '',
|
||||
visible: '',
|
||||
id: '-1',
|
||||
name: '根菜单',
|
||||
children: [] as any[],
|
||||
};
|
||||
menu.children = res.data;
|
||||
state.parentData.push(menu);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const dataRules = reactive({
|
||||
name: [
|
||||
{ required: true, message: '菜单名称不能为空', trigger: 'blur' },
|
||||
@ -153,67 +122,66 @@ const dataRules = reactive({
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (type: string, row?: any) => {
|
||||
if (row?.id && type === 'edit') {
|
||||
state.ruleForm.id = row.id;
|
||||
// 模拟数据,实际请走接口
|
||||
loading.value = true;
|
||||
info(row.id)
|
||||
.then((res) => {
|
||||
Object.assign(state.ruleForm, res.data);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
// 清空表单,此项需加表单验证才能使用
|
||||
nextTick(() => {
|
||||
dataFormRef?.value?.resetFields();
|
||||
state.ruleForm.parentId = row?.id || '-1';
|
||||
});
|
||||
}
|
||||
state.ruleForm.menuId = '';
|
||||
visible.value = true;
|
||||
getMenuData();
|
||||
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
state.ruleForm.parentId = row?.id || '-1';
|
||||
});
|
||||
|
||||
if (row?.id && type === 'edit') {
|
||||
state.ruleForm.menuId = row.id;
|
||||
// 获取当前节点菜单信息
|
||||
getMenuDetail(row.id);
|
||||
}
|
||||
// 渲染上级菜单列表树
|
||||
getAllMenuData();
|
||||
};
|
||||
|
||||
// 保存数据
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 保存 调用刷新
|
||||
if (state.ruleForm.id) {
|
||||
loading.value = true;
|
||||
update(state.ruleForm)
|
||||
.then(() => {
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(state.ruleForm)
|
||||
.then(() => {
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
// 从后端获取菜单信息(含层级)
|
||||
const getAllMenuData = () => {
|
||||
state.parentData = [];
|
||||
pageList({
|
||||
type: '0',
|
||||
}).then((res) => {
|
||||
let menu = {
|
||||
id: '-1',
|
||||
name: '根菜单',
|
||||
children: [],
|
||||
};
|
||||
menu.children = res.data;
|
||||
state.parentData.push(menu);
|
||||
});
|
||||
};
|
||||
|
||||
const getMenuDetail = (id: string) => {
|
||||
info(id)
|
||||
.then((res) => {
|
||||
Object.assign(state.ruleForm, res.data);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
state.ruleForm.menuId ? await update(state.ruleForm) : await addObj(state.ruleForm);
|
||||
useMessage().success(t(state.ruleForm.menuId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量 只有暴漏出来的变量 父组件才能使用
|
||||
defineExpose({
|
||||
openDialog,
|
||||
|
@ -6,7 +6,7 @@
|
||||
<el-button @click="getDataList" class="ml10" icon="search" type="primary">
|
||||
{{ $t('common.queryBtn') }}
|
||||
</el-button>
|
||||
<el-button @click="onOpenAddMenu" class="ml10" icon="folder-add" type="primary" v-auth="'sys_menu_add'">
|
||||
<el-button @click="menuDialogRef.openDialog('add')" class="ml10" icon="folder-add" type="primary" v-auth="'sys_menu_add'">
|
||||
{{ $t('common.addBtn') }}
|
||||
</el-button>
|
||||
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary" v-auth="'sys_post_del'">
|
||||
@ -40,10 +40,12 @@
|
||||
<el-table-column :label="$t('appmenu.permission')" :show-overflow-tooltip="true" prop="permission"></el-table-column>
|
||||
<el-table-column :label="$t('common.action')" show-overflow-tooltip width="200">
|
||||
<template #default="scope">
|
||||
<el-button @click="onOpenAddMenu('add', scope.row)" text type="primary" v-auth="'sys_menu_add'">
|
||||
<el-button @click="menuDialogRef.openDialog('add', scope.row?.id)" text type="primary" v-auth="'sys_menu_add'">
|
||||
{{ $t('common.addBtn') }}
|
||||
</el-button>
|
||||
<el-button @click="onOpenEditMenu('edit', scope.row)" text type="primary" v-auth="'sys_menu_edit'">{{ $t('common.editBtn') }} </el-button>
|
||||
<el-button @click="menuDialogRef.openDialog('edit', scope.row?.id)" text type="primary" v-auth="'sys_menu_edit'"
|
||||
>{{ $t('common.editBtn') }}
|
||||
</el-button>
|
||||
<el-button @click="handleDelete([scope.row.id])" text type="primary" v-auth="'sys_menu_del'">{{ $t('common.delBtn') }} </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -61,9 +63,12 @@ import { useI18n } from 'vue-i18n';
|
||||
// 引入组件
|
||||
const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const { t } = useI18n();
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
|
||||
// 定义变量内容
|
||||
const menuDialogRef = ref<InstanceType<typeof MenuDialog>>();
|
||||
const menuDialogRef = ref();
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
pageList: pageList, // H
|
||||
queryForm: {
|
||||
@ -71,44 +76,28 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
},
|
||||
isPage: false,
|
||||
});
|
||||
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
const { getDataList } = useTable(state);
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
const { getDataList } = useTable(state);
|
||||
|
||||
// 打开新增菜单弹窗
|
||||
const onOpenAddMenu = (type: string, row: any) => {
|
||||
menuDialogRef.value.openDialog(type, row);
|
||||
};
|
||||
// 打开编辑菜单弹窗
|
||||
const onOpenEditMenu = (type: string, row: any) => {
|
||||
menuDialogRef.value.openDialog(type, row);
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -46,7 +46,6 @@ const { t } = useI18n();
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const deptTreeRef = ref();
|
||||
const visible = ref(false);
|
||||
|
||||
// 提交表单数据
|
||||
@ -55,8 +54,6 @@ const form = reactive({
|
||||
roleName: '',
|
||||
roleCode: '',
|
||||
roleDesc: '',
|
||||
dsType: 0,
|
||||
dsScope: '',
|
||||
});
|
||||
|
||||
// 页面对应元数据
|
||||
@ -94,7 +91,6 @@ const dataRules = ref({
|
||||
},
|
||||
],
|
||||
roleDesc: [{ max: 128, message: '长度在 128 个字符内', trigger: 'blur' }],
|
||||
dsType: [{ required: true, message: '请选择数据权限类型', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
@ -103,10 +99,9 @@ const openDialog = (id: string) => {
|
||||
form.roleId = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
// 获取角色信息
|
||||
if (id) {
|
||||
form.roleId = id;
|
||||
@ -115,41 +110,18 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
if (form.dsType === 1) {
|
||||
form.dsScope = deptTreeRef.value.getCheckedKeys().join(',');
|
||||
} else {
|
||||
form.dsScope = '';
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.roleId ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.roleId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更新
|
||||
if (form.roleId) {
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化角色数据
|
||||
|
@ -114,33 +114,31 @@ const resetQuery = () => {
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.roleId);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/app/approle/export', state.queryForm, 'approle.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.roleId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -30,6 +30,7 @@ import { pageList } from '/@/api/app/appmenu';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { Ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import other from '/@/utils/other';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@ -65,7 +66,7 @@ const openDialog = (row: any) => {
|
||||
})
|
||||
.then((r) => {
|
||||
state.treeData = r.data;
|
||||
state.checkedKeys = resolveAllEunuchNodeId(state.treeData, checkedKeys.value, []);
|
||||
state.checkedKeys = other.resolveAllEunuchNodeId(state.treeData, checkedKeys.value, []);
|
||||
});
|
||||
state.dialog.isShowDialog = true;
|
||||
};
|
||||
@ -74,10 +75,12 @@ const openDialog = (row: any) => {
|
||||
const closeDialog = () => {
|
||||
state.dialog.isShowDialog = false;
|
||||
};
|
||||
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
const menuIds = menuTree.value.getCheckedKeys().join(',').concat(',').concat(menuTree.value.getHalfCheckedKeys().join(','));
|
||||
permissionUpd(state.roleId, menuIds).then(() => {
|
||||
@ -86,21 +89,6 @@ const onSubmit = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[]) => {
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
const item = json[i];
|
||||
// 国际化
|
||||
item.name = t(item.name);
|
||||
// 存在子节点,递归遍历;不存在子节点,将json的id添加到临时数组中
|
||||
if (item.children && item.children.length !== 0) {
|
||||
resolveAllEunuchNodeId(item.children, idArr, temp);
|
||||
} else {
|
||||
temp.push(idArr.filter((id) => id === item.id));
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
|
@ -96,9 +96,9 @@ const openDialog = (id: string) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取appSocialDetails信息
|
||||
if (id) {
|
||||
@ -108,43 +108,27 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
if (form.appSecret && form.appSecret.indexOf('******') >= 0) {
|
||||
form.appSecret = undefined;
|
||||
}
|
||||
// 隐藏敏感信息
|
||||
form.appSecret = form.appSecret?.includes('******') ? undefined : form.appSecret;
|
||||
form.appId = form.appId?.includes('******') ? undefined : form.appId;
|
||||
|
||||
if (form.appId && form.appId.indexOf('******') >= 0) {
|
||||
form.appId = undefined;
|
||||
}
|
||||
|
||||
// 更新
|
||||
try {
|
||||
if (form.id) {
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
await putObj(form);
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
await addObj(form);
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
}
|
||||
});
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
|
@ -129,33 +129,31 @@ const resetQuery = () => {
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/app/appsocial/export', state.queryForm, 'appsocial.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: any) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -145,9 +145,9 @@ const openDialog = (id: string) => {
|
||||
dataForm.userId = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
nextTick(() => {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
});
|
||||
|
||||
// 修改获取用户信息
|
||||
if (id) {
|
||||
@ -158,64 +158,52 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新方法
|
||||
if (dataForm.userId) {
|
||||
if (dataForm.phone && dataForm.phone.indexOf('*') >= 0) {
|
||||
dataForm.phone = undefined;
|
||||
}
|
||||
if (dataForm.password && dataForm.password.indexOf('******') >= 0) {
|
||||
dataForm.password = undefined;
|
||||
}
|
||||
putObj(dataForm)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
} else {
|
||||
// 新增方法
|
||||
if (dataForm.phone && dataForm.phone.indexOf('*') > 0) {
|
||||
dataForm.phone = undefined;
|
||||
}
|
||||
addObj(dataForm)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
// 初始化部门数据
|
||||
const getUserData = (id: string) => {
|
||||
// 获取部门数据
|
||||
try {
|
||||
const { userId, phone, password } = dataForm;
|
||||
|
||||
if (userId) {
|
||||
// 清除占位符,避免提交错误的数据
|
||||
if (phone?.includes('*')) dataForm.phone = undefined;
|
||||
if (password?.includes('******')) dataForm.password = undefined;
|
||||
|
||||
loading.value = true;
|
||||
await putObj(dataForm);
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
} else {
|
||||
loading.value = true;
|
||||
await addObj(dataForm);
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
}
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
// 初始化用户信息数据
|
||||
const getUserData = async (id: string) => {
|
||||
loading.value = true;
|
||||
getObj(id)
|
||||
.then((res) => {
|
||||
Object.assign(dataForm, res.data);
|
||||
dataForm.password = '******';
|
||||
if (res.data.roleList) {
|
||||
dataForm.role = [];
|
||||
res.data.roleList.map((item: any) => {
|
||||
dataForm.role.push(item.roleId);
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
try {
|
||||
const { data } = await getObj(id);
|
||||
|
||||
Object.assign(dataForm, data);
|
||||
dataForm.password = '******';
|
||||
|
||||
if (data.roleList) {
|
||||
dataForm.role = data.roleList.map((item: any) => item.roleId);
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 角色数据
|
||||
|
@ -135,34 +135,31 @@ const resetQuery = () => {
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.userId);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/app/appuser/export', state.queryForm, 'users.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.userId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除用户
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
// 删除用户的接口
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -145,9 +145,9 @@ const openDialog = (id: string) => {
|
||||
form.jobId = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取sysJob信息
|
||||
if (id) {
|
||||
@ -157,35 +157,18 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
// 更新
|
||||
if (form.jobId) {
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
try {
|
||||
form.jobId ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.jobId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
|
@ -244,22 +244,21 @@ const handleRunJob = (row: any) => {
|
||||
// 删除操作
|
||||
const handleDelete = (row: any) => {
|
||||
if (!row) {
|
||||
selectObjs.value.forEach((val: any) => {
|
||||
handleDelete(val);
|
||||
});
|
||||
selectObjs.value.forEach(handleDelete);
|
||||
return;
|
||||
}
|
||||
|
||||
const { jobId, jobName } = row;
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText') + '(任务名称:' + row.jobName + ')')
|
||||
.then(() => {
|
||||
delObj(row.jobId)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
.confirm(`${t('common.delConfirmText')}(任务名称:${jobName})`)
|
||||
.then(async () => {
|
||||
try {
|
||||
await delObj(jobId);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg);
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
@ -87,26 +87,25 @@ const openDialog = (id: string) => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.jobLogId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.jobLogId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
@ -90,7 +90,7 @@ const form = reactive({
|
||||
name: '',
|
||||
url: '',
|
||||
username: '',
|
||||
password: '',
|
||||
password: '' as string || undefined,
|
||||
createTime: '',
|
||||
updateTime: '',
|
||||
dsType: '',
|
||||
@ -139,9 +139,9 @@ const openDialog = async (id: string) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取DatasourceConf信息
|
||||
if (id) {
|
||||
@ -153,39 +153,20 @@ const openDialog = async (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
// 更新
|
||||
if (form.id) {
|
||||
if (form.password.indexOf('********') === 0) {
|
||||
form.password = '';
|
||||
}
|
||||
form.password = form.password?.includes('******') ? undefined : form.password;
|
||||
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
} else {
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
|
@ -19,7 +19,7 @@
|
||||
<el-button @click="formDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary">
|
||||
{{ $t('common.addBtn') }}
|
||||
</el-button>
|
||||
<el-button :disabled="multiple" @click="handleDelete(undefined)" class="ml10" icon="Delete" type="primary">
|
||||
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary">
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
<el-button @click="formDialogRef.openDialog(scope.row.id)" text type="primary">{{ $t('common.editBtn') }} </el-button>
|
||||
|
||||
<el-button @click="handleDelete(scope.row)" text type="primary">{{ $t('common.delBtn') }} </el-button>
|
||||
<el-button @click="handleDelete([scope.row.id])" text type="primary">{{ $t('common.delBtn') }} </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -73,7 +73,7 @@ const formDialogRef = ref();
|
||||
const queryRef = ref();
|
||||
const showSearch = ref(true);
|
||||
// 多选变量
|
||||
const selectObjs = ref([]);
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
@ -96,31 +96,26 @@ const resetQuery = () => {
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (val: any) => {
|
||||
selectObjs.value = val;
|
||||
multiple.value = !val.length;
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (row: any) => {
|
||||
if (!row) {
|
||||
selectObjs.value.forEach((val: any) => {
|
||||
handleDelete(val);
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(row.id)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -18,7 +18,9 @@
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { delFormObj, fetchFormList } from '/@/api/gen/table';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
const emit = defineEmits(['refresh']);
|
||||
const { t } = useI18n();
|
||||
// 搜索变量
|
||||
const visible = ref(false);
|
||||
// table hook
|
||||
@ -31,19 +33,20 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle } = useTable(state);
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (id: string) => {
|
||||
useMessageBox()
|
||||
.confirm('此操作将永久删除')
|
||||
.then(() => {
|
||||
delFormObj(id)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success('删除成功');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (id: string) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delFormObj(id);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 回滚
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { fetchFormById, useFormConfSaveApi, useGeneratorVFormApi, useGeneratorVFormSfcApi } from '/@/api/gen/table';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { handleBlobFile } from '/@/utils/other';
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
|
||||
@ -69,11 +70,10 @@ const tableName = ref();
|
||||
const dsName = ref();
|
||||
// 根据当前表,获取json配置信息
|
||||
const importJsonConfig = () => {
|
||||
tableName.value = route.query.tableName;
|
||||
dsName.value = route.query.dsName;
|
||||
const { tableName, dsName } = route.query;
|
||||
|
||||
if (tableName.value && tableName.value) {
|
||||
useGeneratorVFormApi(dsName.value, tableName.value).then((res) => {
|
||||
if (tableName && tableName) {
|
||||
useGeneratorVFormApi(dsName, tableName).then((res) => {
|
||||
vfDesignerRef.value.loadJson(res);
|
||||
});
|
||||
}
|
||||
@ -86,36 +86,36 @@ const handleRefresh = (id: string) => {
|
||||
};
|
||||
|
||||
const saveJsonConfig = () => {
|
||||
const tableName = route.query.tableName;
|
||||
const dsName = route.query.dsName;
|
||||
const { tableName, dsName } = route.query;
|
||||
|
||||
if (tableName && dsName) {
|
||||
// 先保存表单
|
||||
const formJson = vfDesignerRef.value.getFormJson();
|
||||
useFormConfSaveApi({
|
||||
dsName: dsName,
|
||||
tableName: tableName,
|
||||
dsName,
|
||||
tableName,
|
||||
formInfo: JSON.stringify(formJson),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 使用解构赋值,使代码更加简洁易读;
|
||||
// 在对象属性名和变量名一致时,可以使用对象属性的简写方式;
|
||||
// 使用模板字面量和变量名插值,使字符串拼接更加直观。
|
||||
const exportJsonConfig = async () => {
|
||||
const tableName = route.query.tableName;
|
||||
const dsName = route.query.dsName;
|
||||
|
||||
if (tableName && dsName) {
|
||||
// 先保存表单
|
||||
try {
|
||||
const { tableName, dsName } = route.query;
|
||||
if (!tableName || !dsName) throw new Error('表名或数据源名称不能为空');
|
||||
const formJson = vfDesignerRef.value.getFormJson();
|
||||
const result = await useFormConfSaveApi({
|
||||
dsName: dsName,
|
||||
tableName: tableName,
|
||||
const { data } = await useFormConfSaveApi({
|
||||
dsName,
|
||||
tableName,
|
||||
formInfo: JSON.stringify(formJson),
|
||||
});
|
||||
|
||||
//执行 sfc代码生成
|
||||
const res = await useGeneratorVFormSfcApi(result.data.id);
|
||||
handleBlobFile(res, 'form.vue');
|
||||
const sfcRes = await useGeneratorVFormSfcApi(data.id);
|
||||
handleBlobFile(sfcRes, 'form.vue');
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.message);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -74,9 +74,9 @@ const openDialog = (id: string) => {
|
||||
visible.value = true;
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 如果有id参数,表示是编辑操作,需要设置form.id和获取FieldType信息
|
||||
if (id) {
|
||||
|
@ -89,31 +89,31 @@ const resetQuery = () => {
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/gen/fieldtype/export', state.queryForm, 'fieldtype.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -47,9 +47,10 @@ const dsName = ref();
|
||||
const editTableRef = ref();
|
||||
const generatorType = ref();
|
||||
|
||||
const go = async (activeNum) => {
|
||||
const go = async (activeNum: number) => {
|
||||
if (active.value === activeNum) return;
|
||||
active.value = activeNum;
|
||||
|
||||
if (activeNum === 0) {
|
||||
await editTableRef.value.submitHandle();
|
||||
} else if (activeNum === 1) {
|
||||
|
@ -60,27 +60,22 @@ const dataRules = ref({
|
||||
templateId: [{ required: true, message: '模板不能为空', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
nextTick(() => {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
});
|
||||
|
||||
// 修改获取用户信息
|
||||
// 如果有 id 参数,获取 genGroup 信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getgenGroupData(id);
|
||||
}
|
||||
|
||||
// 获取genGroup信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getgenGroupData(id);
|
||||
}
|
||||
// 获取模板信息
|
||||
getTemplateData();
|
||||
};
|
||||
|
||||
|
@ -115,26 +115,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -53,6 +53,10 @@ const openDialog = async (id: string) => {
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
/**
|
||||
* 获取特定资源的代码生成文件,显示在页面上。
|
||||
* @param id 需要渲染的资源 ID。
|
||||
*/
|
||||
const getGenCodeFile = (id: string) => {
|
||||
loading.value = true;
|
||||
fileTreeOriginal.value = [];
|
||||
|
@ -72,10 +72,9 @@ const openDialog = (id: string) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
// 获取genTemplate信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
|
@ -104,26 +104,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -38,19 +38,21 @@ onMounted(() => {
|
||||
initUserInfo(data.user.userId);
|
||||
});
|
||||
|
||||
const initUserInfo = (userId: any) => {
|
||||
loading.value = true;
|
||||
getObj(userId)
|
||||
.then((res) => {
|
||||
userData.value = res.data;
|
||||
userData.value.postName = res.data.postList
|
||||
.map((item) => {
|
||||
return item.postName;
|
||||
})
|
||||
.join(',');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
/**
|
||||
* 根据用户 ID 初始化用户信息。
|
||||
* @param {any} userId - 要查询的用户 ID。
|
||||
* @returns {Promise<void>} - 初始化用户信息的 Promise 实例。
|
||||
*/
|
||||
const initUserInfo = async (userId: any): Promise<void> => {
|
||||
try {
|
||||
loading.value = true; // 显示加载状态
|
||||
|
||||
const res = await getObj(userId); // 执行查询操作
|
||||
userData.value = res.data; // 将查询到的数据保存到 userData 变量中
|
||||
userData.value.postName = res.data?.postList?.map((item: any) => item.postName).join(',') || ''; // 将 postList 中的 postName 合并成字符串并保存到 userData 变量中
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<!-- 新增日程的表单 -->
|
||||
<schedule-form ref="scheduleFormRef" @refresh="initscheduleList(formatDate(calendar, 'YYYY-mm'))" />
|
||||
<!-- 日程查询 -->
|
||||
<schedule ref="scheduleRef" />
|
||||
<schedule ref="scheduleRef" @refresh="initscheduleList(formatDate(calendar, 'YYYY-mm'))" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="SysScheduleCalendar">
|
||||
|
@ -94,9 +94,10 @@ const openDialog = (id: string, row: any) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
if (row?.date) {
|
||||
form.date = row.date;
|
||||
}
|
||||
@ -109,44 +110,21 @@ const openDialog = (id: string, row: any) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新
|
||||
if (form.id) {
|
||||
loading.value = true;
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 初始化表单数据
|
||||
const getsysScheduleData = (id: string) => {
|
||||
// 获取数据
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="visible" title="日程管理" size="80%">
|
||||
<el-drawer v-model="visible" title="日程管理" size="80%" @close="handleClose">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row v-show="showSearch" class="mb8">
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
@ -30,15 +30,7 @@
|
||||
<el-button formDialogRef icon="Download" type="primary" class="ml10" @click="exportExcel">
|
||||
{{ $t('common.exportBtn') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
formDialogRef
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
v-auth="'admin_schedule_del'"
|
||||
@click="handleDelete(selectObjs)"
|
||||
>
|
||||
<el-button formDialogRef :disabled="multiple" icon="Delete" type="primary" class="ml10" @click="handleDelete(selectObjs)">
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
@ -96,7 +88,7 @@ import { useDict } from '/@/hooks/dict';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import DictTag from '/@/components/DictTag/index.vue';
|
||||
const { schedule_type, schedule_status } = useDict('schedule_type', 'schedule_status');
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const { t } = useI18n();
|
||||
@ -111,19 +103,20 @@ const showSearch = ref(true);
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
|
||||
// table hook
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
createdIsNeed: false,
|
||||
pageList: fetchList,
|
||||
});
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile } = useTable(state);
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value.resetFields();
|
||||
queryRef.value?.resetFields();
|
||||
state.queryForm.date = '';
|
||||
// 清空多选
|
||||
selectObjs.value = [];
|
||||
getDataList();
|
||||
@ -136,26 +129,30 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
//关闭日程刷新首页日程数据
|
||||
const handleClose = () => {
|
||||
emit('refresh');
|
||||
};
|
||||
|
||||
const open = (row: any) => {
|
||||
|
@ -78,22 +78,20 @@ const handleSendCode = async () => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理登录请求。
|
||||
*/
|
||||
const handleLogin = async () => {
|
||||
loginFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const valid = await loginFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
loading.value = true;
|
||||
useUserInfo()
|
||||
.loginByMobile(loginForm)
|
||||
.then(() => {
|
||||
emit('signInSuccess');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
try {
|
||||
loading.value = true;
|
||||
await useUserInfo().loginByMobile(loginForm);
|
||||
emit('signInSuccess');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const msg = reactive({
|
||||
|
@ -117,22 +117,20 @@ const handlePassScore = (e) => {
|
||||
score.value = e;
|
||||
};
|
||||
|
||||
const handleRegister = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
registerUser(state.ruleForm)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
loading.value = false;
|
||||
emit('afterSuccess');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleRegister = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
loading.value = true;
|
||||
registerUser(state.ruleForm)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
loading.value = false;
|
||||
emit('afterSuccess');
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -182,7 +182,7 @@ const handleDelete = (ids: string[]) => {
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
@ -197,7 +197,7 @@ const handelBlack = (ids: string[]) => {
|
||||
.then(() => {
|
||||
black(ids, state.queryForm.wxAccountAppid)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
getDataList();
|
||||
useMessage().success('拉黑用户成功');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
@ -212,7 +212,7 @@ const handelUnBlack = (ids: string[]) => {
|
||||
.then(() => {
|
||||
unblack(ids, state.queryForm.wxAccountAppid)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
getDataList();
|
||||
useMessage().success('设置成功');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
@ -171,7 +171,7 @@ const handleDelete = (ids: string[]) => {
|
||||
wxAccountAppid: state.queryForm.wxAccountAppid,
|
||||
})
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
@ -152,7 +152,7 @@ const handleDelete = (ids: string[]) => {
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
@ -79,9 +79,10 @@ const openDialog = (id: string) => {
|
||||
form.leaveId = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
|
||||
nextTick(() => {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
});
|
||||
|
||||
// 获取oaLeaveBill信息
|
||||
if (id) {
|
||||
@ -93,42 +94,18 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新
|
||||
if (form.leaveId) {
|
||||
loading.value = true;
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.leaveId ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.leaveId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
|
@ -130,42 +130,45 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.leaveId);
|
||||
});
|
||||
console.log(selectObjs);
|
||||
selectObjs.value.push(...objs.map((val: any) => val.leaveId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = (row) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.optConfirmText'))
|
||||
.then(() => {
|
||||
submit(row.leaveId)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 提交表单数据。
|
||||
* @param {object} row 当前行数据。
|
||||
* @returns {void}
|
||||
*/
|
||||
const handleSubmit = async (row) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.optConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await submit(row.leaveId);
|
||||
getDataList();
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -64,9 +64,9 @@ const openDialog = (id: string) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
if (id) {
|
||||
form.id = id;
|
||||
@ -86,42 +86,18 @@ const getModelData = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新
|
||||
if (form.id) {
|
||||
loading.value = true;
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
@ -43,7 +43,7 @@
|
||||
<template #default="scope">
|
||||
<el-button @click="handleView(scope.row.id)" text type="primary" v-auth="'oa_model_view'">模型图 </el-button>
|
||||
<el-button @click="handleDeploy(scope.row.id)" text type="primary" v-auth="'oa_model_add'"> 部署 </el-button>
|
||||
<el-button @click="handleDelete([scope.row.roleId])" text type="primary" v-auth="'oa_model_del'">{{ $t('common.delBtn') }} </el-button>
|
||||
<el-button @click="handleDelete([scope.row.id])" text type="primary" v-auth="'oa_model_del'">{{ $t('common.delBtn') }} </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -93,29 +93,26 @@ const resetQuery = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
const handleDeploy = (id: string) => {
|
||||
deploy(id).then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
|
@ -51,7 +51,7 @@
|
||||
<el-button @click="handleView(scope.row)" text type="primary">流程图 </el-button>
|
||||
<el-button @click="handleStatus(scope.row, 'suspend')" text type="primary" v-if="!scope.row.suspend">失效 </el-button>
|
||||
<el-button @click="handleStatus(scope.row, 'active')" text type="primary" v-if="scope.row.suspend">激活 </el-button>
|
||||
<el-button @click="handleDelete([scope.row.roleId])" text type="primary" v-auth="'oa_process_del'">{{ $t('common.delBtn') }} </el-button>
|
||||
<el-button @click="handleDelete([scope.row.processonDefinitionId])" text type="primary" v-auth="'oa_process_del'">{{ $t('common.delBtn') }} </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -103,27 +103,25 @@ const resetQuery = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.roleId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.processonDefinitionId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
//查看流程图
|
||||
@ -135,18 +133,19 @@ const handleView = (row: any) => {
|
||||
};
|
||||
|
||||
// 失效
|
||||
const handleStatus = (row, type) => {
|
||||
useMessageBox()
|
||||
.confirm('是否将此流程设置为 ' + type)
|
||||
.then(() => {
|
||||
status(row.processonDefinitionId, type)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleStatus = async (row, type) => {
|
||||
try {
|
||||
await useMessageBox().confirm('是否将此流程设置为 ' + type);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await status(row.processonDefinitionId, type)
|
||||
getDataList();
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -55,9 +55,7 @@ const { getDataList, sortChangeHandle } = useTable(state);
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.leaveId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
|
@ -86,9 +86,9 @@ const openDialog = (id: string) => {
|
||||
form.taskId = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取oaLeaveBill信息
|
||||
if (id) {
|
||||
@ -100,36 +100,37 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const handleTask = (result) => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
form.taskFlag = result;
|
||||
doTask(form).then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
});
|
||||
const handleTask = async (result) => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
loading.value = true;
|
||||
form.taskFlag = result;
|
||||
doTask(form).then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
const getTaskById = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true;
|
||||
fetchDetail(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
form.comment = res.data.comment ? res.data.comment : '';
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error('操作失败');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
/**
|
||||
* 根据 ID 获取任务数据并初始化表单。
|
||||
* @param {string} id - 要查询的任务 ID。
|
||||
* @returns {Promise<void>} - 初始化表单的 Promise 实例。
|
||||
*/
|
||||
const getTaskById = async (id) => {
|
||||
loading.value = true; // 显示加载状态
|
||||
|
||||
try {
|
||||
const res = await fetchDetail(id); // 执行查询操作
|
||||
// 将查询到的数据合并到表单中,并设置表单评论信息
|
||||
Object.assign(form, res.data);
|
||||
form.comment = res.data.comment ?? '';
|
||||
} catch (err) {
|
||||
useMessage().error('操作失败'); // 如果查询失败,则显示错误提示信息
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
@ -112,27 +112,25 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.taskId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.taskId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObj(ids)
|
||||
.then(() => {
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
//查看流程图
|
||||
|
@ -64,14 +64,24 @@ onMounted(() => {
|
||||
getQr();
|
||||
});
|
||||
|
||||
const getQr = () => {
|
||||
if (state.type === '0') {
|
||||
useBuyApi(state.amount).then((res) => {
|
||||
url.value = res.params;
|
||||
});
|
||||
} else {
|
||||
/**
|
||||
* 获取支付二维码信息。
|
||||
* @param {Object} state - 包含 type 和 amount 两个属性的对象。
|
||||
* @param {string} state.type - 支付类型。"0" 表示直接购买,其他值表示商品购买。
|
||||
* @param {number} state.amount - 支付金额。
|
||||
* @returns {Promise<string>} - 返回 Promise 实例,包含获取到的支付二维码链接地址。
|
||||
*/
|
||||
const getQr = async () => {
|
||||
const { type, amount } = state;
|
||||
try {
|
||||
if (type === '0') {
|
||||
const res = await useBuyApi(amount);
|
||||
return res.params; // 直接返回购买 API 返回的二维码链接地址
|
||||
}
|
||||
const tenantId = Session.getTenant();
|
||||
url.value = `${protocol}//${host}/admin/goods/buy?amount=${state.amount}&TENANT-ID=${tenantId}`;
|
||||
return `${protocol}//${host}/admin/goods/buy?amount=${amount}&TENANT-ID=${tenantId}`; // 返回商品购买的二维码链接地址
|
||||
} catch (err) {
|
||||
throw new Error('获取支付信息失败');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -132,9 +132,9 @@ const openDialog = (id: string) => {
|
||||
form.id = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
nextTick(() => {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
});
|
||||
|
||||
// 获取payChannel信息
|
||||
if (id) {
|
||||
@ -144,55 +144,36 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新
|
||||
if (form.id) {
|
||||
loading.value = true;
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
const getpayChannelData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true;
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
/**
|
||||
* 根据 ID 获取支付通道数据并初始化表单。
|
||||
* @param {string} id - 要查询的支付通道 ID。
|
||||
* @returns {Promise<void>} - 初始化表单的 Promise 实例。
|
||||
*/
|
||||
const getpayChannelData = async (id: string): Promise<void> => {
|
||||
loading.value = true; // 显示加载状态
|
||||
|
||||
try {
|
||||
const res = await getObj(id); // 执行查询操作
|
||||
Object.assign(form, res.data); // 将查询到的数据合并到表单中
|
||||
} catch (err) {
|
||||
useMessage().error('操作失败'); // 如果查询失败,则显示错误提示信息
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
@ -135,26 +135,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -118,55 +118,36 @@ const openDialog = (id: string) => {
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新
|
||||
if (form.goodsOrderId) {
|
||||
loading.value = true;
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
const getpayGoodsOrderData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true;
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
/**
|
||||
* 根据 ID 获取商品支付订单数据并初始化表单。
|
||||
* @param {string} id - 要查询的商品支付订单 ID。
|
||||
* @returns {Promise<void>} - 初始化表单的 Promise 实例。
|
||||
*/
|
||||
const getpayGoodsOrderData = async (id: string): Promise<void> => {
|
||||
loading.value = true; // 显示加载状态
|
||||
|
||||
try {
|
||||
const res = await getObj(id); // 执行查询操作
|
||||
Object.assign(form, res.data); // 将查询到的数据合并到表单中
|
||||
} catch (err) {
|
||||
useMessage().error('操作失败'); // 如果查询失败,则显示错误提示信息
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
@ -136,26 +136,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.goodsOrderId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.goodsOrderId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -107,26 +107,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.id);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.id));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -113,26 +113,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.refundOrderId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.refundOrderId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -155,55 +155,32 @@ const dictType = ref([
|
||||
]);
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 更新
|
||||
if (form.orderId) {
|
||||
loading.value = true;
|
||||
putObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.editSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
loading.value = true;
|
||||
addObj(form)
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
form.orderId ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.orderId ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
const getpayTradeOrderData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true;
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
const getpayTradeOrderData = async (id: string) => {
|
||||
loading.value = true; // 显示加载状态
|
||||
|
||||
try {
|
||||
const res = await getObj(id); // 执行查询操作
|
||||
Object.assign(form, res.data); // 将查询到的数据合并到表单中
|
||||
} catch (err) {
|
||||
useMessage().error('操作失败'); // 如果查询失败,则显示错误提示信息
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
@ -158,26 +158,24 @@ const exportExcel = () => {
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = [];
|
||||
objs.forEach((val: any) => {
|
||||
selectObjs.value.push(val.orderId);
|
||||
});
|
||||
selectObjs.value.push(...objs.map((val: any) => val.orderId));
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = (ids: string[]) => {
|
||||
useMessageBox()
|
||||
.confirm(t('common.delConfirmText'))
|
||||
.then(() => {
|
||||
delObjs(ids)
|
||||
.then(() => {
|
||||
getDataList(false);
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
});
|
||||
});
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -108,9 +108,9 @@ const openDialog = (id: string) => {
|
||||
form.orderId = '';
|
||||
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取payTradeOrder信息
|
||||
if (id) {
|
||||
@ -119,26 +119,33 @@ const openDialog = (id: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dataFormRef.value.validate((valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
useRefundApi({ payOrderId: form.orderId, refundAmount: form.amount, remark: form.remark, channelId: form.channelId })
|
||||
.then(() => {
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh');
|
||||
})
|
||||
.catch((err: any) => {
|
||||
useMessage().error(err.msg);
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 提交表单数据并执行退款操作。
|
||||
* @returns {Promise<void>} - 执行退款操作的 Promise 实例。
|
||||
*/
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true; // 显示加载状态
|
||||
|
||||
await useRefundApi({
|
||||
// 执行退款操作
|
||||
payOrderId: form.orderId,
|
||||
refundAmount: form.amount,
|
||||
remark: form.remark,
|
||||
channelId: form.channelId,
|
||||
});
|
||||
|
||||
useMessage().success(t('common.optSuccessText')); // 如果退款成功,则显示成功提示信息
|
||||
visible.value = false; // 关闭弹窗
|
||||
emit('refresh'); // 触发 refresh 事件
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg); // 如果出现异常,则显示错误提示信息
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
|
@ -2,14 +2,12 @@ import vue from '@vitejs/plugin-vue';
|
||||
import { resolve } from 'path';
|
||||
import { defineConfig, loadEnv, ConfigEnv } from 'vite';
|
||||
import vueSetupExtend from 'vite-plugin-vue-setup-extend';
|
||||
// vue3 自动引入
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import topLevelAwait from 'vite-plugin-top-level-await';
|
||||
import { svgBuilder } from '/@/components/iconSelector/index';
|
||||
|
||||
// 按需加载
|
||||
import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-import';
|
||||
import viteCompression from 'vite-plugin-compression';
|
||||
// @ts-ignore
|
||||
import { svgBuilder } from '/@/components/iconSelector/index';
|
||||
|
||||
const pathResolve = (dir: string) => {
|
||||
return resolve(__dirname, '.', dir);
|
||||
@ -24,42 +22,41 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
||||
const env = loadEnv(mode.mode, process.cwd());
|
||||
return {
|
||||
plugins: [
|
||||
vue(),
|
||||
svgBuilder('./src/assets/icons/'),
|
||||
vueSetupExtend(),
|
||||
vue(), // Vue 插件
|
||||
svgBuilder('./src/assets/icons/'), // 将 SVG 文件转换成 Vue 组件
|
||||
vueSetupExtend(), // setup语法糖增强插件
|
||||
AutoImport({
|
||||
imports: ['vue', 'vue-router', 'pinia'],
|
||||
dts: './auto-imports.d.ts',
|
||||
imports: ['vue', 'vue-router', 'pinia'], // 自动导入的依赖库数组
|
||||
dts: './auto-imports.d.ts', // 自动导入类型定义文件路径
|
||||
}),
|
||||
createStyleImportPlugin({
|
||||
resolves: [VxeTableResolve()],
|
||||
resolves: [VxeTableResolve()], // 配置vxetable 按需加载
|
||||
}),
|
||||
topLevelAwait({
|
||||
// The export name of top-level await promise for each chunk module
|
||||
promiseExportName: '__tla',
|
||||
// The function to generate import names of top-level await promise in each chunk module
|
||||
promiseImportName: (i) => `__tla_${i}`,
|
||||
promiseExportName: '__tla', // TLA Promise 变量名
|
||||
promiseImportName: (i) => `__tla_${i}`, // TLA Promise 导入名
|
||||
}),
|
||||
viteCompression({
|
||||
deleteOriginFile: true,
|
||||
deleteOriginFile: true, // 压缩后删除原来的文件
|
||||
}),
|
||||
],
|
||||
root: process.cwd(),
|
||||
resolve: { alias },
|
||||
root: process.cwd(), // 项目根目录
|
||||
resolve: { alias }, // 路径别名配置
|
||||
base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
|
||||
optimizeDeps: {
|
||||
include: ['element-plus/lib/locale/lang/zh-cn', 'element-plus/lib/locale/lang/en'],
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: env.VITE_PORT as unknown as number,
|
||||
open: env.VITE_OPEN === 'true',
|
||||
hmr: true,
|
||||
host: '0.0.0.0', // 服务器地址
|
||||
port: env.VITE_PORT as unknown as number, // 服务器端口号
|
||||
open: env.VITE_OPEN === 'true', // 是否自动打开浏览器
|
||||
hmr: true, // 启用热更新
|
||||
proxy: {
|
||||
// 代理设置,用于解决跨域问题
|
||||
'/admin': {
|
||||
target: env.VITE_ADMIN_PROXY_PATH,
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
target: env.VITE_ADMIN_PROXY_PATH, // 目标服务器地址
|
||||
ws: true, // 是否启用 WebSocket
|
||||
changeOrigin: true, // 是否修改请求头中的 Origin 字段
|
||||
},
|
||||
'/gen': {
|
||||
target: env.VITE_GEN_PROXY_PATH,
|
||||
@ -69,8 +66,8 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
chunkSizeWarningLimit: 1500,
|
||||
outDir: 'dist', // 打包输出目录
|
||||
chunkSizeWarningLimit: 1500, // 代码分包阈值
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: `assets/[name].[hash].js`,
|
||||
|
Loading…
Reference in New Issue
Block a user