bianjiang 1 tahun lalu
induk
melakukan
06829df54e

+ 28 - 16
src/modules/editor/components/Viewport/Slider/SliderLeft/CompsUser.tsx

@@ -13,42 +13,54 @@ import { Image, Loadmore } from "@queenjs/ui";
 import { defineUI, queenApi } from "queenjs";
 import Menu from "./Menu";
 import ListFilter from "./ListFilter";
-import { watch } from "vue";
+import { onMounted, watch } from "vue";
 
 export default defineUI({
   props: {
     sourceType: string<"comp" | "text" | "shape">().def("comp"),
+    currentIndex: number(),
+    contentIndex: number(),
   },
   setup(props) {
     const editor = useEditor();
     const auth = useAuth();
     const resource = useResource();
 
-    const listCtrl = getCtrl();
-    listCtrl.hasLimit = true;
-    listCtrl.loadPage(1);
-
+    function getData() {
+      const ctrl = getCtrl();
+      ctrl.hasLimit = true;
+      ctrl.loadPage(1);
+    }
     //@ts-ignore
     let isSys = (auth.store.userInfo.roles || []).indexOf("system") > -1;
-
+    onMounted(() => getData());
     function getCtrl() {
       const key = `cust${upperFirst(props.sourceType)}ListCtrl`;
       //@ts-ignore
       return resource.controls[key];
     }
-
+    watch(
+      () => props.currentIndex,
+      () => {
+        if (props.currentIndex == props.contentIndex) {
+          const ctrl = getCtrl();
+          if (ctrl.state.list.length == 0) getData();
+        }
+      }
+    );
     const filterChange = (v: any) => {
-      const query = listCtrl.state.query || {};
-      listCtrl.state.query = {
+      const ctrl = getCtrl();
+      const query = ctrl.state.query || {};
+      ctrl.state.query = {
         ...query,
         categories: v,
       };
-      listCtrl.loadPage(1);
+      ctrl.loadPage(1);
     };
     return () => {
       const { sourceType } = props;
-
-      const dataSource = listCtrl.state.list;
+      const ctrl = getCtrl();
+      const dataSource = ctrl.state.list;
 
       return (
         <div>
@@ -128,7 +140,7 @@ export default defineUI({
                               item,
                               title[sourceType]
                             );
-                            listCtrl.fresh();
+                            ctrl.fresh();
                             queenApi.messageSuccess("删除成功!");
                             return;
                           }
@@ -162,9 +174,9 @@ export default defineUI({
           ) : (
             <Loadmore
               class="mt-20px"
-              loading={listCtrl.state.loading}
-              canLoad={listCtrl.state.canLoadNext}
-              onChange={listCtrl.loadNextPage}
+              loading={ctrl.state.loading}
+              canLoad={ctrl.state.canLoadNext}
+              onChange={ctrl.loadNextPage}
             />
           )}
         </div>

+ 1 - 1
src/modules/editor/components/Viewport/Slider/SliderLeft/CustomComps.tsx

@@ -66,7 +66,7 @@ export default defineUI({
           <ListFilter
             class={"mb-16px"}
             sourceType={"comp"}
-            isSys={false}
+            isSys={true}
             onChange={filterChange}
           />
           <CompList dataSource={dataSource} isSys={true} />

+ 0 - 7
src/modules/editor/components/Viewport/Slider/SliderLeft/Sources/List.tsx

@@ -48,13 +48,6 @@ export const Sources = defineComponent({
 
     onMounted(() => getData());
 
-    watch(
-      () => [props.sourceFrom, props.sourceType],
-      () => {
-        const ctrl = getCurrCtrl();
-        if (ctrl.state.list.length == 0) getData();
-      }
-    );
     const filterChange = (v: any) => {
       const ctrl = getCurrCtrl();
       const query = ctrl.state.query || {};

+ 3 - 1
src/modules/editor/components/Viewport/Slider/SliderLeft/Sources/SourceItem.tsx

@@ -144,7 +144,9 @@ export default defineUI({
                     <Menu.Item>
                       <div onClick={() => emit("menu", "delete")}>删除</div>
                     </Menu.Item>
-
+                    {/* <Menu.Item>
+                      <div onClick={() => emit("menu", "category")}>编辑分类</div>
+                    </Menu.Item> */}
                     {isSys && !record.published && (
                       <Menu.Item>
                         <div onClick={() => emit("menu", "publish")}>

+ 1 - 2
src/modules/editor/components/Viewport/Slider/SliderLeft/Templates/index.tsx

@@ -6,9 +6,8 @@ import { Image, Loadmore } from "@queenjs/ui";
 import { defineUI, queenApi } from "queenjs";
 import Modal from "queenjs/adapter/vue/components/modal";
 import { Container, Draggable } from "vue-dndrop";
-import PreviewTplModal from "./PreviewTplModal";
-import { string } from "vue-types";
 import ListFilter from "../ListFilter";
+import PreviewTplModal from "./PreviewTplModal";
 
 export default defineUI({
   setup() {

+ 8 - 2
src/modules/editor/components/Viewport/Slider/SliderLeft/index.tsx

@@ -138,8 +138,10 @@ export default defineUI({
             if (!list.includes(index)) return null;
             return (
               <PanelContent
-                key={Date.now()}
+                key={index}
                 currentTab={tab}
+                currentIndex={tabIndex}
+                contentIndex={index}
                 class={tabIndex !== index && "hidden"}
               />
             );
@@ -188,6 +190,8 @@ const PanelTabs = defineComponent({
 const PanelContent = defineComponent({
   props: {
     currentTab: object().isRequired,
+    currentIndex: number(),
+    contentIndex: number(),
   },
   setup(props) {
     const state = reactive({
@@ -224,7 +228,7 @@ const PanelContent = defineComponent({
     };
 
     const Subcontent = () => {
-      const { currentTab } = props;
+      const { currentTab, currentIndex, contentIndex } = props;
       const { currCompIndex, list } = state;
 
       const currComps = currentTab.component
@@ -238,6 +242,8 @@ const PanelContent = defineComponent({
             return (
               <currComp.component
                 key={index}
+                currentIndex={currentIndex}
+                contentIndex={contentIndex}
                 class={cx(
                   "flex-1 h-1/1 px-16px !my-10px overflow-x-hidden overflow-y-auto scrollbar",
                   currCompIndex !== index && "hidden"