Form 模块

树型

树型 - 图1

可以设置parent属性来控制父类是否可以勾选,默认为true,multiple设置是否为多选,defaultExpandAll属性是否展开全部树形结构,默认true

  1. <avue-form v-model="form" :option="option" @submit="submit"></avue-form>
  2. <script>
  3. const DIC = [{
  4. value: 'zhinan',
  5. name: '指南',
  6. children: [{
  7. value: 'shejiyuanze',
  8. name: '设计原则',
  9. children: [{
  10. value: 'yizhi',
  11. name: '一致'
  12. }, {
  13. value: 'fankui',
  14. name: '反馈'
  15. }, {
  16. value: 'xiaolv',
  17. name: '效率'
  18. }, {
  19. value: 'kekong',
  20. name: '可控'
  21. }]
  22. }, {
  23. value: 'daohang',
  24. name: '导航',
  25. children: [{
  26. value: 'cexiangdaohang',
  27. name: '侧向导航'
  28. }, {
  29. value: 'dingbudaohang',
  30. name: '顶部导航'
  31. }]
  32. }]
  33. }, {
  34. value: 'zujian',
  35. name: '组件',
  36. children: [{
  37. value: 'basic',
  38. name: 'Basic',
  39. children: [{
  40. value: 'layout',
  41. name: 'Layout 布局'
  42. }, {
  43. value: 'color',
  44. name: 'Color 色彩'
  45. }, {
  46. value: 'typography',
  47. name: 'Typography 字体'
  48. }, {
  49. value: 'icon',
  50. name: 'Icon 图标'
  51. }, {
  52. value: 'button',
  53. name: 'Button 按钮'
  54. }]
  55. }, {
  56. value: 'form',
  57. name: 'Form',
  58. children: [{
  59. value: 'radio',
  60. name: 'Radio 单选框'
  61. }, {
  62. value: 'checkbox',
  63. name: 'Checkbox 多选框'
  64. }, {
  65. value: 'input',
  66. name: 'Input 输入框'
  67. }, {
  68. value: 'input-number',
  69. name: 'InputNumber 计数器'
  70. }, {
  71. value: 'select',
  72. name: 'Select 选择器'
  73. }, {
  74. value: 'cascader',
  75. name: 'Cascader 级联选择器'
  76. }, {
  77. value: 'switch',
  78. name: 'Switch 开关'
  79. }, {
  80. value: 'slider',
  81. name: 'Slider 滑块'
  82. }, {
  83. value: 'time-picker',
  84. name: 'TimePicker 时间选择器'
  85. }, {
  86. value: 'date-picker',
  87. name: 'DatePicker 日期选择器'
  88. }, {
  89. value: 'datetime-picker',
  90. name: 'DateTimePicker 日期时间选择器'
  91. }, {
  92. value: 'upload',
  93. name: 'Upload 上传'
  94. }, {
  95. value: 'rate',
  96. name: 'Rate 评分'
  97. }, {
  98. value: 'form',
  99. name: 'Form 表单'
  100. }]
  101. }, {
  102. value: 'data',
  103. name: 'Data',
  104. children: [{
  105. value: 'table',
  106. name: 'Table 表格'
  107. }, {
  108. value: 'tag',
  109. name: 'Tag 标签'
  110. }, {
  111. value: 'progress',
  112. name: 'Progress 进度条'
  113. }, {
  114. value: 'tree',
  115. name: 'Tree 树形控件'
  116. }, {
  117. value: 'pagination',
  118. name: 'Pagination 分页'
  119. }, {
  120. value: 'badge',
  121. name: 'Badge 标记'
  122. }]
  123. }, {
  124. value: 'notice',
  125. name: 'Notice',
  126. children: [{
  127. value: 'alert',
  128. name: 'Alert 警告'
  129. }, {
  130. value: 'loading',
  131. name: 'Loading 加载'
  132. }, {
  133. value: 'message',
  134. name: 'Message 消息提示'
  135. }, {
  136. value: 'message-box',
  137. name: 'MessageBox 弹框'
  138. }, {
  139. value: 'notification',
  140. name: 'Notification 通知'
  141. }]
  142. }, {
  143. value: 'navigation',
  144. name: 'Navigation',
  145. children: [{
  146. value: 'menu',
  147. name: 'NavMenu 导航菜单'
  148. }, {
  149. value: 'tabs',
  150. name: 'Tabs 标签页'
  151. }, {
  152. value: 'breadcrumb',
  153. name: 'Breadcrumb 面包屑'
  154. }, {
  155. value: 'dropdown',
  156. name: 'Dropdown 下拉菜单'
  157. }, {
  158. value: 'steps',
  159. name: 'Steps 步骤条'
  160. }]
  161. }, {
  162. value: 'others',
  163. name: 'Others',
  164. children: [{
  165. value: 'dialog',
  166. name: 'Dialog 对话框'
  167. }, {
  168. value: 'tooltip',
  169. name: 'Tooltip 文字提示'
  170. }, {
  171. value: 'popover',
  172. name: 'Popover 弹出框'
  173. }, {
  174. value: 'card',
  175. name: 'Card 卡片'
  176. }, {
  177. value: 'carousel',
  178. name: 'Carousel 走马灯'
  179. }, {
  180. value: 'collapse',
  181. name: 'Collapse 折叠面板'
  182. }]
  183. }]
  184. }, {
  185. value: 'ziyuan',
  186. name: '资源',
  187. children: [{
  188. value: 'axure',
  189. name: 'Axure Components'
  190. }, {
  191. value: 'sketch',
  192. name: 'Sketch Templates'
  193. }, {
  194. value: 'jiaohu',
  195. name: '组件交互文档'
  196. }]
  197. }];
  198. export default {
  199. data() {
  200. return {
  201. form: {
  202. shenfeng1: "tag",
  203. shenfeng: ["tag", "progress", "tree", "axure", "sketch", "jiaohu"]
  204. },
  205. option:{
  206. column: [{
  207. name: '多选',
  208. prop: 'shenfeng',
  209. type: 'tree',
  210. multiple: true,
  211. dicData: DIC,
  212. props:{
  213. label:'name',
  214. },
  215. rules: [{
  216. required: true,
  217. message: "请选择多选",
  218. trigger: "change"
  219. }],
  220. nodeClick:(data)=>{
  221. this.$message.success(JSON.stringify(data))
  222. },
  223. checked:(data)=>{
  224. this.$message.success(JSON.stringify(data))
  225. }
  226. }, {
  227. name: '单选',
  228. prop: 'shenfeng1',
  229. type: 'tree',
  230. parent:false,
  231. dicData: DIC,
  232. props:{
  233. label:'name',
  234. },
  235. rules: [{
  236. required: true,
  237. message: "请选择单选",
  238. trigger: "change"
  239. }]
  240. }]
  241. }
  242. }
  243. },
  244. methods: {
  245. submit(){
  246. this.$message.success('当前数据'+JSON.stringify(this.form))
  247. }
  248. }
  249. }
  250. </script>