fix: 修改引用文件名和实际不一致的问题。

feat: 增加根据 location.origin 获取当前请求地址的功能。
This commit is contained in:
yangjiewei
2025-04-03 10:18:55 +08:00
parent 99c3300bad
commit 31b6cdb63b
8 changed files with 444 additions and 497 deletions

View File

@ -16,7 +16,7 @@ VITE_BUILD_COMPRESS = 'gzip'
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
# 接口地址 可以由nginx做转发或者直接写实际地址 # 接口地址 可以由nginx做转发或者直接写实际地址
VITE_GLOB_API_URL=http://10.0.252.5:3100/api VITE_GLOB_API_URL=${location.origin}/api
# 文件上传地址 可以由nginx做转发或者直接写实际地址 # 文件上传地址 可以由nginx做转发或者直接写实际地址

View File

@ -21,7 +21,7 @@ function createConfig(params: CreateConfigParams) {
try { try {
const windowConf = `window.${configName}`; const windowConf = `window.${configName}`;
// Ensure that the variable will not be modified // Ensure that the variable will not be modified
let configStr = `${windowConf}=${JSON.stringify(config)};`; let configStr = `${windowConf}=${JSON.stringify(config).replace(/:"([^"]+)"/g, ':`$1`')};`;
configStr += ` configStr += `
Object.freeze(${windowConf}); Object.freeze(${windowConf});
Object.defineProperty(window, "${configName}", { Object.defineProperty(window, "${configName}", {

View File

@ -1,9 +1,6 @@
<template> <template>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex"> <PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, type: 'radio', onChange: onSelectChange }" @row-db-click="dbClickRow">
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys,type: 'radio', onChange: onSelectChange }" @row-dbClick="dbClickRow">
<template #toolbar> <template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code"> <template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)"> <a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
@ -17,9 +14,6 @@
</template> </template>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'"> <template v-if="column.dataIndex === 'action'">
<TableAction :actions="getActions(record)" /> <TableAction :actions="getActions(record)" />
</template> </template>
@ -42,21 +36,15 @@
<RoleListModal @register="registerRoleListModal" /> <RoleListModal @register="registerRoleListModal" />
<GroupModal @register="registerModal" @success="handleSuccess" /> <GroupModal @register="registerModal" @success="handleSuccess" />
<RoleModal @register="registerRoleModal" @success="handleSelectRoleSuccess" /> <RoleModal @register="registerRoleModal" @success="handleSelectRoleSuccess" />
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, onMounted, onUnmounted, createVNode, import { ref, computed, onMounted, onUnmounted, createVNode } from 'vue';
} from 'vue';
import { Modal } from 'ant-design-vue'; import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table'; import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getXjrGroupPage, deleteXjrGroup} from '/@/api/system/Group'; import { getXjrGroupPage, deleteXjrGroup } from '/@/api/system/group';
import { SelectDepartment } from '/@/components/SelectOrganizational/index'; import { SelectDepartment } from '/@/components/SelectOrganizational/index';
import { PageWrapper } from '/@/components/Page'; import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
@ -67,30 +55,15 @@
import RoleListModal from './components/RoleListModal.vue'; import RoleListModal from './components/RoleListModal.vue';
import RoleModal from '../user/components/RoleModal.vue'; import RoleModal from '../user/components/RoleModal.vue';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import GroupModal from './components/GroupModal.vue'; import GroupModal from './components/GroupModal.vue';
import { searchFormSchema, columns } from './components/config'; import { searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index'; import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus'; import useEventBus from '/@/hooks/event/useEventBus';
import { addGroupUser,getGroupUser,addGroupRole,getGroupRole } from '/@/api/system/group'; import { addGroupUser, getGroupUser, addGroupRole, getGroupRole } from '/@/api/system/group';
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus(); const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
@ -103,25 +76,25 @@
const filterColumns = filterColumnAuth(columns); const filterColumns = filterColumnAuth(columns);
const tableRef = ref(); const tableRef = ref();
const selectedUserId = ref<string[]>([]); const selectedUserId = ref<string[]>([]);
const [registerModal, { openModal:openGroupModal,setModalProps:setGroupModalProps }] = useModal(); const [registerModal, { openModal: openGroupModal, setModalProps: setGroupModalProps }] = useModal();
const [registerAuthModal, { openModal,setModalProps }] = useModal(); const [registerAuthModal, { openModal, setModalProps }] = useModal();
const [registerRoleListModal, { openModal:openRoleListProps,setModalProps:setRoleListProps }] = useModal(); const [registerRoleListModal, { openModal: openRoleListProps, setModalProps: setRoleListProps }] = useModal();
const [registerRoleModal, { openModal:openRoleModal,setModalProps:setRoleModalProps}] = useModal(); const [registerRoleModal, { openModal: openRoleModal, setModalProps: setRoleModalProps }] = useModal();
//展示在列表内的按钮 //展示在列表内的按钮
const actionButtons = ref<string[]>([ 'edit', 'copyData', 'delete', 'startwork','flowRecord']); const actionButtons = ref<string[]>(['edit', 'copyData', 'delete', 'startwork', 'flowRecord']);
const buttonConfigs = computed(()=>{ const buttonConfigs = computed(() => {
const list = [ const list = [
{"isUse":true,"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true}, { isUse: true, name: '编辑', code: 'edit', icon: 'ant-design:form-outlined', isDefault: true },
{"isUse":true,"name":"新增用户组","code":"add","icon":"","isDefault":true,"type":"primary"}, { isUse: true, name: '新增用户组', code: 'add', icon: '', isDefault: true, type: 'primary' },
{"isUse":true,"name":"添加角色","code":"addRole","icon":"","isDefault":true,"type":"primary"}, { isUse: true, name: '添加角色', code: 'addRole', icon: '', isDefault: true, type: 'primary' },
{"isUse":true,"name":"查看角色","code":"viewRole","icon":"","isDefault":true,"type":"primary"}, { isUse: true, name: '查看角色', code: 'viewRole', icon: '', isDefault: true, type: 'primary' },
{"isUse":true,"name":"添加成员","code":"addMember","icon":"","isDefault":true,"type":"primary"}, { isUse: true, name: '添加成员', code: 'addMember', icon: '', isDefault: true, type: 'primary' },
{"isUse":true,"name":"查看成员","code":"viewMember","icon":"","isDefault":true,"type":"primary"}, { isUse: true, name: '查看成员', code: 'viewMember', icon: '', isDefault: true, type: 'primary' },
{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}] { isUse: true, name: '删除', code: 'delete', icon: 'ant-design:delete-outlined', isDefault: true }
];
return filterButtonAuth(list); return filterButtonAuth(list);
}) });
const tableButtonConfig = computed(() => { const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code)); return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
@ -132,54 +105,48 @@
}); });
const btnEvent = { const btnEvent = {
edit : handleEdit, edit: handleEdit,
refresh : handleRefresh, refresh: handleRefresh,
view : handleView, view: handleView,
batchdelete : handleBatchdelete, batchdelete: handleBatchdelete,
delete : handleDelete, delete: handleDelete,
addMember:handleAddUser, addMember: handleAddUser,
add:handleAdd, add: handleAdd,
viewMember:handleViewUser, viewMember: handleViewUser,
addRole:handleAddRole, addRole: handleAddRole,
viewRole:handleViewRole, viewRole: handleViewRole
} };
const { currentRoute } = useRouter(); const { currentRoute } = useRouter();
const router = useRouter(); const router = useRouter();
const formIdComputedRef = ref(); const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId formIdComputedRef.value = currentRoute.value.meta.formId;
const schemaIdComputedRef = ref(); const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId schemaIdComputedRef.value = currentRoute.value.meta.schemaId;
const selectedKeys = ref<string[]>([]); const selectedKeys = ref<string[]>([]);
const selectedRowsData = ref<any[]>([]); const selectedRowsData = ref<any[]>([]);
const formName='用户组管理'; const formName = '用户组管理';
const [registerTable, { reload,getSelectRows }] = useTable({ const [registerTable, { reload, getSelectRows }] = useTable({
title: '' || (formName + '列表'), title: '' || formName + '列表',
api: getXjrGroupPage, api: getXjrGroupPage,
rowKey: 'id', rowKey: 'id',
columns: filterColumns, columns: filterColumns,
formConfig: { formConfig: {
rowProps: { rowProps: {
gutter: 16, gutter: 16
}, },
schemas: searchFormSchema, schemas: searchFormSchema,
fieldMapToTime: [], fieldMapToTime: [],
showResetButton: false, showResetButton: false
}, },
beforeFetch: (params) => { beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id' }; return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
}, },
afterFetch: (res) => { afterFetch: (res) => {
tableRef.value.setToolBarWidth(); tableRef.value.setToolBarWidth();
}, },
useSearchForm: true, useSearchForm: true,
showTableSetting: true, showTableSetting: true,
@ -189,17 +156,17 @@
width: 160, width: 160,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
slots: { customRender: 'action' }, slots: { customRender: 'action' }
}, },
tableSetting: { tableSetting: {
size: false, size: false,
setting: false, setting: false
}, },
customRow, customRow
}); });
function dbClickRow(record) { function dbClickRow(record) {
if (!actionButtonConfig?.value.some(element => element.code == 'view')) { if (!actionButtonConfig?.value.some((element) => element.code == 'view')) {
return; return;
} }
const { processId, taskIds, schemaId } = record.workflowData || {}; const { processId, taskIds, schemaId } = record.workflowData || {};
@ -232,19 +199,17 @@
} }
function buttonClick(code) { function buttonClick(code) {
btnEvent[code](); btnEvent[code]();
} }
function handleAdd() { function handleAdd() {
openGroupModal(true, { openGroupModal(true, {
isUpdate: false, isUpdate: false
}); });
setGroupModalProps({ title: t('新增用户组') }); setGroupModalProps({ title: t('新增用户组') });
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
router.push({ router.push({
path: '/form/Group/' + record.id + '/updateForm', path: '/form/Group/' + record.id + '/updateForm',
query: { query: {
@ -254,13 +219,11 @@
}); });
} }
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
deleteList([record.id]); deleteList([record.id]);
} }
function handleViewUser(){ function handleViewUser() {
let rows = warning(); let rows = warning();
if (!rows) { if (!rows) {
return; return;
@ -293,7 +256,7 @@
try { try {
const res = await getGroupRole(rows.id); const res = await getGroupRole(rows.id);
openRoleModal(true, { openRoleModal(true, {
roles: res, roles: res
}); });
setRoleModalProps({ title: t('添加角色') }); setRoleModalProps({ title: t('添加角色') });
} catch (e) { } catch (e) {
@ -301,7 +264,7 @@
} }
} }
function handleViewRole(){ function handleViewRole() {
let rows = warning(); let rows = warning();
if (!rows) { if (!rows) {
return; return;
@ -310,7 +273,6 @@
openRoleListProps(true, res); openRoleListProps(true, res);
setRoleListProps({ title: t('查看角色') }); setRoleListProps({ title: t('查看角色') });
}); });
} }
function handleSelectUserSuccess(rows, type) { function handleSelectUserSuccess(rows, type) {
@ -325,20 +287,19 @@
addGroupUser(paramas).then((_) => { addGroupUser(paramas).then((_) => {
notification.info({ notification.info({
message: t('添加人员'), message: t('添加人员'),
description: t('成功'), description: t('成功')
}); //提示消息 }); //提示消息
}); });
} }
function handleSelectRoleSuccess(rows, type) { function handleSelectRoleSuccess(rows, type) {
const selectRows = getSelectRows(); const selectRows = getSelectRows();
let paramas = { type, id: selectRows[0].id, roleIds: rows.map(row => row.id) }; let paramas = { type, id: selectRows[0].id, roleIds: rows.map((row) => row.id) };
addGroupRole(paramas).then((_) => { addGroupRole(paramas).then((_) => {
notification.info({ notification.info({
message: t('添加角色'), message: t('添加角色'),
description: t('成功'), description: t('成功')
}); //提示消息 }); //提示消息
}); });
} }
@ -348,13 +309,13 @@
if (selectRows.length === 0) { if (selectRows.length === 0) {
notification.warning({ notification.warning({
message: t('警告'), message: t('警告'),
description: t('必须选中一行!'), description: t('必须选中一行!')
}); //提示消息 }); //提示消息
return false; return false;
} else if (isAdminCantUse && selectRows[0].id === '1') { } else if (isAdminCantUse && selectRows[0].id === '1') {
notification.warning({ notification.warning({
message: t('警告'), message: t('警告'),
description: t('超级管理员不允许授权'), description: t('超级管理员不允许授权')
}); });
return false; return false;
} else { } else {
@ -366,21 +327,18 @@
if (!selectedKeys.value.length) { if (!selectedKeys.value.length) {
notification.warning({ notification.warning({
message: 'Tip', message: 'Tip',
description: t('请选择需要删除的数据'), description: t('请选择需要删除的数据')
}); });
return; return;
} }
//与工作流相关的数据不能进行批量删除 //与工作流相关的数据不能进行批量删除
const cantDelete = selectedRowsData.value.filter((x) => { const cantDelete = selectedRowsData.value.filter((x) => {
return ( return (x.workflowData?.enabled && x.workflowData?.status) || (!x.workflowData?.enabled && !!x.workflowData?.processId);
(x.workflowData?.enabled && x.workflowData?.status) ||
(!x.workflowData?.enabled && !!x.workflowData?.processId)
);
}); });
if (cantDelete.length) { if (cantDelete.length) {
notification.warning({ notification.warning({
message: 'Tip', message: 'Tip',
description: t('含有不能删除的数据'), description: t('含有不能删除的数据')
}); });
return; return;
} }
@ -398,17 +356,14 @@
handleSuccess(); handleSuccess();
notification.success({ notification.success({
message: 'Tip', message: 'Tip',
description: t('删除成功!'), description: t('删除成功!')
}); });
}); });
}, },
onCancel() {}, onCancel() {}
}); });
} }
function onSelectChange(selectedRowKeys: [], selectedRows) { function onSelectChange(selectedRowKeys: [], selectedRows) {
selectedKeys.value = selectedRowKeys; selectedKeys.value = selectedRowKeys;
selectedRowsData.value = selectedRows; selectedRowsData.value = selectedRows;
@ -425,32 +380,24 @@
selectedRowKeys.push(record.id); selectedRowKeys.push(record.id);
} }
selectedKeys.value = selectedRowKeys; selectedKeys.value = selectedRowKeys;
}, }
}; };
} }
function handleRefresh() { function handleRefresh() {
reload(); reload();
} }
function handleSuccess() { function handleSuccess() {
selectedKeys.value = []; selectedKeys.value = [];
selectedRowsData.value = []; selectedRowsData.value = [];
reload(); reload();
} }
function handleView(record: Recordable) { function handleView(record: Recordable) {
dbClickRow(record); dbClickRow(record);
} }
onMounted(() => { onMounted(() => {
if (schemaIdComputedRef.value) { if (schemaIdComputedRef.value) {
bus.on(FLOW_PROCESSED, handleRefresh); bus.on(FLOW_PROCESSED, handleRefresh);
bus.on(CREATE_FLOW, handleRefresh); bus.on(CREATE_FLOW, handleRefresh);
@ -466,22 +413,21 @@
bus.off(FORM_LIST_MODIFIED, handleRefresh); bus.off(FORM_LIST_MODIFIED, handleRefresh);
} }
}); });
function getActions(record: Recordable):ActionItem[] { function getActions(record: Recordable): ActionItem[] {
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => { const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
if (!record.workflowData?.processId) { if (!record.workflowData?.processId) {
return { return {
icon: button?.icon, icon: button?.icon,
tooltip: button?.name, tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined, color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record), onClick: btnEvent[button.code].bind(null, record)
}; };
} else { } else {
if (button.code === 'view') { if (button.code === 'view') {
return { return {
icon: button?.icon, icon: button?.icon,
tooltip: button?.name, tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record), onClick: btnEvent[button.code].bind(null, record)
}; };
} else { } else {
return {}; return {};
@ -490,16 +436,17 @@
}); });
return actionsList; return actionsList;
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.ant-table-selection-col) { :deep(.ant-table-selection-col) {
width: 50px; width: 50px;
} }
.show{
.show {
display: flex; display: flex;
} }
.hide{
.hide {
display: none !important; display: none !important;
} }
</style> </style>