|
@@ -1,18 +1,13 @@
|
|
|
-import { Button, Col, Form, Input, PageHeader, Row } from "ant-design-vue";
|
|
|
+import { Button, Form, Input } from "ant-design-vue";
|
|
|
import { defineComponent, onMounted, reactive } from "vue";
|
|
|
|
|
|
-import loading from "@/components/Provider/Loading";
|
|
|
-import { useArticle } from "@/modules/admin";
|
|
|
+import Modal from "@/components/Provider/Modal";
|
|
|
+import UploadImage from "@/modules/admin/components/UploadImage";
|
|
|
import { ArticleItem } from "@/typings/asset";
|
|
|
+import { css } from "@linaria/core";
|
|
|
import { object } from "vue-types";
|
|
|
import WangEditor from "../../components/WangEditor";
|
|
|
-import { css } from "@linaria/core";
|
|
|
-import Modal from "@/components/Provider/Modal";
|
|
|
-import UploadImage from "@/modules/admin/components/UploadImage";
|
|
|
-const layout = {
|
|
|
- labelCol: { span: 6 },
|
|
|
- wrapperCol: { span: 18 },
|
|
|
-};
|
|
|
+import { useArticle } from "@/modules/admin";
|
|
|
|
|
|
export default defineComponent({
|
|
|
props: {
|
|
@@ -20,7 +15,7 @@ export default defineComponent({
|
|
|
},
|
|
|
setup(props) {
|
|
|
const modal = Modal.use();
|
|
|
- // const artStore = useArticle();
|
|
|
+ const artStore = useArticle();
|
|
|
const state = reactive({
|
|
|
formData: {
|
|
|
...{
|
|
@@ -34,38 +29,29 @@ export default defineComponent({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- onMounted(() => {
|
|
|
- // initDetail();
|
|
|
- });
|
|
|
const rules = reactive({
|
|
|
title: [{ required: true, message: "名称不能为空", trigger: "change" }],
|
|
|
cover: [{ required: false }],
|
|
|
});
|
|
|
|
|
|
const { validate, validateInfos } = Form.useForm(state.formData, rules);
|
|
|
- // const initDetail = async () => {
|
|
|
- // loading.show("");
|
|
|
- // artStore.listController.state.query = JSON.stringify({ cid: data._id });
|
|
|
- // await artStore.listController.loadPage(1);
|
|
|
- // const item = artStore.listController.state.list[0] || {};
|
|
|
- // if (item._id) {
|
|
|
- // const detRes = await artStore.getArticleDetail(item);
|
|
|
- // if (detRes) {
|
|
|
- // state.data = detRes;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // loading.hidden();
|
|
|
- // };
|
|
|
- const editorChange = (v: any) => {
|
|
|
- // state.data.content = v;
|
|
|
+
|
|
|
+ const editorChange = ({ html, text }: any) => {
|
|
|
+ state.formData.content = html;
|
|
|
+ state.formData.summary = text;
|
|
|
};
|
|
|
const submit = () => {
|
|
|
- // const subData = { ...state.data };
|
|
|
- // if (!subData._id) {
|
|
|
- // subData.title = data?.name;
|
|
|
- // subData.cid = data._id;
|
|
|
- // }
|
|
|
- // artStore.addOrUpdateArticle(subData);
|
|
|
+ validate().then(async () => {
|
|
|
+ if (!state.formData.cover) {
|
|
|
+ state.formData.cover = artStore.getContentFirstImage(
|
|
|
+ state.formData.content
|
|
|
+ );
|
|
|
+ }
|
|
|
+ let summary = state.formData.summary.substring(0, 70);
|
|
|
+ summary = summary.replace(/\n/g, "");
|
|
|
+ state.formData.summary = summary;
|
|
|
+ modal.submit(state.formData);
|
|
|
+ });
|
|
|
};
|
|
|
const changeThumb = (v: string) => {
|
|
|
state.formData.cover = v;
|
|
@@ -75,8 +61,13 @@ export default defineComponent({
|
|
|
<div>
|
|
|
<div class={ModalPage}>
|
|
|
<div class={"form_box"}>
|
|
|
- <Form {...layout}>
|
|
|
- <Form.Item {...validateInfos.title} label={"名称"}>
|
|
|
+ <Form>
|
|
|
+ <Form.Item
|
|
|
+ {...validateInfos.title}
|
|
|
+ labelCol={{ span: 24 }}
|
|
|
+ wrapperCol={{ span: 24 }}
|
|
|
+ label={"名称"}
|
|
|
+ >
|
|
|
<Input
|
|
|
placeholder={"请输入名称"}
|
|
|
v-model={[state.formData.title, "value"]}
|
|
@@ -112,12 +103,14 @@ export default defineComponent({
|
|
|
const ModalPage = css`
|
|
|
padding: 20px;
|
|
|
height: 100%;
|
|
|
+ overflow: hidden;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
.form_box {
|
|
|
flex: 1;
|
|
|
width: 100%;
|
|
|
display: flex;
|
|
|
+ overflow: hidden;
|
|
|
.ant-form {
|
|
|
width: 260px;
|
|
|
padding-right: 20px;
|