p-pc-ui 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,7 @@ interface Base<K extends string = string> {
|
|
|
15
15
|
labelSpan?: number,
|
|
16
16
|
valueSpan?: number,
|
|
17
17
|
labelAlign?: 'left' | 'right',
|
|
18
|
-
disabled
|
|
18
|
+
disabled: ?boolean
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
|
|
@@ -106,12 +106,6 @@ export interface Component<K extends string = string> extends Base<K> {
|
|
|
106
106
|
component: any
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export interface Editor<K extends string = string> extends Base<K> {
|
|
110
|
-
type: 'editor',
|
|
111
|
-
getOssToken: ({ file_name: string }) => Promise<any>,
|
|
112
|
-
baseOssUrl?: string,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
109
|
|
|
116
110
|
export type FormDataItem<K extends string = string> =
|
|
117
111
|
| Input<K>
|
|
@@ -125,4 +119,3 @@ export type FormDataItem<K extends string = string> =
|
|
|
125
119
|
| Textarea<K>
|
|
126
120
|
| DatePicker<K>
|
|
127
121
|
| Component<K>
|
|
128
|
-
| Editor<K>
|
|
@@ -23,8 +23,6 @@ import * as _ from "../../utils/dataUtils";
|
|
|
23
23
|
import { api as viewerApi } from "v-viewer";
|
|
24
24
|
import dayjs from "dayjs";
|
|
25
25
|
import { UploadOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
|
26
|
-
import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
|
|
27
|
-
import "@wangeditor/editor/dist/css/style.css"; // 引入 css
|
|
28
26
|
|
|
29
27
|
const uSlots = useSlots();
|
|
30
28
|
|
|
@@ -63,8 +61,6 @@ const emits = defineEmits(["confirm"]);
|
|
|
63
61
|
/**
|
|
64
62
|
* 富文本相关配置
|
|
65
63
|
*/
|
|
66
|
-
const editorRef = shallowRef();
|
|
67
|
-
|
|
68
64
|
onBeforeMount(async () => {
|
|
69
65
|
renderData.value = await disposeRenderData(props.renderData);
|
|
70
66
|
const _formState = initFormState(renderData.value, props.initForm);
|
|
@@ -245,8 +241,6 @@ const initFormState = (renderData: FormDataItem[], initFromData = {}) => {
|
|
|
245
241
|
url: renderItem.baseTosUrl + val,
|
|
246
242
|
};
|
|
247
243
|
});
|
|
248
|
-
} else if (renderItem.type == "editor") {
|
|
249
|
-
initValue = initValue.replace(/\<\<图片替换地址\>\>/g, renderItem.baseOssUrl);
|
|
250
244
|
}
|
|
251
245
|
|
|
252
246
|
_formState[renderItem["key"]] = initValue;
|
|
@@ -304,20 +298,6 @@ const getFormData = async (options: { no_check?: Boolean } = {}) => {
|
|
|
304
298
|
returnFormData[key] = formatData;
|
|
305
299
|
}
|
|
306
300
|
|
|
307
|
-
// 处理富文本字段
|
|
308
|
-
else if (renderItem.type == "editor") {
|
|
309
|
-
const richText = formData[key];
|
|
310
|
-
const dom = new DOMParser().parseFromString(richText, "text/html");
|
|
311
|
-
// 将视频居中展示
|
|
312
|
-
const videos = dom.querySelectorAll('[data-w-e-type="video"]') || [];
|
|
313
|
-
//@ts-ignore
|
|
314
|
-
for (const video of videos) {
|
|
315
|
-
//@ts-ignore
|
|
316
|
-
video.style.textAlign = "center";
|
|
317
|
-
}
|
|
318
|
-
returnFormData[key] = replaceUrl(dom.body.innerHTML, renderItem.baseOssUrl, "<<图片替换地址>>");
|
|
319
|
-
}
|
|
320
|
-
|
|
321
301
|
// 转换成上传对象
|
|
322
302
|
else if (key.includes("__")) {
|
|
323
303
|
_.set(returnFormData, key.split("__"), formData[key]);
|
|
@@ -421,15 +401,6 @@ const uploadRequest = async (options, renderItem: FormDataItem) => {
|
|
|
421
401
|
}
|
|
422
402
|
};
|
|
423
403
|
|
|
424
|
-
/**
|
|
425
|
-
* 富文本上传
|
|
426
|
-
*/
|
|
427
|
-
const editorUpload = async (renderItem, file, insertFn) => {
|
|
428
|
-
const config: any = await renderItem.getOssToken({ type: renderItem.ossKey, file_name: file.name });
|
|
429
|
-
const key = await uploadOss(file, config);
|
|
430
|
-
insertFn(renderItem.baseOssUrl + key);
|
|
431
|
-
};
|
|
432
|
-
|
|
433
404
|
/**
|
|
434
405
|
* 发送验证码
|
|
435
406
|
*/
|
|
@@ -455,10 +426,6 @@ const sendNoticeClick = async (renderItem) => {
|
|
|
455
426
|
renderItem.interval = copyInterval;
|
|
456
427
|
};
|
|
457
428
|
|
|
458
|
-
const handleRichEditorCreated = (editor) => {
|
|
459
|
-
editorRef.value = editor;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
429
|
defineExpose({
|
|
463
430
|
getFormData,
|
|
464
431
|
resetForm,
|
|
@@ -642,38 +609,6 @@ defineExpose({
|
|
|
642
609
|
</div>
|
|
643
610
|
</a-upload>
|
|
644
611
|
|
|
645
|
-
<div style="border: 1px solid #ccc" v-if="renderItem.type == 'editor'">
|
|
646
|
-
<Toolbar
|
|
647
|
-
style="border-bottom: 1px solid #ccc"
|
|
648
|
-
:editor="editorRef"
|
|
649
|
-
:defaultConfig="{
|
|
650
|
-
excludeKeys: ['insertVideo', 'insertImage', 'codeBlock'],
|
|
651
|
-
}"
|
|
652
|
-
mode="default"
|
|
653
|
-
/>
|
|
654
|
-
<Editor
|
|
655
|
-
style="height: 500px; overflow-y: hidden"
|
|
656
|
-
v-model="formState[renderItem.key]"
|
|
657
|
-
:defaultConfig="{
|
|
658
|
-
placeholder: '请输入内容...',
|
|
659
|
-
MENU_CONF: {
|
|
660
|
-
uploadImage: {
|
|
661
|
-
customUpload: async (file, insertFn) => {
|
|
662
|
-
await editorUpload(renderItem, file, insertFn);
|
|
663
|
-
},
|
|
664
|
-
},
|
|
665
|
-
uploadVideo: {
|
|
666
|
-
customUpload: async (file, insertFn) => {
|
|
667
|
-
await editorUpload(renderItem, file, insertFn);
|
|
668
|
-
},
|
|
669
|
-
},
|
|
670
|
-
},
|
|
671
|
-
}"
|
|
672
|
-
mode="default"
|
|
673
|
-
@onCreated="handleRichEditorCreated"
|
|
674
|
-
/>
|
|
675
|
-
</div>
|
|
676
|
-
|
|
677
612
|
<component v-if="renderItem.type == 'component'" :is="renderItem.component"></component>
|
|
678
613
|
</div>
|
|
679
614
|
</a-form-item>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { ref,
|
|
2
|
+
import { ref, computed } from 'vue'
|
|
3
3
|
import { Modal as AModal, Button as AButton } from 'ant-design-vue'
|
|
4
4
|
|
|
5
5
|
const {
|
|
@@ -34,7 +34,6 @@ const confirmClick = async () => {
|
|
|
34
34
|
loading.value = true
|
|
35
35
|
try {
|
|
36
36
|
confirm && (await confirm())
|
|
37
|
-
// 同时兼容多种回调方式
|
|
38
37
|
emits('confirm')
|
|
39
38
|
} catch (err) {
|
|
40
39
|
} finally {
|
|
@@ -47,48 +46,85 @@ const confirmClick = async () => {
|
|
|
47
46
|
<template>
|
|
48
47
|
<a-modal v-model:visible="show" :width="width" centered wrapClassName="p-modal">
|
|
49
48
|
<template #title v-if="title">
|
|
50
|
-
<div class="
|
|
49
|
+
<div class="modal-title">
|
|
51
50
|
{{ title }}
|
|
52
51
|
</div>
|
|
53
52
|
</template>
|
|
54
|
-
<div class="border-t border-[#cecece] p-[20px] pb-[0px] text-[16px] text-[#272727]">
|
|
55
|
-
<div v-html="content"></div>
|
|
56
53
|
|
|
54
|
+
<div class="modal-content">
|
|
55
|
+
<div v-html="content"></div>
|
|
57
56
|
</div>
|
|
58
57
|
|
|
59
58
|
<template #footer>
|
|
60
|
-
<div class="
|
|
59
|
+
<div class="modal-footer">
|
|
61
60
|
<a-button
|
|
62
|
-
class="
|
|
63
|
-
style="border: 1px solid #272727"
|
|
61
|
+
class="modal-btn modal-cancel-btn"
|
|
64
62
|
@click="show = false"
|
|
65
|
-
>取消</a-button
|
|
66
63
|
>
|
|
64
|
+
取消
|
|
65
|
+
</a-button>
|
|
67
66
|
|
|
68
67
|
<a-button
|
|
69
|
-
class="
|
|
68
|
+
class="modal-btn modal-confirm-btn"
|
|
70
69
|
:style="{
|
|
71
70
|
border: 'none',
|
|
72
71
|
backgroundColor: confrimBtnBgColor,
|
|
73
72
|
}"
|
|
74
73
|
@click="confirmClick"
|
|
75
74
|
:loading="loading"
|
|
76
|
-
>确定</a-button
|
|
77
75
|
>
|
|
76
|
+
确定
|
|
77
|
+
</a-button>
|
|
78
78
|
</div>
|
|
79
79
|
</template>
|
|
80
80
|
</a-modal>
|
|
81
81
|
</template>
|
|
82
82
|
|
|
83
|
-
<style
|
|
84
|
-
.p-modal {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
<style>
|
|
84
|
+
.p-modal .ant-modal {
|
|
85
|
+
border-radius: 16px !important;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.p-modal .ant-modal-content {
|
|
90
|
+
padding: 0 !important;
|
|
91
|
+
border-radius: 16px !important;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.modal-title {
|
|
95
|
+
padding: 20px;
|
|
96
|
+
font-size: 18px;
|
|
97
|
+
font-weight: 700;
|
|
98
|
+
line-height: 27px;
|
|
99
|
+
color: #272727;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.modal-content {
|
|
103
|
+
border-top: 1px solid #cecece;
|
|
104
|
+
padding: 20px;
|
|
105
|
+
padding-bottom: 0;
|
|
106
|
+
font-size: 16px;
|
|
107
|
+
color: #272727;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.modal-footer {
|
|
111
|
+
display: flex;
|
|
112
|
+
justify-content: flex-end;
|
|
113
|
+
padding: 20px;
|
|
114
|
+
gap: 8px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.modal-btn {
|
|
118
|
+
width: 76px;
|
|
119
|
+
height: 38px;
|
|
120
|
+
border-radius: 100px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.modal-cancel-btn {
|
|
124
|
+
border: 1px solid #272727;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.modal-confirm-btn {
|
|
128
|
+
color: #fff !important;
|
|
93
129
|
}
|
|
94
130
|
</style>
|