Skip to content

Commit

Permalink
feat: add some parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberty-liu committed Apr 3, 2023
1 parent 0803ad8 commit a08e70c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 20 deletions.
1 change: 0 additions & 1 deletion examples/views/formEditor/objEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const quickImages = ref([
'/public/Everright-logo.svg',
'/public/Everright-logo.svg'
])
</script>
<template>
<div
Expand Down
4 changes: 2 additions & 2 deletions examples/views/formEditor/objList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ onMounted(() => {
</el-form-item>
<el-form-item v-if="!isEdit" label="编辑器类型" prop="layoutType">
<el-radio-group v-model="ruleForm.layoutType" class="ml-4">
<el-radio :label="1" size="large">分离布局与字段</el-radio>
<el-radio :label="2" size="large">不分离布局与字段</el-radio>
<el-radio :label="1" size="large">不分离布局与字段</el-radio>
<el-radio :label="2" size="large">分离布局与字段</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
Expand Down
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
{
"name": "everright-formeditor",
"version": "0.0.9",
"version": "0.0.12",
"files": [
"dist"
],
"license": "MIT",
"keywords": [
"drag-and-drop",
"form",
"formbuilder",
"low-code",
"no-code",
"vue",
"element-plus",
"vant"
],
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/Liberty-liu/Everright-formEditor.git"
},
"main": "dist/Everright-formEditor.umd.cjs",
"module": "dist/Everright-formEditor.js",
"exports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ const setStates = (newTarget, ev, ER) => {
// console.log(ER.props.layoutType === 1)
// console.log(targetContainer)
if (/^(2|4)$/.test(direction)) {
if (targetList.length === 4 && !el.contains(dragEl)) {
if (targetList.length === ER.props.inlineMax && !el.contains(dragEl)) {
return false
}
}
Expand Down Expand Up @@ -264,7 +264,7 @@ const setStates = (newTarget, ev, ER) => {
break
case 5:
// console.log('上')
if (targetList.length === 4 && !el.contains(dragEl)) {
if (targetList.length === ER.props.inlineMax && !el.contains(dragEl)) {
return false
}
if (cols[utils.index(target) - 1] !== dragEl) {
Expand All @@ -276,7 +276,7 @@ const setStates = (newTarget, ev, ER) => {
break
case 6:
// console.log('下')
if (targetList.length === 4 && !el.contains(dragEl)) {
if (targetList.length === ER.props.inlineMax && !el.contains(dragEl)) {
return false
}
if (cols[utils.index(target) + 1] !== dragEl) {
Expand Down
4 changes: 2 additions & 2 deletions packages/formEditor/components/Panels/Fields/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export default {
}
return () => {
return (
<ElAside class={[ns.b()]} width={ER.props.blockPanelWidth}>
<ElAside class={[ns.b()]} width={ER.props.fieldsPanelWidth}>
<el-scrollbar>
<el-menu
default-openeds={ER.props.blockPanelDefaultOpeneds}>
default-openeds={ER.props.fieldsPanelDefaultOpeneds}>
{ER.props.fieldsConfig.map((element, index) => {
return (
<el-sub-menu
Expand Down
5 changes: 3 additions & 2 deletions packages/formEditor/components/Selection/selectElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default {
}
break
case 2:
if (ER.props.copyHandle(props.data) === false) return false
props.data.context.copy()
const copyData = props.parent[index + 1]
setSelection(copyData)
Expand Down Expand Up @@ -264,7 +265,7 @@ export default {
<div class={[ns.e('mask')]}>
</div>
)
const isShowCopy = computed(() => isInlineChildren ? props.hasCopy && props.data.context.parent.columns.length < 4 : props.hasCopy)
const isShowCopy = computed(() => isInlineChildren ? props.hasCopy && props.data.context.parent.columns.length < ER.props.inlineMax : props.hasCopy)
// const isShowSelectParent = computed(() => {
// return !isSelectRoot.value
// })
Expand Down Expand Up @@ -301,7 +302,7 @@ export default {
handleAction(5)
}, ['stop'])} icon="top"></Icon>
{props.hasDel && (
<Icon class={[ns.e('copyDelete')]} onClick={withModifiers((e) => {
<Icon class={[ns.e('copy')]} onClick={withModifiers((e) => {
handleAction(1)
}, ['stop'])} icon="delete"></Icon>
)}
Expand Down
2 changes: 2 additions & 0 deletions packages/formEditor/defaultProps.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { fieldsConfig, globalConfig } from './componentsConfig'
export default {
fieldsConfig: {
type: Array,
default: () => fieldsConfig
},
globalConfig: {
type: Object,
default: () => globalConfig
},
lang: {
Expand Down
31 changes: 24 additions & 7 deletions packages/formEditor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,39 @@ export default {
<script setup>
const emit = defineEmits(['listener'])
const props = defineProps(_.merge({
blockPanelWidth: {
fieldsPanelWidth: {
type: String,
default: '220px'
},
blockPanelDefaultOpeneds: {
fieldsPanelDefaultOpeneds: {
type: Array,
default: () => ['defaultField', 'field', 'container']
},
delHandle: {
type: Function,
default: () => {}
},
copyHandle: {
type: Function,
default: () => {}
},
inlineMax: {
type: Number,
default: 4
},
isShowClear: {
type: Boolean,
default: true
},
isShowI18n: {
type: Boolean,
default: true
}
}, defaultProps))
const layout = {
pc: [],
mobile: []
}
window.layout = layout
const previewPlatform = ref('pc')
const previewLoading = ref(true)
const state = reactive({
Expand Down Expand Up @@ -254,7 +269,6 @@ const getLayoutDataByplatform = (platform) => {
return copyData
}
}
window.layout = layout
const switchPlatform = (platform) => {
if (state.platform === platform) {
return false
Expand Down Expand Up @@ -282,7 +296,6 @@ provide('Everright', {
addFieldData,
canvesScrollRef
})
window.state = state
const ns = hooks.useNamespace('Main', state.Namespace)
const getData1 = () => {
return utils.disassemblyData1(_.cloneDeep({
Expand Down Expand Up @@ -444,13 +457,17 @@ const onClickOutside = () => {
<el-header :class="[ns.e('operation')]">
<div>
<Icon @click="handleOperation(4)" :class="[ns.e('icon')]" icon="save"></Icon>
<Icon @click="handleOperation(2)" :class="[ns.e('icon')]" icon="clear0"></Icon>
<Icon v-if="isShowClear" @click="handleOperation(2)" :class="[ns.e('icon')]" icon="clear0"></Icon>
<slot name="operation-left"></slot>
</div>
<div>
<DeviceSwitch :modelValue="state.platform" @update:modelValue="(val) => switchPlatform(val)"></DeviceSwitch>
</div>
<div>
<el-dropdown @command="(command) => emit('listener', {
<slot name="operation-right"></slot>
<el-dropdown
v-if="isShowI18n"
@command="(command) => emit('listener', {
type: 'lang',
data: command
})">
Expand Down
1 change: 0 additions & 1 deletion packages/region/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const store = new Store(region.getAll(), {
disabled: 'disabled',
multiple: props.multiple
})
// window.store = store
const state = reactive({
Namespace: 'region',
menus: [{
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/formEditor/SelectElement.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
font-size: 20px;
margin: 0 !important;
}
@include e((copyIcon, copyDelete, widthScale, tableOperator, charulieIcon, charuhang, charuhangIcon, selectParent, dragIcon, addCol)) {
@include e((copyIcon, copy, widthScale, tableOperator, charulieIcon, charuhang, charuhangIcon, selectParent, dragIcon, addCol)) {
border-radius: 4px;
//box-shadow: 0 2px 6px #00000040;
background: $primary-color;
Expand Down

0 comments on commit a08e70c

Please sign in to comment.