♻️ Refactoring code. 重构代码

This commit is contained in:
lbw 2023-03-15 17:55:30 +08:00
parent ad2306d39d
commit b03696ad78
99 changed files with 1658 additions and 1854 deletions

View File

@ -1,5 +1,4 @@
import request from '/@/utils/request';
import { getObjDetails } from '/@/api/admin/param';
export function fetchList(query?: Object) {
return request({

View File

@ -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,
});
}

View File

@ -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,
},
//

View File

@ -31,7 +31,7 @@ const props = defineProps({
default: 0,
},
pageSizes: {
type: Array,
type: Array as () => number[],
default: () => {
return [1, 10, 20, 50, 100, 200];
},

View File

@ -61,6 +61,9 @@ const handleNodeClick = (item: any) => {
emit('nodeClick', item);
};
/**
* 获取部门树形结构数据
*/
const getDeptTree = () => {
if (props.query instanceof Function) {
state.localLoading = true;

View File

@ -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'));

View File

@ -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(),

View File

@ -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 {

View File

@ -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) => {

View File

@ -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);
};

View File

@ -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();

View File

@ -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);
// isLockScreenlockScreenTime
themeConfig.value.isLockScreen = false;
themeConfig.value.lockScreenTime = 30;
//
setLocalThemeConfig();
} catch (err: any) {
// mes
mes.value = err.msg;
}
};
const formData = reactive({});

View File

@ -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;
},
},
});

View File

@ -8,11 +8,9 @@ export const useMsg = defineStore('msg', {
getAllMsg() {
return this.msgArray;
},
// 设置字典
setMsg(value: Object) {
this.msgArray.push(value);
},
// 删除字典
removeAll() {
this.msgArray = [];
},

View File

@ -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(),

View File

@ -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 线

View File

@ -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;

View File

@ -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>

View File

@ -197,7 +197,9 @@ const openDialog = (id: string) => {
visible.value = true;
form.id = '';
//
dataFormRef.value?.resetFields();
nextTick(() => {
dataFormRef.value?.resetFields();
});
// sysOauthClientDetails
if (id) {

View File

@ -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>

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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;

View File

@ -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>

View File

@ -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;

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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);
// ;jsonid
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,

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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);
}
};
//

View File

@ -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 = () => {

View File

@ -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);
// ;jsonid
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) => {
//

View File

@ -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 = () => {

View File

@ -8,5 +8,7 @@ export default {
expiresAt: 'expiresAt',
inputUsernameTip: 'input Username',
offlineBtn: 'offline',
offlineConfirmText: 'offline confirm',
offlineSuccessText: 'offline success',
},
};

View File

@ -8,5 +8,7 @@ export default {
expiresAt: '过期时间',
inputUsernameTip: '请输入用户名',
offlineBtn: '下线',
offlineConfirmText: '确认下线',
offlineSuccessText: '下线成功',
},
};

View File

@ -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

View File

@ -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;
}
};

View File

@ -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',

View File

@ -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: '密码等级太低',
},
};

View File

@ -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>

View File

@ -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,

View File

@ -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>

View File

@ -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);
});
}
});
};
//

View File

@ -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>

View File

@ -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);
// ;jsonid
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,

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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;
}
};
//

View File

@ -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>

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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);
}
};
//

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -74,9 +74,9 @@ const openDialog = (id: string) => {
visible.value = true;
//
if (dataFormRef.value) {
dataFormRef.value.resetFields();
}
nextTick(() => {
dataFormRef.value?.resetFields();
});
// idform.idFieldType
if (id) {

View File

@ -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>

View File

@ -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) {

View File

@ -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();
};

View File

@ -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>

View File

@ -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 = [];

View File

@ -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;

View File

@ -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>

View File

@ -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>

View File

@ -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">

View File

@ -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) => {
//

View File

@ -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) => {

View File

@ -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({

View File

@ -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>

View File

@ -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) => {

View File

@ -171,7 +171,7 @@ const handleDelete = (ids: string[]) => {
wxAccountAppid: state.queryForm.wxAccountAppid,
})
.then(() => {
getDataList(false);
getDataList();
useMessage().success(t('common.delSuccessText'));
})
.catch((err: any) => {

View File

@ -152,7 +152,7 @@ const handleDelete = (ids: string[]) => {
.then(() => {
delObjs(ids)
.then(() => {
getDataList(false);
getDataList();
useMessage().success(t('common.delSuccessText'));
})
.catch((err: any) => {

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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);
}
};
//

View File

@ -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'));

View File

@ -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>

View File

@ -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;
};

View File

@ -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; //
}
};
//

View File

@ -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);
}
};
//

View File

@ -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>

View File

@ -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; //
}
};
//

View File

@ -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>

View File

@ -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; //
}
};
//

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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; //
}
};
//

View File

@ -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>

View File

@ -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; //
}
};
//

View File

@ -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`,