FormTemplateEditDialog.vue
4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
<el-dialog
:title="title"
:visible="dialogVisible"
:before-close="handleClose"
custom-class="edit-template-dialog"
append-to-body
top="6vh"
>
<el-form :model="form" data-vv-scope="templateForm">
<el-row>
<el-col :span="8">
<ht-form-item label="模板名称" label-width="90px">
<ht-input
v-model="form.templateName"
autocomplete="off"
:validate="{ required: true }"
:maxlength="50"
:showWordLimit="true"
></ht-input>
</ht-form-item>
</el-col>
<el-col :span="8">
<ht-form-item label="模板别名" label-width="90px">
<ht-input
v-if="form.id"
disabled
v-pinyin="form.templateName"
v-model="form.alias"
autocomplete="off"
></ht-input>
<ht-input
v-else
v-pinyin="form.templateName"
v-model="form.alias"
autocomplete="off"
:validate="{ required: true }"
/>
</ht-form-item>
</el-col>
<el-col :span="8">
<ht-form-item label="类型" label-width="90px">
<ht-select
v-model="form.templateType"
:options="templateType"
:validate="{ required: true }"
></ht-select>
</ht-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="22">
<ht-form-item label="模板描述" label-width="90px">
<ht-input
style="width: 97%"
v-model="form.templateDesc"
autocomplete="off"
:validate="{ required: true }"
:maxlength="200"
:showWordLimit="true"
></ht-input>
</ht-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="22">
<ht-form-item label="模板内容" label-width="90px">
<codemirror ref="scriptText" v-validate="{required:true}" v-model="form.html" :options="cmOptions" class="code" style="width: 99%;height:100%;"></codemirror>
</ht-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<ht-submit-button
:url="saveUrl()"
:model="form"
:is-submit="isSubmit"
scope-name="templateForm"
@before-save-data="beforeSaveData()"
@after-save-data="afterSaveData"
>保存</ht-submit-button
>
</div>
</el-dialog>
</template>
<script>
export default {
props: ["dialogData"],
data() {
return {
title: "",
dialogVisible: false,
isSubmit: false,
form: {
html: "",
alias: "",
templateDesc: "",
templateName: "",
templateType: "",
source: ""
},
templateType: [
{ key: "macro", value: "宏模板" },
{ key: "queryDataTemplate", value: "查询模板" },
{ key: "dataTemplate", value: "业务数据模板" },
{ key: "formDesign", value: "表单设计模板" }
],
cmOptions: {
value: "",
mode: "vue",
readOnly: false,
tabSize: 2,
theme: 'base16-light',
lineNumbers: true,
line: true,
}
};
},
methods: {
//保存地址
saveUrl() {
return window.context.form + "/form/template/v1/save";
},
//保存前
beforeSaveData() {
this.isSubmit = true;
if(this.form.source != "system"){
this.form.source = "custom";
}
},
//保存后
afterSaveData() {
this.dialogVisible = false;
this.init();
this.$emit("loadData");
},
init(){
this.form = {
html: "",
alias: "",
templateDesc: "",
templateName: "",
templateType: "",
source: ""
};
},
//关闭对话
handleClose() {
this.dialogVisible = false;
this.$emit("loadData");
this.init();
},
//打开对话
openDialog() {
this.title = this.dialogData.title;
if (this.dialogData.formData) {
this.form = this.dialogData.formData;
}
this.dialogVisible = true;
}
}
};
</script>
<style lang="scss" scoped>
/deep/.edit-template-dialog{
width: 70%;
}
@media screen and (max-width: 1680px) {
/deep/.edit-template-dialog{
width: 96%;
}
}
</style>