bianjiang 1 year ago
parent
commit
4fd0cc45e6

+ 2 - 1
src/modules/editor/components/Viewport/Toolbar/AiText.tsx

@@ -148,10 +148,11 @@ export default defineComponent({
 const AIStyle = css`
   border-radius: 4px;
   box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2);
+  background-color: rgba(38, 38, 38, 0.6);
   .input_box,
   .result_text {
     position: relative;
-    background-color: #303030;
+    background-color: rgba(255, 255, 255, 0.1);
     border-radius: 4px;
 
     .ai_input {

+ 9 - 19
src/modules/resource/actions/collection.tsx

@@ -2,16 +2,6 @@ import { queenApi } from "queenjs";
 import { ResourceModule } from "..";
 
 export const collectionAction = ResourceModule.action({
-  async renameCollection(record: any) {
-    const title = await queenApi.showInput({
-      title: "请输入标题",
-      defaultValue: record.title,
-    });
-    if (!title) return;
-    await this.https.updateCollection({ _id: record._id, title });
-    record.title = title;
-  },
-
   async deleteCollection(record: any) {
     const res = await queenApi.showConfirm({
       content: `删除后无法恢复,确定要删除:${record.title}?`,
@@ -21,14 +11,14 @@ export const collectionAction = ResourceModule.action({
     await this.https.deleteCollection(record._id);
   },
 
-  async createCollection() {
-    const title = await queenApi.showInput({
-      title: "请输入标题",
-    });
-    if (!title) return;
-    const res = await this.https.createCollection({ title });
-
-    const url = `${location.origin}/editor.html#/?id=${res.result}`;
-    location.href = url;
+  async createOrUpdateCollection(record: any) {
+    const data = await this.showModal(
+      <this.components.CollectionEditModal record={record} />
+    );
+    if (record && record.id) {
+      await this.https.updateCollection(data);
+    } else {
+      await this.https.createCollection(data);
+    }
   },
 });

+ 198 - 0
src/modules/resource/components/CollectionEditModal.tsx

@@ -0,0 +1,198 @@
+import { css } from "@linaria/core";
+import { Button, Form, Input, DatePicker } from "ant-design-vue";
+import dayjs, { Dayjs } from "dayjs";
+import { useModal } from "queenjs";
+import { defineComponent, reactive } from "vue";
+import { any, string } from "vue-types";
+import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
+import localeData from "dayjs/plugin/localeData";
+import weekday from "dayjs/plugin/weekday";
+import { Image } from "@queenjs/ui";
+import { IconImage } from "@/assets/icons";
+import { IconAddLine } from "@queenjs/icons";
+import { useEditor } from "@/modules/editor";
+import { SelectOneImage } from "@/pages/website/Material2/modal";
+const layout = {
+  labelCol: { span: 8 },
+  wrapperCol: { span: 16 },
+};
+dayjs.extend(weekday);
+dayjs.extend(localeData);
+const { RangePicker } = DatePicker;
+type RangeValue = [Dayjs, Dayjs];
+export default defineComponent({
+  props: {
+    record: any().isRequired,
+  },
+  setup(props, { slots }) {
+    const dateLocal: any = locale;
+    dateLocal.lang.shortWeekDays = "日_一_二_三_四_五_六".split("_");
+    dateLocal.lang.shortMonths =
+      "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_");
+    const modal = useModal();
+    const data = props.record
+      ? { ...props.record }
+      : {
+          thumbnail: "",
+          logo: "",
+          title: "",
+          startTime: "",
+          endTime: "",
+        };
+    const formState: { [name: string]: any } = reactive({
+      ...data,
+    });
+
+    const rules = reactive({
+      title: [
+        { required: true, message: "标题不能为空", trigger: "change" },
+        {
+          min: 2,
+          max: 20,
+          message: "长度为2~20位字符",
+          trigger: "change",
+        },
+      ],
+      thumbnail: [
+        { required: true, message: "封面图不能为空", trigger: "change" },
+      ],
+      logo: [{ required: false }],
+    });
+
+    const { validate, validateInfos } = Form.useForm(formState, rules);
+
+    function submit() {
+      validate().then(async () => {
+        modal.submit(formState);
+      });
+    }
+    const pickerRanges = () => {
+      return {
+        今天: [dayjs(), dayjs()] as RangeValue,
+        本周: [
+          dayjs().startOf("week").add(1, "day"),
+          dayjs().endOf("week").add(1, "day"),
+        ] as RangeValue,
+        本月: [dayjs().startOf("month"), dayjs().endOf("month")] as RangeValue,
+      };
+    };
+    return () => {
+      return (
+        <div class={ModalStyle}>
+          <Form {...layout} onSubmit={submit}>
+            <Form.Item {...validateInfos.thumbnail} wrapperCol={{ span: 24 }}>
+              <div class={"w-full h-150px pt-20px"}>
+                <ImageUploader
+                  data={formState.thumbnail}
+                  text="请选择封面图"
+                  onChange={(v) => {
+                    formState.thumbnail = v;
+                    console.log(v);
+                  }}
+                />
+              </div>
+            </Form.Item>
+            <Form.Item {...validateInfos.title} label="标题">
+              <Input
+                placeholder={"请输入标题"}
+                v-model={[formState.title, "value"]}
+              />
+            </Form.Item>
+            <Form.Item {...validateInfos.logo} label="logo">
+              <div class={"w-80px h-80px"}>
+                <ImageUploader
+                  data={formState.logo}
+                  text="请选择logo"
+                  icon={<IconAddLine class="text-18px" />}
+                  onChange={(v) => {
+                    formState.logo = v;
+                    console.log(v);
+                  }}
+                />
+              </div>
+            </Form.Item>
+            <Form.Item label="开始/结束日期">
+              <RangePicker
+                locale={dateLocal}
+                ranges={pickerRanges()}
+                onChange={(datas: any) => {
+                  console.log(datas);
+                  formState.startTime = dayjs(datas[0]).format("YYYY-MM-DD");
+                  formState.endTime = dayjs(datas[1]).format("YYYY-MM-DD");
+                }}
+              />
+            </Form.Item>
+            <Form.Item style={{ marginBottom: 0 }} wrapperCol={{ span: 24 }}>
+              <Button block type="primary" htmlType="submit">
+                确定
+              </Button>
+            </Form.Item>
+          </Form>
+        </div>
+      );
+    };
+  },
+});
+
+const ImageUploader = defineComponent({
+  props: {
+    data: string(),
+    icon: any(),
+    text: string().def(""),
+  },
+  emits: ["change"],
+  setup(props, { emit }) {
+    const { controls } = useEditor();
+    const uploadImage = async () => {
+      const url = await SelectOneImage();
+      if (!url) return;
+      emit("change", url);
+    };
+    return () => (
+      <div class={ImageStyle} onClick={uploadImage}>
+        <div class={"wapper"}>
+          {props.data ? (
+            <Image src={props.data} size={0} />
+          ) : (
+            <div class={"no_value"}>
+              {props.icon ? props.icon : <IconImage class={"text-30px"} />}
+              {props.text ? <div class={"up_txt"}>{props.text}</div> : null}
+            </div>
+          )}
+        </div>
+      </div>
+    );
+  },
+});
+const ImageStyle = css`
+  width: 100%;
+  height: 100%;
+  color: #fff;
+  background-color: #303030;
+  border-radius: 2px;
+  cursor: pointer;
+  .wapper {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+  }
+  .no_value {
+    display: inline-flex;
+    flex-direction: column;
+    align-items: center;
+    .up_txt {
+      margin-top: 10px;
+      font-size: 14px;
+    }
+  }
+  img {
+    width: 100%;
+    height: 100%;
+    border-radius: 2px;
+    object-fit: cover;
+  }
+`;
+
+const ModalStyle = css``;

+ 2 - 0
src/modules/resource/components/index.ts

@@ -1,9 +1,11 @@
 import MaterialItem from "./MaterialItem";
 import PromotionItem from "./PromotionItem";
 import ResourceManager from "./ResourceManager";
+import CollectionEditModal from "./CollectionEditModal";
 
 export const compoents = {
   MaterialItem,
   PromotionItem,
   ResourceManager,
+  CollectionEditModal,
 };

+ 14 - 0
src/modules/resource/controllers/CollectionController.ts

@@ -0,0 +1,14 @@
+import { PageListController } from "@queenjs/controllers";
+
+export class CollectionController {
+  ListCtrl = new PageListController<any, any>();
+  createCollection() {
+    console.log("createCollection");
+  }
+  onMenuClick(menu: string, item: any) {
+    console.log("onMenuClick", menu, item);
+  }
+  onEdit(item: any) {
+    console.log(item);
+  }
+}

+ 0 - 24
src/modules/resource/controllers/ComponentController.ts

@@ -1,24 +0,0 @@
-import { PageListController } from "@queenjs/controllers";
-
-export class ComponentController {
-  ListCtrl = new PageListController<any, any>();
-  createComp() {
-    console.log("createPromotion");
-  }
-  onMenuClick(menu: string, item: any) {
-    console.log("onMenuClick", menu, item);
-  }
-  onEdit(item: any) {
-    const _params = new URLSearchParams(decodeURIComponent(location.search));
-    const host = _params.get("host");
-
-    // if (location.host == "www.infish.cn") {
-    //   const url = `${location.origin}/projects/queenshowv1/editor.html?host=${host}#/?id=${item._id}&mode=editComp`;
-    //   location.href = url;
-    //   return;
-    // }
-
-    const url = `${location.origin}/editor.html?host=${host}#/?id=${item._id}&mode=editComp`;
-    location.href = url;
-  }
-}

+ 8 - 22
src/modules/resource/helper.ts

@@ -1,7 +1,7 @@
 import { PageListController } from "@queenjs/controllers";
 import { queenApi } from "queenjs";
 import { ResourceModule } from ".";
-import { ComponentController } from "./controllers/ComponentController";
+import { CollectionController } from "./controllers/CollectionController";
 
 export const helper = ResourceModule.helper({
   createFileName(fileName: string, dir: string) {
@@ -14,33 +14,19 @@ export const helper = ResourceModule.helper({
     )}_${fileName}`;
   },
 
-  createCompController() {
-    const ctrl = new ComponentController();
-    ctrl.ListCtrl = new PageListController(this.config?.httpConfig);
-    ctrl.ListCtrl.setCrudPrefix("/frame");
-    ctrl.createComp = this.actions.createComp;
-    ctrl.onMenuClick = async (name, record) => {
-      if (name == "delete") {
-        await this.actions.deleteComp(record);
-        ctrl.ListCtrl.fresh();
-      } else if (name == "rename") {
-        await this.actions.renameComp(record);
-      }
-    };
-
-    return ctrl;
-  },
   createCollectionController() {
-    const ctrl = new ComponentController();
+    const ctrl = new CollectionController();
     ctrl.ListCtrl = new PageListController(this.config?.httpConfig);
     ctrl.ListCtrl.setCrudPrefix("/frame");
-    ctrl.createComp = this.actions.createCollection;
-    ctrl.onMenuClick = async (name, record) => {
+    ctrl.createCollection = async () => {
+      await this.actions.createOrUpdateCollection(null);
+    };
+    ctrl.onMenuClick = async (name: string, record: any) => {
       if (name == "delete") {
         await this.actions.deleteCollection(record);
         ctrl.ListCtrl.fresh();
-      } else if (name == "rename") {
-        await this.actions.renameCollection(record);
+      } else if (name == "update") {
+        await this.actions.createOrUpdateCollection(record);
       }
     };
     return ctrl;

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

@@ -38,5 +38,5 @@ export async function SelectOneImage() {
 }
 
 export async function SelectOneVideo() {
-  return  await queenApi.dialog(<SelectMaterialDialog type="image" />,  {title:"选择单个视频", width: "900px"})
+  return  await queenApi.dialog(<SelectMaterialDialog type="video" />,  {title:"选择单个视频", width: "900px"})
 }

+ 1 - 1
src/pages/website/MyCollection/components/CompItem.tsx

@@ -49,7 +49,7 @@ export default defineUI({
               overlay={
                 <Menu class="w-90px">
                   <Menu.Item>
-                    <div onClick={() => emit("menu", "rename")}>重命名</div>
+                    <div onClick={() => emit("menu", "update")}>编辑</div>
                   </Menu.Item>
                   <Menu.Item>
                     <div onClick={() => emit("menu", "delete")}>删除</div>

+ 7 - 3
src/pages/website/MyCollection/components/index.tsx

@@ -1,5 +1,5 @@
 import List from "@/components/AssetsList";
-import { ComponentController } from "@/modules/resource/controllers/ComponentController";
+import { CollectionController } from "@/modules/resource/controllers/CollectionController";
 import { defineUI } from "queenjs";
 import { onMounted } from "vue";
 import { any } from "vue-types";
@@ -8,7 +8,7 @@ import Header from "./Header";
 
 export default defineUI({
   props: {
-    Controller: any<ComponentController>().isRequired,
+    Controller: any<CollectionController>().isRequired,
   },
   slots: {
     Header,
@@ -22,7 +22,11 @@ export default defineUI({
     return () => {
       return (
         <div>
-          <slots.Header onAdd={props.Controller.createComp} />
+          <slots.Header
+            onAdd={() => {
+              props.Controller.createCollection();
+            }}
+          />
           <slots.List
             gap="25px"
             class="my-30px"

+ 20 - 5
src/pages/website/Promotion2/components/CollectionModal.tsx

@@ -36,7 +36,7 @@ export default defineComponent({
               src={require("@/assets/imgs/empty_history.png")}
             />
           </div>
-          <div class={"text-12px mt-16px text-gray"}>暂无历史提交信息</div>
+          <div class={"text-12px mt-16px text-gray"}>暂无历史发送信息</div>
         </div>
       );
     };
@@ -57,7 +57,7 @@ export default defineComponent({
             />
           </div>
           <div class={"text-12px mt-18px text-gray"}>
-            请输入正确的大赛接收地址获取大赛信息
+            请输入正确的接收地址获取信息
           </div>
         </div>
       );
@@ -72,7 +72,13 @@ export default defineComponent({
             >
               <div class={"text-16px"}>接收地址</div>
               <div class={"flex-1 px-30px"}>
-                <Select class={"w-full"}></Select>
+                <Select
+                  class={"w-full text-center"}
+                  placeholder={"请输入接收地址"}
+                  showSearch
+                  showArrow={false}
+                  notFoundContent={null}
+                ></Select>
               </div>
               <div>
                 <Button type="primary" ghost icon={<SearchOutlined />}>
@@ -83,11 +89,11 @@ export default defineComponent({
             <div class={"bg-white px-30px py-20px"}>{EmptyCollection()}</div>
             <div class={"flex items-center space-x-16px"}>
               <div class={"flex-1 bg-white px-30px py-18px rounded-6px"}>
-                <div class={"text-16px"}>当前提交</div>
+                <div class={"text-16px"}>当前发送</div>
                 <div class={"mt-20px h-160px"}></div>
               </div>
               <div class={"flex-1 bg-white px-30px py-18px rounded-6px"}>
-                <div class={"text-16px"}>历史提交</div>
+                <div class={"text-16px"}>历史发送</div>
                 <div class={"mt-20px h-160px"}>{EmptyHistory()}</div>
               </div>
             </div>
@@ -114,8 +120,17 @@ const ModalStyle = css`
     .ant-select-selector {
       border-radius: 4px;
       border-color: rgba(51, 51, 51, 0.3);
+      color: #111;
+      .ant-select-selection-search {
+        input {
+          text-align: center;
+        }
+      }
     }
   }
+  .ant-select-selection-placeholder {
+    color: #999;
+  }
   .ant-btn-background-ghost.ant-btn-primary {
     border-radius: 4px;
     background-color: rgba(255, 227, 178, 0.3);