From d86db78f18c03d97b7b856fd37cd10d6297eecc7 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期六, 24 二月 2024 13:40:18 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/system/role/index.jsx | 192 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 160 insertions(+), 32 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/role/index.jsx b/zy-asrs-flow/src/pages/system/role/index.jsx
index c45062e..ce9021e 100644
--- a/zy-asrs-flow/src/pages/system/role/index.jsx
+++ b/zy-asrs-flow/src/pages/system/role/index.jsx
@@ -1,7 +1,6 @@
import React, { useState, useRef, useEffect } from 'react';
-import { useIntl, FormattedMessage } from '@umijs/max';
-import { Button, message, Modal } from 'antd';
+import { Button, message, Modal, Tag } from 'antd';
import {
FooterToolbar,
PageContainer,
@@ -11,13 +10,17 @@
import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
import Http from '@/utils/http';
import Edit from './components/edit'
-import { TextFilter } from '@/components/TableSearch'
+import Scope from './components/scope'
+import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
+import { statusMap } from '@/utils/enum-util'
+import { repairBug } from '@/utils/common-util';
+
+const TABLE_KEY = "pro-table-role";
const handleSave = async (val) => {
const hide = message.loading('姝e湪娣诲姞');
try {
const resp = await Http.doPost('api/role/save', val);
- hide();
if (resp.code === 200) {
message.success('娣诲姞鎴愬姛');
return true;
@@ -26,9 +29,10 @@
return false;
}
} catch (error) {
- hide();
message.error('娣诲姞澶辫触璇烽噸璇曪紒');
return false;
+ } finally {
+ hide();
}
};
@@ -36,7 +40,6 @@
const hide = message.loading('姝e湪鏇存柊');
try {
const resp = await Http.doPost('api/role/update', val);
- hide();
if (resp.code === 200) {
message.success('鏇存柊鎴愬姛');
return true;
@@ -45,9 +48,10 @@
return false;
}
} catch (error) {
- hide();
message.error('閰嶇疆澶辫触璇烽噸璇曪紒');
return false;
+ } finally {
+ hide();
}
};
@@ -56,7 +60,6 @@
const hide = message.loading('姝e湪鍒犻櫎');
try {
const resp = await Http.doPost('api/role/remove/' + rows.map((row) => row.id).join(','));
- hide();
if (resp.code === 200) {
message.success('鍒犻櫎鎴愬姛');
return true;
@@ -65,26 +68,47 @@
return false;
}
} catch (error) {
- hide();
message.error('鍒犻櫎澶辫触锛岃閲嶈瘯');
return false;
+ } finally {
+ hide();
}
};
const handleExport = async () => {
const hide = message.loading('姝e湪瀵煎嚭');
try {
- await Http.doPost('api/role/export');
- hide();
+ const resp = await Http.doPostBlob('api/role/export');
+ const blob = new Blob([resp], { type: 'application/vnd.ms-excel' });
+ window.location.href = window.URL.createObjectURL(blob);
message.success('瀵煎嚭鎴愬姛');
return true;
} catch (error) {
- hide();
message.error('瀵煎嚭澶辫触锛岃閲嶈瘯');
return false;
+ } finally {
+ hide();
}
};
+const handleScope = async (val) => {
+ const hide = message.loading('姝e湪鍒嗛厤');
+ try {
+ const resp = await Http.doPost('api/role/scope/update', val);
+ if (resp.code === 200) {
+ message.success('鍒嗛厤鎴愬姛');
+ return true;
+ } else {
+ message.error(resp.msg);
+ return false;
+ }
+ } catch (error) {
+ message.error('鍒嗛厤澶辫触璇烽噸璇曪紒');
+ return false;
+ } finally {
+ hide();
+ }
+};
const Main = () => {
const formTableRef = useRef();
@@ -94,7 +118,8 @@
const [currentRow, setCurrentRow] = useState();
const [searchParam, setSearchParam] = useState({});
- const intl = useIntl();
+ const [scopeModalVisible, setScopeModalVisible] = useState(false);
+ const [menuIds, setMenuIds] = useState([]);
useEffect(() => {
@@ -105,40 +130,93 @@
title: 'No',
dataIndex: 'index',
valueType: 'indexBorder',
- width: 48,
+ width: 60,
},
{
title: '濮撳悕',
dataIndex: 'name',
valueType: 'text',
- copyable: true,
- filterDropdown: (props) => <TextFilter name='name' {...props} actionRef={actionRef} setSearchParam={setSearchParam} />,
+ filterDropdown: (props) => <TextFilter
+ name='name'
+ {...props}
+ actionRef={actionRef}
+ setSearchParam={setSearchParam}
+ />,
+ render: (_, record) => {
+ return (
+ <a
+ onClick={() => {
+ Http.doGetPromise('/api/role/scope/list', { roleId: record.id }, (res) => {
+ if (res.data) {
+ setMenuIds(res.data);
+ }
+ setScopeModalVisible(true);
+ setCurrentRow(record);
+ });
+ }}
+ >
+ {_}
+ </a>
+ );
+ },
},
{
title: '鏍囪瘑',
dataIndex: 'code',
valueType: 'text',
- filterDropdown: (props) => <TextFilter name='code' {...props} actionRef={actionRef} setSearchParam={setSearchParam} />,
- },
- {
- title: '鍏徃',
- dataIndex: 'hostId$',
- valueType: 'text',
- },
- {
- title: '鐘舵��',
- dataIndex: 'status$',
- valueType: 'text',
+ copyable: true,
+ filterDropdown: (props) => <TextFilter
+ name='code'
+ {...props}
+ actionRef={actionRef}
+ setSearchParam={setSearchParam}
+ />,
},
{
title: '淇敼鏃堕棿',
dataIndex: 'updateTime$',
valueType: 'text',
+ filterDropdown: (props) => <DatetimeRangeFilter
+ name='updateTime'
+ {...props}
+ actionRef={actionRef}
+ setSearchParam={setSearchParam}
+ />,
+ },
+ {
+ title: '鐘舵��',
+ dataIndex: 'status$',
+ valueType: 'text',
+ filterDropdown: (props) => <SelectFilter
+ name='status'
+ {...props}
+ actionRef={actionRef}
+ setSearchParam={setSearchParam}
+ data={[
+ { label: '姝e父', value: 1 },
+ { label: '绂佺敤', value: 0 },
+ ]}
+ />,
+ render: (_, record) => {
+ const status = statusMap[record.status]
+ return <Tag color={status.color}>{status.text}</Tag>
+ },
+ },
+ {
+ title: '澶囨敞',
+ dataIndex: 'memo',
+ valueType: 'text',
+ filterDropdown: (props) => <TextFilter
+ name='memo'
+ {...props}
+ actionRef={actionRef}
+ setSearchParam={setSearchParam}
+ />,
},
{
title: '鎿嶄綔',
dataIndex: 'option',
- width: '220px',
+ width: 260,
valueType: 'option',
render: (_, record) => [
<Button
@@ -150,6 +228,21 @@
}}
>
缂栬緫
+ </Button>,
+ <Button
+ type="link"
+ key="scope"
+ onClick={() => {
+ Http.doGetPromise('/api/role/scope/list', { roleId: record.id }, (res) => {
+ if (res.data) {
+ setMenuIds(res.data);
+ }
+ setScopeModalVisible(true);
+ setCurrentRow(record);
+ });
+ }}
+ >
+ 鍒嗛厤鏉冮檺
</Button>,
<Button
type="link"
@@ -177,7 +270,11 @@
];
return (
- <PageContainer>
+ <PageContainer
+ header={{
+ breadcrumb: {},
+ }}
+ >
<div style={{ width: '100%', float: 'right' }}>
<ProTable
key="role"
@@ -186,9 +283,12 @@
formRef={formTableRef}
columns={columns}
cardBordered
+ scroll={{ x: 1300 }}
dateFormatter="string"
+ pagination={{ pageSize: 20 }}
search={false}
toolbar={{
+ multipleLine: true,
search: {
onSearch: (value) => {
setSearchParam(prevState => ({
@@ -242,9 +342,10 @@
}
}}
columnsState={{
- persistenceKey: 'pro-table-role',
+ persistenceKey: TABLE_KEY,
persistenceType: 'localStorage',
defaultValue: {
+ memo: { show: repairBug(TABLE_KEY, 'memo', false) },
option: { fixed: 'right', disable: true },
},
onChange(value) {
@@ -257,9 +358,9 @@
<FooterToolbar
extra={
<div>
- <FormattedMessage id="pages.searchTable.chosen" defaultMessage="宸查�夋嫨" />
+ 宸查�夋嫨
<a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
- <FormattedMessage id="pages.searchTable.item" defaultMessage="椤�" />
+ 椤�
</div>
}
>
@@ -311,6 +412,33 @@
}
}
/>
+
+ <Scope
+ open={scopeModalVisible}
+ values={currentRow || {}}
+ originMenuIds={menuIds}
+ onCancel={
+ () => {
+ setScopeModalVisible(false);
+ setCurrentRow(undefined);
+ setMenuIds([]);
+ }
+ }
+ onSubmit={async (values) => {
+ let ok = false;
+ if (values.id) {
+ ok = await handleScope({ ...values })
+ }
+ if (ok) {
+ setScopeModalVisible(false);
+ setCurrentRow(undefined);
+ setMenuIds([]);
+ if (actionRef.current) {
+ actionRef.current.reload();
+ }
+ }
+ }}
+ />
</PageContainer>
);
};
--
Gitblit v1.9.1