gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<script setup lang="ts">
import type { MallDiyPageApi } from '#/api/mall/promotion/diy/page';
 
import { onMounted, ref, unref } from 'vue';
import { useRoute } from 'vue-router';
 
import { message } from 'ant-design-vue';
 
import {
  getDiyPageProperty,
  updateDiyPageProperty,
} from '#/api/mall/promotion/diy/page';
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
 
/** 装修页面表单 */
defineOptions({ name: 'DiyPageDecorate' });
 
const route = useRoute();
 
const formData = ref<MallDiyPageApi.DiyPage>();
 
/** 获取详情 */
async function getPageDetail(id: any) {
  const hideLoading = message.loading({
    content: '加载中...',
    duration: 0,
  });
  try {
    formData.value = await getDiyPageProperty(id);
  } finally {
    hideLoading();
  }
}
 
/** 提交表单 */
async function submitForm() {
  const hideLoading = message.loading({
    content: '保存中...',
    duration: 0,
  });
  try {
    await updateDiyPageProperty(unref(formData)!);
    message.success('保存成功');
  } finally {
    hideLoading();
  }
}
 
/** 初始化 */
onMounted(() => {
  if (!route.params.id) {
    message.warning('参数错误,页面编号不能为空!');
    return;
  }
  formData.value = {} as MallDiyPageApi.DiyPage;
  getPageDetail(route.params.id);
});
</script>
<template>
  <DiyEditor
    v-if="formData?.id"
    v-model="formData!.property"
    :title="formData!.name"
    :libs="PAGE_LIBS"
    @save="submitForm"
  />
</template>