parent
559ceec399
commit
a6647dcefe
@ -0,0 +1,68 @@
|
||||
<script setup lang="ts">
|
||||
import { inject, defineProps } from 'vue'
|
||||
import type { IWidget } from '@/types/widgetsConfigInterface'
|
||||
import RendererDom from '@/components/RendererDom.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
itemData: IWidget
|
||||
}>()
|
||||
|
||||
// 文书表单
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const docForm = inject('docForm') as any
|
||||
|
||||
// 根据表单元素类型初始化对应的值
|
||||
if (props['itemData']['category'] == 'formItem') {
|
||||
docForm[props['itemData']['options']['name']] = props['itemData']['options']['defaultValue'] || ''
|
||||
// 针对数值输入框
|
||||
if (props['itemData']['type'] == 'el-input-number') {
|
||||
docForm[props['itemData']['options']['name']] = props['itemData']['options']['defaultValue'] || 0
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 针对表格容器 -->
|
||||
<template v-if="itemData['type'] == 'table'">
|
||||
<table border="1" cellpadding="10" cellspacing="0" class="w-full">
|
||||
<template v-for="(row, rowIndex) in itemData['rows']" :key="rowIndex">
|
||||
<tr>
|
||||
<RendererDom v-for="subData in row['cols']" :key="subData['id']" :itemData="subData" />
|
||||
</tr>
|
||||
</template>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<!-- 针对表格列 -->
|
||||
<template v-if="itemData['type'] == 'table-cell'">
|
||||
<td v-if="!itemData['merged']" :colspan="itemData['options']['colspan']" :rowspan="itemData['options']['rowspan']">
|
||||
<RendererDom v-for="subData in itemData['widgetList']" :key="subData['id']" :itemData="subData" />
|
||||
</td>
|
||||
</template>
|
||||
|
||||
<!-- 针对普通输入框 -->
|
||||
<template v-if="itemData['type'] == 'el-input'">
|
||||
<el-form-item :label="itemData['options']['label']">
|
||||
<el-input v-model="docForm[itemData['options']['name']]" :placeholder="itemData['options']['placeholder']" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<!-- 针对数值输入框 -->
|
||||
<template v-if="itemData['type'] == 'el-input-number'">
|
||||
<el-form-item :label="itemData['options']['label']">
|
||||
<el-input-number v-model="docForm[itemData['options']['name']]" :placeholder="itemData['options']['placeholder']"
|
||||
:controls-position="'right'" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<!-- 针对单选框 -->
|
||||
<template v-if="itemData['type'] == 'el-radio'">
|
||||
<el-form-item :label="itemData['options']['label']">
|
||||
<el-radio-group v-model="docForm[itemData['options']['name']]">
|
||||
<template v-for="optionItem in itemData['options']['optionItems']" :key="optionItem['value']">
|
||||
<el-radio :label="optionItem['label']" :value="optionItem['value']" />
|
||||
</template>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</template>
|
@ -1,16 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElInput,
|
||||
ElForm,
|
||||
ElFormItem
|
||||
} from 'element-plus'
|
||||
|
||||
export const componentMap: Record<string, any> = {
|
||||
'el-table': ElTable,
|
||||
'el-table-column': ElTableColumn,
|
||||
'el-input': ElInput,
|
||||
'el-form': ElForm,
|
||||
'el-form-item': ElFormItem,
|
||||
}
|
@ -1,10 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { inject } from 'vue'
|
||||
import { provide, inject } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import type { IWidgetJson } from '@/types/widgetsConfigInterface'
|
||||
import RendererDom from '@/components/RendererDom.vue'
|
||||
|
||||
// 文书结构
|
||||
const widgetJson = inject('widgetJson')
|
||||
const widgetJson = inject<IWidgetJson>('widgetJson')!
|
||||
|
||||
// 文书表单
|
||||
const docForm = reactive({})
|
||||
provide('docForm', docForm)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>{{ widgetJson }}</section>
|
||||
<section>
|
||||
<h1 class="text-sky-300">{{ widgetJson }}</h1>
|
||||
<el-form :model="docForm" label-width="80px">
|
||||
<template v-for="item in widgetJson['widgetList']" :key="item['id']">
|
||||
<RendererDom :itemData="item" />
|
||||
</template>
|
||||
</el-form>
|
||||
</section>
|
||||
</template>
|
||||
|
Loading…
Reference in new issue