22 <el-container class =" fm2-container" >
33 <el-main class =" fm2-main" >
44 <el-container >
5- <el-aside style = " wdith : 250px ; " >
5+ <el-aside width = " 250px" >
66 <div class =" components-list" >
77 <div class =" widget-cate" >基础字段</div >
88 <draggable tag =" ul" :list =" basicComponents"
5959 <slot name =" action" >
6060 </slot >
6161 <el-button v-if =" upload" type =" text" size =" medium" icon =" el-icon-upload2" @click =" handleUpload" >导入JSON</el-button >
62+ <el-button v-if =" clearable" type =" text" size =" medium" icon =" el-icon-delete" @click =" handleClear" >清空</el-button >
6263 <el-button v-if =" preview" type =" text" size =" medium" icon =" el-icon-view" @click =" handlePreview" >预览</el-button >
6364 <el-button v-if =" generateJson" type =" text" size =" medium" icon =" el-icon-tickets" @click =" handleGenerateJson" >生成JSON</el-button >
6465 <el-button v-if =" generateCode" type =" text" size =" medium" icon =" el-icon-document" @click =" handleGenerateCode" >生成代码</el-button >
8788 :visible =" previewVisible"
8889 @on-close =" previewVisible = false"
8990 ref =" widgetPreview"
90- @on-submit =" handleTest"
9191 width =" 1000px"
9292 form
9393 >
9898 高度:<el-input v-model =" scope.model.blank.height" style =" width : 100px " ></el-input >
9999 </template >
100100 </generate-form >
101+
102+ <template slot="action">
103+ <el-button type =" primary" @click =" handleTest" >获取数据</el-button >
104+ <el-button @click =" handleReset" >重置</el-button >
105+ </template >
101106 </cus-dialog >
102107
103108 <cus-dialog
123128 <div id =" jsoneditor" style =" height : 400px ;width : 100% ;" >{{jsonTemplate}}</div >
124129
125130 <template slot="action">
126- <el-button id = " copybtn " data-clipboard-target = " .ace_text-input " >双击复制 </el-button >
131+ <el-button type = " primary " class = " json-btn " : data-clipboard-text = " jsonCopyValue " >复制数据 </el-button >
127132 </template >
128133 </cus-dialog >
129134
139144 </cus-dialog >
140145 </el-container >
141146 </el-main >
142- <el-footer height =" 30px" >Powered by <a target =" _blank" href =" https://github.com/GavinZhuLei/vue-form-making" >GavinZhuLei</a ></el-footer >
147+ <el-footer height =" 30px" style = " font-weight : 600 ; " >Powered by <a target =" _blank" href =" https://github.com/GavinZhuLei/vue-form-making" >GavinZhuLei</a ></el-footer >
143148 </el-container >
144149
145150</template >
@@ -183,6 +188,10 @@ export default {
183188 upload: {
184189 type: Boolean ,
185190 default: false
191+ },
192+ clearable: {
193+ type: Boolean ,
194+ default: false
186195 }
187196 },
188197 data () {
@@ -195,7 +204,7 @@ export default {
195204 list: [],
196205 config: {
197206 labelWidth: 100 ,
198- labelPosition: ' top ' ,
207+ labelPosition: ' right ' ,
199208 size: ' small'
200209 },
201210 },
@@ -222,215 +231,17 @@ export default {
222231 resolve (res .uptoken )
223232 })
224233 },
225- func_cascader (resolve ) {
226- const options = [{
227- value: ' zhinan' ,
228- label: ' 指南' ,
229- children: [{
230- value: ' shejiyuanze' ,
231- label: ' 设计原则' ,
232- children: [{
233- value: ' yizhi' ,
234- label: ' 一致'
235- }, {
236- value: ' fankui' ,
237- label: ' 反馈'
238- }, {
239- value: ' xiaolv' ,
240- label: ' 效率'
241- }, {
242- value: ' kekong' ,
243- label: ' 可控'
244- }]
245- }, {
246- value: ' daohang' ,
247- label: ' 导航' ,
248- children: [{
249- value: ' cexiangdaohang' ,
250- label: ' 侧向导航'
251- }, {
252- value: ' dingbudaohang' ,
253- label: ' 顶部导航'
254- }]
255- }]
256- }, {
257- value: ' zujian' ,
258- label: ' 组件' ,
259- children: [{
260- value: ' basic' ,
261- label: ' Basic' ,
262- children: [{
263- value: ' layout' ,
264- label: ' Layout 布局'
265- }, {
266- value: ' color' ,
267- label: ' Color 色彩'
268- }, {
269- value: ' typography' ,
270- label: ' Typography 字体'
271- }, {
272- value: ' icon' ,
273- label: ' Icon 图标'
274- }, {
275- value: ' button' ,
276- label: ' Button 按钮'
277- }]
278- }, {
279- value: ' form' ,
280- label: ' Form' ,
281- children: [{
282- value: ' radio' ,
283- label: ' Radio 单选框'
284- }, {
285- value: ' checkbox' ,
286- label: ' Checkbox 多选框'
287- }, {
288- value: ' input' ,
289- label: ' Input 输入框'
290- }, {
291- value: ' input-number' ,
292- label: ' InputNumber 计数器'
293- }, {
294- value: ' select' ,
295- label: ' Select 选择器'
296- }, {
297- value: ' cascader' ,
298- label: ' Cascader 级联选择器'
299- }, {
300- value: ' switch' ,
301- label: ' Switch 开关'
302- }, {
303- value: ' slider' ,
304- label: ' Slider 滑块'
305- }, {
306- value: ' time-picker' ,
307- label: ' TimePicker 时间选择器'
308- }, {
309- value: ' date-picker' ,
310- label: ' DatePicker 日期选择器'
311- }, {
312- value: ' datetime-picker' ,
313- label: ' DateTimePicker 日期时间选择器'
314- }, {
315- value: ' upload' ,
316- label: ' Upload 上传'
317- }, {
318- value: ' rate' ,
319- label: ' Rate 评分'
320- }, {
321- value: ' form' ,
322- label: ' Form 表单'
323- }]
324- }, {
325- value: ' data' ,
326- label: ' Data' ,
327- children: [{
328- value: ' table' ,
329- label: ' Table 表格'
330- }, {
331- value: ' tag' ,
332- label: ' Tag 标签'
333- }, {
334- value: ' progress' ,
335- label: ' Progress 进度条'
336- }, {
337- value: ' tree' ,
338- label: ' Tree 树形控件'
339- }, {
340- value: ' pagination' ,
341- label: ' Pagination 分页'
342- }, {
343- value: ' badge' ,
344- label: ' Badge 标记'
345- }]
346- }, {
347- value: ' notice' ,
348- label: ' Notice' ,
349- children: [{
350- value: ' alert' ,
351- label: ' Alert 警告'
352- }, {
353- value: ' loading' ,
354- label: ' Loading 加载'
355- }, {
356- value: ' message' ,
357- label: ' Message 消息提示'
358- }, {
359- value: ' message-box' ,
360- label: ' MessageBox 弹框'
361- }, {
362- value: ' notification' ,
363- label: ' Notification 通知'
364- }]
365- }, {
366- value: ' navigation' ,
367- label: ' Navigation' ,
368- children: [{
369- value: ' menu' ,
370- label: ' NavMenu 导航菜单'
371- }, {
372- value: ' tabs' ,
373- label: ' Tabs 标签页'
374- }, {
375- value: ' breadcrumb' ,
376- label: ' Breadcrumb 面包屑'
377- }, {
378- value: ' dropdown' ,
379- label: ' Dropdown 下拉菜单'
380- }, {
381- value: ' steps' ,
382- label: ' Steps 步骤条'
383- }]
384- }, {
385- value: ' others' ,
386- label: ' Others' ,
387- children: [{
388- value: ' dialog' ,
389- label: ' Dialog 对话框'
390- }, {
391- value: ' tooltip' ,
392- label: ' Tooltip 文字提示'
393- }, {
394- value: ' popover' ,
395- label: ' Popover 弹出框'
396- }, {
397- value: ' card' ,
398- label: ' Card 卡片'
399- }, {
400- value: ' carousel' ,
401- label: ' Carousel 走马灯'
402- }, {
403- value: ' collapse' ,
404- label: ' Collapse 折叠面板'
405- }]
406- }]
407- }, {
408- value: ' ziyuan' ,
409- label: ' 资源' ,
410- children: [{
411- value: ' axure' ,
412- label: ' Axure Components'
413- }, {
414- value: ' sketch' ,
415- label: ' Sketch Templates'
416- }, {
417- value: ' jiaohu' ,
418- label: ' 组件交互文档'
419- }]
420- }]
421-
422- resolve (options)
423- },
424234 upload_callback (response , file , fileList ) {
425235 console .log (' callback' , response, file, fileList)
426236 }
427237 },
428- widgetModels: {
429- },
238+ widgetModels: {},
430239 blank: ' ' ,
431240 htmlTemplate: ' ' ,
432241 jsonTemplate: ' ' ,
433242 uploadEditor: null ,
243+ jsonCopyValue: ' ' ,
244+ jsonClipboard: null ,
434245 jsonEg: ` {
435246 "list": [
436247 {
@@ -511,6 +322,9 @@ export default {
511322 this .$refs .widgetPreview .end ()
512323 })
513324 },
325+ handleReset () {
326+ this .$refs .generateForm .reset ()
327+ },
514328 handleGenerateJson () {
515329 this .jsonVisible = true
516330 this .jsonTemplate = this .widgetForm
@@ -520,7 +334,13 @@ export default {
520334 const editor = ace .edit (' jsoneditor' )
521335 editor .session .setMode (" ace/mode/json" )
522336
523- const btnCopy = new Clipboard (' #copybtn' )
337+ if (! this .jsonClipboard ) {
338+ this .jsonClipboard = new Clipboard (' .json-btn' )
339+ this .jsonClipboard .on (' success' , (e ) => {
340+ this .$message .success (' 复制成功' )
341+ })
342+ }
343+ this .jsonCopyValue = JSON .stringify (this .widgetForm )
524344 })
525345 },
526346 handleGenerateCode () {
@@ -547,6 +367,19 @@ export default {
547367 this .$refs .uploadJson .end ()
548368 }
549369 },
370+ handleClear () {
371+ this .widgetForm = {
372+ list: [],
373+ config: {
374+ labelWidth: 100 ,
375+ labelPosition: ' right' ,
376+ size: ' small' ,
377+ customClass: ' '
378+ },
379+ }
380+
381+ this .widgetFormSelect = {}
382+ },
550383 getJSON () {
551384 return this .widgetForm
552385 },
0 commit comments