xy 1 year ago
parent 7cb42fc55c
commit 6bc62282b4

@ -1,52 +1,55 @@
<script> <script>
import { deepCopy } from "@/utils" import { deepCopy } from "@/utils";
import formBuilder from '@/utils/formBuilder' import formBuilder from "@/utils/formBuilder";
import { PopupManager } from "element-ui/lib/utils/popup"; import { PopupManager } from "element-ui/lib/utils/popup";
import { getToken } from "@/utils/auth";
import request from '@/utils/request'
export default { export default {
props: { props: {
isFirstNode: { isFirstNode: {
type: Boolean, type: Boolean,
default: true default: true,
}, },
readable: { readable: {
type: Array, type: Array,
default: () => [], default: () => [],
required: true required: true,
}, },
writeable: { writeable: {
type: Array, type: Array,
default: () => [], default: () => [],
required: true required: true,
}, },
originalForm: { originalForm: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
required: true required: true,
}, },
subForm: { subForm: {
type: Map, type: Map,
default: () => new Map() default: () => new Map(),
}, },
device: { device: {
type: String, type: String,
default: 'desktop', default: "desktop",
required: true required: true,
}, },
fields: { fields: {
type: Array, type: Array,
default: () => [], default: () => [],
required: true required: true,
}, },
fileList: { fileList: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
required: true required: true,
}, },
scriptContent: String, scriptContent: String,
rules: { rules: {
type: Object, type: Object,
default: () => ({}) default: () => ({}),
} },
}, },
data() { data() {
return { return {
@ -57,99 +60,105 @@ export default {
action: process.env.VUE_APP_BASE_API, action: process.env.VUE_APP_BASE_API,
form: {}, form: {},
file: {}, file: {},
} };
}, },
methods: { methods: {
request,
async validate() { async validate() {
return await (this.$refs['elForm'].validate()) return await this.$refs["elForm"].validate();
}
}, },
computed: {
}, },
computed: {},
watch: { watch: {
info(newVal) { info(newVal) {
let keys = newVal.map(i => i.name) let keys = newVal.map((i) => i.name);
keys.forEach(key => { keys.forEach((key) => {
this.form[key] = '' this.form[key] = "";
}) });
}, },
originalForm(newVal) { originalForm(newVal) {
this.form = deepCopy(newVal) this.form = deepCopy(newVal);
}, },
fileList: { fileList: {
handler: function (newVal) { handler: function (newVal) {
this.file = deepCopy(newVal) this.file = deepCopy(newVal);
}, },
immediate: true, immediate: true,
deep: true deep: true,
}, },
scriptContent(newVal) { scriptContent(newVal) {
if (newVal) { if (newVal) {
try { try {
new Function(newVal).bind(this)() new Function(newVal).bind(this)();
} catch (err) { } catch (err) {
console.error(err) console.error(err);
} }
} }
}, },
isShowModal(newVal) { isShowModal(newVal) {
if (newVal) { if (newVal) {
this.zIndex = PopupManager.nextZIndex() this.zIndex = PopupManager.nextZIndex();
}
} }
}, },
},
render(h) { render(h) {
const authFields = this.fields.map(field => ({ const authFields = this.fields.map((field) => ({
...field, ...field,
_readable: this.readable.indexOf(field.id) !== -1 || field.type === 'label', _readable:
this.readable.indexOf(field.id) !== -1 || field.type === "label",
_writeable: this.writeable.indexOf(field.id) !== -1, _writeable: this.writeable.indexOf(field.id) !== -1,
})) }));
authFields.unshift({ authFields.unshift({
name: 'flow_title', name: "flow_title",
label: '工作名称', label: "工作名称",
type: 'text', type: "text",
gs_x: 0, gs_x: 0,
gs_y: 0, gs_y: 0,
gs_width: 12, gs_width: 12,
gs_height: 1, gs_height: 1,
label_show: 1, label_show: 1,
_readable: !this.isFirstNode, _readable: !this.isFirstNode,
_writeable: this.isFirstNode _writeable: this.isFirstNode,
}) });
return h('div',[ return h("div", [
h('el-form', { h(
ref: 'elForm', "el-form",
class: 'form', {
ref: "elForm",
class: "form",
props: { props: {
model: this.form, model: this.form,
'label-position': 'right', "label-position": "right",
'label-width': '100px', "label-width": "100px",
rules: this.rules, rules: this.rules,
'inline-message': true "inline-message": true,
} },
},authFields.map(field => formBuilder.bind(this)(this.device, field, h))), },
authFields.map((field) => formBuilder.bind(this)(this.device, field, h))
),
// //
h('vxe-modal',{ h(
"vxe-modal",
{
props: { props: {
zIndex: this.zIndex, zIndex: this.zIndex,
value: this.isShowModal, value: this.isShowModal,
height: 640, height: 640,
width: 860, width: 860,
'esc-closable': true "esc-closable": true,
}, },
on: { on: {
input: e => { input: (e) => {
this.isShowModal = e this.isShowModal = e;
}
}
}, [
this.modalRender.bind(this)(h)
])
])
}, },
created() {} },
} },
[this.modalRender.bind(this)(h)]
),
]);
},
created() {},
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -303,6 +303,7 @@ export default {
// urldefault_json // urldefault_json
handleDefaultJSON() { handleDefaultJSON() {
try { try {
if(!this.$route.query?.default_json) return
const res = JSON.parse(this.$route.query?.default_json) const res = JSON.parse(this.$route.query?.default_json)
console.log('default_json', res) console.log('default_json', res)
for (let key in this.$route.query) { for (let key in this.$route.query) {

Loading…
Cancel
Save