style: 修改样式
This commit is contained in:
parent
26dc886f8c
commit
207c5b3fc4
|
@ -99,7 +99,6 @@ const handleChange = (editor: IDomEditor) => {
|
||||||
// 组件销毁时,及时销毁编辑器
|
// 组件销毁时,及时销毁编辑器
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
const editor = unref(editorRef.value)
|
const editor = unref(editorRef.value)
|
||||||
if (editor === null) return
|
|
||||||
|
|
||||||
// 销毁,并移除 editor
|
// 销毁,并移除 editor
|
||||||
editor?.destroy()
|
editor?.destroy()
|
||||||
|
@ -121,7 +120,7 @@ defineExpose({
|
||||||
<Toolbar
|
<Toolbar
|
||||||
:editor="editorRef"
|
:editor="editorRef"
|
||||||
:editorId="editorId"
|
:editorId="editorId"
|
||||||
class="b-b-1 border-solid border-[var(--tags-view-border-color)]"
|
class="border-0 b-b-1 border-solid border-[var(--tags-view-border-color)]"
|
||||||
/>
|
/>
|
||||||
<!-- 编辑器 -->
|
<!-- 编辑器 -->
|
||||||
<Editor
|
<Editor
|
||||||
|
|
|
@ -182,41 +182,7 @@ export default defineComponent({
|
||||||
|
|
||||||
// 渲染formItem
|
// 渲染formItem
|
||||||
const renderFormItem = (item: FormSchema) => {
|
const renderFormItem = (item: FormSchema) => {
|
||||||
// 单独给只有options属性的组件做判断
|
const formItemSlots: Recordable = setFormItemSlots(slots, item.field)
|
||||||
// const notRenderOptions = ['SelectV2', 'Cascader', 'Transfer']
|
|
||||||
|
|
||||||
// if (
|
|
||||||
// item?.component !== 'SelectV2' &&
|
|
||||||
// item?.component !== 'Cascader' &&
|
|
||||||
// item?.componentProps?.options
|
|
||||||
// ) {
|
|
||||||
// slotsMap.default = () => renderOptions(item)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const formItemSlots: Recordable = setFormItemSlots(slots, item.field)
|
|
||||||
// 如果有 labelMessage,自动使用插槽渲染
|
|
||||||
// if (item?.labelMessage) {
|
|
||||||
// formItemSlots.label = () => {
|
|
||||||
// return (
|
|
||||||
// <>
|
|
||||||
// <span>{item.label}</span>
|
|
||||||
// <ElTooltip placement="right" raw-content>
|
|
||||||
// {{
|
|
||||||
// content: () => <span v-html={item.labelMessage}></span>,
|
|
||||||
// default: () => (
|
|
||||||
// <Icon
|
|
||||||
// icon="ep:warning"
|
|
||||||
// size={16}
|
|
||||||
// color="var(--el-color-primary)"
|
|
||||||
// class="ml-2px relative top-1px"
|
|
||||||
// ></Icon>
|
|
||||||
// )
|
|
||||||
// }}
|
|
||||||
// </ElTooltip>
|
|
||||||
// </>
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return (
|
return (
|
||||||
<ElFormItem {...(item.formItemProps || {})} prop={item.field} label={item.label || ''}>
|
<ElFormItem {...(item.formItemProps || {})} prop={item.field} label={item.label || ''}>
|
||||||
{{
|
{{
|
||||||
|
@ -291,7 +257,8 @@ export default defineComponent({
|
||||||
</Com>
|
</Com>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
...formItemSlots
|
||||||
}}
|
}}
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
)
|
)
|
||||||
|
|
|
@ -86,7 +86,7 @@ export const setGridProp = (col: ColProps = {}): ColProps => {
|
||||||
export const setComponentProps = (item: FormSchema): Recordable => {
|
export const setComponentProps = (item: FormSchema): Recordable => {
|
||||||
// const notNeedClearable = ['ColorPicker']
|
// const notNeedClearable = ['ColorPicker']
|
||||||
// 拆分事件并组合
|
// 拆分事件并组合
|
||||||
const onEvents = item?.componentProps?.on || {}
|
const onEvents = (item?.componentProps as any)?.on || {}
|
||||||
const newOnEvents: Recordable = {}
|
const newOnEvents: Recordable = {}
|
||||||
|
|
||||||
for (const key in onEvents) {
|
for (const key in onEvents) {
|
||||||
|
@ -165,13 +165,13 @@ export const initModel = (schema: FormSchema[], formModel: Recordable) => {
|
||||||
export const setFormItemSlots = (slots: Slots, field: string): Recordable => {
|
export const setFormItemSlots = (slots: Slots, field: string): Recordable => {
|
||||||
const slotObj: Recordable = {}
|
const slotObj: Recordable = {}
|
||||||
if (slots[`${field}-error`]) {
|
if (slots[`${field}-error`]) {
|
||||||
slotObj['error'] = (data: Recordable) => {
|
slotObj['error'] = (...args: any[]) => {
|
||||||
return getSlot(slots, `${field}-error`, data)
|
return getSlot(slots, `${field}-error`, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slots[`${field}-label`]) {
|
if (slots[`${field}-label`]) {
|
||||||
slotObj['label'] = (data: Recordable) => {
|
slotObj['label'] = (...args: any[]) => {
|
||||||
return getSlot(slots, `${field}-label`, data)
|
return getSlot(slots, `${field}-label`, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return slotObj
|
return slotObj
|
||||||
|
|
|
@ -5,9 +5,11 @@ import {
|
||||||
InputNumberProps,
|
InputNumberProps,
|
||||||
CascaderProps,
|
CascaderProps,
|
||||||
CascaderNode,
|
CascaderNode,
|
||||||
CascaderValue
|
CascaderValue,
|
||||||
|
FormItemRule
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import type { AxiosPromise } from 'axios'
|
import type { AxiosPromise } from 'axios'
|
||||||
|
import { IEditorConfig } from '@wangeditor/editor'
|
||||||
|
|
||||||
export interface PlaceholderModel {
|
export interface PlaceholderModel {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
|
@ -731,6 +733,11 @@ export interface TimeSelectComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface EditorComponentProps {
|
||||||
|
editorConfig?: IEditorConfig
|
||||||
|
style?: CSSProperties
|
||||||
|
}
|
||||||
|
|
||||||
export interface ColProps {
|
export interface ColProps {
|
||||||
span?: number
|
span?: number
|
||||||
xs?: number
|
xs?: number
|
||||||
|
@ -752,10 +759,13 @@ export type FormValueType = string | number | string[] | number[] | boolean | un
|
||||||
export interface FormItemProps {
|
export interface FormItemProps {
|
||||||
labelWidth?: string | number
|
labelWidth?: string | number
|
||||||
required?: boolean
|
required?: boolean
|
||||||
rules?: Recordable
|
rules?: FormItemRule | FormItemRule[]
|
||||||
error?: string
|
error?: string
|
||||||
showMessage?: boolean
|
showMessage?: boolean
|
||||||
inlineMessage?: boolean
|
inlineMessage?: boolean
|
||||||
|
size?: ElementPlusSize
|
||||||
|
for?: string
|
||||||
|
validateStatus?: '' | 'error' | 'validating' | 'success'
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,6 +810,7 @@ export interface FormSchema {
|
||||||
| DatePickerComponentProps
|
| DatePickerComponentProps
|
||||||
| DateTimePickerComponentProps
|
| DateTimePickerComponentProps
|
||||||
| TimePickerComponentProps
|
| TimePickerComponentProps
|
||||||
|
| EditorComponentProps
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formItem组件属性,具体可以查看element-plus文档
|
* formItem组件属性,具体可以查看element-plus文档
|
||||||
|
|
|
@ -53,19 +53,11 @@ const getPasswordStrength = computed(() => {
|
||||||
const zxcvbnRef = zxcvbn(unref(valueRef)) as ZxcvbnResult
|
const zxcvbnRef = zxcvbn(unref(valueRef)) as ZxcvbnResult
|
||||||
return value ? zxcvbnRef.score : -1
|
return value ? zxcvbnRef.score : -1
|
||||||
})
|
})
|
||||||
|
|
||||||
const getIconName = computed(() =>
|
|
||||||
unref(textType) === 'password' ? 'ant-design:eye-invisible-outlined' : 'ant-design:eye-outlined'
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="[prefixCls, `${prefixCls}--${configGlobal?.size}`]">
|
<div :class="[prefixCls, `${prefixCls}--${configGlobal?.size}`]">
|
||||||
<ElInput v-bind="$attrs" v-model="valueRef" :type="textType">
|
<ElInput v-bind="$attrs" v-model="valueRef" showPassword :type="textType" />
|
||||||
<template #suffix>
|
|
||||||
<Icon class="el-input__icon cursor-pointer" :icon="getIconName" @click="changeTextType" />
|
|
||||||
</template>
|
|
||||||
</ElInput>
|
|
||||||
<div
|
<div
|
||||||
v-if="strength"
|
v-if="strength"
|
||||||
:class="`${prefixCls}__bar`"
|
:class="`${prefixCls}__bar`"
|
||||||
|
|
|
@ -280,7 +280,10 @@ export default {
|
||||||
set: 'Set',
|
set: 'Set',
|
||||||
subitem: 'Subitem',
|
subitem: 'Subitem',
|
||||||
formValidation: 'Form validation',
|
formValidation: 'Form validation',
|
||||||
verifyReset: 'Verify reset'
|
verifyReset: 'Verify reset',
|
||||||
|
// 富文本编辑器
|
||||||
|
richText: 'Rich text',
|
||||||
|
form: 'Form'
|
||||||
},
|
},
|
||||||
guideDemo: {
|
guideDemo: {
|
||||||
guide: 'Guide',
|
guide: 'Guide',
|
||||||
|
|
|
@ -279,7 +279,10 @@ export default {
|
||||||
set: '设置',
|
set: '设置',
|
||||||
subitem: '子项',
|
subitem: '子项',
|
||||||
formValidation: '表单验证',
|
formValidation: '表单验证',
|
||||||
verifyReset: '验证重置'
|
verifyReset: '验证重置',
|
||||||
|
// 富文本编辑器
|
||||||
|
richText: '富文本编辑器',
|
||||||
|
form: '表单'
|
||||||
},
|
},
|
||||||
guideDemo: {
|
guideDemo: {
|
||||||
guide: '引导页',
|
guide: '引导页',
|
||||||
|
|
|
@ -166,7 +166,7 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
// {
|
// {
|
||||||
// path: 'table',
|
// path: 'table',
|
||||||
// component: getParentLayout(),
|
// component: getParentLayout(),
|
||||||
|
@ -203,26 +203,26 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// },
|
// },
|
||||||
// {
|
{
|
||||||
// path: 'editor-demo',
|
path: 'editor-demo',
|
||||||
// component: getParentLayout(),
|
component: getParentLayout(),
|
||||||
// redirect: '/components/editor-demo/editor',
|
redirect: '/components/editor-demo/editor',
|
||||||
// name: 'EditorDemo',
|
name: 'EditorDemo',
|
||||||
// meta: {
|
meta: {
|
||||||
// title: t('router.editor'),
|
title: t('router.editor'),
|
||||||
// alwaysShow: true
|
alwaysShow: true
|
||||||
// },
|
},
|
||||||
// children: [
|
children: [
|
||||||
// {
|
{
|
||||||
// path: 'editor',
|
path: 'editor',
|
||||||
// component: () => import('@/views/Components/Editor/Editor.vue'),
|
component: () => import('@/views/Components/Editor/Editor.vue'),
|
||||||
// name: 'Editor',
|
name: 'Editor',
|
||||||
// meta: {
|
meta: {
|
||||||
// title: t('router.richText')
|
title: t('router.richText')
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// ]
|
]
|
||||||
// },
|
}
|
||||||
// {
|
// {
|
||||||
// path: 'search',
|
// path: 'search',
|
||||||
// component: () => import('@/views/Components/Search.vue'),
|
// component: () => import('@/views/Components/Search.vue'),
|
||||||
|
|
|
@ -1343,7 +1343,50 @@ const schema = reactive<FormSchema[]>([
|
||||||
field: 'field63',
|
field: 'field63',
|
||||||
component: 'TimeSelect',
|
component: 'TimeSelect',
|
||||||
label: t('formDemo.default')
|
label: t('formDemo.default')
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
field: 'field64',
|
||||||
|
component: 'Divider',
|
||||||
|
label: t('formDemo.richText')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field65',
|
||||||
|
component: 'Editor',
|
||||||
|
value: 'hello world',
|
||||||
|
label: t('formDemo.default'),
|
||||||
|
componentProps: {
|
||||||
|
editorConfig: {
|
||||||
|
placeholder: '请输入内容...'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colProps: {
|
||||||
|
span: 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field66',
|
||||||
|
component: 'Divider',
|
||||||
|
label: t('formDemo.inputPassword')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field67',
|
||||||
|
component: 'InputPassword',
|
||||||
|
label: t('formDemo.default'),
|
||||||
|
componentProps: {
|
||||||
|
strength: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field68',
|
||||||
|
component: 'Divider',
|
||||||
|
label: `${t('formDemo.form')} t('formDemo.slot')}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field69',
|
||||||
|
component: 'Input',
|
||||||
|
value: 'test',
|
||||||
|
label: `default`,
|
||||||
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
const { register, formRef, methods } = useForm({
|
const { register, formRef, methods } = useForm({
|
||||||
|
@ -1360,68 +1403,8 @@ const changeToggle = () => {
|
||||||
<template>
|
<template>
|
||||||
<button @click="changeToggle">测试</button>
|
<button @click="changeToggle">测试</button>
|
||||||
<ContentWrap :title="t('formDemo.defaultForm')" :message="t('formDemo.formDes')">
|
<ContentWrap :title="t('formDemo.defaultForm')" :message="t('formDemo.formDes')">
|
||||||
<!-- <Form :schema="schema" label-width="auto" :label-position="isMobile ? 'top' : 'right'">
|
<Form @register="register" label-width="auto" :label-position="isMobile ? 'top' : 'right'">
|
||||||
<template #field4-prefix>
|
</Form>
|
||||||
<Icon icon="ep:calendar" class="el-input__icon" />
|
|
||||||
</template>
|
|
||||||
<template #field4-suffix>
|
|
||||||
<Icon icon="ep:calendar" class="el-input__icon" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field5-prepend> Http:// </template>
|
|
||||||
<template #field5-append> .com </template>
|
|
||||||
|
|
||||||
<template #field9-default="{ item }">
|
|
||||||
<div class="value">{{ item.value }}</div>
|
|
||||||
<span class="link">{{ item.link }}</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field15-option="{ item }">
|
|
||||||
<span style="float: left">{{ item.label }}</span>
|
|
||||||
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
|
|
||||||
{{ item.value }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field17-option="{ item }">
|
|
||||||
<span style="float: left">{{ item.label }}</span>
|
|
||||||
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
|
|
||||||
{{ item.value }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field20-default="{ item }">
|
|
||||||
<span style="float: left">{{ item.label }}</span>
|
|
||||||
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
|
|
||||||
{{ item.value }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field22-default="{ item }">
|
|
||||||
<span style="float: left">{{ item.label }}</span>
|
|
||||||
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
|
|
||||||
{{ item.value }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field25-default="{ node, data }">
|
|
||||||
<span>{{ data.label }}</span>
|
|
||||||
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field36-default="{ option }">
|
|
||||||
<span>{{ option.value }} - {{ option.desc }}</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #field55-default="cell">
|
|
||||||
<div class="cell" :class="{ current: cell.isCurrent }">
|
|
||||||
<span class="text">{{ cell.text }}</span>
|
|
||||||
<span v-if="isHoliday(cell)" class="holiday"></span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</Form> -->
|
|
||||||
|
|
||||||
<Form @register="register" />
|
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import { SlateDescendant } from '@wangeditor/editor'
|
|
||||||
|
|
||||||
declare module 'slate' {
|
|
||||||
interface CustomTypes {
|
|
||||||
// 扩展 text
|
|
||||||
Text: {
|
|
||||||
text: string
|
|
||||||
bold?: boolean
|
|
||||||
italic?: boolean
|
|
||||||
code?: boolean
|
|
||||||
through?: boolean
|
|
||||||
underline?: boolean
|
|
||||||
sup?: boolean
|
|
||||||
sub?: boolean
|
|
||||||
color?: string
|
|
||||||
bgColor?: string
|
|
||||||
fontSize?: string
|
|
||||||
fontFamily?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// 扩展 Element 的 type 属性
|
|
||||||
Element: {
|
|
||||||
type: string
|
|
||||||
children: SlateDescendant[]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue