6
6
<el-tab-pane label =" 系统内置" >
7
7
<el-form label-width =" 80px" >
8
8
<div class =" test-form" >
9
- <parser :key =" key2" :form-conf =" formConf" @submit =" sumbitForm2" @bind =" bind" />
9
+ <el-form ref =" form" :model =" form" :rules =" rules" size =" small" label-width =" 100px" >
10
+ <el-form-item label =" 系统名称" prop =" sys_app_name" >
11
+ <el-input v-model =" form.sys_app_name" placeholder =" 请输入系统名称" clearable :style =" {width: '100%'}" />
12
+ </el-form-item >
13
+ <el-form-item label =" 系统logo" prop =" sys_app_logo" required >
14
+ <img v-if =" form.sys_app_logo" :src =" form.sys_app_logo" class =" el-upload el-upload--picture-card" style =" float :left " >
15
+ <el-upload ref =" sys_app_logo" :headers =" headers" :file-list =" sys_app_logofileList" :action =" sys_app_logoAction" style =" float :left " :before-upload =" sys_app_logoBeforeUpload" list-type =" picture-card" :show-file-list =" false" :on-success =" uploadSuccess" >
16
+ <i class =" el-icon-plus" />
17
+ </el-upload >
18
+ </el-form-item >
19
+ <el-form-item label =" 初始密码" prop =" sys_user_initPassword" >
20
+ <el-input v-model =" form.sys_user_initPassword" placeholder =" 请输入初始密码" clearable :style =" {width: '100%'}" />
21
+ </el-form-item >
22
+ <el-form-item label =" 皮肤样式" prop =" sys_index_skinName" >
23
+ <el-select v-model =" form.sys_index_skinName" placeholder =" 请选择皮肤样式" clearable :style =" {width: '100%'}" >
24
+ <el-option v-for =" (item, index) in sys_index_skinNameOptions" :key =" index" :label =" item.label" :value =" item.value" :disabled =" item.disabled" />
25
+ </el-select >
26
+ </el-form-item >
27
+ <el-form-item label =" 侧栏主题" prop =" sys_index_sideTheme" >
28
+ <el-select v-model =" form.sys_index_sideTheme" placeholder =" 请选择侧栏主题" clearable :style =" {width: '100%'}" >
29
+ <el-option v-for =" (item, index) in sys_index_sideThemeOptions" :key =" index" :label =" item.label" :value =" item.value" :disabled =" item.disabled" />
30
+ </el-select >
31
+ </el-form-item >
32
+ <el-form-item size =" large" >
33
+ <el-button type =" primary" @click =" submitForm" >提交</el-button >
34
+ <el-button @click =" resetForm" >重置</el-button >
35
+ </el-form-item >
36
+ </el-form >
10
37
</div >
11
38
</el-form >
12
39
</el-tab-pane >
19
46
</template >
20
47
21
48
<script >
22
- import { getSetConfig , updateSetConfig } from ' @/api/admin/sys-config'
23
- import Parser from ' @/components/FormGenParser/Parser'
49
+ import {
50
+ getSetConfig ,
51
+ updateSetConfig
52
+ } from ' @/api/admin/sys-config'
53
+
54
+ import { getToken } from ' @/utils/auth'
24
55
25
56
export default {
26
57
name: ' SysConfigSet' ,
27
58
components: {
28
- Parser
29
59
},
30
60
data () {
31
61
return {
32
62
// 遮罩层
33
63
loading: true ,
34
64
// 参数表格数据
35
65
configList: [],
36
- key2: + new Date (),
37
- formConf: {}
66
+ formConf: {},
67
+ headers: { ' Authorization' : ' Bearer ' + getToken () },
68
+ form: {
69
+ sys_app_name: undefined ,
70
+ sys_app_logo: null ,
71
+ sys_user_initPassword: undefined ,
72
+ sys_index_skinName: undefined ,
73
+ sys_index_sideTheme: undefined
74
+ },
75
+ rules: {
76
+ sys_app_name: [{
77
+ required: true ,
78
+ message: ' 请输入系统名称' ,
79
+ trigger: ' blur'
80
+ }],
81
+ sys_user_initPassword: [{
82
+ required: true ,
83
+ message: ' 请输入初始密码' ,
84
+ trigger: ' blur'
85
+ }],
86
+ sys_index_skinName: [{
87
+ required: true ,
88
+ message: ' 请选择皮肤样式' ,
89
+ trigger: ' change'
90
+ }],
91
+ sys_index_sideTheme: [{
92
+ required: true ,
93
+ message: ' 请选择侧栏主题' ,
94
+ trigger: ' change'
95
+ }]
96
+ },
97
+ sys_app_logoAction: ' http://localhost:8000/api/v1/public/uploadFile' ,
98
+ sys_app_logofileList: [],
99
+ sys_index_skinNameOptions: [{
100
+ ' label' : ' 蓝色' ,
101
+ ' value' : ' skin-blue'
102
+ }],
103
+ sys_index_sideThemeOptions: [{
104
+ ' label' : ' 深色主题' ,
105
+ ' value' : ' theme-dark'
106
+ }]
38
107
}
39
108
},
40
109
created () {
41
- this .formConf = {
42
- ' fields' : [{
43
- ' __config__' : {
44
- ' label' : ' 系统名称' ,
45
- ' labelWidth' : null ,
46
- ' showLabel' : true ,
47
- ' changeTag' : true ,
48
- ' tag' : ' el-input' ,
49
- ' tagIcon' : ' input' ,
50
- ' required' : true ,
51
- ' layout' : ' colFormItem' ,
52
- ' span' : 24 ,
53
- ' document' : ' https://element.eleme.cn/#/zh-CN/component/input' ,
54
- ' regList' : [],
55
- ' formId' : 103 ,
56
- ' renderKey' : 1621935615221
57
- },
58
- ' __slot__' : {
59
- ' prepend' : ' ' ,
60
- ' append' : ' '
61
- },
62
- ' placeholder' : ' 请输入系统名称' ,
63
- ' style' : {
64
- ' width' : ' 100%'
65
- },
66
- ' clearable' : true ,
67
- ' prefix-icon' : ' ' ,
68
- ' suffix-icon' : ' ' ,
69
- ' maxlength' : null ,
70
- ' show-word-limit' : false ,
71
- ' readonly' : false ,
72
- ' disabled' : false ,
73
- ' __vModel__' : ' sys_app_name'
74
- }, {
75
- ' __config__' : {
76
- ' label' : ' 系统logo' ,
77
- ' tag' : ' el-upload' ,
78
- ' tagIcon' : ' upload' ,
79
- ' layout' : ' colFormItem' ,
80
- ' defaultValue' : null ,
81
- ' showLabel' : true ,
82
- ' labelWidth' : null ,
83
- ' required' : false ,
84
- ' span' : 24 ,
85
- ' showTip' : false ,
86
- ' buttonText' : ' 点击上传' ,
87
- ' regList' : [],
88
- ' changeTag' : true ,
89
- ' fileSize' : 2 ,
90
- ' sizeUnit' : ' MB' ,
91
- ' document' : ' https://element.eleme.cn/#/zh-CN/component/upload' ,
92
- ' formId' : 102 ,
93
- ' renderKey' : 1621935611177
94
- },
95
- ' __slot__' : {
96
- ' list-type' : true
97
- },
98
- ' action' : ' http://localhost:8000/api/v1/public/uploadFile' ,
99
- ' disabled' : false ,
100
- ' accept' : ' image/*' ,
101
- ' name' : ' file' ,
102
- ' v-if' : ' fileList' ,
103
- ' auto-upload' : true ,
104
- ' on-success ' : function (response , file , fileList ) {
105
- this .fileList [0 ] = { ' url' : response .data .full_path }
106
- this .$parent .$parent .$parent .$parent .$parent .$parent .$emit (' bind' , ' sys_app_logo' , response .data .full_path )
107
- return true
108
- },
109
- ' props' : {
110
- ' file-list' : []
111
- },
112
- ' list-type' : ' picture-card' ,
113
-
114
- ' multiple' : false ,
115
- ' __vModel__' : ' sys_app_logo'
116
- }, {
117
- ' __config__' : {
118
- ' label' : ' 初始密码' ,
119
- ' labelWidth' : null ,
120
- ' showLabel' : true ,
121
- ' changeTag' : true ,
122
- ' tag' : ' el-input' ,
123
- ' tagIcon' : ' input' ,
124
- ' required' : true ,
125
- ' layout' : ' colFormItem' ,
126
- ' span' : 24 ,
127
- ' document' : ' https://element.eleme.cn/#/zh-CN/component/input' ,
128
- ' regList' : [],
129
- ' formId' : 101 ,
130
- ' renderKey' : 1621935520984
131
- },
132
- ' __slot__' : {
133
- ' prepend' : ' ' ,
134
- ' append' : ' '
135
- },
136
- ' placeholder' : ' 请输入初始密码' ,
137
- ' style' : {
138
- ' width' : ' 100%'
139
- },
140
- ' clearable' : true ,
141
- ' prefix-icon' : ' el-icon-key' ,
142
- ' suffix-icon' : ' ' ,
143
- ' maxlength' : null ,
144
- ' show-word-limit' : false ,
145
- ' readonly' : false ,
146
- ' disabled' : false ,
147
- ' __vModel__' : ' sys_user_initPassword'
148
- }, {
149
- ' __config__' : {
150
- ' label' : ' 皮肤样式' ,
151
- ' showLabel' : true ,
152
- ' labelWidth' : null ,
153
- ' tag' : ' el-select' ,
154
- ' tagIcon' : ' select' ,
155
- ' layout' : ' colFormItem' ,
156
- ' span' : 24 ,
157
- ' required' : true ,
158
- ' regList' : [],
159
- ' changeTag' : true ,
160
- ' document' : ' https://element.eleme.cn/#/zh-CN/component/select' ,
161
- ' formId' : 104 ,
162
- ' renderKey' : 1621935674152
163
- },
164
- ' __slot__' : {
165
- ' options' : [{
166
- ' label' : ' 蓝色' ,
167
- ' value' : ' skin-blue'
168
- }, {
169
- ' label' : ' 绿色' ,
170
- ' value' : ' skin-green'
171
- }, {
172
- ' label' : ' 紫色' ,
173
- ' value' : ' skin-purple'
174
- }, {
175
- ' label' : ' 红色' ,
176
- ' value' : ' skin-red'
177
- }, {
178
- ' label' : ' 黄色' ,
179
- ' value' : ' skin-yellow'
180
- }]
181
- },
182
- ' placeholder' : ' 请选择皮肤样式' ,
183
- ' style' : {
184
- ' width' : ' 100%'
185
- },
186
- ' clearable' : true ,
187
- ' disabled' : false ,
188
- ' filterable' : false ,
189
- ' multiple' : false ,
190
- ' __vModel__' : ' sys_index_skinName'
191
- }, {
192
- ' __config__' : {
193
- ' label' : ' 侧栏主题' ,
194
- ' showLabel' : true ,
195
- ' labelWidth' : null ,
196
- ' tag' : ' el-select' ,
197
- ' tagIcon' : ' select' ,
198
- ' layout' : ' colFormItem' ,
199
- ' span' : 24 ,
200
- ' required' : true ,
201
- ' regList' : [],
202
- ' changeTag' : true ,
203
- ' document' : ' https://element.eleme.cn/#/zh-CN/component/select' ,
204
- ' formId' : 106 ,
205
- ' renderKey' : 1621935704111
206
- },
207
- ' __slot__' : {
208
- ' options' : [{
209
- ' label' : ' 深色主题' ,
210
- ' value' : ' theme-dark'
211
- }, {
212
- ' label' : ' 浅色主题' ,
213
- ' value' : ' theme-light'
214
- }]
215
- },
216
- ' placeholder' : ' 请选择侧栏主题' ,
217
- ' style' : {
218
- ' width' : ' 100%'
219
- },
220
- ' clearable' : true ,
221
- ' disabled' : false ,
222
- ' filterable' : false ,
223
- ' multiple' : false ,
224
- ' __vModel__' : ' sys_index_sideTheme'
225
- }
226
- ],
227
- ' formRef' : ' elForm' ,
228
- ' formModel' : ' formData' ,
229
- ' size' : ' medium' ,
230
- ' labelPosition' : ' right' ,
231
- ' labelWidth' : 100 ,
232
- ' formRules' : ' rules' ,
233
- ' gutter' : 15 ,
234
- ' disabled' : false ,
235
- ' span' : 24 ,
236
- ' formBtns' : true
237
- }
238
-
239
110
this .getList ()
240
111
},
241
112
methods: {
113
+ submitForm () {
114
+ console .log (this .form )
115
+ this .$refs [' form' ].validate (valid => {
116
+ if (! valid) return
117
+ console .log (this .form )
118
+ var list = []
119
+ var i = 0
120
+ for (var key in this .form ) {
121
+ list[i] = {
122
+ ' configKey' : key,
123
+ ' configValue' : this .form [key]
124
+ }
125
+ i++
126
+ }
127
+ updateSetConfig (list).then (response => {
128
+ if (response .code === 200 ) {
129
+ this .msgSuccess (response .msg )
130
+ this .open = false
131
+ this .getList ()
132
+ } else {
133
+ this .msgError (response .msg )
134
+ }
135
+ })
136
+ })
137
+ },
138
+ resetForm () {
139
+ this .$refs [' form' ].resetFields ()
140
+ },
141
+ sys_app_logoBeforeUpload (file ) {
142
+ const isRightSize = file .size / 1024 / 1024 < 2
143
+ if (! isRightSize) {
144
+ this .$message .error (' 文件大小超过 2MB' )
145
+ }
146
+ return isRightSize
147
+ },
148
+ uploadSuccess (response , file , fileList ) {
149
+ console .log (' sss' )
150
+ this .form .sys_app_logo = process .env .VUE_APP_BASE_API + response .data .full_path
151
+ console .log (response .data .full_path )
152
+ },
242
153
/** 查询参数列表 */
243
154
getList () {
244
155
this .loading = true
245
156
getSetConfig ().then (response => {
246
157
this .configList = response .data
247
158
this .loading = false
248
- this .fillFormData (this .formConf , this .configList )
159
+ this .form = this .configList
160
+ // this.sys_app_logofileList = [this.configList.sys_app_logo]
161
+ // this.fillFormData(this.elForm, this.configList)
249
162
// 更新表单
250
- this .key2 = + new Date ()
251
- }
252
- )
163
+ // this.key2 = +new Date()
164
+ })
253
165
},
254
166
setUrl (url ) {
255
167
const data = {
@@ -285,7 +197,10 @@ export default {
285
197
var list = []
286
198
var i = 0
287
199
for (var key in data) {
288
- list[i] = { ' configKey' : key, ' configValue' : data[key] }
200
+ list[i] = {
201
+ ' configKey' : key,
202
+ ' configValue' : data[key]
203
+ }
289
204
i++
290
205
}
291
206
updateSetConfig (list).then (response => {
@@ -296,8 +211,7 @@ export default {
296
211
} else {
297
212
this .msgError (response .msg )
298
213
}
299
- }
300
- )
214
+ })
301
215
}
302
216
}
303
217
}
0 commit comments