|
@@ -65,6 +65,10 @@
|
|
></div>
|
|
></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="button-form">
|
|
|
|
+ <a-button style="margin-right:20px" @click="goPrev">上一步</a-button>
|
|
|
|
+ <a-button type="primary" @click="submitForm">保存</a-button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<a-modal
|
|
<a-modal
|
|
v-model:visible="modelShow"
|
|
v-model:visible="modelShow"
|
|
@@ -130,14 +134,23 @@
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
import { defineComponent, reactive, ref, toRefs, onMounted } from "vue";
|
|
import { defineComponent, reactive, ref, toRefs, onMounted } from "vue";
|
|
import { getLandingPic, getLandingTempalte } from "@/api";
|
|
import { getLandingPic, getLandingTempalte } from "@/api";
|
|
|
|
+import { message } from "ant-design-vue";
|
|
|
|
+import useApp from "@/hooks/useApp";
|
|
const StepTwo = defineComponent({
|
|
const StepTwo = defineComponent({
|
|
name: "StepTwo",
|
|
name: "StepTwo",
|
|
|
|
+ props: {
|
|
|
|
+ content: Object,
|
|
|
|
+ default() {
|
|
|
|
+ return {};
|
|
|
|
+ },
|
|
|
|
+ },
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
|
|
+ const { route, router } = useApp();
|
|
const state = reactive({
|
|
const state = reactive({
|
|
charptList: ref<Array<{ content: string; title: string }>>([
|
|
charptList: ref<Array<{ content: string; title: string }>>([
|
|
{
|
|
{
|
|
- title: "大苏打萨达速度阿萨德阿萨德阿士大夫撒方式打发的撒范德萨飞",
|
|
|
|
- content: "sadassssssssssssssssasdsaddasdas",
|
|
|
|
|
|
+ title: "",
|
|
|
|
+ content: "",
|
|
},
|
|
},
|
|
]),
|
|
]),
|
|
modelShow: false,
|
|
modelShow: false,
|
|
@@ -175,18 +188,39 @@ const StepTwo = defineComponent({
|
|
state.temItem = item;
|
|
state.temItem = item;
|
|
state.temChecked = idx;
|
|
state.temChecked = idx;
|
|
};
|
|
};
|
|
- onMounted(() => {
|
|
|
|
- getTemList();
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
//模板列表
|
|
//模板列表
|
|
const getTemList = () => {
|
|
const getTemList = () => {
|
|
getLandingTempalte().then((res: any) => {
|
|
getLandingTempalte().then((res: any) => {
|
|
state.templateList = res.data.list;
|
|
state.templateList = res.data.list;
|
|
|
|
+ if (props && (props as any).content && route.query && route.query.id) {
|
|
|
|
+ const {
|
|
|
|
+ content,
|
|
|
|
+ body_template_id,
|
|
|
|
+ head_img,
|
|
|
|
+ } = (props as any).content;
|
|
|
|
+ try {
|
|
|
|
+ state.charptList = JSON.parse(content);
|
|
|
|
+ state.chooseImgUrl = head_img;
|
|
|
|
+ state.selectImg = true;
|
|
|
|
+
|
|
|
|
+ state.templateChecked = state.templateList.findIndex(
|
|
|
|
+ (item) => item.id == body_template_id
|
|
|
|
+ );
|
|
|
|
+ console.log(state.templateChecked)
|
|
|
|
+ state.templateItemChecked =
|
|
|
|
+ state.templateList[state.templateChecked];
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
+
|
|
//选择正文模板
|
|
//选择正文模板
|
|
const chooseTemplate = (item: any, index: number) => {
|
|
const chooseTemplate = (item: any, index: number) => {
|
|
state.templateItemChecked = item;
|
|
state.templateItemChecked = item;
|
|
|
|
+ console.log(state.templateItemChecked);
|
|
state.templateChecked = index;
|
|
state.templateChecked = index;
|
|
};
|
|
};
|
|
//加载更多
|
|
//加载更多
|
|
@@ -212,6 +246,48 @@ const StepTwo = defineComponent({
|
|
state.selectImg = true;
|
|
state.selectImg = true;
|
|
state.modelShow = false;
|
|
state.modelShow = false;
|
|
};
|
|
};
|
|
|
|
+ //上一步
|
|
|
|
+ const goPrev = () => {
|
|
|
|
+ emit("prev");
|
|
|
|
+ };
|
|
|
|
+ //保存表单
|
|
|
|
+ const submitForm = () => {
|
|
|
|
+ let errors = 0;
|
|
|
|
+ let content: Array<any> = [];
|
|
|
|
+ state.charptList.map((r: any) => {
|
|
|
|
+ let item = {
|
|
|
|
+ title: r.title,
|
|
|
|
+ content: r.content,
|
|
|
|
+ };
|
|
|
|
+ if (!r.title || !r.content) {
|
|
|
|
+ message.error("标题或者内容不能为空");
|
|
|
|
+ errors++;
|
|
|
|
+ }
|
|
|
|
+ content.push(item);
|
|
|
|
+ return r;
|
|
|
|
+ });
|
|
|
|
+ if (!state.chooseImgUrl) {
|
|
|
|
+ message.error("头像不能为空");
|
|
|
|
+ errors++;
|
|
|
|
+ }
|
|
|
|
+ if (state.templateItemChecked && !state.templateItemChecked.id) {
|
|
|
|
+ message.error("模板不能为空");
|
|
|
|
+ errors++;
|
|
|
|
+ }
|
|
|
|
+ if (errors > 0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ const data = {
|
|
|
|
+ head_img: state.chooseImgUrl,
|
|
|
|
+ body_template_id: state.templateItemChecked.id,
|
|
|
|
+ content: JSON.stringify(content).replace(/[\\]/g, ""),
|
|
|
|
+ };
|
|
|
|
+ emit("next", data);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ onMounted(() => {
|
|
|
|
+ getTemList();
|
|
|
|
+ });
|
|
return {
|
|
return {
|
|
...toRefs(state),
|
|
...toRefs(state),
|
|
addNewCharpt,
|
|
addNewCharpt,
|
|
@@ -221,6 +297,8 @@ const StepTwo = defineComponent({
|
|
loadMore,
|
|
loadMore,
|
|
chooseImg,
|
|
chooseImg,
|
|
chooseTemplate,
|
|
chooseTemplate,
|
|
|
|
+ goPrev,
|
|
|
|
+ submitForm,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
});
|
|
});
|
|
@@ -228,6 +306,9 @@ const StepTwo = defineComponent({
|
|
export default StepTwo;
|
|
export default StepTwo;
|
|
</script>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
|
+.button-form {
|
|
|
|
+ margin-left: 120px;
|
|
|
|
+}
|
|
.loadmore-list {
|
|
.loadmore-list {
|
|
margin-top: 30px;
|
|
margin-top: 30px;
|
|
.img-item {
|
|
.img-item {
|
|
@@ -280,11 +361,11 @@ export default StepTwo;
|
|
width: 20px;
|
|
width: 20px;
|
|
height: 20px;
|
|
height: 20px;
|
|
z-index: 10;
|
|
z-index: 10;
|
|
- background-image: url('../../../../assets/checked.png');
|
|
|
|
|
|
+ background-image: url("../../../../assets/checked.png");
|
|
background-repeat: no-repeat;
|
|
background-repeat: no-repeat;
|
|
background-size: cover;
|
|
background-size: cover;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.choose-img {
|
|
.choose-img {
|