Browse Source

提交渲染数据

liwei 1 year ago
parent
commit
ffdefc09dd

+ 16 - 2
src/modules/resource/actions/material.ts

@@ -42,7 +42,21 @@ export const materialActions = ResourceModule.action({
     const res = await this.https.queryTplsDetail(id);
     this.store.setSourceDetail(res.result);
   },
-  async submitRender() {
-    //
+  async submitRender(id: string, images:any, vidoes:any) {
+
+    queenApi.showLoading("任务提交中")
+
+    console.log("iamges=>",images, "videos->", vidoes);
+
+    try {
+      await this.https.sourceGen({genRequest: {templateId: id, vidoes: vidoes, images:images}})
+      queenApi.messageSuccess("任务提交成功")
+      return true;
+      
+    } catch (error) {
+      console.error(error);
+    } finally{
+      queenApi.hideLoading();
+    }
   },
 });

+ 5 - 0
src/modules/resource/http.ts

@@ -16,6 +16,11 @@ export const http = ResourceModule.http({
   queryTplsDetail(id: string) {
     return this.request(`/tpls/detail/${id}`, { method: "GET" });
   },
+  
+  sourceGen(data) {
+    return this.request(`/sourceGen/create`, { method: "POST", data});
+  },
+
 
   //   promotion
   createPromotion(data: any) {

+ 2 - 2
src/pages/website/EditMaterial/components/Header.tsx

@@ -10,8 +10,8 @@ export default defineComponent({
   setup() {
     const resource = useResource();
 
-    const showModal = () => {
-      resource.showModal(<SelectTemplateModal />, {
+    const showModal = async () => {
+       resource.showModal(<SelectTemplateModal />, {
         title: "选择模板",
         width: "900px",
       });

+ 13 - 7
src/pages/website/EditMaterial/components/SelectTemplateModal.tsx

@@ -3,22 +3,27 @@ import { List } from "@queenjs/ui";
 import { Button, Empty } from "ant-design-vue";
 import { queenApi, useModal } from "queenjs";
 import { defineComponent, reactive } from "vue";
+import { useRoute } from "vue-router";
 
 export default defineComponent({
   setup() {
     const resource = useResource();
     const modal = useModal();
+    const route = useRoute();
 
     const state = reactive({
-      list: [],
+      list: [] as {id: string, qos:1}[],
     }) as any;
 
-    const submit = () => {
+    const submit =async () => {
       if (state.list.length == 0) {
         queenApi.messageError("请选择至少一个模板");
         return;
       }
-      resource.actions.submitRender();
+      const isOk = await resource.actions.submitRender(route.params.id as string, state.list, []);
+      if (isOk) {
+        modal.submit(true);
+      }
     };
 
     return () => {
@@ -31,16 +36,17 @@ export default defineComponent({
                   <resource.components.MaterialItem
                     record={record}
                     class="cursor-pointer"
-                    active={state.list.includes(record.id)}
+                    active={ !!(state.list.find((v:any)=>v.id == record.id))}
                     onSelect={() => {
-                      if (state.list.includes(record.id)) {
+                      const selected =  !!(state.list.find((v:any)=>v.id == record.id))
+                      if (selected) {
                         const index = state.list.findIndex(
-                          (d: string) => d == record.id
+                          (d: any) => d.id == record.id
                         );
                         state.list.splice(index);
                         return;
                       }
-                      state.list.push(record.id);
+                      state.list.push({id: record.id, qos:1});
                     }}
                   />
                 );