Commit d7f71b0a by xinla

智能表单

1 parent 84226464
......@@ -24,7 +24,7 @@
"crypto-js": "^4.1.1",
"driver.js": "^0.9.8",
"echarts": "^5.4.2",
"element-plus": "^2.3.4",
"element-plus": "^2.3.6",
"fabric": "^5.3.0",
"file-saver": "^2.0.5",
"fuse.js": "^6.6.2",
......
......@@ -3,14 +3,14 @@ import draggable from 'vuedraggable'
import render from './generator/render'
const components = {
itemBtns(element, index, parent) {
const { copyItem, deleteItem } = this.$attrs
const { onCopyItem, onDeleteItem } = this.$attrs
return (
<>
<span
class='drawing-item-copy ssc'
title='复制'
onClick={(event) => {
copyItem(element, parent)
onCopyItem(element, parent)
event.stopPropagation()
}}>
<el-icon-CopyDocument class='el-icon-CopyDocument' />
......@@ -19,7 +19,7 @@ const components = {
class='drawing-item-delete ssc'
title='删除'
onClick={(event) => {
deleteItem(index, parent)
onDeleteItem(index, parent)
event.stopPropagation()
}}>
<el-icon-delete class='el-icon-delete' />
......@@ -30,7 +30,7 @@ const components = {
}
const layouts = {
colFormItem(element, index, parent) {
const { activeItem } = this.$attrs
const { onActiveItem } = this.$attrs
console.log('element.formId', element.formId)
let className = this.activeId === element.formId ? 'drawing-item active-from-item' : 'drawing-item'
//只是用顶部样式
......@@ -42,7 +42,7 @@ const layouts = {
span={element.span}
class={className}
onClick={(event) => {
activeItem && activeItem(element)
onActiveItem && onActiveItem(element)
event.stopPropagation()
}}>
<el-form-item
......@@ -80,7 +80,7 @@ const layouts = {
)
},
rowFormItem(element, index, parent) {
const { activeItem } = this.$attrs
const { onActiveItem } = this.$attrs
const className = this.activeId === element.formId ? 'drawing-row-item active-from-item' : 'drawing-row-item'
let child = renderChildren.apply(this, arguments)
if (element.type === 'flex') {
......@@ -97,7 +97,7 @@ const layouts = {
gutter={element.gutter}
class={className}
onClick={(event) => {
activeItem && activeItem(element)
onActiveItem && onActiveItem(element)
event.stopPropagation()
}}>
<span class='component-name'>{element.componentName}</span>
......
......@@ -113,7 +113,7 @@
:min="0"
:max="activeData.options.length"
placeholder="至少应选"
@input="$set(activeData, 'maxZ', $event ? $event : undefined)" />
@input="activeData['maxZ'] = $event ? $event : undefined" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-checkbox-group'" label="最多可选">
<el-input-number
......@@ -121,7 +121,7 @@
:min="0"
:max="activeData.options.length"
placeholder="最多可选"
@input="$set(activeData, 'max', $event ? $event : undefined)" />
@input="activeData['max'] = $event ? $event : undefined" />
</el-form-item>
<!-- <el-form-item v-if="activeData.prepend!==undefined" label="前缀">
<el-input v-model="activeData.prepend" placeholder="请输入前缀" />
......@@ -294,7 +294,7 @@
</template>
</draggable>
<div style="margin-left: 20px">
<el-button style="padding-bottom: 0" icon="el-icon-circle - plus - outline" text @click="addSelectItem">
<el-button style="padding-bottom: 0" icon="el-icon-CirclePlus" text @click="addSelectItem">
添加选项
</el-button>
</div>
......@@ -333,7 +333,7 @@
:expand-on-click-node="false"
:render-content="renderContent" />
<div v-if="activeData.dataType === 'static'" style="margin-left: 20px">
<el-button style="padding-bottom: 0" icon="el-icon-circle - plus - outline" text @click="addTreeItem">
<el-button style="padding-bottom: 0" icon="el-icon-CirclePlus" text @click="addTreeItem">
添加父级
</el-button>
</div>
......
......@@ -19,9 +19,9 @@ const isAttr = makeMap(
)
function vModel(self, dataObject, defaultValue) {
console.log('defaultValue111', defaultValue)
console.log('dataObject', dataObject)
console.log('self', self)
// console.log('defaultValue111', defaultValue)
// console.log('dataObject', dataObject)
// console.log('self', self)
if (dataObject.formCodeId == 5 || dataObject.formCodeId == 625) {
if (defaultValue) {
console.log('(/(^[1-9]d*$)/.test(defaultValue))', /(^[1-9]\d*$)/.test(defaultValue))
......@@ -47,9 +47,9 @@ function vModel(self, dataObject, defaultValue) {
// console.log('dataObject.props', dataObject.props)
dataObject['model-value'] = defaultValue
// dataObject.onInput = (val) => {
// self.$emit('input', val)
// }
dataObject.onInput = (val) => {
self.$emit('input', val)
}
}
const componentChild = {
......@@ -145,6 +145,26 @@ const componentChild = {
export default {
props: ['conf'],
data() {
return {props:{
value: 'id',
label: 'name',
lazy: true,
lazyLoad(node, resolve) {
debugger
if (node.level == 0) {
getProvinceCityTree().then((data) => {
resolve(data)
})
} else {
if (node.level == 2) {
node.data.children.forEach((e) => (e.leaf = true))
}
resolve([])
}
},
}}
},
render() {
const dataObject = {
// attrs: {},
......@@ -165,11 +185,13 @@ export default {
})
}
console.log('confClone', confClone.formCodeId)
Object.keys(confClone).forEach((key) => {
const val = confClone[key]
if (confClone.layout != 'rowFormItem') {
vModel(this, dataObject, confClone.defaultValue)
}
if (confClone.layout != 'rowFormItem') {
vModel(this, dataObject, confClone.defaultValue)
}
Object.assign(dataObject, confClone)
// Object.keys(confClone).forEach((key) => {
// const val = confClone[key]
// if (key === 'style') {
// Object.assign(dataObject[key], val)
// } else if (!isAttr(key)) {
......@@ -177,29 +199,14 @@ export default {
// } else {
// dataObject.attrs[key] = val
// }
})
Object.assign(dataObject, confClone)
// })
debugger
// 配置省市区数据首次懒加载
if (confClone.formCodeId == 9) {
dataObject.props = {
value: 'id',
label: 'name',
lazy: true,
lazyLoad(node, resolve) {
if (node.level == 0) {
getProvinceCityTree().then((data) => {
resolve(data)
})
} else {
if (node.level == 2) {
node.data.children.forEach((e) => (e.leaf = true))
}
resolve([])
}
},
}
debugger
dataObject.props = this.props
}
return h(resolveComponent(this.conf.tag), dataObject, children)
......
......@@ -398,7 +398,7 @@ export default {
activeFormItem(element) {
this.activeData = element
this.activeId = element.formId
// this.$forceUpdate()
this.$forceUpdate()
},
onEnd(obj, a) {
if (obj.from !== obj.to) {
......@@ -412,6 +412,7 @@ export default {
this.activeFormItem(clone)
},
cloneComponent(origin) {
debugger
const clone = JSON.parse(JSON.stringify(origin))
clone.formId = this.idGlobal = uuid()
clone.span = formConf.span
......@@ -460,8 +461,11 @@ export default {
document.getElementById('copyNode').click()
},
empty() {
this.$confirm('确定要清空所有组件吗?', '提示', {confirmButtonText: '确定',
cancelButtonText: '取消', type: 'warning' }).then(() => {
this.$confirm('确定要清空所有组件吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
this.drawingList = []
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!