分类、部门删除关联跳转相关页面时选中

This commit is contained in:
禺狨
2023-06-09 11:03:04 +08:00
parent 2e7466cea7
commit 12cc5edbf6
10 changed files with 137 additions and 31 deletions

View File

@@ -5,13 +5,13 @@ import { resourceCategory } from "../../api/index";
interface Option {
key: string | number;
title: any;
children?: Option[];
}
interface PropInterface {
type: string;
text: string;
selected: any;
onUpdate: (keys: any, title: any) => void;
}
@@ -20,6 +20,12 @@ export const TreeCategory = (props: PropInterface) => {
const [loading, setLoading] = useState<boolean>(true);
const [selectKey, setSelectKey] = useState<any>([]);
useEffect(() => {
if (props.selected && props.selected.length > 0) {
setSelectKey(props.selected);
}
}, [props.selected]);
useEffect(() => {
resourceCategory.resourceCategoryList().then((res: any) => {
const categories = res.data.categories;

View File

@@ -13,6 +13,7 @@ interface PropInterface {
text: string;
refresh: boolean;
showNum: boolean;
selected: any;
onUpdate: (keys: any, title: any) => void;
}
@@ -22,6 +23,12 @@ export const TreeDepartment = (props: PropInterface) => {
const [selectKey, setSelectKey] = useState<any>([]);
const [userTotal, setUserTotal] = useState(0);
useEffect(() => {
if (props.selected && props.selected.length > 0) {
setSelectKey(props.selected);
}
}, [props.selected]);
useEffect(() => {
setLoading(true);
department.departmentList().then((res: any) => {

View File

@@ -110,6 +110,7 @@ export const UploadImageButton = (props: PropsInterface) => {
<Row style={{ width: 752, minHeight: 520, marginTop: 24 }}>
<Col span={7}>
<TreeCategory
selected={category_ids}
type="no-cate"
text={"图片"}
onUpdate={(keys: any) => {

View File

@@ -173,6 +173,7 @@ export const UploadVideoSub = (props: PropsInterface) => {
<Row style={{ width: 752, minHeight: 520 }}>
<Col span={7}>
<TreeCategory
selected={[]}
type="no-cate"
text={props.label}
onUpdate={(keys: any) => setCategoryIds(keys)}