|
|
|
|
@ -54,7 +54,10 @@ export default {
|
|
|
|
|
props: {
|
|
|
|
|
label: i.name,
|
|
|
|
|
prop: i.field,
|
|
|
|
|
required: i.validation instanceof Array ? !!i.validation.find(i => i === 'required') : false,
|
|
|
|
|
required:
|
|
|
|
|
i.validation instanceof Array
|
|
|
|
|
? !!i.validation.find((i) => i === "required")
|
|
|
|
|
: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
[
|
|
|
|
|
@ -63,7 +66,7 @@ export default {
|
|
|
|
|
{
|
|
|
|
|
ref: `elEdit_${i.field}`,
|
|
|
|
|
style: {
|
|
|
|
|
width: '100%'
|
|
|
|
|
width: "100%",
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
...addPropsMap.get(i.edit_input),
|
|
|
|
|
@ -83,6 +86,55 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
scopedSlots:
|
|
|
|
|
i.edit_input === "file" || i.edit_input === "files"
|
|
|
|
|
? {
|
|
|
|
|
file: (scope) => {
|
|
|
|
|
let { file } = scope;
|
|
|
|
|
|
|
|
|
|
console.log(111, file);
|
|
|
|
|
return [
|
|
|
|
|
h("div", {}, [
|
|
|
|
|
h("i", {
|
|
|
|
|
class: {
|
|
|
|
|
"el-icon-circle-check":
|
|
|
|
|
file.status === "success",
|
|
|
|
|
"el-icon-loading":
|
|
|
|
|
file.status === "uploading",
|
|
|
|
|
},
|
|
|
|
|
style: {
|
|
|
|
|
"color": file.status === "success" ? "green" : ""
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
h(
|
|
|
|
|
"a",
|
|
|
|
|
{
|
|
|
|
|
attrs: {
|
|
|
|
|
href: file.url,
|
|
|
|
|
download: file.name,
|
|
|
|
|
},
|
|
|
|
|
class: {
|
|
|
|
|
"uploaded-a":
|
|
|
|
|
file.status === "success",
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
file.name
|
|
|
|
|
)
|
|
|
|
|
]),
|
|
|
|
|
h("i", {
|
|
|
|
|
class: "el-icon-close",
|
|
|
|
|
on: {
|
|
|
|
|
["click"]: () =>
|
|
|
|
|
this.fileRemoveHandler(
|
|
|
|
|
file,
|
|
|
|
|
i.field
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: "",
|
|
|
|
|
},
|
|
|
|
|
this.optionsRender(h, i)
|
|
|
|
|
),
|
|
|
|
|
@ -140,12 +192,14 @@ export default {
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
form: {},
|
|
|
|
|
rules: {},
|
|
|
|
|
file: {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
file: {},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
fileRemoveHandler(file, field) {
|
|
|
|
|
this.file[field] = this.file[field].filter((item) => item !== file);
|
|
|
|
|
this.file = Object.assign({}, this.file);
|
|
|
|
|
},
|
|
|
|
|
//on事件类别获取
|
|
|
|
|
getEventType(info) {
|
|
|
|
|
if (info.type === "checkbox") {
|
|
|
|
|
@ -159,11 +213,13 @@ export default {
|
|
|
|
|
if (info.edit_input === "checkbox" || info.edit_input === "radio") {
|
|
|
|
|
return info._paramters && info._paramters instanceof Array
|
|
|
|
|
? info._paramters.map((i) =>
|
|
|
|
|
h(
|
|
|
|
|
"el-option",
|
|
|
|
|
{ props: { label: i.name || i.no || i.value || i.id , value : i.id } }
|
|
|
|
|
h("el-option", {
|
|
|
|
|
props: {
|
|
|
|
|
label: i.name || i.no || i.value || i.id,
|
|
|
|
|
value: i.id,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
: [];
|
|
|
|
|
}
|
|
|
|
|
if (info.edit_input === "file" || info.edit_input === "files") {
|
|
|
|
|
@ -230,6 +286,14 @@ export default {
|
|
|
|
|
props.onRemove = (file, fileList) => {
|
|
|
|
|
this.file[info.field] = fileList;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
props.onError = (err,file,fileList) => {
|
|
|
|
|
this.file[info.field] = fileList;
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "warning",
|
|
|
|
|
message: err
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return props;
|
|
|
|
|
},
|
|
|
|
|
@ -270,6 +334,18 @@ export default {
|
|
|
|
|
const res = await show({ id: this.id, table_name: this.tableName });
|
|
|
|
|
this.$integrateData(this.form, res);
|
|
|
|
|
this.form = Object.assign({}, this.form);
|
|
|
|
|
|
|
|
|
|
this.formInfo.forEach((i) => {
|
|
|
|
|
if (i && i.edit_input === "file") {
|
|
|
|
|
this.file[i.field] = [
|
|
|
|
|
{
|
|
|
|
|
name: res[i.link_with_name]?.original_name,
|
|
|
|
|
url: res[i.link_with_name]?.url,
|
|
|
|
|
response: res[i.link_with_name],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
|
@ -294,8 +370,8 @@ export default {
|
|
|
|
|
(i) => i?.response?.id
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if(info.edit_input === "file") {
|
|
|
|
|
this.form[info.field] = this.file[info.field][0]?.response?.id
|
|
|
|
|
if (info.edit_input === "file") {
|
|
|
|
|
this.form[info.field] = this.file[info.field][0]?.response?.id;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log(this.form);
|
|
|
|
|
@ -322,7 +398,11 @@ export default {
|
|
|
|
|
newVal.forEach((i) => {
|
|
|
|
|
if (i.field) {
|
|
|
|
|
this.form[i.field] = "";
|
|
|
|
|
if (i.validation instanceof Array && i.validation.length > 0 && !!i.validation.find(i => i === 'required')) {
|
|
|
|
|
if (
|
|
|
|
|
i.validation instanceof Array &&
|
|
|
|
|
i.validation.length > 0 &&
|
|
|
|
|
!!i.validation.find((i) => i === "required")
|
|
|
|
|
) {
|
|
|
|
|
this.rules[i.field] = [
|
|
|
|
|
{ required: true, message: `请填写${i.name}` },
|
|
|
|
|
];
|
|
|
|
|
@ -330,7 +410,7 @@ export default {
|
|
|
|
|
if (i.edit_input === "files") {
|
|
|
|
|
this.form[i.field] = [];
|
|
|
|
|
}
|
|
|
|
|
if(i.edit_input === "files" || i.edit_input === "file") {
|
|
|
|
|
if (i.edit_input === "files" || i.edit_input === "file") {
|
|
|
|
|
this.file[i.field] = [];
|
|
|
|
|
}
|
|
|
|
|
if (i.edit_input === "checkbox") {
|
|
|
|
|
@ -359,4 +439,15 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss"></style>
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.uploaded-a {
|
|
|
|
|
color: red;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
transition: all 0.2s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.uploaded-a:hover {
|
|
|
|
|
color: red;
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|