From 4500b9fb772d78e67113f956ccce3f6fb962ef88 Mon Sep 17 00:00:00 2001
From: quantulr <35954003+quantulr@users.noreply.github.com>
Date: Thu, 15 Dec 2022 22:25:46 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BA=A7=E8=81=94=E9=80=89=E6=8B=A9=E5=99=A8,?=
=?UTF-8?q?=20=E5=88=A0=E9=99=A4=E8=A1=8C=E5=B8=83=E5=B1=80=E5=AD=90?=
=?UTF-8?q?=E5=85=83=E7=B4=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/generator/config.js | 8 +++---
src/utils/generator/render.jsx | 31 ++++++++++++++------
src/views/tool/build/DraggableItem.jsx | 40 ++++++++++++--------------
3 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/src/utils/generator/config.js b/src/utils/generator/config.js
index 84d34fe..d3b4b52 100644
--- a/src/utils/generator/config.js
+++ b/src/utils/generator/config.js
@@ -421,8 +421,8 @@ export const selectComponents = [
style: { width: "100%" },
disabled: false,
clearable: true,
- format: "yyyy-MM-dd",
- "value-format": "yyyy-MM-dd",
+ format: "YYYY-MM-DD",
+ "value-format": "YYYY-MM-DD",
readonly: false,
},
{
@@ -447,8 +447,8 @@ export const selectComponents = [
"end-placeholder": "结束日期",
disabled: false,
clearable: true,
- format: "yyyy-MM-dd",
- "value-format": "yyyy-MM-dd",
+ format: "YYYY-MM-DD",
+ "value-format": "YYYY-MM-DD",
readonly: false,
},
{
diff --git a/src/utils/generator/render.jsx b/src/utils/generator/render.jsx
index 927ea45..51c408a 100644
--- a/src/utils/generator/render.jsx
+++ b/src/utils/generator/render.jsx
@@ -66,6 +66,7 @@ function mountSlotFiles(confClone, children) {
if (childObjs) {
Object.keys(childObjs).forEach((key) => {
const childFunc = childObjs[key];
+ console.log(childFunc);
if (confClone.__slot__ && confClone.__slot__[key]) {
children.push(childFunc(confClone, key));
}
@@ -217,6 +218,7 @@ export default defineComponent({
render() {
const dataObject = makeDataObject();
const confClone = deepClone(this.$props.conf);
+ console.log(this.$slots.default, "lot");
const children = [];
// 如果slots文件夹存在与当前tag同名的文件,则执行文件中的代码
mountSlotFiles(confClone, children);
@@ -225,16 +227,29 @@ export default defineComponent({
// 将json表单配置转化为vue render可以识别的 “数据对象(dataObject)”
buildDataObject.call(this, confClone, dataObject);
- console.log(dataObject);
const Tag = formComponentsMap[this.$props.conf.__config__.tag];
+
+ // return h(Tag, dataObject.attrs, children);
return (
-
- {children}
-
+ <>
+ {children.length > 0 ? (
+
+ {children}
+
+ ) : (
+
+ )}
+ >
+
+ //
);
},
// render() {
diff --git a/src/views/tool/build/DraggableItem.jsx b/src/views/tool/build/DraggableItem.jsx
index de04822..77e3613 100644
--- a/src/views/tool/build/DraggableItem.jsx
+++ b/src/views/tool/build/DraggableItem.jsx
@@ -37,14 +37,15 @@ const components = {
const layouts = {
colFormItem(
// h,
- currentItem
- // index,
- // list
+ currentItem,
+ index,
+ list
) {
const { onActiveItem } = this.$attrs;
const config = currentItem.__config__;
// console.log(arguments, "argu");
const child = renderChildren.apply(this, arguments);
+
let className =
this.activeId === config.formId
? "drawing-item active-from-item"
@@ -81,7 +82,9 @@ const layouts = {
// config.defaultValue = event;
}}
>
- {child}
+ {{
+ default: child,
+ }}
{components.itemBtns.apply(this, arguments)}
@@ -90,9 +93,9 @@ const layouts = {
},
rowFormItem(
// h,
- currentItem
- // index,
- // list
+ currentItem,
+ index,
+ list
) {
const { onActiveItem } = this.$attrs;
const config = currentItem.__config__;
@@ -141,13 +144,9 @@ const layouts = {
{{
item: ({ element, index }) => {
const layout = layouts[element.__config__.layout];
+ console.log(element, "element");
if (layout) {
- return layout.call(
- this,
- element,
- index,
- element.__config__.children
- );
+ return layout.call(this, element, index, config.children);
}
return layoutIsNotFound.call(this);
},
@@ -160,9 +159,9 @@ const layouts = {
},
raw(
// h,
- currentItem
- // index,
- // list
+ currentItem,
+ index,
+ list
) {
const config = currentItem.__config__;
const child = renderChildren.apply(this, arguments);
@@ -171,9 +170,6 @@ const layouts = {
key={config.renderKey}
conf={currentItem}
onInput={(event) => {
- // console.log(event, "oninput");
- // // this.$set(config, "defaultValue", event);
- // // console.log(this.currentItem.__config__.defaultValue);
this.currentItem.__config__.defaultValue = event;
}}
>
@@ -185,9 +181,9 @@ const layouts = {
function renderChildren(
// // h,
- currentItem
- // // index,
- // // list
+ currentItem,
+ index,
+ list
) {
const config = currentItem.__config__;
// // console.log(config, "config");