@longhongguo/form-create-ant-design-vue 3.3.11 → 3.3.13
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.
- package/dist/form-create.css +22 -0
- package/dist/form-create.esm.css +22 -0
- package/dist/form-create.esm.js +2 -2
- package/dist/form-create.esm.js.map +1 -1
- package/dist/form-create.js +2 -2
- package/dist/form-create.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FcEditorWrapper.vue +58 -1
- package/src/core/manager.js +2 -0
- package/src/parsers/accTable.js +122 -0
- package/src/style/index.css +22 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longhongguo/form-create-ant-design-vue",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.13",
|
|
4
4
|
"description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
|
|
5
5
|
"main": "./dist/form-create.min.js",
|
|
6
6
|
"module": "./dist/form-create.esm.js",
|
|
@@ -96,6 +96,8 @@ export default defineComponent({
|
|
|
96
96
|
config.autoFocus = false
|
|
97
97
|
// 只读模式下隐藏 placeholder
|
|
98
98
|
delete config.placeholder
|
|
99
|
+
// 只读模式下移除固定高度,使用自适应
|
|
100
|
+
delete config.height
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
// 如果设置了 uploadImgServer,配置图片上传
|
|
@@ -541,8 +543,16 @@ export default defineComponent({
|
|
|
541
543
|
}
|
|
542
544
|
|
|
543
545
|
this.$nextTick(() => {
|
|
546
|
+
// 查找编辑器的根元素
|
|
547
|
+
let editorRootElement = null
|
|
548
|
+
if (this._editor.id) {
|
|
549
|
+
editorRootElement = document.getElementById(this._editor.id)
|
|
550
|
+
}
|
|
551
|
+
|
|
544
552
|
// 查找编辑器的文本容器
|
|
545
553
|
let textContainer = null
|
|
554
|
+
let containerElement = null
|
|
555
|
+
|
|
546
556
|
if (this._editor.$textElem && this._editor.$textElem[0]) {
|
|
547
557
|
textContainer = this._editor.$textElem[0]
|
|
548
558
|
} else {
|
|
@@ -551,6 +561,7 @@ export default defineComponent({
|
|
|
551
561
|
const editorEl = document.getElementById(editorId)
|
|
552
562
|
if (editorEl) {
|
|
553
563
|
textContainer = editorEl.querySelector('.w-e-text')
|
|
564
|
+
containerElement = editorEl.querySelector('.w-e-text-container')
|
|
554
565
|
}
|
|
555
566
|
}
|
|
556
567
|
}
|
|
@@ -561,12 +572,43 @@ export default defineComponent({
|
|
|
561
572
|
this._editor.$textContainerElem &&
|
|
562
573
|
this._editor.$textContainerElem[0]
|
|
563
574
|
) {
|
|
564
|
-
|
|
575
|
+
containerElement = this._editor.$textContainerElem[0]
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// 查找容器元素(如果还没找到)
|
|
580
|
+
if (
|
|
581
|
+
!containerElement &&
|
|
582
|
+
this._editor.$textContainerElem &&
|
|
583
|
+
this._editor.$textContainerElem[0]
|
|
584
|
+
) {
|
|
585
|
+
containerElement = this._editor.$textContainerElem[0]
|
|
586
|
+
} else if (!containerElement && this._editor.id) {
|
|
587
|
+
const editorEl = document.getElementById(this._editor.id)
|
|
588
|
+
if (editorEl) {
|
|
589
|
+
containerElement = editorEl.querySelector('.w-e-text-container')
|
|
565
590
|
}
|
|
566
591
|
}
|
|
567
592
|
|
|
568
593
|
if (textContainer) {
|
|
569
594
|
if (readOnly) {
|
|
595
|
+
// 设置根元素为自适应高度(移除内联样式中的固定高度)
|
|
596
|
+
if (editorRootElement) {
|
|
597
|
+
editorRootElement.style.height = 'auto'
|
|
598
|
+
editorRootElement.style.minHeight = 'auto'
|
|
599
|
+
editorRootElement.style.maxHeight = 'none'
|
|
600
|
+
}
|
|
601
|
+
// 设置容器和文本区域为自适应高度
|
|
602
|
+
if (containerElement) {
|
|
603
|
+
containerElement.style.height = 'auto'
|
|
604
|
+
containerElement.style.minHeight = 'auto'
|
|
605
|
+
containerElement.style.maxHeight = 'none'
|
|
606
|
+
}
|
|
607
|
+
if (textContainer) {
|
|
608
|
+
textContainer.style.height = 'auto'
|
|
609
|
+
textContainer.style.minHeight = 'auto'
|
|
610
|
+
textContainer.style.maxHeight = 'none'
|
|
611
|
+
}
|
|
570
612
|
// 强制设置为只读:禁用编辑,但允许选择和点击链接
|
|
571
613
|
const forceReadOnly = () => {
|
|
572
614
|
// 强制设置 contenteditable
|
|
@@ -577,6 +619,21 @@ export default defineComponent({
|
|
|
577
619
|
textContainer.style.mozUserSelect = 'text'
|
|
578
620
|
textContainer.style.msUserSelect = 'text'
|
|
579
621
|
textContainer.style.cursor = 'text'
|
|
622
|
+
// 保持根元素自适应高度
|
|
623
|
+
if (editorRootElement) {
|
|
624
|
+
editorRootElement.style.height = 'auto'
|
|
625
|
+
editorRootElement.style.minHeight = 'auto'
|
|
626
|
+
editorRootElement.style.maxHeight = 'none'
|
|
627
|
+
}
|
|
628
|
+
// 保持容器和文本区域自适应高度
|
|
629
|
+
if (containerElement) {
|
|
630
|
+
containerElement.style.height = 'auto'
|
|
631
|
+
containerElement.style.minHeight = 'auto'
|
|
632
|
+
containerElement.style.maxHeight = 'none'
|
|
633
|
+
}
|
|
634
|
+
textContainer.style.height = 'auto'
|
|
635
|
+
textContainer.style.minHeight = 'auto'
|
|
636
|
+
textContainer.style.maxHeight = 'none'
|
|
580
637
|
}
|
|
581
638
|
|
|
582
639
|
forceReadOnly()
|
package/src/core/manager.js
CHANGED
package/src/parsers/accTable.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hasProperty } from '@form-create/utils/lib/type'
|
|
2
2
|
import { deepCopy } from '@form-create/utils/lib/deepextend'
|
|
3
|
+
import { h } from 'vue'
|
|
3
4
|
|
|
4
5
|
// 简单的 getValue 函数,根据路径字符串获取嵌套对象的值
|
|
5
6
|
function getValue(obj, path) {
|
|
@@ -165,6 +166,127 @@ export default {
|
|
|
165
166
|
// 如果已经是数字,直接使用
|
|
166
167
|
}
|
|
167
168
|
|
|
169
|
+
// 处理单元格表单组件
|
|
170
|
+
if (
|
|
171
|
+
column.cellType &&
|
|
172
|
+
['input', 'select', 'radio'].includes(column.cellType)
|
|
173
|
+
) {
|
|
174
|
+
const cellType = column.cellType
|
|
175
|
+
const dataIndex = column.dataIndex
|
|
176
|
+
// 确保 cellOptions 是数组
|
|
177
|
+
let cellOptions = column.cellOptions
|
|
178
|
+
if (!Array.isArray(cellOptions)) {
|
|
179
|
+
cellOptions = []
|
|
180
|
+
}
|
|
181
|
+
const cellProps = column.cellProps || {}
|
|
182
|
+
|
|
183
|
+
// 创建 customRender 函数
|
|
184
|
+
column.customRender = ({ text, record, index }) => {
|
|
185
|
+
const cellValue = record && dataIndex ? record[dataIndex] : text
|
|
186
|
+
// 在 render 函数内部再次确保 cellOptions 是数组(因为可能在外部被修改)
|
|
187
|
+
const options = Array.isArray(column.cellOptions)
|
|
188
|
+
? column.cellOptions
|
|
189
|
+
: []
|
|
190
|
+
|
|
191
|
+
if (cellType === 'input') {
|
|
192
|
+
// 渲染 input 组件 - 使用组件名字符串
|
|
193
|
+
return h('a-input', {
|
|
194
|
+
value: cellValue,
|
|
195
|
+
onChange: (e) => {
|
|
196
|
+
const val =
|
|
197
|
+
e.target?.value !== undefined
|
|
198
|
+
? e.target.value
|
|
199
|
+
: e?.target?.inputValue !== undefined
|
|
200
|
+
? e.target.inputValue
|
|
201
|
+
: e
|
|
202
|
+
if (record && dataIndex) {
|
|
203
|
+
record[dataIndex] = val
|
|
204
|
+
// 触发表格数据更新
|
|
205
|
+
if (ctx.api && ctx.api.form && rule.field) {
|
|
206
|
+
ctx.api.form[rule.field] = props.dataSource
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
placeholder: cellProps.placeholder || '',
|
|
211
|
+
disabled: cellProps.disabled || false,
|
|
212
|
+
size: cellProps.size || 'small',
|
|
213
|
+
...cellProps
|
|
214
|
+
})
|
|
215
|
+
} else if (cellType === 'select') {
|
|
216
|
+
// 渲染 select 组件 - 使用组件名字符串
|
|
217
|
+
return h(
|
|
218
|
+
'a-select',
|
|
219
|
+
{
|
|
220
|
+
value: cellValue,
|
|
221
|
+
onChange: (val) => {
|
|
222
|
+
if (record && dataIndex) {
|
|
223
|
+
record[dataIndex] = val
|
|
224
|
+
// 触发表格数据更新
|
|
225
|
+
if (ctx.api && ctx.api.form && rule.field) {
|
|
226
|
+
ctx.api.form[rule.field] = props.dataSource
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
placeholder: cellProps.placeholder || '',
|
|
231
|
+
disabled: cellProps.disabled || false,
|
|
232
|
+
size: cellProps.size || 'small',
|
|
233
|
+
...cellProps
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
default: () =>
|
|
237
|
+
options.map((opt) => {
|
|
238
|
+
return h('a-select-option', {
|
|
239
|
+
key: opt.value,
|
|
240
|
+
value: opt.value,
|
|
241
|
+
label: opt.label
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
} else if (cellType === 'radio') {
|
|
247
|
+
// 渲染 radio 组件 - 使用组件名字符串
|
|
248
|
+
return h(
|
|
249
|
+
'a-radio-group',
|
|
250
|
+
{
|
|
251
|
+
value: cellValue,
|
|
252
|
+
onChange: (e) => {
|
|
253
|
+
const val =
|
|
254
|
+
e.target?.value !== undefined ? e.target.value : e
|
|
255
|
+
if (record && dataIndex) {
|
|
256
|
+
record[dataIndex] = val
|
|
257
|
+
// 触发表格数据更新
|
|
258
|
+
if (ctx.api && ctx.api.form && rule.field) {
|
|
259
|
+
ctx.api.form[rule.field] = props.dataSource
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
disabled: cellProps.disabled || false,
|
|
264
|
+
size: cellProps.size || 'small',
|
|
265
|
+
...cellProps
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
default: () =>
|
|
269
|
+
options.map((opt) => {
|
|
270
|
+
return h(
|
|
271
|
+
'a-radio',
|
|
272
|
+
{
|
|
273
|
+
key: opt.value,
|
|
274
|
+
value: opt.value
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
default: () => opt.label || opt.value
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
})
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// 如果没有匹配的类型,返回原始文本
|
|
286
|
+
return text
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
168
290
|
// 确保其他列属性也被保留(align、fixed、title、dataIndex 等)
|
|
169
291
|
return column
|
|
170
292
|
})
|
package/src/style/index.css
CHANGED
|
@@ -420,6 +420,28 @@ textarea[readonly].ant-input {
|
|
|
420
420
|
max-height: none !important;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
/* 只读模式:富文本编辑器样式(通过 contenteditable="false" 识别) */
|
|
424
|
+
.w-e-text[contenteditable='false'] {
|
|
425
|
+
border: none !important;
|
|
426
|
+
box-shadow: none !important;
|
|
427
|
+
background: transparent !important;
|
|
428
|
+
/* 移除高度限制,让内容自适应 */
|
|
429
|
+
height: auto !important;
|
|
430
|
+
min-height: auto !important;
|
|
431
|
+
max-height: none !important;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/* 预览模式:编辑器根元素自适应高度 */
|
|
435
|
+
.form-create.is-preview div[id^='editor'][readonly='true'],
|
|
436
|
+
.form-create.is-preview div[id^='editor'][readonly] {
|
|
437
|
+
height: auto !important;
|
|
438
|
+
min-height: auto !important;
|
|
439
|
+
max-height: none !important;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* 只读模式下,通过 JavaScript 设置容器自适应高度 */
|
|
443
|
+
/* 容器样式会在 setReadOnlyMode 中通过 JavaScript 动态设置 */
|
|
444
|
+
|
|
423
445
|
/* 富文本内容只读:允许选择文本和点击链接,但禁止编辑 */
|
|
424
446
|
.form-create.is-preview .w-e-text p,
|
|
425
447
|
.form-create.is-preview .w-e-text div,
|