|
@@ -1,17 +1,27 @@
|
|
|
+import { IconImage } from "@/assets/icons";
|
|
|
+import { useEditor } from "@/modules/editor";
|
|
|
+import { SelectOneImage } from "@/pages/website/Material2/modal";
|
|
|
+import { PlusOutlined } from "@ant-design/icons-vue";
|
|
|
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 { IconAddLine } from "@queenjs/icons";
|
|
|
+import { Image } from "@queenjs/ui";
|
|
|
+import {
|
|
|
+ Button,
|
|
|
+ DatePicker,
|
|
|
+ Divider,
|
|
|
+ Form,
|
|
|
+ Input,
|
|
|
+ Select,
|
|
|
+} from "ant-design-vue";
|
|
|
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
|
|
|
+import dayjs, { Dayjs } from "dayjs";
|
|
|
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";
|
|
|
+import { queenApi, useModal } from "queenjs";
|
|
|
+import { defineComponent, reactive } from "vue";
|
|
|
+import { any, string } from "vue-types";
|
|
|
+import { useResource } from "..";
|
|
|
+
|
|
|
const layout = {
|
|
|
labelCol: { span: 8 },
|
|
|
wrapperCol: { span: 16 },
|
|
@@ -33,17 +43,30 @@ export default defineComponent({
|
|
|
const data = props.record
|
|
|
? { ...props.record }
|
|
|
: {
|
|
|
- thumbnail: "",
|
|
|
+ cover: "",
|
|
|
logo: "",
|
|
|
- url: "",
|
|
|
+ introLink: "",
|
|
|
+ introH5Id: "",
|
|
|
+ statues: [],
|
|
|
+ flags: [],
|
|
|
+ status: "",
|
|
|
title: "",
|
|
|
startTime: "",
|
|
|
endTime: "",
|
|
|
};
|
|
|
+
|
|
|
+ const resource = useResource();
|
|
|
+ resource.controls.promotionListCtrl.loadPage(1);
|
|
|
const formState: { [name: string]: any } = reactive({
|
|
|
...data,
|
|
|
});
|
|
|
|
|
|
+ const state = reactive({
|
|
|
+ linkType: "id",
|
|
|
+ });
|
|
|
+ if (data.introLink) {
|
|
|
+ state.linkType = "link";
|
|
|
+ }
|
|
|
const rules = reactive({
|
|
|
title: [
|
|
|
{ required: true, message: "标题不能为空", trigger: "change" },
|
|
@@ -54,11 +77,7 @@ export default defineComponent({
|
|
|
trigger: "change",
|
|
|
},
|
|
|
],
|
|
|
- thumbnail: [
|
|
|
- { required: true, message: "封面图不能为空", trigger: "change" },
|
|
|
- ],
|
|
|
- logo: [{ required: false }],
|
|
|
- url: [{ required: false }],
|
|
|
+ cover: [{ required: true, message: "封面图不能为空", trigger: "change" }],
|
|
|
});
|
|
|
|
|
|
const { validate, validateInfos } = Form.useForm(formState, rules);
|
|
@@ -78,18 +97,69 @@ export default defineComponent({
|
|
|
本月: [dayjs().startOf("month"), dayjs().endOf("month")] as RangeValue,
|
|
|
};
|
|
|
};
|
|
|
+
|
|
|
+ const statusOptions = () => {
|
|
|
+ const options = formState.statues.map((e: any) => {
|
|
|
+ return { label: e, value: e };
|
|
|
+ });
|
|
|
+ return options;
|
|
|
+ };
|
|
|
+ const addStatus = async () => {
|
|
|
+ const text = await queenApi.showInput({
|
|
|
+ title: "添加状态",
|
|
|
+ placeholder: "输入状态名称",
|
|
|
+ });
|
|
|
+ if (!text) return;
|
|
|
+ if (formState.statues.length == 0) {
|
|
|
+ formState.status = text;
|
|
|
+ }
|
|
|
+ formState.statues.push(text);
|
|
|
+ };
|
|
|
+ const flagsOptions = () => {
|
|
|
+ const options = formState.flags.map((e: any) => {
|
|
|
+ return { label: e, value: e };
|
|
|
+ });
|
|
|
+ return options;
|
|
|
+ };
|
|
|
+ const addFlag = async () => {
|
|
|
+ const text = await queenApi.showInput({
|
|
|
+ title: "添加标签",
|
|
|
+ placeholder: "输入标签名称",
|
|
|
+ });
|
|
|
+ if (!text) return;
|
|
|
+ formState.flags.push(text);
|
|
|
+ };
|
|
|
+ const h5Options = () => {
|
|
|
+ const options = resource.controls.promotionListCtrl.state.list.map(
|
|
|
+ (e: any) => {
|
|
|
+ return { label: e.title, value: e._id };
|
|
|
+ }
|
|
|
+ );
|
|
|
+ return options;
|
|
|
+ };
|
|
|
+ const scorllEnd = (e: any) => {
|
|
|
+ const { target } = e;
|
|
|
+ if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
|
|
|
+ if (resource.controls.promotionListCtrl.state.canLoadNext) {
|
|
|
+ resource.controls.promotionListCtrl.loadNextPage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
return () => {
|
|
|
+ const time: [Dayjs, Dayjs] | undefined =
|
|
|
+ formState.startTime && formState.endTime
|
|
|
+ ? [dayjs(formState.startTime), dayjs(formState.endTime)]
|
|
|
+ : undefined;
|
|
|
return (
|
|
|
<div class={ModalStyle}>
|
|
|
<Form {...layout} onSubmit={submit}>
|
|
|
- <Form.Item {...validateInfos.thumbnail} wrapperCol={{ span: 24 }}>
|
|
|
- <div class={"w-full h-150px pt-20px"}>
|
|
|
+ <Form.Item {...validateInfos.cover} wrapperCol={{ span: 24 }}>
|
|
|
+ <div class={"w-full h-180px pt-20px"}>
|
|
|
<ImageUploader
|
|
|
- data={formState.thumbnail}
|
|
|
+ data={formState.cover}
|
|
|
text="请选择封面图"
|
|
|
onChange={(v) => {
|
|
|
- formState.thumbnail = v;
|
|
|
- console.log(v);
|
|
|
+ formState.cover = v;
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
@@ -100,13 +170,42 @@ export default defineComponent({
|
|
|
v-model={[formState.title, "value"]}
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
- <Form.Item {...validateInfos.url} label="详情链接">
|
|
|
- <Input
|
|
|
- placeholder={"请输入链接地址"}
|
|
|
- v-model={[formState.url, "value"]}
|
|
|
- />
|
|
|
+ <Form.Item label="详情介绍">
|
|
|
+ <Input.Group compact>
|
|
|
+ <Select
|
|
|
+ defaultValue={state.linkType}
|
|
|
+ onChange={(v: any) => {
|
|
|
+ state.linkType = v;
|
|
|
+ if (v == "id") {
|
|
|
+ formState.introLink = "";
|
|
|
+ } else {
|
|
|
+ formState.introH5Id = null;
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Select.Option value="id">站内作品</Select.Option>
|
|
|
+ <Select.Option value="link">站外链接</Select.Option>
|
|
|
+ </Select>
|
|
|
+ {state.linkType == "link" ? (
|
|
|
+ <Input
|
|
|
+ class={"flex-1"}
|
|
|
+ placeholder={"请输入链接地址"}
|
|
|
+ v-model={[formState.introLink, "value"]}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <Select
|
|
|
+ value={formState.introH5Id}
|
|
|
+ class={"flex-1"}
|
|
|
+ options={h5Options()}
|
|
|
+ onPopupScroll={scorllEnd}
|
|
|
+ onChange={(v: any) => {
|
|
|
+ formState.introH5Id = v;
|
|
|
+ }}
|
|
|
+ ></Select>
|
|
|
+ )}
|
|
|
+ </Input.Group>
|
|
|
</Form.Item>
|
|
|
- <Form.Item {...validateInfos.logo} label="logo">
|
|
|
+ <Form.Item label="logo">
|
|
|
<div class={"w-80px h-80px"}>
|
|
|
<ImageUploader
|
|
|
data={formState.logo}
|
|
@@ -114,19 +213,73 @@ export default defineComponent({
|
|
|
icon={<IconAddLine class="text-18px" />}
|
|
|
onChange={(v) => {
|
|
|
formState.logo = v;
|
|
|
- console.log(v);
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="开始/结束日期">
|
|
|
+ <Form.Item label={"自定义状态"}>
|
|
|
+ <Select
|
|
|
+ options={statusOptions()}
|
|
|
+ listHeight={150}
|
|
|
+ value={formState.status}
|
|
|
+ onChange={(v: any) => {
|
|
|
+ formState.status = v;
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ dropdownRender: ({ menuNode }: any) => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {menuNode}
|
|
|
+ <Divider style={{ margin: 0 }} />
|
|
|
+ <Button
|
|
|
+ type="link"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ onMousedown={(e) => {
|
|
|
+ e.stopPropagation();
|
|
|
+ }}
|
|
|
+ onClick={addStatus}
|
|
|
+ >
|
|
|
+ 添加状态
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ </Select>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={"自定义标签"}>
|
|
|
+ <Select options={flagsOptions()} listHeight={150}>
|
|
|
+ {{
|
|
|
+ dropdownRender: ({ menuNode }: any) => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {menuNode}
|
|
|
+ <Divider style={{ margin: 0 }} />
|
|
|
+ <Button
|
|
|
+ type="link"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ onMousedown={(e) => {
|
|
|
+ e.stopPropagation();
|
|
|
+ }}
|
|
|
+ onClick={addFlag}
|
|
|
+ >
|
|
|
+ 添加标签
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ </Select>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="征集日期">
|
|
|
<RangePicker
|
|
|
locale={dateLocal}
|
|
|
ranges={pickerRanges()}
|
|
|
+ value={time}
|
|
|
onChange={(datas: any) => {
|
|
|
- console.log(datas);
|
|
|
- formState.startTime = dayjs(datas[0]).format("YYYY-MM-DD");
|
|
|
- formState.endTime = dayjs(datas[1]).format("YYYY-MM-DD");
|
|
|
+ formState.startTime = dayjs(datas[0]);
|
|
|
+ formState.endTime = dayjs(datas[1]);
|
|
|
}}
|
|
|
/>
|
|
|
</Form.Item>
|
|
@@ -203,4 +356,9 @@ const ImageStyle = css`
|
|
|
}
|
|
|
`;
|
|
|
|
|
|
-const ModalStyle = css``;
|
|
|
+const ModalStyle = css`
|
|
|
+ width: 480px;
|
|
|
+ .ant-input-group.ant-input-group-compact {
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
+`;
|