|
|
@@ -1,13 +1,17 @@
|
|
|
import { ProFormCascader } from "@ant-design/pro-components";
|
|
|
import { message } from "antd";
|
|
|
+import { useAppSelector } from "../../hooks";
|
|
|
+import { currentUser } from "../../reducers/current-user";
|
|
|
|
|
|
import { get } from "../../request";
|
|
|
import { IApiResponseChannelList } from "../api/Channel";
|
|
|
+import { IStudio } from "../auth/StudioName";
|
|
|
|
|
|
interface IOption {
|
|
|
value: string;
|
|
|
- label: string;
|
|
|
+ label?: string;
|
|
|
lang?: string;
|
|
|
+ children?: IOption[];
|
|
|
}
|
|
|
|
|
|
interface IWidget {
|
|
|
@@ -32,6 +36,7 @@ const ChannelSelectWidget = ({
|
|
|
placeholder,
|
|
|
onSelect,
|
|
|
}: IWidget) => {
|
|
|
+ const user = useAppSelector(currentUser);
|
|
|
return (
|
|
|
<ProFormCascader
|
|
|
width={width}
|
|
|
@@ -57,19 +62,47 @@ const ChannelSelectWidget = ({
|
|
|
if (typeof parentChannelId === "string") {
|
|
|
channels.push({ value: parentChannelId, label: "仅此版本" });
|
|
|
}
|
|
|
- studio.forEach((value, key, map) => {
|
|
|
- const node = {
|
|
|
- value: key,
|
|
|
- label: value,
|
|
|
+
|
|
|
+ if (user) {
|
|
|
+ channels.push({
|
|
|
+ value: user.realName,
|
|
|
+ label: user.realName,
|
|
|
children: json.data.rows
|
|
|
- .filter((value) => value.studio.id === key)
|
|
|
+ .filter((value) => value.studio.id === user.id)
|
|
|
.map((item) => {
|
|
|
return { value: item.uid, label: item.name, lang: item.lang };
|
|
|
}),
|
|
|
- };
|
|
|
- channels.push(node);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ let arrStudio: IStudio[] = [];
|
|
|
+ studio.forEach((value, key, map) => {
|
|
|
+ arrStudio.push({ id: key, nickName: value });
|
|
|
});
|
|
|
|
|
|
+ const others: IOption[] = arrStudio
|
|
|
+ .sort((a, b) =>
|
|
|
+ a.nickName && b.nickName ? (a.nickName > b.nickName ? 1 : -1) : 0
|
|
|
+ )
|
|
|
+ .filter((value) => value.id !== user?.id)
|
|
|
+ .map((item) => {
|
|
|
+ const node = {
|
|
|
+ value: item.id,
|
|
|
+ label: item.nickName,
|
|
|
+ children: json.data.rows
|
|
|
+ .filter((value) => value.studio.id === item.id)
|
|
|
+ .map((item) => {
|
|
|
+ return {
|
|
|
+ value: item.uid,
|
|
|
+ label: item.name,
|
|
|
+ lang: item.lang,
|
|
|
+ };
|
|
|
+ }),
|
|
|
+ };
|
|
|
+ return node;
|
|
|
+ });
|
|
|
+ channels = [...channels, ...others];
|
|
|
+
|
|
|
console.log("json", channels);
|
|
|
return channels;
|
|
|
} else {
|