|
@@ -39,7 +39,12 @@ function profile(props) {
|
|
|
OA: 2,
|
|
|
};
|
|
|
|
|
|
- const { data: OAData, loading: OALoading } = useRequest(queryProfileList, {
|
|
|
+ //OA我的申请列表
|
|
|
+ const {
|
|
|
+ data: OAApplyData,
|
|
|
+ run: OAApplyRun,
|
|
|
+ loading: OAApplyLoading,
|
|
|
+ } = useRequest(queryProfileList, {
|
|
|
// manual: true,
|
|
|
formatResult: (res) => {
|
|
|
return res.data?.list?.map((item) => {
|
|
@@ -47,21 +52,47 @@ function profile(props) {
|
|
|
...item,
|
|
|
CName: item.AuthorInfo.CName,
|
|
|
table_desc: [item.table_desc],
|
|
|
- statusText: item.status,
|
|
|
+ statusText: (() => {
|
|
|
+ switch (item.audit_status) {
|
|
|
+ case 0:
|
|
|
+ return '审核中';
|
|
|
+ case 1:
|
|
|
+ return '通过';
|
|
|
+ case 2:
|
|
|
+ return '拒绝';
|
|
|
+ case 3:
|
|
|
+ return '终审通过';
|
|
|
+ }
|
|
|
+ })(),
|
|
|
+ key: `${TYPE.Contract}_${item.id}`,
|
|
|
type: TYPE.OA,
|
|
|
};
|
|
|
});
|
|
|
},
|
|
|
- onSuccess: (data) => {
|
|
|
- console.log(data);
|
|
|
- },
|
|
|
- });
|
|
|
- const queryProfileListRequest = useRequest(queryProfileList, {
|
|
|
- manual: true,
|
|
|
});
|
|
|
- const queryApplyListRequest = useRequest(queryApplyList, {
|
|
|
+ //OA我的审批和待审批列表
|
|
|
+ const {
|
|
|
+ data: OAAuditData,
|
|
|
+ run: OAAuditRun,
|
|
|
+ loading: OAAuditLoading,
|
|
|
+ } = useRequest(queryProfileList, {
|
|
|
manual: true,
|
|
|
+ formatResult: (res) => {
|
|
|
+ return res.data?.list?.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ CName: item.AuthorInfo.CName,
|
|
|
+ table_desc: [item.table_desc],
|
|
|
+ statusText: item.status,
|
|
|
+ // key: `${TYPE.Contract}_${item.id}`,
|
|
|
+ showBtn: true,
|
|
|
+ type: TYPE.OA,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
});
|
|
|
+
|
|
|
+ //合同管理返回处理函数
|
|
|
const contractResult = (res) => {
|
|
|
let data = res.data?.list;
|
|
|
return data?.map((item) => {
|
|
@@ -77,6 +108,9 @@ function profile(props) {
|
|
|
create_time: item.cancel_on || item.created_on,
|
|
|
type: TYPE.Contract,
|
|
|
statusText: StatusText[item.status],
|
|
|
+ showBtn:
|
|
|
+ item.status == Status.Checking || item.status == Status.CalChecking,
|
|
|
+ // key: `${TYPE.Contract}_${item.id}`,
|
|
|
};
|
|
|
});
|
|
|
};
|
|
@@ -84,23 +118,31 @@ function profile(props) {
|
|
|
//合同管理相关数据
|
|
|
//请求我的申请列表
|
|
|
const {
|
|
|
- data: ApplyData,
|
|
|
- run: applyRun,
|
|
|
- loading: applyLoading,
|
|
|
+ data: conApplyData,
|
|
|
+ run: conApplyRun,
|
|
|
+ loading: conApplyLoading,
|
|
|
} = useRequest(queryGetContractList, {
|
|
|
defaultParams: [{ created_by: user?.ID }],
|
|
|
formatResult: contractResult,
|
|
|
});
|
|
|
- //我的审批列表
|
|
|
+ //我的待审批列表
|
|
|
+ const {
|
|
|
+ data: conAuditData,
|
|
|
+ run: conAuditRun,
|
|
|
+ loading: conAduitLoading,
|
|
|
+ } = useRequest((data) => queryGetContractList(data), {
|
|
|
+ manual: true,
|
|
|
+ formatResult: contractResult,
|
|
|
+ });
|
|
|
+ //我审批过的列表
|
|
|
const {
|
|
|
- data: AuditData,
|
|
|
- run,
|
|
|
- loading: aduitLoading,
|
|
|
+ data: conAuditedData,
|
|
|
+ run: conAuditedRun,
|
|
|
+ loading: conAduitedLoading,
|
|
|
} = useRequest((data) => queryGetContractList(data), {
|
|
|
manual: true,
|
|
|
formatResult: contractResult,
|
|
|
});
|
|
|
- console.log('================', ApplyData, AuditData, OAData);
|
|
|
|
|
|
//审核合同
|
|
|
const { run: runCheck, loading: checkLoading } = useRequest(
|
|
@@ -108,6 +150,8 @@ function profile(props) {
|
|
|
{
|
|
|
manual: true,
|
|
|
onSuccess: () => {
|
|
|
+ conAuditRun({ status: 1 });
|
|
|
+ conAuditedRun({ check_by: user.CName });
|
|
|
setConVisible(false);
|
|
|
message.success('审核成功');
|
|
|
},
|
|
@@ -117,12 +161,50 @@ function profile(props) {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- if (user?.Permission['menu-001-audit']) run({ status: 1 });
|
|
|
- }, [user]);
|
|
|
+ //拼接审核数据和申请数据 审核loading和申请loading
|
|
|
+ const auditData = useMemo(() => {
|
|
|
+ let result = [];
|
|
|
+ if (OAAuditData && OAAuditData.length > 0) result = [...OAAuditData];
|
|
|
+ if (conAuditData && conAuditData.length > 0)
|
|
|
+ result = [...result, ...conAuditData];
|
|
|
+ if (conAuditedData && conAuditedData.length > 0)
|
|
|
+ result = [...result, ...conAuditedData];
|
|
|
+ return result;
|
|
|
+ }, [OAAuditData, conAuditData, conAuditedData]);
|
|
|
+
|
|
|
+ const auditLoading = useMemo(() => {
|
|
|
+ let loading = false;
|
|
|
+ if (OAAuditLoading || conAduitLoading || conAduitedLoading) loading = true;
|
|
|
+ return loading;
|
|
|
+ }, [OAAuditLoading, conAduitLoading, conAduitedLoading]);
|
|
|
+
|
|
|
+ const applyData = useMemo(() => {
|
|
|
+ let result = [];
|
|
|
+ if (OAApplyData && OAApplyData.length > 0) result = [...OAApplyData];
|
|
|
+ if (conApplyData && conApplyData.length > 0)
|
|
|
+ result = [...result, ...conApplyData];
|
|
|
+ return result;
|
|
|
+ }, [OAApplyData, conApplyData]);
|
|
|
+
|
|
|
+ const applyLoading = useMemo(() => {
|
|
|
+ let loading = false;
|
|
|
+ if (OAApplyLoading || conApplyLoading) loading = true;
|
|
|
+ return loading;
|
|
|
+ }, [OAApplyLoading, conApplyLoading]);
|
|
|
+
|
|
|
+ // useEffect(() => {
|
|
|
+ // if (user?.Permission['menu-001-audit']) run({ status: 1 });
|
|
|
+ // }, [user]);
|
|
|
|
|
|
const onTabChange = (activeKey) => {
|
|
|
- applyRun();
|
|
|
+ if (activeKey == '1') {
|
|
|
+ OAApplyRun();
|
|
|
+ conApplyRun();
|
|
|
+ } else {
|
|
|
+ OAAuditRun();
|
|
|
+ if (user?.Permission['menu-001-audit']) conAuditRun({ status: 1 });
|
|
|
+ conAuditedRun({ check_by: user.CName });
|
|
|
+ }
|
|
|
setTabActive(activeKey);
|
|
|
};
|
|
|
const columns = [
|
|
@@ -222,21 +304,26 @@ function profile(props) {
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
|
- render: (record) => (
|
|
|
+ dataIndex: 'showBtn',
|
|
|
+ render: (text, record) => (
|
|
|
<>
|
|
|
- <a
|
|
|
- style={{ color: '#4096ff' }}
|
|
|
- onClick={() => {
|
|
|
- if (record.type == TYPE.Contract) {
|
|
|
- setDetail(record);
|
|
|
- setConVisible(true);
|
|
|
- } else {
|
|
|
- navigate(`/oa/detail/${record.flow_id}/${record.id}`);
|
|
|
- }
|
|
|
- }}
|
|
|
- >
|
|
|
- 审批
|
|
|
- </a>
|
|
|
+ {text ? (
|
|
|
+ <a
|
|
|
+ style={{ color: '#4096ff' }}
|
|
|
+ onClick={() => {
|
|
|
+ if (record.type == TYPE.Contract) {
|
|
|
+ setDetail(record);
|
|
|
+ setConVisible(true);
|
|
|
+ } else {
|
|
|
+ navigate(`/oa/detail/${record.flow_id}/${record.id}`);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 审批
|
|
|
+ </a>
|
|
|
+ ) : (
|
|
|
+ <div>已审批</div>
|
|
|
+ )}
|
|
|
</>
|
|
|
),
|
|
|
},
|
|
@@ -286,16 +373,17 @@ function profile(props) {
|
|
|
</Button>
|
|
|
</Form.Item>
|
|
|
</div>
|
|
|
- <Table
|
|
|
- columns={columns}
|
|
|
- dataSource={ApplyData}
|
|
|
- // columns={columns}
|
|
|
- // loading={queryApplyListRequest.loading}
|
|
|
- // dataSource={queryApplyListRequest?.data?.list}
|
|
|
- // pagination={queryApplyListRequest?.data?.pagination}
|
|
|
- // onChange={handleApplyPaginationChange}
|
|
|
- />
|
|
|
</Form>
|
|
|
+ <Table
|
|
|
+ columns={columns}
|
|
|
+ dataSource={applyData}
|
|
|
+ loading={applyLoading}
|
|
|
+ // columns={columns}
|
|
|
+ // loading={queryApplyListRequest.loading}
|
|
|
+ // dataSource={queryApplyListRequest?.data?.list}
|
|
|
+ // pagination={queryApplyListRequest?.data?.pagination}
|
|
|
+ // onChange={handleApplyPaginationChange}
|
|
|
+ />
|
|
|
</>
|
|
|
);
|
|
|
else if (activeKey == '2')
|
|
@@ -337,12 +425,9 @@ function profile(props) {
|
|
|
</div>
|
|
|
</Form>
|
|
|
<Table
|
|
|
- rowKey="id"
|
|
|
columns={approveColumns}
|
|
|
- dataSource={[...OAData, ...AuditData].sort(
|
|
|
- (a, b) => a.create_time > b.create_time,
|
|
|
- )}
|
|
|
-
|
|
|
+ dataSource={auditData}
|
|
|
+ loading={auditLoading}
|
|
|
// loading={queryProfileListRequest.loading}
|
|
|
// columns={approveColumns}
|
|
|
// dataSource={queryProfileListRequest?.data?.list}
|