|
@@ -1,52 +1,97 @@
|
|
|
-import React, { useState } from 'react';
|
|
|
+import React, { useEffect } from 'react';
|
|
|
import { Table, Collapse } from 'antd';
|
|
|
-import { connect } from 'umi';
|
|
|
+import { connect } from 'dva';
|
|
|
+import router from 'umi/router';
|
|
|
|
|
|
const { Panel } = Collapse;
|
|
|
|
|
|
function Auth(props) {
|
|
|
- const { dispatch } = props;
|
|
|
+ const {
|
|
|
+ dispatch,
|
|
|
+ authList,
|
|
|
+ checkedList,
|
|
|
+ checkedPagination,
|
|
|
+ typeOptions,
|
|
|
+ currentUser,
|
|
|
+ loading,
|
|
|
+ } = props;
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (!currentUser.ID) return;
|
|
|
+ dispatch({
|
|
|
+ type: 'auth/queryAuthList',
|
|
|
+ payload: { user_id: currentUser.ID },
|
|
|
+ });
|
|
|
+ dispatch({
|
|
|
+ type: 'auth/queryCheckedList',
|
|
|
+ payload: { user_id: currentUser.ID, params: {} },
|
|
|
+ });
|
|
|
+ }, [currentUser]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ dispatch({
|
|
|
+ type: 'auth/queryClassify',
|
|
|
+ });
|
|
|
+ }, []);
|
|
|
|
|
|
const columns = [
|
|
|
{ title: '流程名称', dataIndex: 'name' },
|
|
|
- { title: '所属项目', dataIndex: 'project' },
|
|
|
+ { title: '所属项目', dataIndex: 'project_name' },
|
|
|
];
|
|
|
|
|
|
const flowColumns = [
|
|
|
- { title: '名称', dataIndex: 'name' },
|
|
|
- { title: '节点', dataIndex: 'node' },
|
|
|
+ { title: '名称', dataIndex: 'version_name' },
|
|
|
+ { title: '节点', dataIndex: 'node_name' },
|
|
|
{ title: '创建人', dataIndex: 'author' },
|
|
|
- { title: '分类', dataIndex: 'type' },
|
|
|
- { title: '状态', dataIndex: 'status' },
|
|
|
- { title: '印章申请', render: () => '-' },
|
|
|
- { title: '操作', render: () => <a>加载</a> },
|
|
|
+ {
|
|
|
+ title: '分类',
|
|
|
+ render: (_, record) => typeOptions.find(cur => cur.id == record.classify_id)?.name,
|
|
|
+ },
|
|
|
+ { title: '操作', render: (_, record) => <a onClick={() => loadNode(record)}>加载</a> },
|
|
|
];
|
|
|
|
|
|
- const temp = [{ name: '测试', project: '测试' }];
|
|
|
+ const loadNode = item => {
|
|
|
+ localStorage.excelItem = JSON.stringify({ version_id: item.version_id });
|
|
|
+ router.push(`/home/detail/${item.project_id}/${item.template_id}`);
|
|
|
+ };
|
|
|
|
|
|
- const flowTemp = [{ name: '测试', node: '测试', author: '测试', type: '测试', status: '测试' }];
|
|
|
-
|
|
|
- const renderUnauth = () => (
|
|
|
- <Table columns={flowColumns} dataSource={flowTemp} pagination={false} />
|
|
|
+ const renderUnauth = data => (
|
|
|
+ <Table columns={flowColumns} dataSource={data} pagination={false} rowKey="id" />
|
|
|
);
|
|
|
|
|
|
- const renderAuth = () => <Table columns={flowColumns} dataSource={flowTemp} pagination={false} />;
|
|
|
+ const renderAuth = data => (
|
|
|
+ <Table columns={flowColumns} dataSource={data} pagination={false} rowKey="id" />
|
|
|
+ );
|
|
|
|
|
|
return (
|
|
|
<Collapse defaultActiveKey={['0']}>
|
|
|
<Panel header="未审批" key="0">
|
|
|
<Table
|
|
|
columns={columns}
|
|
|
- dataSource={temp}
|
|
|
- expandable={{ expandedRowRender: renderUnauth }}
|
|
|
+ dataSource={authList}
|
|
|
+ expandable={{ expandedRowRender: record => renderUnauth(record.nodes) }}
|
|
|
pagination={false}
|
|
|
+ rowKey="key"
|
|
|
/>
|
|
|
</Panel>
|
|
|
<Panel header="已审批" key="1">
|
|
|
- <Table columns={columns} dataSource={temp} expandable={{ expandedRowRender: renderAuth }} />
|
|
|
+ <Table
|
|
|
+ columns={columns}
|
|
|
+ dataSource={checkedList}
|
|
|
+ expandable={{ expandedRowRender: record => renderAuth(record.nodes) }}
|
|
|
+ pagination={false}
|
|
|
+ rowKey="key"
|
|
|
+ />
|
|
|
</Panel>
|
|
|
</Collapse>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export default Auth;
|
|
|
+export default connect(({ auth, loading, user }) => ({
|
|
|
+ authList: auth.authList,
|
|
|
+ checkedList: auth.checkedList.list,
|
|
|
+ checkedPagination: auth.checkedList.pagination,
|
|
|
+ typeOptions: auth.typeOptions,
|
|
|
+ loading: loading.models.auth,
|
|
|
+ currentUser: user.currentUser,
|
|
|
+}))(Auth);
|