fix: 修改引用文件名和实际不一致的问题。
feat: 增加根据 location.origin 获取当前请求地址的功能。
This commit is contained in:
@ -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做转发或者直接写实际地址
|
||||||
|
|||||||
@ -11,18 +11,18 @@ import { getConfigFileName } from '../getConfigFileName';
|
|||||||
import pkg from '../../package.json';
|
import pkg from '../../package.json';
|
||||||
|
|
||||||
interface CreateConfigParams {
|
interface CreateConfigParams {
|
||||||
configName: string;
|
configName: string;
|
||||||
config: any;
|
config: any;
|
||||||
configFileName?: string;
|
configFileName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createConfig(params: CreateConfigParams) {
|
function createConfig(params: CreateConfigParams) {
|
||||||
const { configName, config, configFileName } = params;
|
const { configName, config, configFileName } = params;
|
||||||
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}", {
|
||||||
configurable: false,
|
configurable: false,
|
||||||
@ -30,18 +30,18 @@ function createConfig(params: CreateConfigParams) {
|
|||||||
});
|
});
|
||||||
`.replace(/\s/g, '');
|
`.replace(/\s/g, '');
|
||||||
|
|
||||||
fs.mkdirp(getRootPath(OUTPUT_DIR));
|
fs.mkdirp(getRootPath(OUTPUT_DIR));
|
||||||
writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
||||||
|
|
||||||
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||||
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n');
|
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(colors.red('configuration file configuration file failed to package:\n' + error));
|
console.log(colors.red('configuration file configuration file failed to package:\n' + error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runBuildConfig() {
|
export function runBuildConfig() {
|
||||||
const config = getEnvConfig();
|
const config = getEnvConfig();
|
||||||
const configFileName = getConfigFileName(config);
|
const configFileName = getConfigFileName(config);
|
||||||
createConfig({ config, configName: configFileName, configFileName: GLOB_CONFIG_FILE_NAME });
|
createConfig({ config, configName: configFileName, configFileName: GLOB_CONFIG_FILE_NAME });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,505 +1,452 @@
|
|||||||
<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">
|
||||||
|
<template #toolbar>
|
||||||
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys,type: 'radio', onChange: onSelectChange }" @row-dbClick="dbClickRow">
|
<template v-for="button in tableButtonConfig" :key="button.code">
|
||||||
|
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
|
||||||
<template #toolbar>
|
<template #icon><Icon :icon="button.icon" /></template>
|
||||||
<template v-for="button in tableButtonConfig" :key="button.code">
|
{{ button.name }}
|
||||||
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
|
</a-button>
|
||||||
<template #icon><Icon :icon="button.icon" /></template>
|
<a-button v-else :type="button.type">
|
||||||
{{ button.name }}
|
<template #icon><Icon :icon="button.icon" /></template>
|
||||||
</a-button>
|
{{ button.name }}
|
||||||
<a-button v-else :type="button.type">
|
</a-button>
|
||||||
<template #icon><Icon :icon="button.icon" /></template>
|
</template>
|
||||||
{{ button.name }}
|
</template>
|
||||||
</a-button>
|
<template #bodyCell="{ column, record }">
|
||||||
</template>
|
<template v-if="column.dataIndex === 'action'">
|
||||||
</template>
|
<TableAction :actions="getActions(record)" />
|
||||||
<template #bodyCell="{ column, record }">
|
</template>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
|
||||||
<TableAction :actions="getActions(record)" />
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</BasicTable>
|
|
||||||
|
|
||||||
<SelectDepartment
|
<SelectDepartment
|
||||||
v-if="visible"
|
v-if="visible"
|
||||||
:visible="visible"
|
:visible="visible"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:selectedIds="selectedUserId"
|
:selectedIds="selectedUserId"
|
||||||
@close="
|
@close="
|
||||||
() => {
|
() => {
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@change="handleSelectUserSuccess"
|
@change="handleSelectUserSuccess"
|
||||||
/>
|
/>
|
||||||
<AuthModal @register="registerAuthModal" />
|
<AuthModal @register="registerAuthModal" />
|
||||||
<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 { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||||
import { Modal } from 'ant-design-vue';
|
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
|
||||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
import { getXjrGroupPage, deleteXjrGroup } from '/@/api/system/group';
|
||||||
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
|
import { SelectDepartment } from '/@/components/SelectOrganizational/index';
|
||||||
import { getXjrGroupPage, deleteXjrGroup} from '/@/api/system/Group';
|
import { PageWrapper } from '/@/components/Page';
|
||||||
import { SelectDepartment } from '/@/components/SelectOrganizational/index';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { PageWrapper } from '/@/components/Page';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { usePermission } from '/@/hooks/web/usePermission';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useRouter } from 'vue-router';
|
||||||
import { usePermission } from '/@/hooks/web/usePermission';
|
import AuthModal from '../dataAuthority/components/AuthModal.vue';
|
||||||
import { useRouter } from 'vue-router';
|
import RoleListModal from './components/RoleListModal.vue';
|
||||||
import AuthModal from '../dataAuthority/components/AuthModal.vue';
|
import RoleModal from '../user/components/RoleModal.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 { searchFormSchema, columns } from './components/config';
|
||||||
|
import Icon from '/@/components/Icon/index';
|
||||||
|
|
||||||
|
|
||||||
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';
|
|
||||||
|
|
||||||
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 { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
defineEmits(['register']);
|
const { notification } = useMessage();
|
||||||
const { filterColumnAuth, filterButtonAuth } = usePermission();
|
const { t } = useI18n();
|
||||||
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();
|
|
||||||
|
|
||||||
|
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 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(() => {
|
|
||||||
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 tableButtonConfig = computed(() => {
|
||||||
|
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
|
||||||
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({
|
const actionButtonConfig = computed(() => {
|
||||||
message: 'Tip',
|
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
|
||||||
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 btnEvent = {
|
||||||
|
edit: handleEdit,
|
||||||
|
refresh: handleRefresh,
|
||||||
|
view: handleView,
|
||||||
function onSelectChange(selectedRowKeys: [], selectedRows) {
|
batchdelete: handleBatchdelete,
|
||||||
selectedKeys.value = selectedRowKeys;
|
delete: handleDelete,
|
||||||
selectedRowsData.value = selectedRows;
|
addMember: handleAddUser,
|
||||||
}
|
add: handleAdd,
|
||||||
|
viewMember: handleViewUser,
|
||||||
function customRow(record: Recordable) {
|
addRole: handleAddRole,
|
||||||
return {
|
viewRole: handleViewRole
|
||||||
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 { currentRoute } = useRouter();
|
||||||
|
const router = useRouter();
|
||||||
function handleRefresh() {
|
|
||||||
reload();
|
const formIdComputedRef = ref();
|
||||||
}
|
formIdComputedRef.value = currentRoute.value.meta.formId;
|
||||||
function handleSuccess() {
|
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 = [];
|
selectedKeys.value = [];
|
||||||
selectedRowsData.value = [];
|
selectedRowsData.value = [];
|
||||||
reload();
|
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);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
onUnmounted(() => {
|
function handleView(record: Recordable) {
|
||||||
if (schemaIdComputedRef.value) {
|
dbClickRow(record);
|
||||||
bus.off(FLOW_PROCESSED, handleRefresh);
|
|
||||||
bus.off(CREATE_FLOW, handleRefresh);
|
|
||||||
} else {
|
|
||||||
bus.off(FORM_LIST_MODIFIED, handleRefresh);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
function getActions(record: Recordable):ActionItem[] {
|
onMounted(() => {
|
||||||
|
if (schemaIdComputedRef.value) {
|
||||||
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
|
bus.on(FLOW_PROCESSED, handleRefresh);
|
||||||
if (!record.workflowData?.processId) {
|
bus.on(CREATE_FLOW, handleRefresh);
|
||||||
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 {
|
} 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>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
:deep(.ant-table-selection-col) {
|
:deep(.ant-table-selection-col) {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
.show{
|
|
||||||
display: flex;
|
.show {
|
||||||
}
|
display: flex;
|
||||||
.hide{
|
}
|
||||||
display: none !important;
|
|
||||||
}
|
.hide {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user