|
@@ -1,80 +1,102 @@
|
|
|
+import { cx } from "@linaria/core";
|
|
|
+import { Tag } from "ant-design-vue";
|
|
|
+import dayjs from "dayjs";
|
|
|
+import { onMounted, watch } from "vue";
|
|
|
import { Container, Draggable } from "vue-dndrop";
|
|
|
-import { any, bool, string } from "vue-types";
|
|
|
+import { string } from "vue-types";
|
|
|
|
|
|
+import Empty from "@/components/Empty";
|
|
|
import { useEditor } from "@/modules/editor";
|
|
|
-import { ICompKeys } from "@/modules/editor/typings";
|
|
|
-import { Empty, Image } from "@queenjs/ui";
|
|
|
-import { useReactive } from "@queenjs/use";
|
|
|
-import { defineUI, queenApi } from "queenjs";
|
|
|
+import { useResource } from "@/modules/resource";
|
|
|
import { useAuth } from "@queenjs-modules/auth";
|
|
|
-import { Dropdown, Tag } from "ant-design-vue";
|
|
|
-import dayjs from "dayjs";
|
|
|
+import { Image } from "@queenjs/ui";
|
|
|
+import { defineUI, queenApi } from "queenjs";
|
|
|
import Menu from "./Menu";
|
|
|
-import { useResource } from "@/modules/resource";
|
|
|
-import { onMounted} from "vue";
|
|
|
|
|
|
export default defineUI({
|
|
|
-
|
|
|
+ props: {
|
|
|
+ sourceType: string<"comp" | "text" | "shape">().def("comp"),
|
|
|
+ },
|
|
|
setup(props) {
|
|
|
const editor = useEditor();
|
|
|
const auth = useAuth();
|
|
|
const resource = useResource();
|
|
|
+
|
|
|
const listCtrl = resource.controls.CustCompListCtrl;
|
|
|
listCtrl.hasLimit = true;
|
|
|
|
|
|
- //@ts-ignore
|
|
|
+ //@ts-ignore
|
|
|
let isSys = (auth.store.userInfo.roles || []).indexOf("system") > -1;
|
|
|
- onMounted(() => {
|
|
|
- listCtrl.loadPage(1)
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ //@ts-ignore
|
|
|
+ listCtrl.state.query.type = props.sourceType;
|
|
|
+ listCtrl.loadPage(1);
|
|
|
});
|
|
|
|
|
|
+ watch(
|
|
|
+ () => props.sourceType,
|
|
|
+ () => {
|
|
|
+ //@ts-ignore
|
|
|
+ listCtrl.state.query.type = props.sourceType;
|
|
|
+ listCtrl.loadPage(1);
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
return () => {
|
|
|
+ const { sourceType } = props;
|
|
|
|
|
|
- if (listCtrl.state.list.length == 0) return <Empty />;
|
|
|
+ if (listCtrl.state.list.length == 0) return <Empty class="pt-150px" />;
|
|
|
|
|
|
return (
|
|
|
- <Container
|
|
|
- class="space-y-10px scrollbar"
|
|
|
- behaviour="copy"
|
|
|
- group-name="canvas"
|
|
|
- animation-duration={0}
|
|
|
- get-child-payload={(index: number) => {
|
|
|
- return {type:"CompCard", data: {id: listCtrl.state.list[index]._id, isSys: isSys}};
|
|
|
- }}
|
|
|
- >
|
|
|
- {listCtrl.state.list.map((item:any) => {
|
|
|
- const items = ["删除"];
|
|
|
+ <div class="scrollbar">
|
|
|
+ <Container
|
|
|
+ class={cx(
|
|
|
+ "grid gap-10px",
|
|
|
+ sourceType == "comp" ? "grid-cols-1" : "grid-cols-2"
|
|
|
+ )}
|
|
|
+ behaviour="copy"
|
|
|
+ group-name="canvas"
|
|
|
+ animation-duration={0}
|
|
|
+ get-child-payload={(index: number) => {
|
|
|
+ return {
|
|
|
+ type: "CompCard",
|
|
|
+ data: { id: listCtrl.state.list[index]._id, isSys: isSys },
|
|
|
+ };
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {listCtrl.state.list.map((item: any) => {
|
|
|
+ const items = ["删除"];
|
|
|
|
|
|
- if (isSys) {
|
|
|
- item.published ? items.push("取消发布") : items.push("发布平台");
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <Draggable>
|
|
|
- <div
|
|
|
- class="text-center leading-50px bg-dark-50 rounded draggable-item relative"
|
|
|
- key={item.compKey}
|
|
|
- title={item.name}
|
|
|
- >
|
|
|
- <Image
|
|
|
- class="w-full rounded"
|
|
|
- src={item.thumbnail}
|
|
|
- onClick={() => {
|
|
|
- editor.actions.clickCompUserToDesign(item._id, isSys)
|
|
|
- }
|
|
|
- }
|
|
|
- size={240}
|
|
|
- />
|
|
|
-
|
|
|
- {isSys && (
|
|
|
- <Tag
|
|
|
- color={item.published ? "green" : "#E88B00"}
|
|
|
- // color="rgba(0, 0, 0, 0.4)"
|
|
|
- class="absolute top-0 left-0 z-1 !rounded-none"
|
|
|
- >
|
|
|
- {item.published ? "已发布" : "未发布"}
|
|
|
- </Tag>
|
|
|
- )}
|
|
|
+ if (isSys) {
|
|
|
+ item.published
|
|
|
+ ? items.push("取消发布")
|
|
|
+ : items.push("发布平台");
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <Draggable>
|
|
|
+ <div
|
|
|
+ class="text-center leading-50px bg-dark-50 rounded draggable-item relative"
|
|
|
+ key={item.compKey}
|
|
|
+ title={item.name}
|
|
|
+ >
|
|
|
+ <Image
|
|
|
+ class="w-full rounded"
|
|
|
+ src={item.thumbnail}
|
|
|
+ onClick={() => {
|
|
|
+ editor.actions.clickCompUserToDesign(item._id, isSys);
|
|
|
+ }}
|
|
|
+ size={240}
|
|
|
+ />
|
|
|
+ {isSys && (
|
|
|
+ <Tag
|
|
|
+ color={item.published ? "green" : "#E88B00"}
|
|
|
+ // color="rgba(0, 0, 0, 0.4)"
|
|
|
+ class="absolute top-0 left-0 z-1 !rounded-none"
|
|
|
+ >
|
|
|
+ {item.published ? "已发布" : "未发布"}
|
|
|
+ </Tag>
|
|
|
+ )}
|
|
|
<div class="item_footer rounded-b-4px flex items-center justify-between p-4px">
|
|
|
<div class="flex-1 w-0">
|
|
|
{/* <div class="text-white text-bold truncate">{record.title}</div> */}
|
|
@@ -87,23 +109,23 @@ export default defineUI({
|
|
|
onMenu={async (name) => {
|
|
|
console.log("name", name);
|
|
|
if (name == "删除") {
|
|
|
- await resource.actions.deleteCustomComp(item)
|
|
|
+ await resource.actions.deleteCustomComp(item);
|
|
|
listCtrl.fresh();
|
|
|
-
|
|
|
- queenApi.messageSuccess("删除成功!")
|
|
|
+ queenApi.messageSuccess("删除成功!");
|
|
|
return;
|
|
|
}
|
|
|
- const pub = (name == "发布平台");
|
|
|
- await resource.actions.publishFrame(item, pub)
|
|
|
+ const pub = name == "发布平台";
|
|
|
+ await resource.actions.publishFrame(item, pub);
|
|
|
item.published = pub;
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </Draggable>
|
|
|
- );
|
|
|
- })}
|
|
|
- </Container>
|
|
|
+ </div>
|
|
|
+ </Draggable>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </Container>
|
|
|
+ </div>
|
|
|
);
|
|
|
};
|
|
|
},
|