| 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
 | | <template> |  |   <div> |  |     <el-dialog |  |       v-bind="$attrs" |  |       width="500px" |  |       :close-on-click-modal="false" |  |       :modal-append-to-body="false" |  |       v-on="$listeners" |  |       @open="onOpen" |  |       @close="onClose" |  |     > |  |       <el-row :gutter="15"> |  |         <el-form |  |           ref="elForm" |  |           :model="formData" |  |           :rules="rules" |  |           size="medium" |  |           label-width="100px" |  |         > |  |           <el-col :span="24"> |  |             <el-form-item label="生成类型" prop="type"> |  |               <el-radio-group v-model="formData.type"> |  |                 <el-radio-button |  |                   v-for="(item, index) in typeOptions" |  |                   :key="index" |  |                   :label="item.value" |  |                   :disabled="item.disabled" |  |                 > |  |                   {{ item.label }} |  |                 </el-radio-button> |  |               </el-radio-group> |  |             </el-form-item> |  |             <el-form-item v-if="showFileName" label="文件名" prop="fileName"> |  |               <el-input v-model="formData.fileName" placeholder="请输入文件名" clearable /> |  |             </el-form-item> |  |           </el-col> |  |         </el-form> |  |       </el-row> |  |   |  |       <div slot="footer"> |  |         <el-button @click="close"> |  |           取消 |  |         </el-button> |  |         <el-button type="primary" @click="handleConfirm"> |  |           确定 |  |         </el-button> |  |       </div> |  |     </el-dialog> |  |   </div> |  | </template> |  | <script> |  | export default { |  |   inheritAttrs: false, |  |   props: ['showFileName'], |  |   data() { |  |     return { |  |       formData: { |  |         fileName: undefined, |  |         type: 'file' |  |       }, |  |       rules: { |  |         fileName: [{ |  |           required: true, |  |           message: '请输入文件名', |  |           trigger: 'blur' |  |         }], |  |         type: [{ |  |           required: true, |  |           message: '生成类型不能为空', |  |           trigger: 'change' |  |         }] |  |       }, |  |       typeOptions: [{ |  |         label: '页面', |  |         value: 'file' |  |       }, { |  |         label: '弹窗', |  |         value: 'dialog' |  |       }] |  |     } |  |   }, |  |   computed: { |  |   }, |  |   watch: {}, |  |   mounted() {}, |  |   methods: { |  |     onOpen() { |  |       if (this.showFileName) { |  |         this.formData.fileName = `${+new Date()}.vue` |  |       } |  |     }, |  |     onClose() { |  |     }, |  |     close(e) { |  |       this.$emit('update:visible', false) |  |     }, |  |     handleConfirm() { |  |       this.$refs.elForm.validate(valid => { |  |         if (!valid) return |  |         this.$emit('confirm', { ...this.formData }) |  |         this.close() |  |       }) |  |     } |  |   } |  | } |  | </script> | 
 |