Bladeren bron

Merge branch 'master' of http://124.70.149.18:10880/lianghj/queenshow

lianghongjie 1 jaar geleden
bovenliggende
commit
d7cf498a8f

+ 27 - 16
src/components/AssetsList.tsx

@@ -1,6 +1,6 @@
 import { css } from "@linaria/core";
 import { List } from "@queenjs/ui";
-import { Empty, Pagination } from "ant-design-vue";
+import { Empty, Pagination, Spin } from "ant-design-vue";
 import { defineUI } from "queenjs";
 import { any, number, string } from "vue-types";
 
@@ -14,24 +14,35 @@ export default defineUI({
   setup(props) {
     return () => {
       const { control, columns, gap } = props;
+      const loading = control.state.loading;
 
       return (
         <div class={styles}>
-          <List data={control.state.list} columns={columns} gap={gap}>
-            {{
-              item: (record: any) => props.item?.(record),
-              empty: () => <Empty class="py-50px" description="暂无数据" />,
-            }}
-          </List>
-          <div class="text-center my-30px">
-            <Pagination
-              size="default"
-              hideOnSinglePage
-              pageSize={control.state.size}
-              total={control.state.total}
-              onChange={(p) => control.loadPage(p)}
-            />
-          </div>
+          {loading && (
+            <div class="h-200px flex items-center justify-center">
+              <Spin spinning tip="加载中"></Spin>
+            </div>
+          )}
+          {!loading && (
+            <>
+              <List gap={gap} columns={columns} data={control.state.list}>
+                {{
+                  item: (record: any) => props.item?.(record),
+                  empty: () => <Empty class="py-50px" description="暂无数据" />,
+                }}
+              </List>
+              <div class="text-center my-50px">
+                <Pagination
+                  size="default"
+                  hideOnSinglePage
+                  pageSize={control.state.size}
+                  total={control.state.total}
+                  current={control.state.page}
+                  onChange={(p) => control.loadPage(p)}
+                />
+              </div>
+            </>
+          )}
         </div>
       );
     };

+ 4 - 1
src/modules/resource/actions/promotion.ts

@@ -1,5 +1,7 @@
 import { queenApi } from "queenjs";
 import { ResourceModule } from "..";
+import { PromotionController } from "../controllers/PromotionController";
+import { PageListController } from "@queenjs/controllers";
 
 export const promotionAction = ResourceModule.action({
   async renamePromotion(record: any) {
@@ -30,5 +32,6 @@ export const promotionAction = ResourceModule.action({
     const res = await this.https.createPromotion({ title });
     const url = `${location.origin}/editor.html#/?id=${res.result}`;
     location.href = url;
-  },
+  }
+
 });

+ 15 - 1
src/pages/website/Material2/components/MaterialController.ts → src/modules/resource/controllers/MaterialController.ts

@@ -6,13 +6,23 @@ export class MaterialController  {
     imageCtrl = new PageListController<any, any>();
     vidoeCtrl = new PageListController<any, any>();
     taskCtrl = new PageListController<any, any>();
+    tplCtrl = new PageListController<any, any>();
 
+    async showDialog(type:string) {
+        const ctrl = this.tplCtrl;
+        ctrl.state.query = type == "video" ? { hasVideo: true } : {}
+        ctrl.loadPage(1);
+        const record:any = await this.onShowDialog(ctrl, type);
+        if (record && record._id) {
+            const url = `${location.origin}/index.html#/create/${record._id}`;
+            location.href = url;
+        }
+    }
     switchTab(name: string, fresh = true) {
         this.state.currTab = name;
         const ctrol = this.getCurrControl();
         if(fresh)  ctrol.fresh();
     }
-
     getCurrControl() : PageListController<any, any> {
         switch (this.state.currTab) {
             case "image": return this.imageCtrl;
@@ -21,12 +31,16 @@ export class MaterialController  {
         }
     }
 
+
     onBtnClick(name:string) {
         console.log("onBtnClick", name)
     }
     onItemClick(name: "delete" | "download", record:any) {
         console.log("onItemClick", name, record)
     }
+    async onShowDialog(listCtrl: PageListController<any, any>, type:string) {
+        console.log("onShowDialog", type)
+    }
 }
 
 export const TabNames = {

+ 0 - 0
src/pages/website/Promotion2/components/PromotionController.ts → src/modules/resource/controllers/PromotionController.ts


+ 37 - 0
src/modules/resource/helper.ts

@@ -1,4 +1,7 @@
+import { PageListController } from "@queenjs/controllers";
 import { ResourceModule } from ".";
+import { PromotionController } from "./controllers/PromotionController";
+import { MaterialController } from "./controllers/MaterialController";
 
 export const helper = ResourceModule.helper({
   createFileName(fileName: string, dir: string) {
@@ -10,4 +13,38 @@ export const helper = ResourceModule.helper({
       6
     )}_${fileName}`;
   },
+
+  createPromotinController() {
+    const ctrl= new PromotionController();
+    ctrl.ListCtrl = new PageListController(this.config?.httpConfig);
+    ctrl.ListCtrl.setCrudPrefix("/h5")
+    ctrl.createPromotion = this.actions.createPromotion;
+
+    return ctrl;
+  },
+
+  createSourceController(isSelectModel:boolean, selectType :string) {
+      const {controls, actions} = this;
+      
+      const ctrl = new MaterialController();
+      ctrl.imageCtrl = controls.materialImageListCtrl;
+      ctrl.vidoeCtrl = controls.materialVideoListCtrl;
+      ctrl.taskCtrl = controls.renderTaskListCtrl;
+      ctrl.tplCtrl = controls.matTempListCtrl;
+
+      ctrl.onBtnClick = async function (name: string) {
+        if (name == "upload") {
+          const uploaded = await actions.uploadMaterial();
+          ctrl.switchTab(uploaded.fileType, false);
+          ctrl.getCurrControl().loadPage(1);
+          return;
+        }
+        ctrl.showDialog(name);
+      };
+      ctrl.onItemClick = function (name, record) {
+        if (name == "delete") return actions.deleteMaterial(record);
+        return actions.downloadMaterial(record);
+      };
+      return ctrl
+  }
 });

+ 1 - 1
src/modules/resource/index.ts

@@ -18,7 +18,7 @@ export class ResourceModule extends ModuleRoot {
   components = this.useComponents(compoents);
   store = this.createStore([store]);
   https = this.createHttps(http);
-  helpers = this.createHelper(helper);
+  helper = this.createHelper(helper);
 
   controls = {
     uploader: new UploadController({

+ 0 - 0
src/pages/website/CreateMat/components/RightPanel.tsx → src/pages/website/CreateMat/components/AttrPanel.tsx


+ 2 - 2
src/pages/website/CreateMat/index.tsx

@@ -4,9 +4,9 @@ import { switchSceneProdComp } from "@queenjs-modules/queditor/module/controls/Q
 import { initExpViewer } from "@queenjs-modules/queentree-explorer-viewer";
 import { defineComponent, onBeforeUnmount, onMounted } from "vue";
 import { useRoute } from "vue-router";
+import AttrPanel from "./components/AttrPanel";
 import Header from "./components/Header";
 import LeftPanel from "./components/LeftPanel";
-import RightPanel from "./components/RightPanel";
 
 export default defineComponent({
   setup() {
@@ -30,7 +30,7 @@ export default defineComponent({
           default: Header,
         },
         EditPanel: {
-          default: RightPanel,
+          default: AttrPanel,
         },
       },
     });

+ 2 - 2
src/pages/website/Material/index.tsx

@@ -1,10 +1,10 @@
-import { useResource } from "@/modules/resource";
+import { initResource, useResource } from "@/modules/resource";
 import { defineComponent } from "vue";
 
 export default defineComponent({
   setup() {
     const resource = useResource();
-
+    
     return () => {
       return (
         <div>

+ 1 - 1
src/pages/website/Material2/components/Material.tsx

@@ -5,8 +5,8 @@ import { Button } from "ant-design-vue";
 import AssetsList from "@/components/AssetsList";
 import { any } from "vue-types";
 import MaterialItem from "./MaterialItem";
-import {MaterialController } from "./MaterialController";
 import { onMounted } from "vue";
+import { MaterialController } from "@/modules/resource/controllers/MaterialController";
 
 
 export default defineUI({

+ 1 - 1
src/pages/website/Material2/components/MaterialToolbar.tsx

@@ -2,7 +2,7 @@ import { Button } from "ant-design-vue";
 import { defineComponent } from "vue";
 import { css, cx } from "@linaria/core";
 import { any } from "vue-types";
-import { BtnNames, MaterialController, TabNames } from "./MaterialController";
+import { BtnNames, MaterialController, TabNames } from "../../../../modules/resource/controllers/MaterialController";
 import { defineUI } from "queenjs";
 
 const materialType = [

+ 1 - 1
src/pages/website/Material2/controller.tsx

@@ -1,5 +1,5 @@
 import SelectListItemModal from "./components/SelectListItemModal";
-import { MaterialController } from "./components/MaterialController";
+import { MaterialController } from "../../../modules/resource/controllers/MaterialController";
 
 export default function createController(resource:any, isSelectModel:boolean, selectType :string) {
     const {controls, actions} = resource;

+ 1 - 1
src/pages/website/Promotion2/components/index.tsx

@@ -5,7 +5,7 @@ import Header from "./Header";
 import PromotionItem from "./PromotionItem"
 import { defineUI } from "queenjs";
 import { any } from "vue-types";
-import { PromotionController } from "./PromotionController";
+import { PromotionController } from "@/modules/resource/controllers/PromotionController";
 
 
 export default defineUI({

+ 2 - 9
src/pages/website/Promotion2/index.tsx

@@ -1,18 +1,11 @@
 import { useResource } from "@/modules/resource";
 import { defineComponent } from "vue";
-import PromotionUI from "./components";
-import { PromotionController } from "./components/PromotionController";
-import { PageListController } from "@queenjs/controllers";
 
+import PromotionUI from "./components";
 export default defineComponent({
   setup() {
-    
     const resource = useResource();
-    const ctrl= new PromotionController();
-    ctrl.ListCtrl = new PageListController(resource.config?.httpConfig);
-    ctrl.ListCtrl.setCrudPrefix("/h5")
-    ctrl.createPromotion = resource.actions.createPromotion;
-    
+    const ctrl = resource.helper.createPromotinController();
     return () => (
       <PromotionUI
         Controller={ctrl}