|
|
|
|
@ -55,6 +55,7 @@
|
|
|
|
|
:script-content="scriptContent"
|
|
|
|
|
:writeable="writeableFields"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
:sub-rules="subRules"
|
|
|
|
|
></DesktopForm>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
@ -300,6 +301,7 @@ export default {
|
|
|
|
|
result: {},
|
|
|
|
|
fileList: {},
|
|
|
|
|
rules: {},
|
|
|
|
|
subRules: {},
|
|
|
|
|
flows: [],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
@ -421,10 +423,9 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
generateForm(object, fields) {
|
|
|
|
|
this.rules = {};
|
|
|
|
|
generateForm(object, fields, relation = false, pname) {
|
|
|
|
|
fields.forEach((field) => {
|
|
|
|
|
if (field.rules && field.rules.length > 0 && this.writeableFields.find(i => i.id === field.id)) {
|
|
|
|
|
if (field.rules && field.rules.length > 0 && this.writeableFields.find(i => i === field.id) && !relation) {
|
|
|
|
|
this.rules[field.name] = field.rules.map((rule) => {
|
|
|
|
|
switch (rule) {
|
|
|
|
|
case "required":
|
|
|
|
|
@ -451,21 +452,52 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (relation) {
|
|
|
|
|
this.subRules[`${pname}_rules`][field.name] = field.rules.map((rule) => {
|
|
|
|
|
switch (rule) {
|
|
|
|
|
case "required":
|
|
|
|
|
return {
|
|
|
|
|
required: true,
|
|
|
|
|
message: `请填写${field.label}`,
|
|
|
|
|
};
|
|
|
|
|
default:
|
|
|
|
|
return {
|
|
|
|
|
validator: ({ cellValue }) => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
if (validation.get(rule).test(cellValue) || cellValue === '') {
|
|
|
|
|
resolve()
|
|
|
|
|
} else {
|
|
|
|
|
reject(
|
|
|
|
|
new Error(
|
|
|
|
|
`${field.label}必须为${validationName.get(rule)}`
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (field.type === "file") {
|
|
|
|
|
this.fileList[field.name] = [];
|
|
|
|
|
}
|
|
|
|
|
if (field.type === "relation") {
|
|
|
|
|
this.subRules[`${field.name}_rules`] = {}
|
|
|
|
|
object[field.name] = [{}];
|
|
|
|
|
|
|
|
|
|
this.generateForm(
|
|
|
|
|
object[field.name][0],
|
|
|
|
|
this.subConfig.get(field.sub_custom_model_id)?.customModel?.fields
|
|
|
|
|
this.subConfig.get(field.sub_custom_model_id)?.customModel?.fields,
|
|
|
|
|
true,
|
|
|
|
|
field.name
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
object[field.name] = field.default_value ? field.default_value : "";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(345, this.rules)
|
|
|
|
|
this.form['flow_title'] = this.config?.flow?.title ?? `${this.config.customModel.name}(${this.$store.getters.name} ${this.$moment().format('YYYY-MM-DD HH:mm')})`
|
|
|
|
|
},
|
|
|
|
|
formatTime(time) {
|
|
|
|
|
|