提交 423e6466 authored 作者: 钟是志's avatar 钟是志

28974 辅导员考核相关需求,有疑问联系我

上级 e28fea6f
......@@ -28,33 +28,40 @@ export default function SelectPerson(props) {
const [jqpp, setJqpp] = useState(false); // 是否精确匹配
function changeShow() {
setShow(!show);
setCheckedList([]);
setSgUserIds([]);
// setSelectUsers([]);
setSearchKey('');
setSearchResult([]);
setDetailList([]);
}
function initShowData(stateList = {}) {
setCheckedList(stateList.checkedList || []);
setSgUserIds(stateList.sgUserIds || []);
setSelectUsers(stateList.sgUsers || []);
setSearchKey(stateList.searchKey || '');
setSearchResult(stateList.searchResult || []);
setDetailList(stateList.detailList || []);
}
useEffect(() => {
window.smartFormSelectPersonComponent = {
changeShow,
setSelectUsers,
initShowData,
lowCodeProps: lowCodeProps(),
callback: (selectUsers) => {
console.log(selectUsers);
callback: ({
value,
componentState,
}) => {
console.log(value, componentState);
},
};
}, []);
// 第二栏树形数据
const getTreeList = () => {
requestData({}, apis.findTree).then(res => {
if (res) {
res = formatTreeData(res);
setAuthInstitutionInfo(res);
}
});
requestData({}, apis.findTree)
.then(res => {
if (res) {
res = formatTreeData(res);
setAuthInstitutionInfo(res);
}
});
};
//根据关键字搜索
......@@ -62,7 +69,7 @@ export default function SelectPerson(props) {
if (searchKey === '') {
setSearchResult([]);
} else {
if(searchKey.length < 2){
if (searchKey.length < 2) {
message.warning('请至少输入2个字符');
return false;
}
......@@ -72,11 +79,12 @@ export default function SelectPerson(props) {
isExact: jqpp,
},
apis.search,
).then(res => {
if (res) {
setSearchResult(res);
}
});
)
.then(res => {
if (res) {
setSearchResult(res);
}
});
}
};
......@@ -88,7 +96,10 @@ export default function SelectPerson(props) {
//根据id进行搜索
const searchById = (selectedKeys, e) => {
const { businessKey, selectType } = e.node.props;
const {
businessKey,
selectType
} = e.node.props;
let bKey = businessKey;
requestData(
{
......@@ -96,11 +107,12 @@ export default function SelectPerson(props) {
selectType,
},
apis.findList,
).then(res => {
if (res) {
setDetailList(res);
}
});
)
.then(res => {
if (res) {
setDetailList(res);
}
});
};
//选中的人
......@@ -143,16 +155,27 @@ export default function SelectPerson(props) {
return false;
}
message.info(propsDiy.getResultProps.message);
requestData(data, apis.getData).then(res => {
if (res) {
message.success('操作成功');
if(window.smartFormSelectPersonComponent.callback){
window.smartFormSelectPersonComponent.callback(res);
requestData(data, apis.getData)
.then(res => {
if (res) {
message.success('操作成功');
if (window.smartFormSelectPersonComponent.callback) {
window.smartFormSelectPersonComponent.callback({
value: res,
componentState: {
checkedList,
sgUserIds,
sgUsers,
searchKey,
searchResult,
// detailList,
},
});
}
changeShow();
// props.getData();
}
changeShow();
// props.getData();
}
});
});
};
const changeJqpp = e => {
......@@ -160,7 +183,6 @@ export default function SelectPerson(props) {
};
useEffect(() => {
if (show) {
getTreeList();
......@@ -209,12 +231,12 @@ export default function SelectPerson(props) {
}
arr = [...map.values()];
arr.sort((a, b) => { // 排序解决 多层子级的问题。
if(a.businessKey && b.businessKey){
if (a.businessKey && b.businessKey) {
return a.businessKey.length - b.businessKey.length;
}
return 0;
});
const distnctBusinessKey = arr.reduce(function(response, current, index) {
const distnctBusinessKey = arr.reduce(function (response, current, index) {
// 删除子级 key 保证数据唯一性
let add = true;
for (let item of response) {
......@@ -286,7 +308,7 @@ export default function SelectPerson(props) {
: () => selectUser(x)
}
>
<span style={{ color: sgUserIds.includes(x.businessKey) && 'red' }}>
<span style={{ backgroundColor: sgUserIds.includes(x.businessKey) && 'red' }}>
{x.businessName}
</span>
</div>
......@@ -314,7 +336,8 @@ export default function SelectPerson(props) {
/>
) : (
<div className={styles.no_result}>
<Spin spinning={true} tip={propsDiy.secondTreeProps.loadingTreeDataMessage} size="large" />
<Spin spinning={true} tip={propsDiy.secondTreeProps.loadingTreeDataMessage}
size="large"/>
</div>
)}
</div>
......@@ -327,7 +350,8 @@ export default function SelectPerson(props) {
<div className={styles.search_result}>
{detailList?.filter(g => {
return g.isSelect;
}).map(x => {
})
.map(x => {
return (
<div
key={x.businessKey}
......@@ -341,7 +365,7 @@ export default function SelectPerson(props) {
fontWeight: 'normal',
}
: {
color: sgUserIds.includes(x.businessKey) && 'red',
backgroundColor: sgUserIds.includes(x.businessKey) && 'red',
}
}
>
......@@ -352,7 +376,8 @@ export default function SelectPerson(props) {
})}
</div>
) : (
<div className={styles.no_result}>{propsDiy.thirdDetailListProps.emptyMessage}</div>
<div
className={styles.no_result}>{propsDiy.thirdDetailListProps.emptyMessage}</div>
)}
</div>
</div>
......@@ -377,7 +402,7 @@ export default function SelectPerson(props) {
onClick={e => deleteSg(x, index, e)}
/>
<Tooltip title={x.businessName}>
{x.businessName}
{x.businessName}
</Tooltip>
</div>
</div>
......
export default function lowCodeProps(info) {
return {
searchType: 'instructorSearch', // teacherSearch || studentSearch || instructorSearch
ModalProps: { // 弹窗的属性
title: '选择辅导员',
},
firstSearchProps: { // 最左侧搜索栏的属性
inputProps: {
placeholder: '输入辅导员姓名/工号搜索',
},
searchResultTitle: '搜索结果',
},
secondTreeProps: { // 树形
title: '部门',
loadingTreeDataMessage: '正在加载数据',
},
thirdDetailListProps: { // 第三栏
title: '详细辅导员列表',
emptyMessage: '暂无详细辅导员列表数据',
},
fourRangeProps: { // 第四栏
title: '所选择的辅导员范围',
emptyMessage: '暂无选中的辅导员',
},
getResultProps: {
emptySelectMessage: '请至少选择一个辅导员',
message: '正在查询中,请耐心等待',
},
};
return {
searchType: 'instructorSearch', // teacherSearch || studentSearch || instructorSearch
ModalProps: {
// 弹窗的属性
title: '选择辅导员',
},
firstSearchProps: {
// 最左侧搜索栏的属性
inputProps: {
placeholder: '输入辅导员姓名/工号搜索',
},
searchResultTitle: '搜索结果',
},
secondTreeProps: {
// 树形
title: '部门',
loadingTreeDataMessage: '正在加载数据',
},
thirdDetailListProps: {
// 第三栏
title: '详细辅导员列表',
emptyMessage: '暂无详细辅导员列表数据',
},
fourRangeProps: {
// 第四栏
title: '所选择的辅导员范围',
emptyMessage: '暂无选中的辅导员',
},
getResultProps: {
emptySelectMessage: '请至少选择一个辅导员',
message: '正在查询中,请耐心等待',
},
};
}
/**
......@@ -35,11 +39,12 @@ export default function lowCodeProps(info) {
return {
before: [
{
{
children: "选择辅导员", type: "primary", onClick: () => {
if (window.smartFormSelectPersonComponent) {
// window.smartFormSelectPersonComponent.lowCodeProps =
// 钟是志
// 2022年10月12日
// 解决按部门选择 辅导员, 选择老师, 选择学生的需求
// window.smartFormSelectPersonComponent.lowCodeProps =
// {
// searchType: 'instructorSearch', // teacherSearch || studentSearch || instructorSearch
// ModalProps: { // 弹窗的属性
......@@ -68,13 +73,43 @@ export default function lowCodeProps(info) {
// message: '正在查询中,请耐心等待',
// },
// };
window.smartFormSelectPersonComponent.setSelectUsers([{ // 设置已经选中的用户
businessKey: "71-1300",
businessName: '钟是志',
isSelect: true,
}]);
window.smartFormSelectPersonComponent.callback = (selectUsers) => { // 回调函数
console.log(selectUsers);
if (window.smartFormSelectPersonComponent) {
// window.smartFormSelectPersonComponent.initShowData({
// 初始化显示的选中数据 从 callback 的componentState读取
// "checkedList": [],
// "sgUserIds": ['40-1723", "40-1470", "40-971'],
// "sgUsers": [{
// "businessKey": "40-1723",
// "businessMemo": "",
// "businessName": "丁心",
// "children": [],
// "ext": null,
// "isSelect": true,
// "level": 1
// }, {
// "businessKey": "40-1470",
// "businessMemo": "",
// "businessName": "程丽娜",
// "children": [],
// "ext": null,
// "isSelect": true,
// "level": 1
// }, {
// "businessKey": "40-971",
// "businessMemo": "",
// "businessName": "石头",
// "children": [],
// "ext": null,
// "isSelect": true,
// "level": 1
// }],
// "searchKey": "",
// "searchResult": []
// });
window.smartFormSelectPersonComponent.callback = ({ value, componentState }) => { // 回调函数
console.log(value, JSON.stringify(componentState));
// componentState 用于组件数据回显,
};
window.smartFormSelectPersonComponent.changeShow(); // 打开弹窗
}
......@@ -83,5 +118,5 @@ export default function lowCodeProps(info) {
]
}
** 使用方法
* */
** 使用方法
* */
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论