Browse Source

Merge branch 'liwenxuan_v4'

# Conflicts:
#	src/components/DesignForm/formControlAttr.vue
#	src/components/DesignForm/public/form/formGroup.vue
lwx_v6
超级管理员 2 years ago
parent
commit
54b2ff6196
  1. 11
      src/components/DesignForm/assembly/index.ts
  2. 1988
      src/components/DesignForm/formControlAttr.vue
  3. 4
      src/components/DesignForm/public/form/formGroup.vue
  4. 15
      src/widget/associatedforms/associatedForms.vue
  5. 181
      src/widget/associatedforms/index.vue
  6. 2
      src/widget/index.ts

11
src/components/DesignForm/assembly/index.ts

@ -592,6 +592,17 @@ const selectOption: any = [
},
config: {}
},
{
type: 'associatedForms',
label: '关联表单',
icon: '',
iconFont: 'fa-wpforms',
control: {
modelValue: '',
},
config: {}
}
]
},
{

1988
src/components/DesignForm/formControlAttr.vue

File diff suppressed because it is too large

4
src/components/DesignForm/public/form/formGroup.vue

@ -458,11 +458,15 @@ const getFormItemLableStyle = (ele: any) => {
</div>
</template>
<<<<<<< HEAD
<DigitPage v-else-if="element.type === 'digitpage'" :data="element" />
=======
<AssociatedForms v-else-if="element.type === 'associatedForms'" :data="element" />
>>>>>>> liwenxuan_v4
<LowcodeImage v-else-if="element.type === 'lowcodeImage'" :data="element" />
<LowcodeTransfer v-else-if="element.type === 'lowcodeTransfer'" :data="element" />

15
src/widget/associatedforms/associatedForms.vue

@ -0,0 +1,15 @@
<template>
<el-input v-model="input" style="width: 240px" placeholder="" />
</template>
<script setup >
</script>
<style>
</style>

181
src/widget/associatedforms/index.vue

@ -0,0 +1,181 @@
<!--
@ 作者: 李文轩
@ 时间: 2024-03-14 13:49:57
@ 备注:
-->
<template>
<el-form-item
v-bind="data.item"
:prop="tProp || data.name"
:class="config.className"
:rules="itemRules as any"
:label="getLabel(data.item as FormItem)"
>
<input v-model="value" type="hidden" >
</el-form-item>
<AssociatedForms :data="props.data"></AssociatedForms>
</template>
<script lang='ts' setup>
import AssociatedForms from './associatedForms.vue';
import {
constControlChange,
constFormProps,
} from '@/api/DesignForm/utils'
import validate from '@/api/DesignForm/validate'
import { FormItem, FormList } from '@/api/DesignForm/types'
const props = withDefaults(
defineProps<{
data: FormList
tablekey: any
numrun?: number
modelValue?: any //
tProp?: string // form-itemprop
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', numVal: any): void
}>()
const formProps = inject(constFormProps, {}) as any
const type = computed(() => {
return formProps.value.type
})
const config = computed(() => {
return props.data.config || {}
})
const changeEvent = inject(constControlChange, '') as any
const value = computed({
get() {
if (props.tProp) {
//
return props.modelValue
} else {
return formProps.value.model[props.data.name]
}
},
set(newVal: any) {
if (props.tProp) {
emits('update:modelValue', newVal)
}
updateModel(newVal)
}
})
const updateModel = (val: any) => {
let controlAttribute = ""
if(props.data.control){
if(props.data.control.type){
controlAttribute = props.data.control.type
}
}
changeEvent &&
changeEvent({
key: props.data.name,
value: val,
data: props.data,
tProp: props.tProp,
type: props.data.type,
attribute: controlAttribute
})
}
const getLabel = (ele: FormItem) => {
const showColon = formProps.value.showColon ? ':' : ''
if (ele) {
return ele.showLabel ? '' : ele.label + showColon
} else {
return ''
}
}
// item
const itemRules = computed(() => {
let temp
const itemR: any = props.data.item?.rules || []
const customR = formatCustomRules()
// undefined
if (itemR?.length || customR?.length) {
temp = [...customR, ...itemR]
}
return temp
})
// customRulesrules
const formatCustomRules = () => {
const rulesReg: any = {}
validate &&
validate.forEach(item => {
rulesReg[item.type] = item.regExp
})
// 使provide
const temp: any = []
props.data.customRules?.forEach((item: any) => {
if (!item.message && item.type !== 'methods') {
return //
}
let obj = {}
if (item.type === 'required') {
obj = { required: true }
} else if (item.type === 'rules') {
//
obj = { pattern: item.rules }
} else if (item.type === 'methods') {
//
const methods: any = item.methods
if (methods) {
obj = { validator: inject(methods, {}) }
}
} else if (item.type) {
obj = { pattern: rulesReg[item.type as string] }
}
// push
let message: any = { message: item.message }
if (!item.message) {
// 使validatormessage使 callback(new Error('x'));
message = {}
}
temp.push(
Object.assign(
{
trigger: item.trigger || 'blur'
},
obj,
message
)
)
})
return temp
}
</script>
<style lang='scss' scoped>
.imgbox{
padding: 0 5px;
max-width: 300px;
max-height: 200px;
width: 100%;
height: 200px;
.image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
background: var(--el-fill-color-light);
color: var(--el-text-color-secondary);
font-size: 30px;
}
}
</style>

2
src/widget/index.ts

@ -14,6 +14,7 @@ import videoUpAndPlay from './videoupload/index.vue'
import lowcodeCarsusel from './carousel/index.vue'
import lowcodeTransfer from './lowcodetransfer/index.vue'
import lowcodeImage from './lowcodeimage/index.vue'
import associatedForms from './associatedforms/index.vue'
export default (app: any) => {
@ -30,4 +31,5 @@ export default (app: any) => {
app.component('LowcodeCarsusel',lowcodeCarsusel)
app.component('LowcodeTransfer',lowcodeTransfer)
app.component('LowcodeImage',lowcodeImage)
app.component('AssociatedForms',associatedForms)
}

Loading…
Cancel
Save