|
|
|
|
@ -255,6 +255,7 @@ import MobileForm from "./MobileForm.vue";
|
|
|
|
|
import assign from "./components/assign.vue";
|
|
|
|
|
import forward from "./components/forward.vue";
|
|
|
|
|
import rollback from "./components/rollback.vue";
|
|
|
|
|
import { generateRandomString } from '@/utils'
|
|
|
|
|
import {
|
|
|
|
|
create,
|
|
|
|
|
deal,
|
|
|
|
|
@ -304,6 +305,7 @@ export default {
|
|
|
|
|
rules: {},
|
|
|
|
|
subRules: {},
|
|
|
|
|
flows: [],
|
|
|
|
|
csrf_token: '',
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
@ -342,6 +344,7 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async print(isLog=false) {
|
|
|
|
|
const _this = this
|
|
|
|
|
let customModelId = this.config.customModel.id || this.$route.query.module_id
|
|
|
|
|
const modelRes = await fieldConfig(customModelId,true)
|
|
|
|
|
let pickTemplate = 0
|
|
|
|
|
@ -418,13 +421,13 @@ export default {
|
|
|
|
|
type: 'html',
|
|
|
|
|
download: false
|
|
|
|
|
})
|
|
|
|
|
print(printText, isLog, res.content)
|
|
|
|
|
print(printText, isLog, _this.config.flow, res.content)
|
|
|
|
|
} else {
|
|
|
|
|
print(printText, isLog)
|
|
|
|
|
print(printText, isLog, _this.config.flow)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
generateForm(object, fields, relation = false, pname) {
|
|
|
|
|
generateForm(object, fields, relation = false, pname, pFilelist = this.fileList) {
|
|
|
|
|
fields.forEach((field) => {
|
|
|
|
|
if (field.rules && field.rules.length > 0 && this.writeableFields.find(i => i === field.id) && !relation) {
|
|
|
|
|
this.rules[field.name] = field.rules.map((rule) => {
|
|
|
|
|
@ -482,23 +485,28 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (field.type === "file") {
|
|
|
|
|
this.fileList[field.name] = [];
|
|
|
|
|
pFilelist[field.name] = relation ? [[]] : [];
|
|
|
|
|
}
|
|
|
|
|
if (field.type === "relation") {
|
|
|
|
|
this.subRules[`${field.name}_rules`] = {}
|
|
|
|
|
object[field.name] = [{}];
|
|
|
|
|
pFilelist[field.name] = {}
|
|
|
|
|
|
|
|
|
|
this.generateForm(
|
|
|
|
|
object[field.name][0],
|
|
|
|
|
this.subConfig.get(field.sub_custom_model_id)?.customModel?.fields,
|
|
|
|
|
true,
|
|
|
|
|
field.name
|
|
|
|
|
field.name,
|
|
|
|
|
pFilelist[field.name]
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
object[field.name] = field.default_value ? field.default_value : "";
|
|
|
|
|
if (/\/detail/.test(this.$route.path) && this.$route.query.flow_id) {
|
|
|
|
|
object[field.name] = "";
|
|
|
|
|
} else {
|
|
|
|
|
object[field.name] = (this.writeableFields.indexOf(field.id) !== -1 && 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) {
|
|
|
|
|
@ -553,6 +561,7 @@ export default {
|
|
|
|
|
this.config = res;
|
|
|
|
|
this.generateForm(this.form, fields);
|
|
|
|
|
this.form = Object.assign({}, this.form);
|
|
|
|
|
this.fileList = Object.assign({}, this.fileList);
|
|
|
|
|
const { data } = res?.flow;
|
|
|
|
|
for (let key in data) {
|
|
|
|
|
try {
|
|
|
|
|
@ -581,7 +590,9 @@ export default {
|
|
|
|
|
loading.close();
|
|
|
|
|
}
|
|
|
|
|
} else if (!this.$route.query.flow_id) {
|
|
|
|
|
// 新建
|
|
|
|
|
try {
|
|
|
|
|
this.csrf_token = generateRandomString()
|
|
|
|
|
const res = await preConfig(this.$route.query.module_id);
|
|
|
|
|
const { fields } = res?.customModel;
|
|
|
|
|
let subFormRequest = [];
|
|
|
|
|
@ -603,6 +614,7 @@ export default {
|
|
|
|
|
this.generateForm(this.form, fields);
|
|
|
|
|
this.handleDefaultJSON();
|
|
|
|
|
this.form = Object.assign({}, this.form);
|
|
|
|
|
this.fileList = Object.assign({}, this.fileList);
|
|
|
|
|
loading.close();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
@ -716,6 +728,7 @@ export default {
|
|
|
|
|
callback = () => this.$router.push("/flow/list/todo");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
copyForm['csrf_token'] = this.csrf_token
|
|
|
|
|
this.result = await create(this.$route.query.module_id, copyForm);
|
|
|
|
|
}
|
|
|
|
|
callback();
|
|
|
|
|
|