|
@@ -0,0 +1,106 @@
|
|
|
+import React, { useEffect } from 'react';
|
|
|
+import { Table, Collapse } from 'antd';
|
|
|
+import { connect } from 'dva';
|
|
|
+import router from 'umi/router';
|
|
|
+
|
|
|
+const { Panel } = Collapse;
|
|
|
+
|
|
|
+function Auth(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_name' },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const flowColumns = [
|
|
|
+ { title: '名称', dataIndex: 'version_name' },
|
|
|
+ { title: '节点', dataIndex: 'node_name' },
|
|
|
+ { title: '创建人', dataIndex: 'author' },
|
|
|
+ {
|
|
|
+ title: '分类',
|
|
|
+ render: (_, record) => typeOptions.find(cur => cur.id == record.classify_id)?.name,
|
|
|
+ },
|
|
|
+ { title: '操作', render: (_, record) => <a onClick={() => loadNode(record)}>加载</a> },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const loadNode = item => {
|
|
|
+ // localStorage.excelItem = JSON.stringify({ version_id: item.version_id });
|
|
|
+ //调用接口获取version信息
|
|
|
+ dispatch({
|
|
|
+ type: 'auth/queryVersionByNode',
|
|
|
+ callback: versionList => {
|
|
|
+ let version = versionList.find(v => v.id == item.version_id) || {};
|
|
|
+ localStorage.excelItem = JSON.stringify(version);
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ router.push(`/home/detail/${item.project_id}/${item.template_id}`);
|
|
|
+ };
|
|
|
+
|
|
|
+ const renderUnauth = data => (
|
|
|
+ <Table columns={flowColumns} dataSource={data} pagination={false} rowKey="id" />
|
|
|
+ );
|
|
|
+
|
|
|
+ const renderAuth = data => (
|
|
|
+ <Table columns={flowColumns} dataSource={data} pagination={checkedPagination} rowKey="id" />
|
|
|
+ );
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Collapse defaultActiveKey={['0']}>
|
|
|
+ <Panel header="未审批" key="0">
|
|
|
+ <Table
|
|
|
+ columns={columns}
|
|
|
+ dataSource={authList}
|
|
|
+ expandable={{ expandedRowRender: record => renderUnauth(record.nodes) }}
|
|
|
+ pagination={false}
|
|
|
+ rowKey="key"
|
|
|
+ />
|
|
|
+ </Panel>
|
|
|
+ <Panel header="已审批" key="1">
|
|
|
+ <Table
|
|
|
+ columns={columns}
|
|
|
+ dataSource={checkedList}
|
|
|
+ expandable={{ expandedRowRender: record => renderAuth(record.nodes) }}
|
|
|
+ pagination={false}
|
|
|
+ rowKey="key"
|
|
|
+ />
|
|
|
+ </Panel>
|
|
|
+ </Collapse>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+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);
|