提交角色界面修改
This commit is contained in:
1 parent
d45af45132
commit
2b5db607f6
8 files changed
+325
-31
No files matched your search
@@ -100,6 +100,7 @@ watch(
|
||||
if (Array.isArray(val)) {
|
||||
list = val as OssVO[];
|
||||
} else if (typeof val === 'string') {
|
||||
console.log('val', val);
|
||||
// 检查是否包含逗号分隔的URL
|
||||
if (val.includes(',')) {
|
||||
// 多个URL用逗号分隔
|
||||
@@ -136,6 +137,7 @@ watch(
|
||||
}
|
||||
return itemData;
|
||||
});
|
||||
console.log('fileList', fileList.value);
|
||||
} else {
|
||||
fileList.value = [];
|
||||
return [];
|
||||
@@ -238,6 +240,7 @@ const handleUploadError = () => {
|
||||
|
||||
// 预览
|
||||
const handlePictureCardPreview = (file: any) => {
|
||||
console.log('file', file);
|
||||
dialogImageUrl.value = file.url;
|
||||
dialogVisible.value = true;
|
||||
};
|
||||
@@ -247,9 +250,9 @@ const listToString = (list: any[], separator?: string) => {
|
||||
let strs = '';
|
||||
separator = separator || ',';
|
||||
for (const i in list) {
|
||||
if (undefined !== list[i].url && list[i].url.indexOf('blob:') !== 0) {
|
||||
if (undefined !== list[i].ossId && list[i].ossId.indexOf('blob:') !== 0) {
|
||||
// 始终返回URL而不是ossId
|
||||
strs += list[i].url + separator;
|
||||
strs += list[i].ossId + separator;
|
||||
}
|
||||
}
|
||||
return strs != '' ? strs.substring(0, strs.length - 1) : '';
|
||||
|
||||
+40
-14
@@ -4,27 +4,27 @@ import errorCode from '@/utils/errorCode';
|
||||
import { blobValidate } from '@/utils/ruoyi';
|
||||
import { LoadingInstance } from 'element-plus/es/components/loading/src/loading.mjs';
|
||||
import { globalHeaders } from '@/utils/request';
|
||||
import { getFileDownloadUrl } from '@/api/system/file';
|
||||
|
||||
const baseURL = import.meta.env.VITE_APP_BASE_API;
|
||||
let downloadLoadingInstance: LoadingInstance;
|
||||
export default {
|
||||
async oss(ossId: string | number) {
|
||||
const url = baseURL + '/resource/oss/download/' + ossId;
|
||||
downloadLoadingInstance = ElLoading.service({ text: '正在下载数据,请稍候', background: 'rgba(0, 0, 0, 0.7)' });
|
||||
downloadLoadingInstance = ElLoading.service({ text: '正在获取文件访问链接,请稍候', background: 'rgba(0, 0, 0, 0.7)' });
|
||||
try {
|
||||
const res = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
headers: globalHeaders()
|
||||
});
|
||||
const isBlob = blobValidate(res.data);
|
||||
if (isBlob) {
|
||||
const blob = new Blob([res.data], { type: 'application/octet-stream' });
|
||||
FileSaver.saveAs(blob, decodeURIComponent(res.headers['download-filename'] as string));
|
||||
} else {
|
||||
this.printErrMsg(res.data);
|
||||
// 使用新的安全下载方法
|
||||
const { data: downloadUrl } = await getFileDownloadUrl(Number(ossId));
|
||||
|
||||
// 使用fetch下载文件
|
||||
const response = await fetch(downloadUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error('下载失败');
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const filename = response.headers.get('content-disposition')?.split('filename=')[1]?.replace(/"/g, '') || `file_${ossId}`;
|
||||
|
||||
FileSaver.saveAs(blob, decodeURIComponent(filename));
|
||||
downloadLoadingInstance.close();
|
||||
} catch (r) {
|
||||
console.error(r);
|
||||
@@ -32,6 +32,32 @@ export default {
|
||||
downloadLoadingInstance.close();
|
||||
}
|
||||
},
|
||||
|
||||
// 新增:安全下载文件方法
|
||||
async secureOss(ossId: string | number, fileName?: string) {
|
||||
downloadLoadingInstance = ElLoading.service({ text: '正在获取文件访问链接,请稍候', background: 'rgba(0, 0, 0, 0.7)' });
|
||||
try {
|
||||
// 获取临时下载URL
|
||||
const { data: downloadUrl } = await getFileDownloadUrl(Number(ossId));
|
||||
|
||||
// 使用fetch下载文件
|
||||
const response = await fetch(downloadUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error('下载失败');
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const finalFileName = fileName || response.headers.get('content-disposition')?.split('filename=')[1]?.replace(/"/g, '') || `file_${ossId}`;
|
||||
|
||||
FileSaver.saveAs(blob, decodeURIComponent(finalFileName));
|
||||
downloadLoadingInstance.close();
|
||||
} catch (r) {
|
||||
console.error(r);
|
||||
ElMessage.error('下载文件出现错误,请联系管理员!');
|
||||
downloadLoadingInstance.close();
|
||||
}
|
||||
},
|
||||
|
||||
async zip(url: string, name: string) {
|
||||
url = baseURL + url;
|
||||
downloadLoadingInstance = ElLoading.service({ text: '正在下载数据,请稍候', background: 'rgba(0, 0, 0, 0.7)' });
|
||||
|
||||
@@ -312,6 +312,7 @@ const handleUpdate = async (row?: HallInfoVO) => {
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
console.log('form.value', form.value);
|
||||
hallInfoFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
|
||||
@@ -310,12 +310,21 @@ const dialog = reactive<DialogOption>({
|
||||
|
||||
/** 判断是否为系统角色(权限字符以XT-BJZW-开头) */
|
||||
const isSystemRole = computed(() => {
|
||||
return form.value.roleKey && form.value.roleKey.startsWith('XT-BJZW-');
|
||||
if (form.value.roleKey && form.value.roleKey.trim() !== '') {
|
||||
return form.value.roleKey.startsWith('XT-BJZW-');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/** 判断表格中的角色是否为系统角色 */
|
||||
const isSystemRoleInTable = (row: RoleVO) => {
|
||||
return row.roleKey && row.roleKey.startsWith('XT-BJZW-');
|
||||
if (row.roleKey && row.roleKey.trim() !== '') {
|
||||
return row.roleKey.startsWith('XT-BJZW-');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// return row.roleKey && row.roleKey.trim() !== '' && row.roleKey.startsWith('XT-BJZW-');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -431,12 +440,17 @@ const reset = () => {
|
||||
deptExpand.value = true;
|
||||
deptNodeAll.value = false;
|
||||
form.value = { ...initForm };
|
||||
// 确保roleKey被明确重置为空字符串
|
||||
form.value.roleKey = '';
|
||||
roleFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 添加角色 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
// 确保roleKey被正确重置为空字符串
|
||||
form.value.roleKey = '';
|
||||
console.log('新增角色 - roleKey:', `"${form.value.roleKey}"`, 'isSystemRole:', isSystemRole.value);
|
||||
getMenuTreeselect();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加角色';
|
||||
@@ -448,6 +462,7 @@ const handleUpdate = async (row?: RoleVO) => {
|
||||
const { data } = await getRole(roleId);
|
||||
Object.assign(form.value, data);
|
||||
form.value.roleSort = Number(form.value.roleSort);
|
||||
console.log('修改角色 - roleKey:', `"${form.value.roleKey}"`, 'isSystemRole:', isSystemRole.value);
|
||||
const res = await getRoleMenuTreeselect(roleId);
|
||||
dialog.title = '修改角色';
|
||||
dialog.visible = true;
|
||||
|
||||
Reference in new issue
Block a user