Compare commits

...

2 Commits

@ -1,6 +1,11 @@
module.exports = {
extends: ['@vue/eslint-config-standard'],
root: true,
extends: ['plugin:vue/vue3-essential', '@vue/eslint-config-standard-with-typescript'],
parserOptions: {
ecmaVersion: 'latest',
},
rules: {
'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
}

@ -2,5 +2,5 @@
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"singleQuote": true,
"printWidth": 100
"printWidth": 180
}

@ -4,7 +4,6 @@
"vitest.explorer",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"vscode-icons-team.vscode-icons",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",

@ -0,0 +1,232 @@
{
"widgetList": [
{
"key": 47004,
"type": "table",
"category": "container",
"icon": "table",
"rows": [
{
"cols": [
{
"type": "table-cell",
"category": "container",
"icon": "table-cell",
"internal": true,
"widgetList": [],
"merged": false,
"options": {
"name": "table-cell-89646",
"cellWidth": "",
"cellHeight": "",
"colspan": 1,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
},
"id": "table-cell-89646"
},
{
"type": "table-cell",
"category": "container",
"icon": "table-cell",
"internal": true,
"widgetList": [],
"merged": false,
"options": {
"name": "table-cell-94169",
"cellWidth": "",
"cellHeight": "",
"colspan": 1,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
},
"id": "table-cell-94169"
}
],
"id": "table-row-17138",
"merged": false
},
{
"cols": [
{
"type": "table-cell",
"category": "container",
"icon": "table-cell",
"internal": true,
"widgetList": [
{
"key": 63447,
"type": "input",
"alias": "",
"icon": "text-field",
"formItemFlag": true,
"options": {
"name": "input52553",
"keyNameEnabled": false,
"keyName": "",
"label": "input",
"labelAlign": "",
"type": "text",
"defaultValue": "",
"placeholder": "",
"columnWidth": "200px",
"size": "",
"labelWidth": null,
"labelHidden": false,
"labelWrap": false,
"readonly": false,
"disabled": false,
"hidden": false,
"clearable": true,
"showPassword": false,
"required": false,
"requiredHint": "",
"validation": "",
"validationHint": "",
"customClass": "",
"labelIconClass": null,
"labelIconPosition": "rear",
"labelTooltip": null,
"minLength": null,
"maxLength": null,
"showWordLimit": false,
"prefixIcon": "",
"suffixIcon": "",
"appendButton": false,
"appendButtonDisabled": false,
"buttonIcon": "custom-search",
"appendText": false,
"textForAppend": "",
"onCreated": "",
"onMounted": "",
"onInput": "",
"onChange": "",
"onFocus": "",
"onBlur": "",
"onValidate": "",
"onAppendButtonClick": ""
},
"id": "input52553"
}
],
"merged": false,
"options": {
"name": "table-cell-57911",
"cellWidth": "",
"cellHeight": "",
"colspan": 2,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
},
"id": "table-cell-57911"
},
{
"type": "table-cell",
"category": "container",
"icon": "table-cell",
"internal": true,
"widgetList": [],
"merged": true,
"options": {
"name": "table-cell-74240",
"cellWidth": "",
"cellHeight": "",
"colspan": 2,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
},
"id": "table-cell-74240"
}
],
"id": "table-row-57542",
"merged": false
}
],
"options": {
"name": "table61396",
"hidden": false,
"customClass": []
},
"id": "table61396"
},
{
"key": 63447,
"type": "input",
"alias": "",
"icon": "text-field",
"formItemFlag": true,
"options": {
"name": "input26255",
"keyNameEnabled": false,
"keyName": "",
"label": "input",
"labelAlign": "",
"type": "text",
"defaultValue": "",
"placeholder": "",
"columnWidth": "200px",
"size": "",
"labelWidth": null,
"labelHidden": false,
"labelWrap": false,
"readonly": false,
"disabled": false,
"hidden": false,
"clearable": true,
"showPassword": false,
"required": false,
"requiredHint": "",
"validation": "",
"validationHint": "",
"customClass": [],
"labelIconClass": null,
"labelIconPosition": "rear",
"labelTooltip": null,
"minLength": null,
"maxLength": null,
"showWordLimit": false,
"prefixIcon": "",
"suffixIcon": "",
"appendButton": false,
"appendButtonDisabled": false,
"buttonIcon": "custom-search",
"appendText": false,
"textForAppend": "",
"onCreated": "",
"onMounted": "",
"onInput": "",
"onChange": "",
"onFocus": "",
"onBlur": "",
"onValidate": "",
"onAppendButtonClick": ""
},
"id": "input26255"
}
],
"formConfig": {
"modelName": "formData",
"refName": "vForm",
"rulesName": "rules",
"labelWidth": 80,
"labelPosition": "left",
"h5LabelTop": false,
"gridResponsive": false,
"size": "",
"labelAlign": "label-left-align",
"cssCode": "",
"customClass": [],
"functions": "",
"layoutType": "PC",
"jsonVersion": 3,
"dataSources": [],
"onFormCreated": "",
"onFormMounted": "",
"onFormDataChange": "",
"onFormValidate": ""
}
}

141
package-lock.json generated

@ -1071,9 +1071,9 @@
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.6.0.tgz",
"integrity": "sha512-WhCn7Z7TauhBtmzhvKpoQs0Wwb/kBcy4CwpuI0/eEIr2Lx2auxmulAzLr91wVZJaz47iUZdkXOK7WlAfxGKCnA==",
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.6.1.tgz",
"integrity": "sha512-KTsJMmobmbrFLe3LDh0PC2FXpcSYJt/MLjlkh/9LEnmKYLSYmT/0EW9JWANjeoemiuZrmogti0tW5Ch+qNUYDw==",
"dev": true,
"dependencies": {
"eslint-visitor-keys": "^3.4.3"
@ -2334,25 +2334,25 @@
}
},
"node_modules/@vue/devtools-api": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.7.2.tgz",
"integrity": "sha512-1syn558KhyN+chO5SjlZIwJ8bV/bQ1nOVTG66t2RbG66ZGekyiYNmRO7X9BJCXQqPsFHlnksqvPhce2qpzxFnA==",
"version": "7.7.5",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.7.5.tgz",
"integrity": "sha512-HYV3tJGARROq5nlVMJh5KKHk7GU8Au3IrrmNNqr978m0edxgpHgYPDoNUGrvEgIbObz09SQezFR3A1EVmB5WZg==",
"dependencies": {
"@vue/devtools-kit": "^7.7.2"
"@vue/devtools-kit": "^7.7.5"
}
},
"node_modules/@vue/devtools-core": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@vue/devtools-core/-/devtools-core-7.7.2.tgz",
"integrity": "sha512-lexREWj1lKi91Tblr38ntSsy6CvI8ba7u+jmwh2yruib/ltLUcsIzEjCnrkh1yYGGIKXbAuYV2tOG10fGDB9OQ==",
"version": "7.7.5",
"resolved": "https://registry.npmjs.org/@vue/devtools-core/-/devtools-core-7.7.5.tgz",
"integrity": "sha512-ElKr0NDor57gVaT+gMQ8kcVP4uFGqHcxuuQndW/rPwh6aHWvEcUL3sxL8cEk+e1Rdt28kS88erpsiIMO6hEENQ==",
"dev": true,
"dependencies": {
"@vue/devtools-kit": "^7.7.2",
"@vue/devtools-shared": "^7.7.2",
"@vue/devtools-kit": "^7.7.5",
"@vue/devtools-shared": "^7.7.5",
"mitt": "^3.0.1",
"nanoid": "^5.0.9",
"pathe": "^2.0.2",
"vite-hot-client": "^0.2.4"
"nanoid": "^5.1.0",
"pathe": "^2.0.3",
"vite-hot-client": "^2.0.4"
},
"peerDependencies": {
"vue": "^3.0.0"
@ -2377,23 +2377,23 @@
}
},
"node_modules/@vue/devtools-kit": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.2.tgz",
"integrity": "sha512-CY0I1JH3Z8PECbn6k3TqM1Bk9ASWxeMtTCvZr7vb+CHi+X/QwQm5F1/fPagraamKMAHVfuuCbdcnNg1A4CYVWQ==",
"version": "7.7.5",
"resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.5.tgz",
"integrity": "sha512-S9VAVJYVAe4RPx2JZb9ZTEi0lqTySz2CBeF0wHT5D3dkTLnT9yMMGegKNl4b2EIELwLSkcI9bl2qp0/jW+upqA==",
"dependencies": {
"@vue/devtools-shared": "^7.7.2",
"birpc": "^0.2.19",
"@vue/devtools-shared": "^7.7.5",
"birpc": "^2.3.0",
"hookable": "^5.5.3",
"mitt": "^3.0.1",
"perfect-debounce": "^1.0.0",
"speakingurl": "^14.0.1",
"superjson": "^2.2.1"
"superjson": "^2.2.2"
}
},
"node_modules/@vue/devtools-shared": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.7.2.tgz",
"integrity": "sha512-uBFxnp8gwW2vD6FrJB8JZLUzVb6PNRG0B0jBnHsOH8uKyva2qINY8PTF5Te4QlTbMDqU5K6qtJDr6cNsKWhbOA==",
"version": "7.7.5",
"resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.7.5.tgz",
"integrity": "sha512-QBjG72RfpM0DKtpns2RZOxBltO226kOAls9e4Lri6YxS2gWTgL0H+wj1R2K76lxxIeOrqo4+2Ty6RQnzv+WSTQ==",
"dependencies": {
"rfdc": "^1.4.1"
}
@ -2821,9 +2821,9 @@
}
},
"node_modules/birpc": {
"version": "0.2.19",
"resolved": "https://registry.npmjs.org/birpc/-/birpc-0.2.19.tgz",
"integrity": "sha512-5WeXXAvTmitV1RqJFppT5QtUiz2p1mRSYU000Jkft5ZUCLJIk4uQriYNO50HknxKwM6jd8utNc66K1qGIwwWBQ==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/birpc/-/birpc-2.3.0.tgz",
"integrity": "sha512-ijbtkn/F3Pvzb6jHypHRyve2QApOCZDR25D/VnkY2G/lBNcXCTsnsCxgY4k4PkVB7zfwzYbY3O9Lcqe3xufS5g==",
"funding": {
"url": "https://github.com/sponsors/antfu"
}
@ -4714,12 +4714,15 @@
}
},
"node_modules/lilconfig": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz",
"integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==",
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz",
"integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==",
"dev": true,
"engines": {
"node": ">=10"
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/antonk52"
}
},
"node_modules/lines-and-columns": {
@ -5462,18 +5465,6 @@
}
}
},
"node_modules/postcss-load-config/node_modules/lilconfig": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz",
"integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==",
"dev": true,
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/antonk52"
}
},
"node_modules/postcss-nested": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz",
@ -6508,33 +6499,33 @@
}
},
"node_modules/tailwindcss": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz",
"integrity": "sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==",
"version": "3.4.17",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.17.tgz",
"integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==",
"dev": true,
"dependencies": {
"@alloc/quick-lru": "^5.2.0",
"arg": "^5.0.2",
"chokidar": "^3.5.3",
"chokidar": "^3.6.0",
"didyoumean": "^1.2.2",
"dlv": "^1.1.3",
"fast-glob": "^3.3.0",
"fast-glob": "^3.3.2",
"glob-parent": "^6.0.2",
"is-glob": "^4.0.3",
"jiti": "^1.19.1",
"lilconfig": "^2.1.0",
"micromatch": "^4.0.5",
"jiti": "^1.21.6",
"lilconfig": "^3.1.3",
"micromatch": "^4.0.8",
"normalize-path": "^3.0.0",
"object-hash": "^3.0.0",
"picocolors": "^1.0.0",
"postcss": "^8.4.23",
"picocolors": "^1.1.1",
"postcss": "^8.4.47",
"postcss-import": "^15.1.0",
"postcss-js": "^4.0.1",
"postcss-load-config": "^4.0.1",
"postcss-nested": "^6.0.1",
"postcss-selector-parser": "^6.0.11",
"resolve": "^1.22.2",
"sucrase": "^3.32.0"
"postcss-load-config": "^4.0.2",
"postcss-nested": "^6.2.0",
"postcss-selector-parser": "^6.1.2",
"resolve": "^1.22.8",
"sucrase": "^3.35.0"
},
"bin": {
"tailwind": "lib/cli.js",
@ -6707,9 +6698,9 @@
}
},
"node_modules/tr46": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.0.tgz",
"integrity": "sha512-IUWnUK7ADYR5Sl1fZlO1INDUhVhatWl7BtJWsIhwJ0UAK7ilzzIa8uIqOO/aYVWHZPJkKbEL+362wrzoeRF7bw==",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz",
"integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==",
"dev": true,
"dependencies": {
"punycode": "^2.3.1"
@ -6868,9 +6859,9 @@
"dev": true
},
"node_modules/vite": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.0.tgz",
"integrity": "sha512-9aC0n4pr6hIbvi1YOpFjwQ+QOTGssvbJKoeYkuHHGWwlXfdxQlI8L2qNMo9awEEcCPSiS+5mJZk5jH1PAqoDeQ==",
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.1.tgz",
"integrity": "sha512-kkzzkqtMESYklo96HKKPE5KKLkC1amlsqt+RjFMlX2AvbRB/0wghap19NdBxxwGZ+h/C6DLCrcEphPIItlGrRQ==",
"dev": true,
"dependencies": {
"esbuild": "^0.25.0",
@ -6942,9 +6933,9 @@
}
},
"node_modules/vite-hot-client": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/vite-hot-client/-/vite-hot-client-0.2.4.tgz",
"integrity": "sha512-a1nzURqO7DDmnXqabFOliz908FRmIppkBKsJthS8rbe8hBEXwEwe4C3Pp33Z1JoFCYfVL4kTOMLKk0ZZxREIeA==",
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/vite-hot-client/-/vite-hot-client-2.0.4.tgz",
"integrity": "sha512-W9LOGAyGMrbGArYJN4LBCdOC5+Zwh7dHvOHC0KmGKkJhsOzaKbpo/jEjpPKVHIW0/jBWj8RZG0NUxfgA8BxgAg==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/antfu"
@ -7007,16 +6998,16 @@
}
},
"node_modules/vite-plugin-vue-devtools": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/vite-plugin-vue-devtools/-/vite-plugin-vue-devtools-7.7.2.tgz",
"integrity": "sha512-5V0UijQWiSBj32blkyPEqIbzc6HO9c1bwnBhx+ay2dzU0FakH+qMdNUT8nF9BvDE+i6I1U8CqCuJiO20vKEdQw==",
"version": "7.7.5",
"resolved": "https://registry.npmjs.org/vite-plugin-vue-devtools/-/vite-plugin-vue-devtools-7.7.5.tgz",
"integrity": "sha512-cSlQYI1E+8d0qubBg70suTBbXMFbTHLn7vLPYUPK9GjNNJ0nw+Yks0ZLOAp7/+PjmqSpN5fK1taor6HeAjKb1g==",
"dev": true,
"dependencies": {
"@vue/devtools-core": "^7.7.2",
"@vue/devtools-kit": "^7.7.2",
"@vue/devtools-shared": "^7.7.2",
"execa": "^9.5.1",
"sirv": "^3.0.0",
"@vue/devtools-core": "^7.7.5",
"@vue/devtools-kit": "^7.7.5",
"@vue/devtools-shared": "^7.7.5",
"execa": "^9.5.2",
"sirv": "^3.0.1",
"vite-plugin-inspect": "0.8.9",
"vite-plugin-vue-inspector": "^5.3.1"
},

@ -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>

@ -0,0 +1,19 @@
<script setup lang="ts">
import { computed, type Component } from 'vue'
import * as icons from '@element-plus/icons-vue'
import { QuestionFilled } from '@element-plus/icons-vue'
const props = defineProps<{
iconName: string
}>()
const iconComponent = computed<Component>(() => {
return (icons as Record<string, Component>)[props.iconName] || QuestionFilled
})
</script>
<template>
<el-icon>
<component :is="iconComponent" />
</el-icon>
</template>

@ -1,12 +0,0 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', () => {
const count = ref(0)
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
return { count, doubleCount, increment }
})

@ -0,0 +1,9 @@
import type { App } from "vue";
import { createPinia } from "pinia";
const store = createPinia();
export function setupStore(app: App<Element>) {
app.use(store);
}
export { store };

@ -0,0 +1,17 @@
import { defineStore } from 'pinia'
import { store } from "@/stores";
export const configStore = defineStore('formConfig', {
state: () => ({
formConfig: {}
}),
getters: {
getFormConfig: (state) => state.formConfig,
},
actions: {
}
})
export function useConfigStore() {
return configStore(store);
}

@ -0,0 +1,17 @@
import { defineStore } from 'pinia'
import { store } from "@/stores";
export const widgetStore = defineStore('widget', {
state: () => ({
widgetList: [],
}),
getters: {
getWidgetList: (state) => state.widgetList,
},
actions: {
}
})
export function useWidgetStore() {
return widgetStore(store);
}

@ -0,0 +1,49 @@
export interface IOption {
// 元素唯一标识符
name: string
// 隐藏状态
hidden: boolean
// 自定义类名
customClass?: string
// 标签名称
label?: string
// 默认值
defaultValue?: string | boolean | number | []
// 提示词
placeholder?: string
// 选择项
optionItems?: []
// 行合并
colspan?: number
// 列合并
rowspan?: number
}
export type ICategory = 'container' | 'formItem'
export interface IWidget {
// 元素唯一标识符
key?: number
// 元素id
id?: string
// 类别
category: ICategory
// 类型
type: string
// 展示名称
displayName: string
// 图标
icon: string
// 子类
rows?: [{ cols: [IWidget] }]
// 属性
options: IOption
// 子结构
widgetList?: []
// 单元格是否被合并
merged?: boolean
}
export interface IWidgetJson {
widgetList: IWidget[]
}

@ -0,0 +1,16 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import melonJson from "./melon.json";
/**
*
* @param widgetJson
*/
export const initJson = (widgetJson: any) => {
widgetJson['widgetList'] = []
// widgetJson['formConfig'] = {}
}
export const addItem = (fatherId = "", widgetJson: any) => {
if (fatherId) { } else {
widgetJson['widgetList'] = [melonJson]
}
}

@ -0,0 +1,174 @@
{
"key": 47004,
"id": "table-61396",
"category": "container",
"type": "table",
"displayName": "表格",
"icon": "Monitor",
"rows": [
{
"cols": [
{
"key": 47005,
"id": "table-cell-12332",
"category": "container",
"type": "table-cell",
"displayName": "子单元格",
"icon": "Monitor",
"merged": false,
"widgetList": [
{
"key": 47016,
"id": "input-12355",
"category": "formItem",
"type": "el-input",
"displayName": "输入框",
"icon": "Folder",
"options": {
"name": "input-12355",
"keyNameEnabled": false,
"keyName": "",
"label": "名称",
"labelAlign": "",
"type": "text",
"defaultValue": "",
"hidden": false,
"customClass": "",
"placeholder": "请输入名称"
}
}
],
"rows": [],
"options": {
"name": "table-cell-12332",
"cellWidth": "",
"cellHeight": "",
"colspan": 1,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
}
},
{
"key": 47015,
"id": "table-cell-12344",
"category": "container",
"type": "table-cell",
"displayName": "子单元格",
"icon": "Monitor",
"merged": false,
"widgetList": [
{
"key": 47016,
"id": "input-12366",
"category": "formItem",
"type": "el-input-number",
"displayName": "输入框",
"icon": "Folder",
"options": {
"name": "input-12366",
"keyNameEnabled": false,
"keyName": "",
"label": "年龄",
"labelAlign": "",
"type": "number",
"defaultValue": "",
"hidden": false,
"customClass": ""
}
}
],
"rows": [],
"options": {
"name": "table-cell-12344",
"cellWidth": "",
"cellHeight": "",
"colspan": 1,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
}
}
]
},
{
"cols": [
{
"key": 47015,
"id": "table-cell-12344",
"category": "container",
"type": "table-cell",
"displayName": "子单元格",
"icon": "Monitor",
"merged": false,
"widgetList": [
{
"key": 47016,
"id": "radio-12377",
"category": "formItem",
"type": "el-radio",
"displayName": "单选框",
"icon": "Folder",
"options": {
"name": "input-12377",
"keyNameEnabled": false,
"keyName": "",
"label": "性别",
"labelAlign": "",
"type": "text",
"defaultValue": "1",
"hidden": false,
"customClass": "",
"optionItems": [
{
"label": "男",
"value": "1"
},
{
"label": "女",
"value": 2
}
]
}
}
],
"rows": [],
"options": {
"name": "table-cell-12344",
"cellWidth": "",
"cellHeight": "",
"colspan": 2,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
}
},
{
"key": 47018,
"id": "table-cell-12399",
"category": "container",
"type": "table-cell",
"displayName": "子单元格",
"icon": "Monitor",
"merged": true,
"widgetList": [],
"rows": [],
"options": {
"name": "table-cell-12399",
"cellWidth": "",
"cellHeight": "",
"colspan": 2,
"rowspan": 1,
"wordBreak": false,
"customClass": ""
}
}
]
}
],
"options": {
"name": "",
"hidden": false,
"customClass": ""
}
}

@ -0,0 +1,58 @@
import type { IWidget } from "@/types/widgetsConfigInterface"
export const containers: IWidget[] = [
{
category: 'container',
type: 'el-table',
displayName: '表格',
icon: 'Monitor',
options: {
name: '',
hidden: false,
}
},
{
category: 'container',
type: 'el-table-column',
displayName: '子单元格',
icon: 'Monitor',
options: {
name: '',
hidden: false,
}
}
]
export const basicFields: IWidget[] = [
{
category: 'formItem',
type: 'el-input',
displayName: '输入框',
icon: 'Folder',
options: {
name: '',
hidden: false,
},
},
{
category: 'formItem',
type: 'el-input-number',
displayName: '数值输入框',
icon: 'Folder',
options: {
name: '',
hidden: false,
},
},
{
category: 'formItem',
type: 'el-redio',
displayName: ' 单选项',
icon: 'Folder',
options: {
name: '',
hidden: false,
},
},
]

@ -1,18 +1,24 @@
<script setup lang="ts">
import { provide, ref } from 'vue'
import { initJson } from '@/utils'
import LeftSide from './subCom/LeftSide.vue'
import NavBar from './subCom/NavBar.vue'
import MainWrapper from './subCom/MainWrapper.vue'
import RightSide from './subCom/RightSide.vue'
const widgetJson = ref({})
initJson(widgetJson['value'])
provide('widgetJson', widgetJson)
</script>
<template>
<section class="h-full flex">
<LeftSide class="w-[260px]" />
<LeftSide class="w-[260px] shrink-0" />
<main class="grow h-full">
<NavBar />
<MainWrapper />
</main>
<RightSide class="w-[300px]" />
<RightSide class="w-[300px] shrink-0" />
</section>
</template>

@ -1,9 +1,28 @@
<script setup lang="ts">
import { ref } from 'vue'
import { DataBoard } from '@element-plus/icons-vue'
import { ref, inject } from 'vue'
import { containers, basicFields } from '@/utils/widgetsConfig'
import { addItem } from '@/utils'
import UseIcon from '@/components/UseIcon.vue'
//
const tabsActive = ref('ZJK')
//
const collapseActive = ref(['RQ', 'JCZD'])
//
const collapseList = ref([
{
display: '容器',
activeName: 'RQ',
subItem: [...containers],
},
{
display: '基础字段',
activeName: 'JCZD',
subItem: [...basicFields],
},
])
//
const widgetJson = inject('widgetJson')
</script>
<template>
@ -11,46 +30,22 @@ const collapseActive = ref(['RQ', 'JCZD'])
<el-tabs v-model="tabsActive">
<el-tab-pane label="组件库" name="ZJK">
<div class="px-2">
<el-collapse v-model="collapseActive">
<el-collapse-item title="容器" name="RQ">
<div class="flex flex-wrap justify-between content-center px-2">
<div
class="basis-2/5 flex justify-between items-center border border-solid border-[#c1c1c1] px-2 mb-4"
>
<el-icon><DataBoard /></el-icon>
<p>组件一</p>
<template v-for="group in collapseList" :key="group['activeName']">
<el-collapse v-model="collapseActive">
<el-collapse-item :title="group['display']" :name="group['activeName']">
<div class="flex flex-wrap justify-between content-center px-2">
<template v-for="item in group['subItem']" :key="item['displayName']">
<div
class="basis-2/5 flex justify-between items-center border border-solid border-[#c1c1c1] px-2 mb-4"
@click="addItem('', widgetJson)">
<UseIcon :iconName="item['icon']"></UseIcon>
<p>{{ item['displayName'] }}</p>
</div>
</template>
</div>
<div
class="basis-2/5 flex justify-between items-center border border-solid border-[#c1c1c1] px-2 mb-4"
>
<el-icon><DataBoard /></el-icon>
<p>组件一</p>
</div>
<div
class="basis-2/5 flex justify-between items-center border border-solid border-[#c1c1c1] px-2 mb-4"
>
<el-icon><DataBoard /></el-icon>
<p>组件一</p>
</div>
</div>
</el-collapse-item>
<el-collapse-item title="基础字段" name="JCZD">
<div class="flex flex-wrap justify-between content-center px-2">
<div
class="basis-2/5 flex justify-between items-center border border-solid border-[#c1c1c1] px-2 mb-4"
>
<el-icon><DataBoard /></el-icon>
<p>组件一</p>
</div>
<div
class="basis-2/5 flex justify-between items-center border border-solid border-[#c1c1c1] px-2 mb-4"
>
<el-icon><DataBoard /></el-icon>
<p>组件一</p>
</div>
</div>
</el-collapse-item>
</el-collapse>
</el-collapse-item>
</el-collapse>
</template>
</div>
</el-tab-pane>
</el-tabs>

@ -1,5 +1,24 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { provide, inject } from 'vue'
import { reactive } from 'vue'
import type { IWidgetJson } from '@/types/widgetsConfigInterface'
import RendererDom from '@/components/RendererDom.vue'
//
const widgetJson = inject<IWidgetJson>('widgetJson')!
//
const docForm = reactive({})
provide('docForm', docForm)
</script>
<template>
<section></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…
Cancel
Save