feat:add checkbox control menu

This commit is contained in:
Hufe921
2022-04-15 21:45:19 +08:00
parent 1315ce070b
commit 440db738cb
5 changed files with 40 additions and 6 deletions
+1
View File
@@ -274,6 +274,7 @@ export class Control {
const elementList = this.getElementList()
const startElement = elementList[startIndex]
const control = startElement.control!
if (!control.placeholder) return
const placeholderStrList = control.placeholder.split('')
for (let p = 0; p < placeholderStrList.length; p++) {
const value = placeholderStrList[p]
+1 -1
View File
@@ -23,7 +23,7 @@ export interface IControlCheckbox {
export interface IControlBasic {
type: ControlType;
value: IElement[] | null;
placeholder: string;
placeholder?: string;
conceptId?: string;
prefix?: string;
postfix?: string;
+1 -1
View File
@@ -162,7 +162,7 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme
}
}
}
} else {
} else if (placeholder) {
// placeholder
const thePlaceholderArgs: Pick<IElement, 'color'> = {}
if (editorOptions && editorOptions.control) {
+34 -2
View File
@@ -415,7 +415,7 @@ window.onload = function () {
switch (type) {
case ControlType.TEXT:
new Dialog({
title: '文本控件',
title: '文本控件',
data: [{
type: 'text',
label: '占位符',
@@ -449,7 +449,7 @@ window.onload = function () {
break
case ControlType.SELECT:
new Dialog({
title: '列举控件',
title: '列举控件',
data: [{
type: 'text',
label: '占位符',
@@ -487,6 +487,38 @@ window.onload = function () {
}
})
break
case ControlType.CHECKBOX:
new Dialog({
title: '复选框控件',
data: [{
type: 'text',
label: '默认值',
name: 'code',
placeholder: '请输入默认值,多个值以英文逗号分割'
}, {
type: 'textarea',
label: '值集',
name: 'valueSets',
height: 100,
placeholder: `请输入值集JSON,例:\n[{\n"value":"有",\n"code":"98175"\n}]`
}],
onConfirm: (payload) => {
const valueSets = payload.find(p => p.name === 'valueSets')?.value
if (!valueSets) return
const code = payload.find(p => p.name === 'code')?.value
instance.command.executeInsertElementList([{
type: ElementType.CONTROL,
value: '',
control: {
type,
code,
value: null,
valueSets: JSON.parse(valueSets)
}
}])
}
})
break
default:
break
}