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 { PublicApi } from '@/services/api';
import { PlusOutlined } from '@ant-design/icons';
import { ISchema } from '@formily/antd';
import React, { useMemo } from 'react';
import React, { useCallback, useMemo } from 'react';
import useModal from '../../hooks/useModal';
interface Iprops {
value: any[],
// handleFetch
// onOk: (selectRowKeys: string[] | number[], selectRowRecord: any[]) => void;
fetchData: (params: any) => Promise<any>,
// fetchData: (params: any) => Promise<any>,
mutators: {
change: (params: any[]) => void
},
......@@ -19,17 +21,17 @@ const DEFAULT_RETURN_DATA = {
}
const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props: Iprops) => {
const { value, mutators, fetchData } = props;
const { value, mutators } = props;
const { visible, toggle } = useModal();
const columns = useMemo(() => [
{
title: '评估项目',
dataIndex: 'project'
dataIndex: 'subMemberId'
},
{
title: '评估内容',
dataIndex: 'content'
dataIndex: 'name'
},
], [])
......@@ -56,12 +58,21 @@ const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props
}), [])
const handleOnOk = (selectRowKeys: string[] | number[], selectRowRecord: any[] ) => {
// const target = selectRowRecord[0];
// onOk?.(selectRowKeys, selectRowRecord);
mutators.change(selectRowRecord)
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 (
<div>
<TableModal
......@@ -71,14 +82,29 @@ const EvaluateProject: React.FC<Iprops> & { isFieldComponent: boolean } = (props
columns={columns}
schema={schema}
onOk={handleOnOk}
fetchData={fetchData}
fetchData={handleFetchData}
tableProps={{
rowKey: (record) => `${record.subMemberId}_${record.subRoleId}`,
}}
mode={"checkbox"}
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>
)
}
......
......@@ -3,7 +3,7 @@ import { Card, Button } from 'antd';
import { history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
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 ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
......@@ -23,6 +23,7 @@ import { PublicApi } from '@/services/api';
import EvaluateProject from '../components/EvaluateProject';
const formActions = createFormActions()
const { onFieldValueChange$ } = FormEffectHooks
const EvaluateAdd = () => {
const { visible, toggle } = useModal()
......@@ -56,6 +57,35 @@ const EvaluateAdd = () => {
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 (
<PageHeaderWrapper
onBack={() => history.goBack()}
......@@ -64,7 +94,6 @@ const EvaluateAdd = () => {
extra={
(
<Button
key={1}
type="primary"
icon={<SaveOutlined />}
// loading={submitLoading}
......@@ -92,18 +121,15 @@ const EvaluateAdd = () => {
}}
expressionScope={{
renderAddition: renderAddition,
// selectProject: (
// <div style={{background: 'red'}}>123</div>
// ),
connectMember: (
<div onClick={() => toggle(true)}>
<LinkOutlined style={{marginRight: 4}}/>
选择
<LinkOutlined />
<span style={{marginLeft: 4}}>选择</span>
</div>
),
renderListTableRemove,
}}
effects={() => {}}
effects={handleEffect}
/>
</Card>
<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