You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
3.7 KiB

2 years ago
<script>
2 years ago
import { deepCopy } from "@/utils";
import formBuilder from "@/utils/formBuilder";
2 years ago
import { PopupManager } from "element-ui/lib/utils/popup";
2 years ago
import { getToken } from "@/utils/auth";
import request from '@/utils/request'
2 years ago
export default {
props: {
2 years ago
flows: {
type: Array,
default: () => [],
},
2 years ago
isFirstNode: {
type: Boolean,
2 years ago
default: true,
2 years ago
},
2 years ago
readable: {
type: Array,
default: () => [],
2 years ago
required: true,
2 years ago
},
writeable: {
type: Array,
default: () => [],
2 years ago
required: true,
2 years ago
},
2 years ago
originalForm: {
type: Object,
default: () => ({}),
2 years ago
required: true,
2 years ago
},
subForm: {
type: Map,
2 years ago
default: () => new Map(),
2 years ago
},
2 years ago
device: {
type: String,
2 years ago
default: "desktop",
required: true,
2 years ago
},
2 years ago
fields: {
2 years ago
type: Array,
default: () => [],
2 years ago
required: true,
2 years ago
},
fileList: {
type: Object,
default: () => ({}),
2 years ago
required: true,
2 years ago
},
2 years ago
scriptContent: String,
rules: {
type: Object,
2 years ago
default: () => ({}),
},
2 years ago
subRules: {
type: Object,
default: () => ({}),
},
2 years ago
},
data() {
return {
2 years ago
zIndex: PopupManager.nextZIndex(),
isShowModal: false,
modalRender: () => {},
action: process.env.VUE_APP_BASE_API,
2 years ago
form: {},
2 years ago
file: {},
2 years ago
};
2 years ago
},
methods: {
2 years ago
request,
2 years ago
async validate() {
2 years ago
return await this.$refs["elForm"].validate();
2 years ago
}
2 years ago
},
2 years ago
computed: {},
2 years ago
watch: {
info(newVal) {
2 years ago
let keys = newVal.map((i) => i.name);
keys.forEach((key) => {
this.form[key] = "";
});
2 years ago
},
originalForm(newVal) {
2 years ago
this.form = deepCopy(newVal);
2 years ago
},
fileList: {
2 years ago
handler: function (newVal) {
this.file = deepCopy(newVal);
},
immediate: true,
2 years ago
deep: true,
2 years ago
},
scriptContent(newVal) {
2 years ago
if (newVal) {
2 years ago
try {
2 years ago
new Function(newVal).bind(this)();
2 years ago
} catch (err) {
2 years ago
console.error(err);
2 years ago
}
}
2 years ago
},
isShowModal(newVal) {
2 years ago
if (newVal) {
this.zIndex = PopupManager.nextZIndex();
2 years ago
}
2 years ago
},
2 years ago
},
render(h) {
2 years ago
const authFields = this.fields.map((field) => ({
2 years ago
...field,
2 years ago
_readable:
this.readable.indexOf(field.id) !== -1 || field.type === "label",
_writeable: this.writeable.indexOf(field.id) !== -1,
2 years ago
}));
2 years ago
authFields.unshift({
2 years ago
name: "flow_title",
label: "工作名称",
type: "text",
2 years ago
gs_x: 0,
gs_y: 0,
gs_width: 12,
gs_height: 1,
2 years ago
label_show: 1,
2 years ago
_readable: !this.isFirstNode,
2 years ago
_writeable: this.isFirstNode,
});
return h("div", [
h(
"el-form",
{
ref: "elForm",
class: "form",
props: {
model: this.form,
"label-position": "right",
2 years ago
"label-width": "120px",
2 years ago
rules: this.rules,
"inline-message": true,
},
},
authFields.map((field) => formBuilder.bind(this)(this.device, field, h))
),
2 years ago
// 用于编写脚本中弹窗
2 years ago
h(
"vxe-modal",
{
props: {
zIndex: this.zIndex,
value: this.isShowModal,
height: 640,
width: 860,
"esc-closable": true,
},
on: {
input: (e) => {
this.isShowModal = e;
},
},
2 years ago
},
2 years ago
[this.modalRender.bind(this)(h)]
),
]);
},
2 years ago
created() {},
};
2 years ago
</script>
<style scoped lang="scss">
.form {
display: grid;
grid-template-columns: repeat(12, 1fr);
}
::v-deep .el-form-item {
2 years ago
border: 1px solid #dee2e6;
padding: 8px 12px;
margin: -1px 0 0 -1px;
2 years ago
}
2 years ago
::v-deep .el-form-item__content {
2 years ago
}
</style>