fix: 修改引用文件名和实际不一致的问题。
feat: 增加根据 location.origin 获取当前请求地址的功能。
This commit is contained in:
@ -16,7 +16,7 @@ VITE_BUILD_COMPRESS = 'gzip'
|
||||
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
|
||||
|
||||
# 接口地址 可以由nginx做转发或者直接写实际地址
|
||||
VITE_GLOB_API_URL=http://10.0.252.5:3100/api
|
||||
VITE_GLOB_API_URL=${location.origin}/api
|
||||
|
||||
|
||||
# 文件上传地址 可以由nginx做转发或者直接写实际地址
|
||||
|
||||
@ -11,18 +11,18 @@ import { getConfigFileName } from '../getConfigFileName';
|
||||
import pkg from '../../package.json';
|
||||
|
||||
interface CreateConfigParams {
|
||||
configName: string;
|
||||
config: any;
|
||||
configFileName?: string;
|
||||
configName: string;
|
||||
config: any;
|
||||
configFileName?: string;
|
||||
}
|
||||
|
||||
function createConfig(params: CreateConfigParams) {
|
||||
const { configName, config, configFileName } = params;
|
||||
try {
|
||||
const windowConf = `window.${configName}`;
|
||||
// Ensure that the variable will not be modified
|
||||
let configStr = `${windowConf}=${JSON.stringify(config)};`;
|
||||
configStr += `
|
||||
const { configName, config, configFileName } = params;
|
||||
try {
|
||||
const windowConf = `window.${configName}`;
|
||||
// Ensure that the variable will not be modified
|
||||
let configStr = `${windowConf}=${JSON.stringify(config).replace(/:"([^"]+)"/g, ':`$1`')};`;
|
||||
configStr += `
|
||||
Object.freeze(${windowConf});
|
||||
Object.defineProperty(window, "${configName}", {
|
||||
configurable: false,
|
||||
@ -30,18 +30,18 @@ function createConfig(params: CreateConfigParams) {
|
||||
});
|
||||
`.replace(/\s/g, '');
|
||||
|
||||
fs.mkdirp(getRootPath(OUTPUT_DIR));
|
||||
writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
||||
fs.mkdirp(getRootPath(OUTPUT_DIR));
|
||||
writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
||||
|
||||
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n');
|
||||
} catch (error) {
|
||||
console.log(colors.red('configuration file configuration file failed to package:\n' + error));
|
||||
}
|
||||
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n');
|
||||
} catch (error) {
|
||||
console.log(colors.red('configuration file configuration file failed to package:\n' + error));
|
||||
}
|
||||
}
|
||||
|
||||
export function runBuildConfig() {
|
||||
const config = getEnvConfig();
|
||||
const configFileName = getConfigFileName(config);
|
||||
createConfig({ config, configName: configFileName, configFileName: GLOB_CONFIG_FILE_NAME });
|
||||
const config = getEnvConfig();
|
||||
const configFileName = getConfigFileName(config);
|
||||
createConfig({ config, configName: configFileName, configFileName: GLOB_CONFIG_FILE_NAME });
|
||||
}
|
||||
|
||||
@ -1,505 +1,452 @@
|
||||
<template>
|
||||
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
|
||||
|
||||
|
||||
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys,type: 'radio', onChange: onSelectChange }" @row-dbClick="dbClickRow">
|
||||
|
||||
<template #toolbar>
|
||||
<template v-for="button in tableButtonConfig" :key="button.code">
|
||||
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
|
||||
<template #icon><Icon :icon="button.icon" /></template>
|
||||
{{ button.name }}
|
||||
</a-button>
|
||||
<a-button v-else :type="button.type">
|
||||
<template #icon><Icon :icon="button.icon" /></template>
|
||||
{{ button.name }}
|
||||
</a-button>
|
||||
</template>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
|
||||
|
||||
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<TableAction :actions="getActions(record)" />
|
||||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
|
||||
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, type: 'radio', onChange: onSelectChange }" @row-db-click="dbClickRow">
|
||||
<template #toolbar>
|
||||
<template v-for="button in tableButtonConfig" :key="button.code">
|
||||
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
|
||||
<template #icon><Icon :icon="button.icon" /></template>
|
||||
{{ button.name }}
|
||||
</a-button>
|
||||
<a-button v-else :type="button.type">
|
||||
<template #icon><Icon :icon="button.icon" /></template>
|
||||
{{ button.name }}
|
||||
</a-button>
|
||||
</template>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<TableAction :actions="getActions(record)" />
|
||||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
|
||||
<SelectDepartment
|
||||
v-if="visible"
|
||||
:visible="visible"
|
||||
:multiple="true"
|
||||
:selectedIds="selectedUserId"
|
||||
@close="
|
||||
() => {
|
||||
visible = false;
|
||||
}
|
||||
"
|
||||
@change="handleSelectUserSuccess"
|
||||
/>
|
||||
<AuthModal @register="registerAuthModal" />
|
||||
<RoleListModal @register="registerRoleListModal" />
|
||||
<GroupModal @register="registerModal" @success="handleSuccess" />
|
||||
<RoleModal @register="registerRoleModal" @success="handleSelectRoleSuccess" />
|
||||
|
||||
|
||||
|
||||
|
||||
</PageWrapper>
|
||||
<SelectDepartment
|
||||
v-if="visible"
|
||||
:visible="visible"
|
||||
:multiple="true"
|
||||
:selectedIds="selectedUserId"
|
||||
@close="
|
||||
() => {
|
||||
visible = false;
|
||||
}
|
||||
"
|
||||
@change="handleSelectUserSuccess"
|
||||
/>
|
||||
<AuthModal @register="registerAuthModal" />
|
||||
<RoleListModal @register="registerRoleListModal" />
|
||||
<GroupModal @register="registerModal" @success="handleSuccess" />
|
||||
<RoleModal @register="registerRoleModal" @success="handleSelectRoleSuccess" />
|
||||
</PageWrapper>
|
||||
</template>
|
||||
<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 { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
|
||||
import { getXjrGroupPage, deleteXjrGroup} from '/@/api/system/Group';
|
||||
import { SelectDepartment } from '/@/components/SelectOrganizational/index';
|
||||
import { PageWrapper } from '/@/components/Page';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
import { useRouter } from 'vue-router';
|
||||
import AuthModal from '../dataAuthority/components/AuthModal.vue';
|
||||
import RoleListModal from './components/RoleListModal.vue';
|
||||
import RoleModal from '../user/components/RoleModal.vue';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
|
||||
import { getXjrGroupPage, deleteXjrGroup } from '/@/api/system/group';
|
||||
import { SelectDepartment } from '/@/components/SelectOrganizational/index';
|
||||
import { PageWrapper } from '/@/components/Page';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
import { useRouter } from 'vue-router';
|
||||
import AuthModal from '../dataAuthority/components/AuthModal.vue';
|
||||
import RoleListModal from './components/RoleListModal.vue';
|
||||
import RoleModal from '../user/components/RoleModal.vue';
|
||||
|
||||
import { useModal } from '/@/components/Modal';
|
||||
|
||||
import GroupModal from './components/GroupModal.vue';
|
||||
|
||||
import { useModal } from '/@/components/Modal';
|
||||
|
||||
|
||||
|
||||
import GroupModal from './components/GroupModal.vue';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import { searchFormSchema, columns } from './components/config';
|
||||
import Icon from '/@/components/Icon/index';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import useEventBus from '/@/hooks/event/useEventBus';
|
||||
import { addGroupUser,getGroupUser,addGroupRole,getGroupRole } from '/@/api/system/group';
|
||||
import { searchFormSchema, columns } from './components/config';
|
||||
import Icon from '/@/components/Icon/index';
|
||||
|
||||
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
|
||||
import useEventBus from '/@/hooks/event/useEventBus';
|
||||
import { addGroupUser, getGroupUser, addGroupRole, getGroupRole } from '/@/api/system/group';
|
||||
|
||||
const { notification } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
|
||||
|
||||
defineEmits(['register']);
|
||||
const { filterColumnAuth, filterButtonAuth } = usePermission();
|
||||
const visible = ref<boolean>(false);
|
||||
const filterColumns = filterColumnAuth(columns);
|
||||
const tableRef = ref();
|
||||
const selectedUserId = ref<string[]>([]);
|
||||
const [registerModal, { openModal:openGroupModal,setModalProps:setGroupModalProps }] = useModal();
|
||||
const [registerAuthModal, { openModal,setModalProps }] = useModal();
|
||||
const [registerRoleListModal, { openModal:openRoleListProps,setModalProps:setRoleListProps }] = useModal();
|
||||
const [registerRoleModal, { openModal:openRoleModal,setModalProps:setRoleModalProps}] = useModal();
|
||||
const { notification } = useMessage();
|
||||
const { t } = useI18n();
|
||||
|
||||
defineEmits(['register']);
|
||||
const { filterColumnAuth, filterButtonAuth } = usePermission();
|
||||
const visible = ref<boolean>(false);
|
||||
const filterColumns = filterColumnAuth(columns);
|
||||
const tableRef = ref();
|
||||
const selectedUserId = ref<string[]>([]);
|
||||
const [registerModal, { openModal: openGroupModal, setModalProps: setGroupModalProps }] = useModal();
|
||||
const [registerAuthModal, { openModal, setModalProps }] = useModal();
|
||||
const [registerRoleListModal, { openModal: openRoleListProps, setModalProps: setRoleListProps }] = useModal();
|
||||
const [registerRoleModal, { openModal: openRoleModal, setModalProps: setRoleModalProps }] = useModal();
|
||||
|
||||
//展示在列表内的按钮
|
||||
const actionButtons = ref<string[]>([ 'edit', 'copyData', 'delete', 'startwork','flowRecord']);
|
||||
const buttonConfigs = computed(()=>{
|
||||
const list = [
|
||||
{"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":"addRole","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":"viewMember","icon":"","isDefault":true,"type":"primary"},
|
||||
{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}]
|
||||
return filterButtonAuth(list);
|
||||
})
|
||||
|
||||
const tableButtonConfig = computed(() => {
|
||||
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
|
||||
});
|
||||
|
||||
const actionButtonConfig = computed(() => {
|
||||
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
|
||||
});
|
||||
|
||||
const btnEvent = {
|
||||
edit : handleEdit,
|
||||
refresh : handleRefresh,
|
||||
view : handleView,
|
||||
batchdelete : handleBatchdelete,
|
||||
delete : handleDelete,
|
||||
addMember:handleAddUser,
|
||||
add:handleAdd,
|
||||
viewMember:handleViewUser,
|
||||
addRole:handleAddRole,
|
||||
viewRole:handleViewRole,
|
||||
}
|
||||
|
||||
const { currentRoute } = useRouter();
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
const formIdComputedRef = ref();
|
||||
formIdComputedRef.value = currentRoute.value.meta.formId
|
||||
const schemaIdComputedRef = ref();
|
||||
schemaIdComputedRef.value = currentRoute.value.meta.schemaId
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const selectedKeys = ref<string[]>([]);
|
||||
const selectedRowsData = ref<any[]>([]);
|
||||
|
||||
const formName='用户组管理';
|
||||
const [registerTable, { reload,getSelectRows }] = useTable({
|
||||
title: '' || (formName + '列表'),
|
||||
api: getXjrGroupPage,
|
||||
rowKey: 'id',
|
||||
columns: filterColumns,
|
||||
formConfig: {
|
||||
rowProps: {
|
||||
gutter: 16,
|
||||
},
|
||||
schemas: searchFormSchema,
|
||||
fieldMapToTime: [],
|
||||
showResetButton: false,
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
|
||||
},
|
||||
afterFetch: (res) => {
|
||||
tableRef.value.setToolBarWidth();
|
||||
|
||||
},
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
|
||||
striped: false,
|
||||
actionColumn: {
|
||||
width: 160,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' },
|
||||
},
|
||||
tableSetting: {
|
||||
size: false,
|
||||
setting: false,
|
||||
},
|
||||
customRow,
|
||||
});
|
||||
|
||||
function dbClickRow(record) {
|
||||
if (!actionButtonConfig?.value.some(element => element.code == 'view')) {
|
||||
return;
|
||||
}
|
||||
const { processId, taskIds, schemaId } = record.workflowData || {};
|
||||
if (taskIds && taskIds.length) {
|
||||
router.push({
|
||||
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
|
||||
query: {
|
||||
taskId: taskIds[0],
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
} else if (schemaId && !taskIds && processId) {
|
||||
router.push({
|
||||
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
|
||||
query: {
|
||||
readonly: 1,
|
||||
taskId: '',
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
path: '/form/Group/' + record.id + '/viewForm',
|
||||
query: {
|
||||
formPath: 'system/Group',
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function buttonClick(code) {
|
||||
|
||||
btnEvent[code]();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openGroupModal(true, {
|
||||
isUpdate: false,
|
||||
});
|
||||
setGroupModalProps({ title: t('新增用户组') });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
|
||||
router.push({
|
||||
path: '/form/Group/' + record.id + '/updateForm',
|
||||
query: {
|
||||
formPath: 'system/group',
|
||||
formName: formName
|
||||
}
|
||||
//展示在列表内的按钮
|
||||
const actionButtons = ref<string[]>(['edit', 'copyData', 'delete', 'startwork', 'flowRecord']);
|
||||
const buttonConfigs = computed(() => {
|
||||
const list = [
|
||||
{ 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: 'addRole', 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: 'viewMember', icon: '', isDefault: true, type: 'primary' },
|
||||
{ isUse: true, name: '删除', code: 'delete', icon: 'ant-design:delete-outlined', isDefault: true }
|
||||
];
|
||||
return filterButtonAuth(list);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
deleteList([record.id]);
|
||||
}
|
||||
|
||||
function handleViewUser(){
|
||||
let rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
getGroupUser(rows.id).then((res) => {
|
||||
openModal(true, res);
|
||||
setModalProps({ title: t('查看成员') });
|
||||
});
|
||||
}
|
||||
|
||||
function handleAddUser(record: Recordable) {
|
||||
let rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
getGroupUser(rows.id).then((res) => {
|
||||
selectedUserId.value = res.map((item) => {
|
||||
return item.id;
|
||||
});
|
||||
console.log(selectedUserId.value);
|
||||
visible.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAddRole() {
|
||||
const rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await getGroupRole(rows.id);
|
||||
openRoleModal(true, {
|
||||
roles: res,
|
||||
});
|
||||
setRoleModalProps({ title: t('添加角色') });
|
||||
} catch (e) {
|
||||
console.error('获取角色失败', e);
|
||||
}
|
||||
}
|
||||
|
||||
function handleViewRole(){
|
||||
let rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
getGroupRole(rows.id).then((res) => {
|
||||
openRoleListProps(true, res);
|
||||
setRoleListProps({ title: t('查看角色') });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function handleSelectUserSuccess(rows, type) {
|
||||
const selectRows = getSelectRows();
|
||||
let paramas;
|
||||
if (type === 0) {
|
||||
paramas = { type, id: selectRows[0].id, userIds: rows };
|
||||
} else {
|
||||
paramas = { type, id: selectRows[0].id, departmentIds: rows };
|
||||
}
|
||||
|
||||
addGroupUser(paramas).then((_) => {
|
||||
notification.info({
|
||||
message: t('添加人员'),
|
||||
description: t('成功'),
|
||||
}); //提示消息
|
||||
});
|
||||
}
|
||||
|
||||
function handleSelectRoleSuccess(rows, type) {
|
||||
const selectRows = getSelectRows();
|
||||
let paramas = { type, id: selectRows[0].id, roleIds: rows.map(row => row.id) };
|
||||
|
||||
|
||||
addGroupRole(paramas).then((_) => {
|
||||
notification.info({
|
||||
message: t('添加角色'),
|
||||
description: t('成功'),
|
||||
}); //提示消息
|
||||
});
|
||||
}
|
||||
|
||||
function warning(isAdminCantUse = false) {
|
||||
const selectRows = getSelectRows();
|
||||
if (selectRows.length === 0) {
|
||||
notification.warning({
|
||||
message: t('警告'),
|
||||
description: t('必须选中一行!'),
|
||||
}); //提示消息
|
||||
return false;
|
||||
} else if (isAdminCantUse && selectRows[0].id === '1') {
|
||||
notification.warning({
|
||||
message: t('警告'),
|
||||
description: t('超级管理员不允许授权'),
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
return selectRows[0];
|
||||
}
|
||||
}
|
||||
|
||||
function handleBatchdelete() {
|
||||
if (!selectedKeys.value.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: t('请选择需要删除的数据'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
//与工作流相关的数据不能进行批量删除
|
||||
const cantDelete = selectedRowsData.value.filter((x) => {
|
||||
return (
|
||||
(x.workflowData?.enabled && x.workflowData?.status) ||
|
||||
(!x.workflowData?.enabled && !!x.workflowData?.processId)
|
||||
);
|
||||
const tableButtonConfig = computed(() => {
|
||||
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
|
||||
});
|
||||
if (cantDelete.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: t('含有不能删除的数据'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
deleteList(selectedKeys.value);
|
||||
}
|
||||
function deleteList(ids) {
|
||||
Modal.confirm({
|
||||
title: '提示信息',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '是否确认删除?',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk() {
|
||||
deleteXjrGroup(ids).then((_) => {
|
||||
handleSuccess();
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: t('删除成功!'),
|
||||
});
|
||||
});
|
||||
},
|
||||
onCancel() {},
|
||||
|
||||
const actionButtonConfig = computed(() => {
|
||||
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function onSelectChange(selectedRowKeys: [], selectedRows) {
|
||||
selectedKeys.value = selectedRowKeys;
|
||||
selectedRowsData.value = selectedRows;
|
||||
}
|
||||
|
||||
function customRow(record: Recordable) {
|
||||
return {
|
||||
onClick: () => {
|
||||
let selectedRowKeys = [...selectedKeys.value];
|
||||
if (selectedRowKeys.indexOf(record.id) >= 0) {
|
||||
let index = selectedRowKeys.indexOf(record.id);
|
||||
selectedRowKeys.splice(index, 1);
|
||||
} else {
|
||||
selectedRowKeys.push(record.id);
|
||||
}
|
||||
selectedKeys.value = selectedRowKeys;
|
||||
},
|
||||
|
||||
const btnEvent = {
|
||||
edit: handleEdit,
|
||||
refresh: handleRefresh,
|
||||
view: handleView,
|
||||
batchdelete: handleBatchdelete,
|
||||
delete: handleDelete,
|
||||
addMember: handleAddUser,
|
||||
add: handleAdd,
|
||||
viewMember: handleViewUser,
|
||||
addRole: handleAddRole,
|
||||
viewRole: handleViewRole
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function handleRefresh() {
|
||||
reload();
|
||||
}
|
||||
function handleSuccess() {
|
||||
|
||||
|
||||
const { currentRoute } = useRouter();
|
||||
const router = useRouter();
|
||||
|
||||
const formIdComputedRef = ref();
|
||||
formIdComputedRef.value = currentRoute.value.meta.formId;
|
||||
const schemaIdComputedRef = ref();
|
||||
schemaIdComputedRef.value = currentRoute.value.meta.schemaId;
|
||||
|
||||
const selectedKeys = ref<string[]>([]);
|
||||
const selectedRowsData = ref<any[]>([]);
|
||||
|
||||
const formName = '用户组管理';
|
||||
const [registerTable, { reload, getSelectRows }] = useTable({
|
||||
title: '' || formName + '列表',
|
||||
api: getXjrGroupPage,
|
||||
rowKey: 'id',
|
||||
columns: filterColumns,
|
||||
formConfig: {
|
||||
rowProps: {
|
||||
gutter: 16
|
||||
},
|
||||
schemas: searchFormSchema,
|
||||
fieldMapToTime: [],
|
||||
showResetButton: false
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
|
||||
},
|
||||
afterFetch: (res) => {
|
||||
tableRef.value.setToolBarWidth();
|
||||
},
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
|
||||
striped: false,
|
||||
actionColumn: {
|
||||
width: 160,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' }
|
||||
},
|
||||
tableSetting: {
|
||||
size: false,
|
||||
setting: false
|
||||
},
|
||||
customRow
|
||||
});
|
||||
|
||||
function dbClickRow(record) {
|
||||
if (!actionButtonConfig?.value.some((element) => element.code == 'view')) {
|
||||
return;
|
||||
}
|
||||
const { processId, taskIds, schemaId } = record.workflowData || {};
|
||||
if (taskIds && taskIds.length) {
|
||||
router.push({
|
||||
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
|
||||
query: {
|
||||
taskId: taskIds[0],
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
} else if (schemaId && !taskIds && processId) {
|
||||
router.push({
|
||||
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
|
||||
query: {
|
||||
readonly: 1,
|
||||
taskId: '',
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
path: '/form/Group/' + record.id + '/viewForm',
|
||||
query: {
|
||||
formPath: 'system/Group',
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function buttonClick(code) {
|
||||
btnEvent[code]();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openGroupModal(true, {
|
||||
isUpdate: false
|
||||
});
|
||||
setGroupModalProps({ title: t('新增用户组') });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
router.push({
|
||||
path: '/form/Group/' + record.id + '/updateForm',
|
||||
query: {
|
||||
formPath: 'system/group',
|
||||
formName: formName
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
deleteList([record.id]);
|
||||
}
|
||||
|
||||
function handleViewUser() {
|
||||
let rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
getGroupUser(rows.id).then((res) => {
|
||||
openModal(true, res);
|
||||
setModalProps({ title: t('查看成员') });
|
||||
});
|
||||
}
|
||||
|
||||
function handleAddUser(record: Recordable) {
|
||||
let rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
getGroupUser(rows.id).then((res) => {
|
||||
selectedUserId.value = res.map((item) => {
|
||||
return item.id;
|
||||
});
|
||||
console.log(selectedUserId.value);
|
||||
visible.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAddRole() {
|
||||
const rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await getGroupRole(rows.id);
|
||||
openRoleModal(true, {
|
||||
roles: res
|
||||
});
|
||||
setRoleModalProps({ title: t('添加角色') });
|
||||
} catch (e) {
|
||||
console.error('获取角色失败', e);
|
||||
}
|
||||
}
|
||||
|
||||
function handleViewRole() {
|
||||
let rows = warning();
|
||||
if (!rows) {
|
||||
return;
|
||||
}
|
||||
getGroupRole(rows.id).then((res) => {
|
||||
openRoleListProps(true, res);
|
||||
setRoleListProps({ title: t('查看角色') });
|
||||
});
|
||||
}
|
||||
|
||||
function handleSelectUserSuccess(rows, type) {
|
||||
const selectRows = getSelectRows();
|
||||
let paramas;
|
||||
if (type === 0) {
|
||||
paramas = { type, id: selectRows[0].id, userIds: rows };
|
||||
} else {
|
||||
paramas = { type, id: selectRows[0].id, departmentIds: rows };
|
||||
}
|
||||
|
||||
addGroupUser(paramas).then((_) => {
|
||||
notification.info({
|
||||
message: t('添加人员'),
|
||||
description: t('成功')
|
||||
}); //提示消息
|
||||
});
|
||||
}
|
||||
|
||||
function handleSelectRoleSuccess(rows, type) {
|
||||
const selectRows = getSelectRows();
|
||||
let paramas = { type, id: selectRows[0].id, roleIds: rows.map((row) => row.id) };
|
||||
|
||||
addGroupRole(paramas).then((_) => {
|
||||
notification.info({
|
||||
message: t('添加角色'),
|
||||
description: t('成功')
|
||||
}); //提示消息
|
||||
});
|
||||
}
|
||||
|
||||
function warning(isAdminCantUse = false) {
|
||||
const selectRows = getSelectRows();
|
||||
if (selectRows.length === 0) {
|
||||
notification.warning({
|
||||
message: t('警告'),
|
||||
description: t('必须选中一行!')
|
||||
}); //提示消息
|
||||
return false;
|
||||
} else if (isAdminCantUse && selectRows[0].id === '1') {
|
||||
notification.warning({
|
||||
message: t('警告'),
|
||||
description: t('超级管理员不允许授权')
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
return selectRows[0];
|
||||
}
|
||||
}
|
||||
|
||||
function handleBatchdelete() {
|
||||
if (!selectedKeys.value.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: t('请选择需要删除的数据')
|
||||
});
|
||||
return;
|
||||
}
|
||||
//与工作流相关的数据不能进行批量删除
|
||||
const cantDelete = selectedRowsData.value.filter((x) => {
|
||||
return (x.workflowData?.enabled && x.workflowData?.status) || (!x.workflowData?.enabled && !!x.workflowData?.processId);
|
||||
});
|
||||
if (cantDelete.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: t('含有不能删除的数据')
|
||||
});
|
||||
return;
|
||||
}
|
||||
deleteList(selectedKeys.value);
|
||||
}
|
||||
function deleteList(ids) {
|
||||
Modal.confirm({
|
||||
title: '提示信息',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '是否确认删除?',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk() {
|
||||
deleteXjrGroup(ids).then((_) => {
|
||||
handleSuccess();
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: t('删除成功!')
|
||||
});
|
||||
});
|
||||
},
|
||||
onCancel() {}
|
||||
});
|
||||
}
|
||||
|
||||
function onSelectChange(selectedRowKeys: [], selectedRows) {
|
||||
selectedKeys.value = selectedRowKeys;
|
||||
selectedRowsData.value = selectedRows;
|
||||
}
|
||||
|
||||
function customRow(record: Recordable) {
|
||||
return {
|
||||
onClick: () => {
|
||||
let selectedRowKeys = [...selectedKeys.value];
|
||||
if (selectedRowKeys.indexOf(record.id) >= 0) {
|
||||
let index = selectedRowKeys.indexOf(record.id);
|
||||
selectedRowKeys.splice(index, 1);
|
||||
} else {
|
||||
selectedRowKeys.push(record.id);
|
||||
}
|
||||
selectedKeys.value = selectedRowKeys;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function handleRefresh() {
|
||||
reload();
|
||||
}
|
||||
function handleSuccess() {
|
||||
selectedKeys.value = [];
|
||||
selectedRowsData.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleView(record: Recordable) {
|
||||
|
||||
dbClickRow(record);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
if (schemaIdComputedRef.value) {
|
||||
bus.on(FLOW_PROCESSED, handleRefresh);
|
||||
bus.on(CREATE_FLOW, handleRefresh);
|
||||
} else {
|
||||
bus.on(FORM_LIST_MODIFIED, handleRefresh);
|
||||
reload();
|
||||
}
|
||||
});
|
||||
onUnmounted(() => {
|
||||
if (schemaIdComputedRef.value) {
|
||||
bus.off(FLOW_PROCESSED, handleRefresh);
|
||||
bus.off(CREATE_FLOW, handleRefresh);
|
||||
} else {
|
||||
bus.off(FORM_LIST_MODIFIED, handleRefresh);
|
||||
|
||||
function handleView(record: Recordable) {
|
||||
dbClickRow(record);
|
||||
}
|
||||
});
|
||||
function getActions(record: Recordable):ActionItem[] {
|
||||
|
||||
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
|
||||
if (!record.workflowData?.processId) {
|
||||
return {
|
||||
icon: button?.icon,
|
||||
tooltip: button?.name,
|
||||
color: button.code === 'delete' ? 'error' : undefined,
|
||||
onClick: btnEvent[button.code].bind(null, record),
|
||||
};
|
||||
} else {
|
||||
if (button.code === 'view') {
|
||||
return {
|
||||
icon: button?.icon,
|
||||
tooltip: button?.name,
|
||||
onClick: btnEvent[button.code].bind(null, record),
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (schemaIdComputedRef.value) {
|
||||
bus.on(FLOW_PROCESSED, handleRefresh);
|
||||
bus.on(CREATE_FLOW, handleRefresh);
|
||||
} else {
|
||||
return {};
|
||||
bus.on(FORM_LIST_MODIFIED, handleRefresh);
|
||||
}
|
||||
}
|
||||
});
|
||||
return actionsList;
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
if (schemaIdComputedRef.value) {
|
||||
bus.off(FLOW_PROCESSED, handleRefresh);
|
||||
bus.off(CREATE_FLOW, handleRefresh);
|
||||
} else {
|
||||
bus.off(FORM_LIST_MODIFIED, handleRefresh);
|
||||
}
|
||||
});
|
||||
function getActions(record: Recordable): ActionItem[] {
|
||||
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
|
||||
if (!record.workflowData?.processId) {
|
||||
return {
|
||||
icon: button?.icon,
|
||||
tooltip: button?.name,
|
||||
color: button.code === 'delete' ? 'error' : undefined,
|
||||
onClick: btnEvent[button.code].bind(null, record)
|
||||
};
|
||||
} else {
|
||||
if (button.code === 'view') {
|
||||
return {
|
||||
icon: button?.icon,
|
||||
tooltip: button?.name,
|
||||
onClick: btnEvent[button.code].bind(null, record)
|
||||
};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
});
|
||||
return actionsList;
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-table-selection-col) {
|
||||
width: 50px;
|
||||
}
|
||||
.show{
|
||||
display: flex;
|
||||
}
|
||||
.hide{
|
||||
display: none !important;
|
||||
}
|
||||
:deep(.ant-table-selection-col) {
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user