Skip to content

Commit

Permalink
feat: 新增否显示表单标签
Browse files Browse the repository at this point in the history
  • Loading branch information
JakHuang committed Mar 3, 2020
1 parent 2bcf1f9 commit 1c5983f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 212 deletions.
17 changes: 17 additions & 0 deletions src/components/generator/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const inputComponents = [
placeholder: '请输入',
defaultValue: undefined,
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
clearable: true,
Expand All @@ -43,6 +44,7 @@ export const inputComponents = [
placeholder: '请输入',
defaultValue: undefined,
span: 24,
showLabel: true,
labelWidth: null,
autosize: {
minRows: 4,
Expand All @@ -66,6 +68,7 @@ export const inputComponents = [
defaultValue: undefined,
span: 24,
'show-password': true,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
clearable: true,
Expand All @@ -89,6 +92,7 @@ export const inputComponents = [
placeholder: '',
defaultValue: undefined,
span: 24,
showLabel: true,
labelWidth: null,
min: undefined,
max: undefined,
Expand All @@ -112,6 +116,7 @@ export const selectComponents = [
placeholder: '请选择',
defaultValue: undefined,
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
clearable: true,
Expand All @@ -137,6 +142,7 @@ export const selectComponents = [
placeholder: '请选择',
defaultValue: [],
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
props: {
Expand Down Expand Up @@ -174,6 +180,7 @@ export const selectComponents = [
tagIcon: 'radio',
defaultValue: undefined,
span: 24,
showLabel: true,
labelWidth: null,
style: {},
optionType: 'default',
Expand All @@ -198,6 +205,7 @@ export const selectComponents = [
tagIcon: 'checkbox',
defaultValue: [],
span: 24,
showLabel: true,
labelWidth: null,
style: {},
optionType: 'default',
Expand All @@ -222,6 +230,7 @@ export const selectComponents = [
tagIcon: 'switch',
defaultValue: false,
span: 24,
showLabel: true,
labelWidth: null,
style: {},
disabled: false,
Expand All @@ -242,6 +251,7 @@ export const selectComponents = [
tagIcon: 'slider',
defaultValue: null,
span: 24,
showLabel: true,
labelWidth: null,
disabled: false,
required: true,
Expand All @@ -261,6 +271,7 @@ export const selectComponents = [
placeholder: '请选择',
defaultValue: null,
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
disabled: false,
Expand All @@ -281,6 +292,7 @@ export const selectComponents = [
tagIcon: 'time-range',
defaultValue: null,
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
disabled: false,
Expand All @@ -304,6 +316,7 @@ export const selectComponents = [
defaultValue: null,
type: 'date',
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
disabled: false,
Expand All @@ -322,6 +335,7 @@ export const selectComponents = [
tagIcon: 'date-range',
defaultValue: null,
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
type: 'daterange',
Expand All @@ -344,6 +358,7 @@ export const selectComponents = [
tagIcon: 'rate',
defaultValue: 0,
span: 24,
showLabel: true,
labelWidth: null,
style: {},
max: 5,
Expand All @@ -361,6 +376,7 @@ export const selectComponents = [
tag: 'el-color-picker',
tagIcon: 'color',
defaultValue: null,
showLabel: true,
labelWidth: null,
'show-alpha': false,
'color-format': '',
Expand All @@ -377,6 +393,7 @@ export const selectComponents = [
tagIcon: 'upload',
action: 'https://jsonplaceholder.typicode.com/posts/',
defaultValue: null,
showLabel: true,
labelWidth: null,
disabled: false,
required: true,
Expand Down
5 changes: 4 additions & 1 deletion src/components/generator/drawingDefalut.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default [
placeholder: '请输入手机号',
defaultValue: '',
span: 24,
showLabel: true,
labelWidth: null,
style: { width: '100%' },
clearable: true,
prepend: '',
Expand All @@ -24,6 +26,7 @@ export default [
regList: [{
pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
message: '手机号格式错误'
}]
}],
document: 'https://element.eleme.cn/#/zh-CN/component/input'
}
]
7 changes: 6 additions & 1 deletion src/components/generator/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,17 @@ function colWrapper(element, str) {
const layouts = {
colFormItem(element) {
let labelWidth = ''
let label = `label="${element.label}"`
if (element.labelWidth && element.labelWidth !== confGlobal.labelWidth) {
labelWidth = `label-width="${element.labelWidth}px"`
}
if(element.showLabel === false) {
labelWidth = 'label-width="0"'
label = ''
}
const required = !trigger[element.tag] && element.required ? 'required' : ''
const tagDom = tags[element.tag] ? tags[element.tag](element) : null
let str = `<el-form-item ${labelWidth} label="${element.label}" prop="${element.vModel}" ${required}>
let str = `<el-form-item ${labelWidth} ${label} prop="${element.vModel}" ${required}>
${tagDom}
</el-form-item>`
str = colWrapper(element, str)
Expand Down
4 changes: 2 additions & 2 deletions src/views/index/DraggableItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const layouts = {
return (
<el-col span={element.span} class={className}
nativeOnClick={event => { activeItem(element); event.stopPropagation() }}>
<el-form-item label-width={element.labelWidth ? `${element.labelWidth}px` : null}
label={element.label} required={element.required}>
<el-form-item label-width={element.showLabel ? element.labelWidth ? `${element.labelWidth}px` : null : '0'}
label={element.showLabel ? element.label: ''} required={element.required}>
<render key={element.renderKey} conf={element} onInput={ event => {
this.$set(element, 'defaultValue', event)
}} />
Expand Down
3 changes: 3 additions & 0 deletions src/views/index/RightPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@
<el-color-picker v-model="activeData['inactive-color']" />
</el-form-item>

<el-form-item v-if="activeData.showLabel !== undefined && activeData.labelWidth !== undefined" label="显示标签">
<el-switch v-model="activeData.showLabel" />
</el-form-item>
<el-form-item v-if="activeData['allow-half'] !== undefined" label="允许半选">
<el-switch v-model="activeData['allow-half']" />
</el-form-item>
Expand Down
Loading

0 comments on commit 1c5983f

Please sign in to comment.