|
|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
<script>
|
|
|
|
|
import linkPickModal from './linkPickModal.vue'
|
|
|
|
|
import {save, show, index, destroy} from "@/api/system/baseForm";
|
|
|
|
|
import linkPickModal from "./linkPickModal.vue";
|
|
|
|
|
import { save, show, index, destroy } from "@/api/system/baseForm";
|
|
|
|
|
import { getparameter } from "@/api/system/dictionary";
|
|
|
|
|
import { domMap } from "@/const/inputType";
|
|
|
|
|
import { addPropsMap } from "@/const/addProps";
|
|
|
|
|
import {deepCopy} from "@/utils";
|
|
|
|
|
import { deepCopy } from "@/utils";
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
linkPickModal
|
|
|
|
|
linkPickModal,
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
formInfo: {
|
|
|
|
|
@ -17,7 +17,7 @@ export default {
|
|
|
|
|
tableName: String,
|
|
|
|
|
},
|
|
|
|
|
render(h) {
|
|
|
|
|
return h('div',[
|
|
|
|
|
return h("div", [
|
|
|
|
|
h(
|
|
|
|
|
"el-dialog",
|
|
|
|
|
{
|
|
|
|
|
@ -47,7 +47,9 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
(() => {
|
|
|
|
|
let dom = [];
|
|
|
|
|
this.formInfo.filter(i => i.form_show).forEach((i, index) => {
|
|
|
|
|
this.formInfo
|
|
|
|
|
.filter((i) => i.form_show)
|
|
|
|
|
.forEach((i, index) => {
|
|
|
|
|
dom.push(
|
|
|
|
|
h(
|
|
|
|
|
"el-form-item",
|
|
|
|
|
@ -66,38 +68,74 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
this.$scopedSlots[i.field]
|
|
|
|
|
? this.$scopedSlots[i.field]({ fieldInfo: i, form: this.form, file: this.file })
|
|
|
|
|
: i._relations ?
|
|
|
|
|
[
|
|
|
|
|
h('el-input',{
|
|
|
|
|
? this.$scopedSlots[i.field]({
|
|
|
|
|
fieldInfo: i,
|
|
|
|
|
form: this.form,
|
|
|
|
|
file: this.file,
|
|
|
|
|
})
|
|
|
|
|
: i._relations
|
|
|
|
|
? [
|
|
|
|
|
h(
|
|
|
|
|
"el-input",
|
|
|
|
|
{
|
|
|
|
|
props: {
|
|
|
|
|
readonly: true,
|
|
|
|
|
value: (this.form[i.field] && this.form[i.field] instanceof Array) ? this.form[i.field]?.map(i => i.name || i.mingcheng || i.xingming || i.no || i.id)?.toString() : ''
|
|
|
|
|
value:
|
|
|
|
|
i._relations.link_relation ===
|
|
|
|
|
"newHasOne" ||
|
|
|
|
|
i._relations.link_relation === "hasOne"
|
|
|
|
|
? this.originalForm[
|
|
|
|
|
i._relations.link_with_name
|
|
|
|
|
]?.name ||
|
|
|
|
|
this.originalForm[
|
|
|
|
|
i._relations.link_with_name
|
|
|
|
|
]?.mingcheng ||
|
|
|
|
|
this.originalForm[
|
|
|
|
|
i._relations.link_with_name
|
|
|
|
|
]?.no ||
|
|
|
|
|
this.originalForm[
|
|
|
|
|
i._relations.link_with_name
|
|
|
|
|
]?.id
|
|
|
|
|
: this.originalForm[
|
|
|
|
|
i._relations.link_with_name
|
|
|
|
|
]
|
|
|
|
|
?.map(
|
|
|
|
|
(j) =>
|
|
|
|
|
j[i._relations.custom_form_field]
|
|
|
|
|
)
|
|
|
|
|
?.toString(),
|
|
|
|
|
},
|
|
|
|
|
on: {
|
|
|
|
|
// ['focus']:e => {
|
|
|
|
|
// this.$refs['linkPickModal'].show()
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
},[
|
|
|
|
|
h('el-button',{
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
[
|
|
|
|
|
h("el-button", {
|
|
|
|
|
props: {
|
|
|
|
|
icon: 'el-icon-document'
|
|
|
|
|
icon: "el-icon-arrow-right",
|
|
|
|
|
},
|
|
|
|
|
slot: 'append',
|
|
|
|
|
slot: "append",
|
|
|
|
|
on: {
|
|
|
|
|
click:e => {
|
|
|
|
|
click: (e) => {
|
|
|
|
|
this.pickedLinkField.field = i.field;
|
|
|
|
|
this.pickedLinkField.linkType = i._relations.link_relation;
|
|
|
|
|
this.pickedLinkField.linkTableName = i._relations.link_table_name;
|
|
|
|
|
this.$refs['linkPickModal'].show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
])
|
|
|
|
|
this.pickedLinkField.linkType =
|
|
|
|
|
i._relations.link_relation;
|
|
|
|
|
this.pickedLinkField.linkTableName =
|
|
|
|
|
i._relations.link_table_name;
|
|
|
|
|
this.pickedLinkField.originalRows =
|
|
|
|
|
this.originalForm[
|
|
|
|
|
i._relations.link_with_name
|
|
|
|
|
];
|
|
|
|
|
this.$refs["linkPickModal"].show();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
]
|
|
|
|
|
:
|
|
|
|
|
[
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
: [
|
|
|
|
|
h(
|
|
|
|
|
domMap.get(i.edit_input),
|
|
|
|
|
{
|
|
|
|
|
@ -156,7 +194,7 @@ export default {
|
|
|
|
|
file.status === "success",
|
|
|
|
|
},
|
|
|
|
|
style: {
|
|
|
|
|
'padding': '0 4px'
|
|
|
|
|
padding: "0 4px",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
file.name
|
|
|
|
|
@ -224,21 +262,22 @@ export default {
|
|
|
|
|
]),
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
h('linkPickModal',{
|
|
|
|
|
ref: 'linkPickModal',
|
|
|
|
|
h("linkPickModal", {
|
|
|
|
|
ref: "linkPickModal",
|
|
|
|
|
props: {
|
|
|
|
|
linkType: this.pickedLinkField.linkType,
|
|
|
|
|
linkTableName: this.pickedLinkField.linkTableName,
|
|
|
|
|
field: this.pickedLinkField.field
|
|
|
|
|
field: this.pickedLinkField.field,
|
|
|
|
|
originalRows: this.pickedLinkField.originalRows,
|
|
|
|
|
},
|
|
|
|
|
on: {
|
|
|
|
|
['confirm']:({ field, value }) => {
|
|
|
|
|
this.form[field] = value
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
])
|
|
|
|
|
["confirm"]: ({ field, value }) => {
|
|
|
|
|
this.form[field] = value;
|
|
|
|
|
console.log(this.form);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
]);
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
@ -251,10 +290,11 @@ export default {
|
|
|
|
|
file: {},
|
|
|
|
|
|
|
|
|
|
pickedLinkField: {
|
|
|
|
|
linkType: '',
|
|
|
|
|
linkTableName: '',
|
|
|
|
|
field: '',
|
|
|
|
|
}
|
|
|
|
|
linkType: "",
|
|
|
|
|
linkTableName: "",
|
|
|
|
|
field: "",
|
|
|
|
|
originalRows: [],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
@ -277,8 +317,11 @@ export default {
|
|
|
|
|
? info._params.map((i) =>
|
|
|
|
|
h("el-option", {
|
|
|
|
|
props: {
|
|
|
|
|
label: i.key || i.value || i.name || i.no || i.mingcheng || i.id,
|
|
|
|
|
value: info._relations ? i[info._relations.foreign_key] : i.value,
|
|
|
|
|
label:
|
|
|
|
|
i.key || i.value || i.name || i.no || i.mingcheng || i.id,
|
|
|
|
|
value: info._relations
|
|
|
|
|
? i[info._relations.foreign_key]
|
|
|
|
|
: i.value,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
@ -398,21 +441,25 @@ export default {
|
|
|
|
|
this.form = Object.assign({}, this.form);
|
|
|
|
|
|
|
|
|
|
this.formInfo.forEach((i) => {
|
|
|
|
|
if (i && (i.edit_input === "file" || i.edit_input === 'files')) {
|
|
|
|
|
res[i._relations.link_with_name] ? (
|
|
|
|
|
this.file[i.field] = res[i._relations.link_with_name] instanceof Array ? res[i._relations.link_with_name].map(i => {
|
|
|
|
|
if (i && (i.edit_input === "file" || i.edit_input === "files")) {
|
|
|
|
|
res[i._relations.link_with_name]
|
|
|
|
|
? (this.file[i.field] =
|
|
|
|
|
res[i._relations.link_with_name] instanceof Array
|
|
|
|
|
? res[i._relations.link_with_name].map((i) => {
|
|
|
|
|
return {
|
|
|
|
|
name: i?.original_name,
|
|
|
|
|
url: i?.url,
|
|
|
|
|
response: i
|
|
|
|
|
}
|
|
|
|
|
}) : [{
|
|
|
|
|
response: i,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
: [
|
|
|
|
|
{
|
|
|
|
|
name: res[i._relations.link_with_name]?.original_name,
|
|
|
|
|
url: res[i._relations.link_with_name]?.url,
|
|
|
|
|
response: res[i._relations.link_with_name]
|
|
|
|
|
}]
|
|
|
|
|
) : this.file[i.field] = []
|
|
|
|
|
|
|
|
|
|
response: res[i._relations.link_with_name],
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
: (this.file[i.field] = []);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -477,19 +524,19 @@ export default {
|
|
|
|
|
copyForm[info._relations.link_with_name] = copyForm[
|
|
|
|
|
info.field
|
|
|
|
|
]?.map((i) => {
|
|
|
|
|
let copyRelation = info._params.find(
|
|
|
|
|
(param) => param[info._relations?.foreign_key] === i
|
|
|
|
|
)
|
|
|
|
|
? deepCopy(
|
|
|
|
|
info._params.find(
|
|
|
|
|
(param) => param[info._relations?.foreign_key] === i
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
: "";
|
|
|
|
|
delete copyRelation.id;
|
|
|
|
|
// let copyRelation = info._params.find(
|
|
|
|
|
// (param) => param[info._relations?.foreign_key] === i
|
|
|
|
|
// )
|
|
|
|
|
// ? deepCopy(
|
|
|
|
|
// info._params.find(
|
|
|
|
|
// (param) => param[info._relations?.foreign_key] === i
|
|
|
|
|
// )
|
|
|
|
|
// )
|
|
|
|
|
// : "";
|
|
|
|
|
// delete copyRelation.id;
|
|
|
|
|
return {
|
|
|
|
|
[info._relations.custom_form_field]: i.id,
|
|
|
|
|
...copyRelation,
|
|
|
|
|
[info._relations.custom_form_field]: i,
|
|
|
|
|
//...copyRelation,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -508,26 +555,26 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
let copyRelation = deepCopy(
|
|
|
|
|
info._params.find(
|
|
|
|
|
(param) => param.id == this.form[info.field]
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
if (copyRelation) {
|
|
|
|
|
delete copyRelation.id;
|
|
|
|
|
copyForm[info._relations.link_with_name] = [
|
|
|
|
|
{
|
|
|
|
|
id: this.form[info._relations?.link_with_name]?.id,
|
|
|
|
|
[info.field === "shenhebumen"
|
|
|
|
|
? "dept_id"
|
|
|
|
|
: info._relations.foreign_key]: this.form[info.field],
|
|
|
|
|
...copyRelation,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
// let copyRelation = deepCopy(
|
|
|
|
|
// info._params.find(
|
|
|
|
|
// (param) => param.id == this.form[info.field]
|
|
|
|
|
// )
|
|
|
|
|
// );
|
|
|
|
|
// if (copyRelation) {
|
|
|
|
|
// delete copyRelation.id;
|
|
|
|
|
// copyForm[info._relations.link_with_name] = [
|
|
|
|
|
// {
|
|
|
|
|
// id: this.form[info._relations?.link_with_name]?.id,
|
|
|
|
|
// [info.field === "shenhebumen"
|
|
|
|
|
// ? "dept_id"
|
|
|
|
|
// : info._relations.foreign_key]: this.form[info.field],
|
|
|
|
|
// ...copyRelation,
|
|
|
|
|
// },
|
|
|
|
|
// ];
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete copyForm[info.field];
|
|
|
|
|
//delete copyForm[info.field];
|
|
|
|
|
}
|
|
|
|
|
if (!copyForm[info._relations?.link_with_name]) {
|
|
|
|
|
delete copyForm[info._relations?.link_with_name];
|
|
|
|
|
@ -589,7 +636,10 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
document.documentElement.style.setProperty('--column-num', Math.floor(newVal.length / 8).toString())
|
|
|
|
|
document.documentElement.style.setProperty(
|
|
|
|
|
"--column-num",
|
|
|
|
|
Math.floor(newVal.length / 8).toString()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
//immediate: true,
|
|
|
|
|
},
|
|
|
|
|
|