jianghu-ui 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +376 -0
  2. package/dist/jianghu-ui.css +2318 -0
  3. package/dist/jianghu-ui.js +2 -0
  4. package/dist/jianghu-ui.js.LICENSE.txt +1 -0
  5. package/package.json +56 -0
  6. package/src/Design.stories.mdx +195 -0
  7. package/src/Introduction.stories.mdx +148 -0
  8. package/src/components/JhAddressSelect/JhAddressSelect.md +250 -0
  9. package/src/components/JhAddressSelect/JhAddressSelect.stories.js +282 -0
  10. package/src/components/JhAddressSelect/JhAddressSelect.vue +261 -0
  11. package/src/components/JhCard/JhCard.md +246 -0
  12. package/src/components/JhCard/JhCard.stories.js +688 -0
  13. package/src/components/JhCard/JhCard.vue +604 -0
  14. package/src/components/JhCheckCard/JhCheckCard.md +245 -0
  15. package/src/components/JhCheckCard/JhCheckCard.stories.js +750 -0
  16. package/src/components/JhCheckCard/JhCheckCard.vue +476 -0
  17. package/src/components/JhConfirmDialog/JhConfirmDialog.md +70 -0
  18. package/src/components/JhConfirmDialog/JhConfirmDialog.stories.js +550 -0
  19. package/src/components/JhConfirmDialog/JhConfirmDialog.vue +181 -0
  20. package/src/components/JhDateRangePicker/JhDateRangePicker.md +56 -0
  21. package/src/components/JhDateRangePicker/JhDateRangePicker.stories.js +320 -0
  22. package/src/components/JhDateRangePicker/JhDateRangePicker.vue +307 -0
  23. package/src/components/JhDescriptions/JhDescriptions.md +724 -0
  24. package/src/components/JhDescriptions/JhDescriptions.stories.js +858 -0
  25. package/src/components/JhDescriptions/JhDescriptions.vue +933 -0
  26. package/src/components/JhDraggable/JhDraggable.md +66 -0
  27. package/src/components/JhDraggable/JhDraggable.stories.js +161 -0
  28. package/src/components/JhDraggable/JhDraggable.vue +254 -0
  29. package/src/components/JhDrawer/JhDrawer.md +68 -0
  30. package/src/components/JhDrawer/JhDrawer.stories.js +478 -0
  31. package/src/components/JhDrawer/JhDrawer.vue +281 -0
  32. package/src/components/JhDrawerForm/JhDrawerForm.md +69 -0
  33. package/src/components/JhDrawerForm/JhDrawerForm.stories.js +492 -0
  34. package/src/components/JhDrawerForm/JhDrawerForm.vue +297 -0
  35. package/src/components/JhEditableTable/JhEditableTable.md +507 -0
  36. package/src/components/JhEditableTable/JhEditableTable.stories.js +615 -0
  37. package/src/components/JhEditableTable/JhEditableTable.vue +685 -0
  38. package/src/components/JhFileInput/JhFileInput.md +56 -0
  39. package/src/components/JhFileInput/JhFileInput.stories.js +103 -0
  40. package/src/components/JhFileInput/JhFileInput.vue +253 -0
  41. package/src/components/JhForm/JhForm.md +676 -0
  42. package/src/components/JhForm/JhForm.stories.js +1375 -0
  43. package/src/components/JhForm/JhForm.vue +657 -0
  44. package/src/components/JhFormField/JhFormField.stories.js +217 -0
  45. package/src/components/JhFormField/JhFormField.vue +439 -0
  46. package/src/components/JhFormFields/JhFormFields.md +647 -0
  47. package/src/components/JhFormFields/JhFormFields.stories.js +922 -0
  48. package/src/components/JhFormFields/JhFormFields.vue +998 -0
  49. package/src/components/JhFormList/JhFormList.md +303 -0
  50. package/src/components/JhFormList/JhFormList.stories.js +661 -0
  51. package/src/components/JhFormList/JhFormList.vue +1127 -0
  52. package/src/components/JhJsonEditor/JhJsonEditor.md +54 -0
  53. package/src/components/JhJsonEditor/JhJsonEditor.stories.js +157 -0
  54. package/src/components/JhJsonEditor/JhJsonEditor.vue +178 -0
  55. package/src/components/JhLayout/JhLayout.md +580 -0
  56. package/src/components/JhLayout/JhLayout.stories.js +414 -0
  57. package/src/components/JhLayout/JhLayout.vue +387 -0
  58. package/src/components/JhList/JhList.md +441 -0
  59. package/src/components/JhList/JhList.stories.js +524 -0
  60. package/src/components/JhList/JhList.vue +571 -0
  61. package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +56 -0
  62. package/src/components/JhMarkdownEditor/JhMarkdownEditor.stories.js +191 -0
  63. package/src/components/JhMarkdownEditor/JhMarkdownEditor.vue +188 -0
  64. package/src/components/JhMask/JhMask.md +62 -0
  65. package/src/components/JhMask/JhMask.stories.js +270 -0
  66. package/src/components/JhMask/JhMask.vue +123 -0
  67. package/src/components/JhMenu/JhMenu.md +85 -0
  68. package/src/components/JhMenu/JhMenu.stories.js +384 -0
  69. package/src/components/JhMenu/JhMenu.vue +545 -0
  70. package/src/components/JhModal/JhModal.md +68 -0
  71. package/src/components/JhModal/JhModal.stories.js +562 -0
  72. package/src/components/JhModal/JhModal.vue +235 -0
  73. package/src/components/JhModalForm/JhModalForm.md +69 -0
  74. package/src/components/JhModalForm/JhModalForm.stories.js +592 -0
  75. package/src/components/JhModalForm/JhModalForm.vue +298 -0
  76. package/src/components/JhPageContainer/JhPageContainer.md +409 -0
  77. package/src/components/JhPageContainer/JhPageContainer.stories.js +209 -0
  78. package/src/components/JhPageContainer/JhPageContainer.vue +72 -0
  79. package/src/components/JhQueryFilter/JhQueryFilter.md +77 -0
  80. package/src/components/JhQueryFilter/JhQueryFilter.stories.js +684 -0
  81. package/src/components/JhQueryFilter/JhQueryFilter.vue +429 -0
  82. package/src/components/JhScene/JhScene.md +64 -0
  83. package/src/components/JhScene/JhScene.stories.js +317 -0
  84. package/src/components/JhScene/JhScene.vue +376 -0
  85. package/src/components/JhStatisticCard/JhStatisticCard.md +363 -0
  86. package/src/components/JhStatisticCard/JhStatisticCard.stories.js +847 -0
  87. package/src/components/JhStatisticCard/JhStatisticCard.vue +459 -0
  88. package/src/components/JhStepsForm/JhStepsForm.md +666 -0
  89. package/src/components/JhStepsForm/JhStepsForm.stories.js +1224 -0
  90. package/src/components/JhStepsForm/JhStepsForm.vue +749 -0
  91. package/src/components/JhTable/JhTable.md +730 -0
  92. package/src/components/JhTable/JhTable.stories.js +1444 -0
  93. package/src/components/JhTable/JhTable.vue +2298 -0
  94. package/src/components/JhTableAttachment/JhTableAttachment.md +70 -0
  95. package/src/components/JhTableAttachment/JhTableAttachment.stories.js +198 -0
  96. package/src/components/JhTableAttachment/JhTableAttachment.vue +264 -0
  97. package/src/components/JhToast/JhToast.md +67 -0
  98. package/src/components/JhToast/JhToast.stories.js +386 -0
  99. package/src/components/JhToast/JhToast.vue +239 -0
  100. package/src/components/JhTreeSelect/JhTreeSelect.md +82 -0
  101. package/src/components/JhTreeSelect/JhTreeSelect.stories.js +391 -0
  102. package/src/components/JhTreeSelect/JhTreeSelect.vue +727 -0
  103. package/src/components/JhWaterMark/JhWaterMark.md +190 -0
  104. package/src/components/JhWaterMark/JhWaterMark.stories.js +675 -0
  105. package/src/components/JhWaterMark/JhWaterMark.vue +351 -0
  106. package/src/components/README.md +52 -0
  107. package/src/index.js +135 -0
  108. package/src/style/globalCSSJHV4.css +348 -0
  109. package/src/style/globalCSSVuetifyV4.css +637 -0
  110. package/src/style/storybook.css +4 -0
  111. package/src/tailwind.css +3 -0
  112. package/src/utils/vuetify.js +31 -0
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "jianghu-ui",
3
+ "version": "1.0.1",
4
+ "description": "JianghuJS UI Component Library with Storybook, Vue 2, and Vuetify 2",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "storybook": "storybook dev -p 6006",
8
+ "build-storybook": "storybook build",
9
+ "build": "webpack --config webpack.config.js",
10
+ "build:watch": "webpack --config webpack.config.js --watch",
11
+ "serve-storybook": "npx http-server storybook-static",
12
+ "deploy": "npm run build && npm run build-storybook && npx gh-pages -d storybook-static"
13
+ },
14
+ "keywords": [
15
+ "jianghujs",
16
+ "vue",
17
+ "vuetify",
18
+ "ui-components",
19
+ "storybook"
20
+ ],
21
+ "author": "JianghuJS Team",
22
+ "license": "MIT",
23
+ "files": [
24
+ "dist",
25
+ "src"
26
+ ],
27
+ "devDependencies": {
28
+ "@storybook/addon-docs": "^7.6.17",
29
+ "@storybook/addon-essentials": "^7.6.17",
30
+ "@storybook/addon-links": "^7.6.17",
31
+ "@storybook/addon-storysource": "^7.6.20",
32
+ "@storybook/blocks": "^7.6.17",
33
+ "@storybook/vue-webpack5": "^7.6.17",
34
+ "autoprefixer": "^10.4.20",
35
+ "gh-pages": "^6.1.1",
36
+ "http-server": "^14.1.1",
37
+ "postcss": "^8.4.49",
38
+ "postcss-loader": "^8.2.0",
39
+ "storybook": "^7.6.17",
40
+ "tailwindcss": "^3.4.16",
41
+ "vue": "^2.7.16",
42
+ "vue-loader": "^15.11.1",
43
+ "vue-template-compiler": "^2.7.16",
44
+ "@babel/core": "^7.23.0",
45
+ "@babel/preset-env": "^7.23.0",
46
+ "babel-loader": "^9.1.3",
47
+ "css-loader": "^6.8.1",
48
+ "mini-css-extract-plugin": "^2.7.6",
49
+ "webpack": "^5.89.0",
50
+ "webpack-cli": "^5.1.4"
51
+ },
52
+ "dependencies": {
53
+ "@mdi/font": "^7.4.47",
54
+ "vuetify": "^2.7.0"
55
+ }
56
+ }
@@ -0,0 +1,195 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ <Meta title="介绍/设计原则" />
4
+
5
+ # 设计原则
6
+
7
+ JianghuJS UI 组件库遵循以下设计原则,确保组件的一致性、可用性和可维护性。
8
+
9
+ ## 一致性 (Consistency)
10
+
11
+ ### 视觉一致性
12
+ - 所有组件遵循 Material Design 规范
13
+ - 统一的颜色系统和间距规范
14
+ - 一致的交互反馈和动画效果
15
+
16
+ ### 代码一致性
17
+ - 统一的 props 命名规范
18
+ - 一致的事件命名和触发方式
19
+ - 标准化的插槽设计
20
+
21
+ ## 简洁性 (Simplicity)
22
+
23
+ ### 易于使用
24
+ - 提供合理的默认值,减少必填配置
25
+ - 清晰的 API 设计,避免复杂的嵌套结构
26
+ - 完善的文档和示例代码
27
+
28
+ ### 代码简洁
29
+ - 组件职责单一,避免过度封装
30
+ - 保持组件的可组合性
31
+ - 减少不必要的依赖
32
+
33
+ ## 灵活性 (Flexibility)
34
+
35
+ ### 高度可定制
36
+ - 丰富的 props 支持各种使用场景
37
+ - 插槽机制支持自定义内容
38
+ - 支持主题定制和样式覆盖
39
+
40
+ ### 可扩展性
41
+ - 组件设计预留扩展空间
42
+ - 支持事件监听和自定义行为
43
+ - 易于集成第三方功能
44
+
45
+ ## 性能 (Performance)
46
+
47
+ ### 优化策略
48
+ - 按需加载,减少初始包体积
49
+ - 合理使用计算属性和侦听器
50
+ - 避免不必要的重渲染
51
+
52
+ ### CDN 优势
53
+ - 利用浏览器缓存
54
+ - 减少项目构建时间
55
+ - 降低部署复杂度
56
+
57
+ ## 可访问性 (Accessibility)
58
+
59
+ ### 无障碍设计
60
+ - 支持键盘导航
61
+ - 合理的 ARIA 标签
62
+ - 良好的色彩对比度
63
+
64
+ ### 响应式设计
65
+ - 移动端优先
66
+ - 适配各种屏幕尺寸
67
+ - 支持触摸和鼠标交互
68
+
69
+ ## 组件设计规范
70
+
71
+ ### Props 设计
72
+
73
+ ```javascript
74
+ // ✅ 好的设计
75
+ {
76
+ color: 'primary', // 使用预定义值
77
+ size: 'medium', // 语义化的尺寸
78
+ disabled: false, // 布尔值使用 is/has/should 等前缀或直接描述状态
79
+ }
80
+
81
+ // ❌ 避免的设计
82
+ {
83
+ col: '#1976D2', // 避免缩写
84
+ s: 2, // 不清晰的命名
85
+ dis: 0, // 用数字表示布尔值
86
+ }
87
+ ```
88
+
89
+ ### 事件设计
90
+
91
+ ```javascript
92
+ // ✅ 好的设计
93
+ this.$emit('click', event);
94
+ this.$emit('change', value);
95
+ this.$emit('submit', formData);
96
+
97
+ // ❌ 避免的设计
98
+ this.$emit('c', event); // 避免缩写
99
+ this.$emit('on-click', event); // 不需要 on- 前缀
100
+ this.$emit('buttonClick', event); // 避免组件名前缀
101
+ ```
102
+
103
+ ### 插槽设计
104
+
105
+ ```vue
106
+ <!-- ✅ 好的设计 -->
107
+ <template>
108
+ <div class="component">
109
+ <slot name="header"></slot>
110
+ <slot></slot> <!-- 默认插槽 -->
111
+ <slot name="footer"></slot>
112
+ </div>
113
+ </template>
114
+
115
+ <!-- 提供作用域插槽支持自定义 -->
116
+ <template v-slot:item="{ item }">
117
+ <slot name="item" :item="item">
118
+ {{ item.name }}
119
+ </slot>
120
+ </template>
121
+ ```
122
+
123
+ ## 颜色系统
124
+
125
+ ### 主题色
126
+
127
+ | 颜色名称 | 色值 | 用途 |
128
+ |---------|------|------|
129
+ | Primary | #1976D2 | 主要操作、重要信息 |
130
+ | Secondary | #424242 | 次要操作 |
131
+ | Success | #4CAF50 | 成功状态 |
132
+ | Error | #FF5252 | 错误状态 |
133
+ | Warning | #FB8C00 | 警告状态 |
134
+ | Info | #2196F3 | 提示信息 |
135
+
136
+ ### 中性色
137
+
138
+ | 颜色名称 | 色值 | 用途 |
139
+ |---------|------|------|
140
+ | Black | #000000 | 标题、重要文本 |
141
+ | Grey-Dark | #424242 | 正文文本 |
142
+ | Grey | #757575 | 辅助文本 |
143
+ | Grey-Light | #BDBDBD | 禁用文本、边框 |
144
+ | White | #FFFFFF | 背景、反色文本 |
145
+
146
+ ## 间距系统
147
+
148
+ 采用 8px 基准的间距系统:
149
+
150
+ - **xs**: 4px
151
+ - **sm**: 8px
152
+ - **md**: 16px
153
+ - **lg**: 24px
154
+ - **xl**: 32px
155
+ - **xxl**: 48px
156
+
157
+ ## 字体规范
158
+
159
+ ### 字体大小
160
+
161
+ - **标题 1**: 32px
162
+ - **标题 2**: 24px
163
+ - **标题 3**: 20px
164
+ - **标题 4**: 18px
165
+ - **正文**: 16px
166
+ - **辅助文本**: 14px
167
+ - **小文本**: 12px
168
+
169
+ ### 字体粗细
170
+
171
+ - **Regular**: 400
172
+ - **Medium**: 500
173
+ - **Bold**: 700
174
+
175
+ ## 响应式断点
176
+
177
+ ```javascript
178
+ {
179
+ xs: 0, // 手机竖屏
180
+ sm: 600, // 手机横屏 / 平板竖屏
181
+ md: 960, // 平板横屏 / 小屏电脑
182
+ lg: 1264, // 桌面
183
+ xl: 1904, // 大屏
184
+ }
185
+ ```
186
+
187
+ ## 动画时长
188
+
189
+ - **快速**: 100ms - 用于小元素的简单过渡
190
+ - **标准**: 200ms - 用于大多数过渡效果
191
+ - **复杂**: 300ms - 用于复杂动画或大元素
192
+
193
+ ---
194
+
195
+ 遵循这些设计原则,可以确保组件库的质量和一致性,提供良好的开发体验。
@@ -0,0 +1,148 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ <Meta title="介绍/快速开始" />
4
+
5
+ # JianghuJS UI 组件库
6
+
7
+ 欢迎使用 **JianghuJS UI** 组件库!这是一个基于 Vue 2 和 Vuetify 2 构建的现代化 UI 组件库,专为 JianghuJS 项目设计。
8
+
9
+ ## 特性
10
+
11
+ - 🚀 **开箱即用** - 无需复杂配置,直接通过 CDN 引入即可使用
12
+ - 🎨 **Material Design** - 基于 Vuetify 2,遵循 Material Design 设计规范
13
+ - 📱 **响应式设计** - 完美适配各种屏幕尺寸
14
+ - 🔧 **高度可定制** - 丰富的 props 和插槽支持
15
+ - 📖 **完善的文档** - 通过 Storybook 提供交互式文档和示例
16
+
17
+ ## 快速开始
18
+
19
+ ### 1. CDN 引入(推荐)
20
+
21
+ 在 HTML 文件的 `<head>` 标签中引入必要的资源:
22
+
23
+ ```html
24
+ <!DOCTYPE html>
25
+ <html>
26
+ <head>
27
+ <link href="https://jianghujs.github.io/jianghu-ui/cdn/jianghu-ui.css" rel="stylesheet">
28
+ </head>
29
+ <body>
30
+ <div id="app">
31
+ <!-- 你的应用内容 -->
32
+ </div>
33
+ <script src="https://jianghujs.github.io/jianghu-ui/cdn/jianghu-ui.js"></script>
34
+ </body>
35
+ </html>
36
+ ```
37
+
38
+ ### 2. 初始化 Vue 应用
39
+
40
+ ```javascript
41
+ new Vue({
42
+ el: '#app',
43
+ vuetify: new Vuetify(),
44
+ // 你的组件和配置
45
+ });
46
+ ```
47
+
48
+ ### 3. 使用组件
49
+
50
+ ```vue
51
+ <template>
52
+ <v-app>
53
+ <jh-button label="点击我" color="primary" @click="handleClick" />
54
+ </v-app>
55
+ </template>
56
+
57
+ <script>
58
+ export default {
59
+ methods: {
60
+ handleClick() {
61
+ alert('按钮被点击了!');
62
+ }
63
+ }
64
+ }
65
+ </script>
66
+ ```
67
+
68
+ ## 组件列表
69
+
70
+ ### 基础组件
71
+ - **JhButton** - 按钮组件,支持多种样式和状态
72
+ - **JhCard** - 卡片组件,用于展示内容块
73
+
74
+ ### 数据展示
75
+ - **JhTable** - 数据表格组件,支持排序、搜索、分页等功能
76
+
77
+ ### 表单组件
78
+ - **JhForm** - 表单组件,支持多种输入类型和验证
79
+
80
+ ## 主题定制
81
+
82
+ 你可以在初始化 Vuetify 时自定义主题颜色:
83
+
84
+ ```javascript
85
+ new Vue({
86
+ el: '#app',
87
+ vuetify: new Vuetify({
88
+ theme: {
89
+ themes: {
90
+ light: {
91
+ primary: '#1976D2',
92
+ secondary: '#424242',
93
+ accent: '#82B1FF',
94
+ error: '#FF5252',
95
+ info: '#2196F3',
96
+ success: '#4CAF50',
97
+ warning: '#FB8C00',
98
+ },
99
+ },
100
+ },
101
+ }),
102
+ });
103
+ ```
104
+
105
+ ## 开发指南
106
+
107
+ ### 本地开发
108
+
109
+ ```bash
110
+ # 安装依赖
111
+ npm install
112
+
113
+ # 启动 Storybook
114
+ npm run storybook
115
+
116
+ # 访问 http://localhost:6006
117
+ ```
118
+
119
+ ### 构建文档
120
+
121
+ ```bash
122
+ # 构建静态文档站点
123
+ npm run build-storybook
124
+
125
+ # 预览构建结果
126
+ npm run serve-storybook
127
+ ```
128
+
129
+ ## 浏览器支持
130
+
131
+ - Chrome (最新版)
132
+ - Firefox (最新版)
133
+ - Safari (最新版)
134
+ - Edge (最新版)
135
+
136
+ ## 相关资源
137
+
138
+ - [Vue 2 官方文档](https://v2.vuejs.org/)
139
+ - [Vuetify 2 官方文档](https://v2.vuetifyjs.com/)
140
+ - [Material Design Icons](https://materialdesignicons.com/)
141
+
142
+ ## 贡献指南
143
+
144
+ 欢迎提交 Issue 和 Pull Request!
145
+
146
+ ## 许可证
147
+
148
+ MIT License
@@ -0,0 +1,250 @@
1
+ # JhAddressSelect - 省市区选择组件
2
+
3
+ 省市区三级联动选择组件,支持自定义显示层级、标签文本和数据源。
4
+
5
+ - ✅ **四级联动**: 支持省、市、区、镇四级联动选择
6
+ - ✅ **自定义层级**: 可配置显示 1-4 级(仅省份、省市、省市区、省市区镇)
7
+ - ✅ **自定义标签**: 支持自定义各级别的显示文本
8
+ - ✅ **自定义数据**: 支持传入自定义省市区数据源
9
+ - ✅ **样式透传**: 支持 Vuetify 的 outlined、dense、loading 等样式
10
+ - ✅ **双向绑定**: 支持 v-model 双向数据绑定
11
+ - ✅ **事件触发**: change 事件在值变化时触发
12
+ - ✅ **清除功能**: 支持清除已选值
13
+ - ✅ **返回完整信息**: 事件返回包含 code 和 name 的完整对象
14
+
15
+ ## 基本用法
16
+
17
+ ```vue
18
+ <template>
19
+ <jh-address-select
20
+ v-model="address"
21
+ :data="addressData"
22
+ @change="handleAddressChange"
23
+ ></jh-address-select>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ data() {
29
+ return {
30
+ address: { province: null, city: null, district: null, town: null },
31
+ addressData: [
32
+ { code: '110000', name: '北京市', children: [...] },
33
+ { code: '440000', name: '广东省', children: [...] }
34
+ ]
35
+ };
36
+ },
37
+ methods: {
38
+ handleAddressChange(value) {
39
+ console.log('省份:', value.province?.name, value.province?.code);
40
+ console.log('城市:', value.city?.name, value.city?.code);
41
+ console.log('区县:', value.district?.name, value.district?.code);
42
+ console.log('乡镇:', value.town?.name, value.town?.code);
43
+ }
44
+ }
45
+ };
46
+ </script>
47
+ ```
48
+
49
+ ## API
50
+
51
+ ### Props
52
+
53
+ | 参数 | 说明 | 类型 | 默认值 |
54
+ | --- | --- | --- | --- |
55
+ | value / v-model | 绑定值,返回包含 code 和 name 的对象 | object | { province: null, city: null, district: null } |
56
+ | level | 显示层级:1-仅省份,2-省市,3-省市区,4-省市区镇 | number | 3 |
57
+ | outlined | 是否使用 outlined 样式 | boolean | true |
58
+ | dense | 是否使用紧凑模式 | boolean | false |
59
+ | loading | 是否显示加载状态 | boolean | false |
60
+ | labels | 自定义标签文本 | object | { province: '省份', city: '城市', district: '区/县', town: '乡镇' } |
61
+ | data | 省市区数据源 | array | 内置示例数据 |
62
+
63
+ ### Events
64
+
65
+ | 事件名 | 说明 | 回调参数 |
66
+ | --- | --- | --- |
67
+ | input | 值变化时触发(v-model) | (value: object) |
68
+ | change | 值变化时触发 | (value: object) |
69
+
70
+ ### 返回值格式
71
+
72
+ v-model 绑定值和事件回调参数的格式:
73
+
74
+ ```javascript
75
+ {
76
+ province: { code: '440000', name: '广东省' },
77
+ city: { code: '440300', name: '深圳市' },
78
+ district: { code: '440305', name: '南山区' },
79
+ town: { code: '440305001', name: '南头街道' } // level=4 时存在
80
+ }
81
+ ```
82
+
83
+ 每个字段都是一个对象,包含 `code`(编码)和 `name`(名称)两个属性。未选择时为 `null`。
84
+
85
+ ### 数据格式
86
+
87
+ data 属性需要符合以下格式:
88
+
89
+ ```javascript
90
+ [
91
+ {
92
+ code: '110000', // 省份编码
93
+ name: '北京市', // 省份名称
94
+ children: [ // 城市列表
95
+ {
96
+ code: '110100', // 城市编码
97
+ name: '市辖区', // 城市名称
98
+ children: [ // 区县列表
99
+ {
100
+ code: '110101', // 区县编码
101
+ name: '东城区' // 区县名称
102
+ }
103
+ ]
104
+ }
105
+ ]
106
+ }
107
+ ]
108
+ ```
109
+
110
+ ## 使用示例
111
+
112
+ ### 默认三级联动
113
+
114
+ ```vue
115
+ <jh-address-select
116
+ v-model="address"
117
+ :data="addressData"
118
+ ></jh-address-select>
119
+ ```
120
+
121
+ ### 仅选择到城市
122
+
123
+ ```vue
124
+ <jh-address-select
125
+ v-model="address"
126
+ :level="2"
127
+ :data="addressData"
128
+ ></jh-address-select>
129
+ ```
130
+
131
+ ### 仅选择省份
132
+
133
+ ```vue
134
+ <jh-address-select
135
+ v-model="address"
136
+ :level="1"
137
+ :data="addressData"
138
+ ></jh-address-select>
139
+ ```
140
+
141
+ ### 四级联动(省市区镇)
142
+
143
+ ```vue
144
+ <jh-address-select
145
+ v-model="address"
146
+ :level="4"
147
+ :data="addressData"
148
+ ></jh-address-select>
149
+ ```
150
+
151
+ ### 四级联动(带初始值)
152
+
153
+ ```vue
154
+ <jh-address-select
155
+ v-model="address"
156
+ :level="4"
157
+ :data="addressData"
158
+ ></jh-address-select>
159
+
160
+ <script>
161
+ export default {
162
+ data() {
163
+ return {
164
+ address: {
165
+ province: { code: '440000', name: '广东省' },
166
+ city: { code: '440300', name: '深圳市' },
167
+ district: { code: '440305', name: '南山区' },
168
+ town: { code: '440305001', name: '南头街道' }
169
+ }
170
+ };
171
+ }
172
+ };
173
+ </script>
174
+ ```
175
+
176
+ ### 紧凑模式
177
+
178
+ ```vue
179
+ <jh-address-select
180
+ v-model="address"
181
+ dense
182
+ :data="addressData"
183
+ ></jh-address-select>
184
+ ```
185
+
186
+ ### 自定义标签文本
187
+
188
+ ```vue
189
+ <jh-address-select
190
+ v-model="address"
191
+ :labels="{ province: '所在省份', city: '所在城市', district: '所在区县' }"
192
+ :data="addressData"
193
+ ></jh-address-select>
194
+ ```
195
+
196
+ ### 加载状态
197
+
198
+ ```vue
199
+ <jh-address-select
200
+ v-model="address"
201
+ :loading="isLoading"
202
+ :data="addressData"
203
+ ></jh-address-select>
204
+ ```
205
+
206
+ ### 使用 filled 样式
207
+
208
+ ```vue
209
+ <jh-address-select
210
+ v-model="address"
211
+ :outlined="false"
212
+ :data="addressData"
213
+ ></jh-address-select>
214
+ ```
215
+
216
+ ### 监听变化
217
+
218
+ ```vue
219
+ <template>
220
+ <jh-address-select
221
+ v-model="address"
222
+ :data="addressData"
223
+ @change="handleAddressChange"
224
+ ></jh-address-select>
225
+ </template>
226
+
227
+ <script>
228
+ export default {
229
+ methods: {
230
+ handleAddressChange(value) {
231
+ console.log('地址变化:', value);
232
+ }
233
+ }
234
+ };
235
+ </script>
236
+ ```
237
+
238
+ ## 注意事项
239
+
240
+ 1. **数据格式**: data 属性必须符合指定的嵌套格式,包含 code 和 name 字段
241
+ 2. **层级控制**: level 属性控制显示的级数,设置为 1 时只显示省份,2 时显示省市,3 时显示省市区,4 时显示省市区镇
242
+ 3. **联动逻辑**: 选择省份后会清空城市、区县和乡镇,选择城市后会清空区县和乡镇,选择区县后会清空乡镇
243
+ 4. **禁用状态**: 未选择上级时,下级选择器会自动禁用
244
+ 5. **响应式布局**: 组件会根据 level 自动调整栅格布局(level=1 时占 12 列,level=2 时占 6 列,level=3 时占 4 列,level=4 时占 3 列)
245
+ 6. **返回值格式**: v-model 和事件返回的值包含 code 和 name 两个字段,方便获取编码和名称
246
+
247
+ ## 相关链接
248
+
249
+ - [Vuetify Autocomplete](https://vuetifyjs.com/en/components/autocompletes/)
250
+ - [中国行政区划代码](http://www.mca.gov.cn/article/sj/xzqh/)