|
@@ -12,6 +12,7 @@
|
|
|
<script>
|
|
|
import { camelCase, toUnderline } from "@/utils";
|
|
|
import LayoutItem from "./LayoutItem.vue";
|
|
|
+import { cloneDeep } from "lodash";
|
|
|
export default {
|
|
|
name: "LayoutIndex",
|
|
|
props: ["layoutData"],
|
|
@@ -27,7 +28,7 @@ export default {
|
|
|
myLayoutData: {
|
|
|
handler(newVal, oldVal) {
|
|
|
if (newVal) {
|
|
|
- this.initLayoutData(newVal);
|
|
|
+ // this.initLayoutData(newVal);
|
|
|
}
|
|
|
},
|
|
|
deep: true,
|
|
@@ -41,9 +42,9 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
initLayoutData(formData) {
|
|
|
+ console.log(JSON.parse(JSON.stringify(formData)));
|
|
|
let { layoutJson, mainForm, subFormList } = formData;
|
|
|
this.layoutJson = JSON.parse(layoutJson);
|
|
|
- console.log(formData);
|
|
|
this.transformDataFormat(formData);
|
|
|
this.formArray = this.disableHandler(this.formList);
|
|
|
this.setFormInfo(this.layoutJson.list);
|
|
@@ -63,10 +64,13 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (showValue) {
|
|
|
+ console.log("main showValue", showValue);
|
|
|
for (const key of Object.keys(showValue)) {
|
|
|
if (key != "remark") {
|
|
|
showValue[toUnderline(key)] = showValue[key];
|
|
|
- delete showValue[key];
|
|
|
+ if (toUnderline(key) != key) {
|
|
|
+ delete showValue[key];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
mainForm.showTemplate.resultMap = [showValue];
|
|
@@ -88,19 +92,19 @@ export default {
|
|
|
});
|
|
|
if (subFormList && subFormList.length > 0) {
|
|
|
subFormList.forEach((item) => {
|
|
|
- let showValue = null;
|
|
|
+ console.log(JSON.parse(JSON.stringify(item)));
|
|
|
+ let subShowValue = null;
|
|
|
if (item.showValue) {
|
|
|
- showValue = item.showValue[0];
|
|
|
+ subShowValue = item.showValue[0];
|
|
|
}
|
|
|
let defaultValue = {};
|
|
|
- if (showValue) {
|
|
|
+ if (subShowValue) {
|
|
|
if (item.showTemplate.spare == "2") {
|
|
|
//动态表格表单
|
|
|
let batch = {},
|
|
|
tableName = item.formItem?.split(".")?.[0];
|
|
|
batch[tableName] = item.showValue.map((item) => item.resultMap);
|
|
|
defaultValue = JSON.parse(JSON.stringify(batch));
|
|
|
- console.log(JSON.parse(JSON.stringify(batch)));
|
|
|
// 所有字段驼峰转下划线
|
|
|
batch[tableName].forEach((i) => {
|
|
|
for (const key of Object.keys(i)) {
|
|
@@ -116,13 +120,16 @@ export default {
|
|
|
},
|
|
|
];
|
|
|
} else {
|
|
|
- for (const key of Object.keys(item.showValue[0].resultMap)) {
|
|
|
- item.showValue[0].resultMap[toUnderline(key)] =
|
|
|
- item.showValue[0].resultMap[key];
|
|
|
- delete item.showValue[0].resultMap[key];
|
|
|
+ console.log("showValue", subShowValue.resultMap);
|
|
|
+ for (const key of Object.keys(subShowValue.resultMap)) {
|
|
|
+ subShowValue.resultMap[toUnderline(key)] =
|
|
|
+ subShowValue.resultMap[key];
|
|
|
+ if (toUnderline(key) != key) {
|
|
|
+ delete subShowValue.resultMap[key];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- item.showTemplate.resultMap = [item.showValue[0].resultMap];
|
|
|
+ item.showTemplate.resultMap = [subShowValue.resultMap];
|
|
|
}
|
|
|
}
|
|
|
this.formList.push({
|