Commit 6d9ebe7c authored by 卢均锐's avatar 卢均锐

Merge branch 'dev-srm' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform into dev-srm

* 'dev-srm' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform: feat: 对接考评
parents f6ee9989 72d60e15
import TableModal from '@/pages/member/components/TableModal'; import TableModal from '@/pages/member/components/TableModal';
import { PublicApi } from '@/services/api';
import { PlusOutlined } from '@ant-design/icons';
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
import React, { useMemo } from 'react'; import React, { useCallback, useMemo } from 'react';
import useModal from '../../hooks/useModal'; import useModal from '../../hooks/useModal';
interface Iprops { interface Iprops {
value: any[], value: any[],
// handleFetch // handleFetch
// onOk: (selectRowKeys: string[] | number[], selectRowRecord: any[]) => void; // onOk: (selectRowKeys: string[] | number[], selectRowRecord: any[]) => void;
fetchData: (params: any) => Promise<any>, // fetchData: (params: any) => Promise<any>,
mutators: { mutators: {
change: (params: any[]) => void change: (params: any[]) => void
}, },
...@@ -19,17 +21,17 @@ const DEFAULT_RETURN_DATA = { ...@@ -19,17 +21,17 @@ const DEFAULT_RETURN_DATA = {
} }
const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props: Iprops) => { const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props: Iprops) => {
const { value, mutators, fetchData } = props; const { value, mutators } = props;
const { visible, toggle } = useModal(); const { visible, toggle } = useModal();
const columns = useMemo(() => [ const columns = useMemo(() => [
{ {
title: '评估项目', title: '评估项目',
dataIndex: 'project' dataIndex: 'subMemberId'
}, },
{ {
title: '评估内容', title: '评估内容',
dataIndex: 'content' dataIndex: 'name'
}, },
], []) ], [])
...@@ -56,12 +58,21 @@ const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props ...@@ -56,12 +58,21 @@ const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props
}), []) }), [])
const handleOnOk = (selectRowKeys: string[] | number[], selectRowRecord: any[] ) => { const handleOnOk = (selectRowKeys: string[] | number[], selectRowRecord: any[] ) => {
// const target = selectRowRecord[0];
// onOk?.(selectRowKeys, selectRowRecord);
mutators.change(selectRowRecord) mutators.change(selectRowRecord)
toggle(false) toggle(false)
} }
/**
* 业务组件,未看到复用情况,暂时写死
*/
const handleFetchData = useCallback(async (params: any): Promise<any> => {
const { data, code } = await PublicApi.getMemberInspectMembers(params);
if (code === 1000) {
return data;
}
return DEFAULT_RETURN_DATA as any
}, [])
return ( return (
<div> <div>
<TableModal <TableModal
...@@ -71,14 +82,29 @@ const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props ...@@ -71,14 +82,29 @@ const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props
columns={columns} columns={columns}
schema={schema} schema={schema}
onOk={handleOnOk} onOk={handleOnOk}
fetchData={fetchData} fetchData={handleFetchData}
tableProps={{ tableProps={{
rowKey: (record) => `${record.subMemberId}_${record.subRoleId}`, rowKey: (record) => `${record.subMemberId}_${record.subRoleId}`,
}} }}
mode={"checkbox"} mode={"checkbox"}
value={value} value={value}
/> />
<div>选择评估项目</div> <div
style={{
cursor: 'pointer',
width: '100%',
background: '#fbfbfb',
padding: '8px 0px',
display: "flex",
flexDirection: "row",
justifyContent: "center",
alignItems: "center"
}}
onClick={() => toggle(true)}
>
<PlusOutlined />
<span style={{marginLeft: "4px"}}>选择评估项目</span>
</div>
</div> </div>
) )
} }
......
...@@ -3,7 +3,7 @@ import { Card, Button } from 'antd'; ...@@ -3,7 +3,7 @@ import { Card, Button } from 'antd';
import { history } from 'umi'; import { history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { LinkOutlined, PlusOutlined, SaveOutlined } from '@ant-design/icons'; import { LinkOutlined, PlusOutlined, SaveOutlined } from '@ant-design/icons';
import { createFormActions } from '@formily/antd'; import { createFormActions, FormEffectHooks } from '@formily/antd';
import { ArrayTable } from '@formily/antd-components' import { ArrayTable } from '@formily/antd-components'
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
...@@ -23,6 +23,7 @@ import { PublicApi } from '@/services/api'; ...@@ -23,6 +23,7 @@ import { PublicApi } from '@/services/api';
import EvaluateProject from '../components/EvaluateProject'; import EvaluateProject from '../components/EvaluateProject';
const formActions = createFormActions() const formActions = createFormActions()
const { onFieldValueChange$ } = FormEffectHooks
const EvaluateAdd = () => { const EvaluateAdd = () => {
const { visible, toggle } = useModal() const { visible, toggle } = useModal()
...@@ -56,6 +57,35 @@ const EvaluateAdd = () => { ...@@ -56,6 +57,35 @@ const EvaluateAdd = () => {
toggle(false) toggle(false)
} }
const handleEffect = ($, actions) => {
onFieldValueChange$('tabs.tab-2.selectProject').subscribe(({value}) => {
const tempData = value?.map((_item, index) => ({
projectName: _item.name,
projectContent: _item.name + _item.roleName,
id: _item.subMemberId
})) || []
// const withProjectId = new Set(tempData.map((_item) => _item.id));
const dataSource = formActions.getFieldValue('tabs.tab-2.array') || [];
// 对比两个数据, 如果dataSource 中 有 tempData 的值, 那么保留,如果没有择去除(没有id项)
const dataSourceKey = new Set(Array.from(dataSource?.map((_item) => _item.id)).filter(Boolean));
// 获取新增组
const newAddProject = tempData.filter((_item) => !dataSourceKey.has(_item.id));
const tempDataKey = new Set(tempData.map((_row) => _row.id));
// 过滤减少项
const hasRemoveListRes = []
dataSource.forEach((_item) => {
if(typeof _item.id === 'undefined' || tempDataKey.has(_item.id)) {
hasRemoveListRes.push(_item)
}
})
const newDataSource = hasRemoveListRes.concat(newAddProject)
formActions.setFieldValue('tabs.tab-2.array', newDataSource);
})
}
return ( return (
<PageHeaderWrapper <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
...@@ -64,7 +94,6 @@ const EvaluateAdd = () => { ...@@ -64,7 +94,6 @@ const EvaluateAdd = () => {
extra={ extra={
( (
<Button <Button
key={1}
type="primary" type="primary"
icon={<SaveOutlined />} icon={<SaveOutlined />}
// loading={submitLoading} // loading={submitLoading}
...@@ -92,18 +121,15 @@ const EvaluateAdd = () => { ...@@ -92,18 +121,15 @@ const EvaluateAdd = () => {
}} }}
expressionScope={{ expressionScope={{
renderAddition: renderAddition, renderAddition: renderAddition,
// selectProject: (
// <div style={{background: 'red'}}>123</div>
// ),
connectMember: ( connectMember: (
<div onClick={() => toggle(true)}> <div onClick={() => toggle(true)}>
<LinkOutlined style={{marginRight: 4}}/> <LinkOutlined />
选择 <span style={{marginLeft: 4}}>选择</span>
</div> </div>
), ),
renderListTableRemove, renderListTableRemove,
}} }}
effects={() => {}} effects={handleEffect}
/> />
</Card> </Card>
<TableModal <TableModal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment