hbte-saas-ui 0.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 (137) hide show
  1. package/.browserslistrc +3 -0
  2. package/.editorconfig +7 -0
  3. package/.env.development +1 -0
  4. package/.env.lib +1 -0
  5. package/.eslintrc.js +14 -0
  6. package/.prettierrc +3 -0
  7. package/README.md +53 -0
  8. package/babel.config.js +3 -0
  9. package/docs/.vuepress/config.js +23 -0
  10. package/docs/.vuepress/styles/index.styl +4 -0
  11. package/docs/AdvQuery.md +26 -0
  12. package/docs/CustomQuery.md +21 -0
  13. package/docs/EditArea.md +16 -0
  14. package/docs/FilterDrop.md +29 -0
  15. package/docs/FullTable.md +68 -0
  16. package/docs/Pagination.md +22 -0
  17. package/docs/QueryForm.md +27 -0
  18. package/docs/README.md +17 -0
  19. package/docs/Table.md +58 -0
  20. package/docs/ToolGroup.md +32 -0
  21. package/examples/App.vue +97 -0
  22. package/examples/image/hb-image-viewer/3k.jpg +0 -0
  23. package/examples/image/hb-image-viewer/a.jpg +0 -0
  24. package/examples/image/hb-image-viewer/b.jpg +0 -0
  25. package/examples/main.js +39 -0
  26. package/examples/mock/authority.js +1108 -0
  27. package/examples/mock/dept.js +4001 -0
  28. package/examples/mock/fulltable.js +407 -0
  29. package/examples/mock/organizeData.js +18965 -0
  30. package/examples/router/index.js +111 -0
  31. package/examples/views/ElementCpTest.vue +299 -0
  32. package/examples/views/Fragment.vue +196 -0
  33. package/examples/views/HBAdvQuery.vue +150 -0
  34. package/examples/views/HBAuthority.vue +339 -0
  35. package/examples/views/HBDialog.vue +39 -0
  36. package/examples/views/HBEditarea.vue +350 -0
  37. package/examples/views/HBFilterDrop.vue +72 -0
  38. package/examples/views/HBFloatFooter.vue +42 -0
  39. package/examples/views/HBFullTable.vue +751 -0
  40. package/examples/views/HBImageViewer.vue +57 -0
  41. package/examples/views/HBNavMenu.vue +37 -0
  42. package/examples/views/HBOrganizeDialog.vue +133 -0
  43. package/examples/views/HBPagination.vue +80 -0
  44. package/examples/views/HBSelectVague.vue +57 -0
  45. package/examples/views/HBToolgroup.vue +29 -0
  46. package/examples/views/HBTopBar.vue +16 -0
  47. package/lib/demo.html +10 -0
  48. package/lib/fonts/iconfont.9e99af35.ttf +0 -0
  49. package/lib/hbte-ui.common.js +38291 -0
  50. package/lib/hbte-ui.css +1 -0
  51. package/lib/hbte-ui.umd.js +38301 -0
  52. package/lib/hbte-ui.umd.min.js +21 -0
  53. package/lib/img/nodata.f87d17c1.png +0 -0
  54. package/lib/img/user-logo--default.a53bd193.png +0 -0
  55. package/package.json +40 -0
  56. package/packages/adv-query/index.js +5 -0
  57. package/packages/adv-query/src/main.vue +294 -0
  58. package/packages/area-select/index.js +7 -0
  59. package/packages/area-select/src/main.vue +37 -0
  60. package/packages/authority/index.js +5 -0
  61. package/packages/authority/src/main.vue +606 -0
  62. package/packages/config.js +3 -0
  63. package/packages/custom-query/index.js +5 -0
  64. package/packages/custom-query/src/main.vue +80 -0
  65. package/packages/dialog/index.js +7 -0
  66. package/packages/dialog/src/main.vue +176 -0
  67. package/packages/edit-area/index.js +13 -0
  68. package/packages/edit-area/src/config.js +3 -0
  69. package/packages/edit-area/src/main.vue +304 -0
  70. package/packages/edit-area/src/simulateEvent.js +219 -0
  71. package/packages/filter-drop/index.js +6 -0
  72. package/packages/filter-drop/src/main.vue +107 -0
  73. package/packages/float-footer/index.js +7 -0
  74. package/packages/float-footer/src/main.vue +40 -0
  75. package/packages/fragment/index.js +7 -0
  76. package/packages/fragment/src/main.vue +74 -0
  77. package/packages/fragment/src/old.vue +144 -0
  78. package/packages/full-table/index.js +6 -0
  79. package/packages/full-table/src/config.js +14 -0
  80. package/packages/full-table/src/main.vue +141 -0
  81. package/packages/image-viewer/index.js +8 -0
  82. package/packages/image-viewer/src/main.js +14 -0
  83. package/packages/image-viewer/src/main.vue +138 -0
  84. package/packages/image-viewer/src/svg/cancel.svg +2 -0
  85. package/packages/image-viewer/src/svg/delete.svg +2 -0
  86. package/packages/image-viewer/src/svg/download.svg +2 -0
  87. package/packages/image-viewer/src/svg/rotate.svg +77 -0
  88. package/packages/image-viewer/src/svg/scaledown.svg +71 -0
  89. package/packages/image-viewer/src/svg/scaleup.svg +72 -0
  90. package/packages/index.js +43 -0
  91. package/packages/nav-menu/index.js +7 -0
  92. package/packages/nav-menu/src/main.vue +277 -0
  93. package/packages/organize-dialog/index.js +5 -0
  94. package/packages/organize-dialog/src/main.vue +427 -0
  95. package/packages/pagination/index.js +6 -0
  96. package/packages/pagination/src/main.vue +145 -0
  97. package/packages/query-form/index.js +5 -0
  98. package/packages/query-form/src/main.vue +142 -0
  99. package/packages/select-vague/index.js +5 -0
  100. package/packages/select-vague/src/main.vue +80 -0
  101. package/packages/table/index.js +5 -0
  102. package/packages/table/src/main.vue +265 -0
  103. package/packages/theme-chalk/adv-query.scss +107 -0
  104. package/packages/theme-chalk/authority.scss +103 -0
  105. package/packages/theme-chalk/common/elementCover.scss +722 -0
  106. package/packages/theme-chalk/common/flex.scss +66 -0
  107. package/packages/theme-chalk/common/global.scss +147 -0
  108. package/packages/theme-chalk/common/reset.scss +92 -0
  109. package/packages/theme-chalk/common/var.scss +46 -0
  110. package/packages/theme-chalk/custom-query.scss +10 -0
  111. package/packages/theme-chalk/dialog.scss +9 -0
  112. package/packages/theme-chalk/edit-area.scss +119 -0
  113. package/packages/theme-chalk/filter-drop.scss +81 -0
  114. package/packages/theme-chalk/float-footer.scss +14 -0
  115. package/packages/theme-chalk/fonts/iconfont.ttf +0 -0
  116. package/packages/theme-chalk/fragment.scss +51 -0
  117. package/packages/theme-chalk/full-table.scss +40 -0
  118. package/packages/theme-chalk/icon.scss +96 -0
  119. package/packages/theme-chalk/image-viewer.scss +94 -0
  120. package/packages/theme-chalk/images/company-logo--default.png +0 -0
  121. package/packages/theme-chalk/images/nodata.png +0 -0
  122. package/packages/theme-chalk/images/user-logo--default.png +0 -0
  123. package/packages/theme-chalk/index.scss +21 -0
  124. package/packages/theme-chalk/nav-menu.scss +205 -0
  125. package/packages/theme-chalk/organize-dialog.scss +170 -0
  126. package/packages/theme-chalk/pagination.scss +91 -0
  127. package/packages/theme-chalk/select.scss +8 -0
  128. package/packages/theme-chalk/table.scss +102 -0
  129. package/packages/theme-chalk/tool-group.scss +105 -0
  130. package/packages/theme-chalk/top-bar.scss +195 -0
  131. package/packages/tool-group/index.js +13 -0
  132. package/packages/tool-group/src/config.js +40 -0
  133. package/packages/tool-group/src/main.vue +93 -0
  134. package/packages/top-bar/index.js +7 -0
  135. package/packages/top-bar/src/main.vue +280 -0
  136. package/public/index.html +20 -0
  137. package/vue.config.js +6 -0
@@ -0,0 +1,176 @@
1
+ <template>
2
+ <div class="hb-dialog">
3
+ <el-dialog
4
+ v-bind="$attrs"
5
+ v-on="$listeners"
6
+ :title="title"
7
+ :visible.sync="visible"
8
+ :close-on-click-modal="closeOnClick"
9
+ :close-on-press-escape="closeOnEsc"
10
+ :destroy-on-close="true"
11
+ @close="onClose"
12
+ @closed="onClosed"
13
+ >
14
+ <!-- 弹窗主体内容插槽,before和after插槽只是为了普通内容和表单内容的布局考虑 -->
15
+ <div class="content hb-dialog__wrapper">
16
+ <slot name="before"></slot>
17
+ <!-- 表单内容插槽 -->
18
+ <el-form
19
+ class="form-wrapper"
20
+ ref="ruleForm"
21
+ size="small"
22
+ v-if="formData"
23
+ :model="formData"
24
+ :rules="rules"
25
+ :label-width="labelWidth"
26
+ :label-position="labelPosition"
27
+ >
28
+ <slot name="form"></slot>
29
+ </el-form>
30
+ <!-- 普通内容插槽 -->
31
+ <slot name="normal"></slot>
32
+ <slot name="after"></slot>
33
+ </div>
34
+ <slot name="bottom"></slot>
35
+ <!-- 底部按钮插槽 -->
36
+
37
+ <!-- 默认底部按钮组,父组件传自定义按钮组件则默认的不显示 -->
38
+ <div
39
+ class="default-footer-btn-wrapper flex-end hb-dialog__footer-btn"
40
+ slot="footer"
41
+ v-if="showFooter"
42
+ >
43
+ <slot name="dialogFooter" :submit="submit" :loading="loading">
44
+ <el-button
45
+ class="exist-btn"
46
+ size="small"
47
+ @click="close(false, $event)"
48
+ v-show="footerText.exist"
49
+ >{{ footerText.exist }}</el-button
50
+ >
51
+ <el-button
52
+ type="primary"
53
+ class="confirm-btn"
54
+ size="small"
55
+ @click="submit"
56
+ :loading="loading"
57
+ v-show="footerText.confirm"
58
+ >{{ footerText.confirm }}</el-button
59
+ >
60
+ </slot>
61
+ </div>
62
+ </el-dialog>
63
+ </div>
64
+ </template>
65
+ <script>
66
+ export default {
67
+ name: "HbDialog",
68
+ componentName: "HbDialog",
69
+ data() {
70
+ return {
71
+ visible: false,
72
+ loading: false,
73
+ };
74
+ },
75
+ props: {
76
+ title: {
77
+ type: String,
78
+ default: "",
79
+ },
80
+ labelPosition: {
81
+ type: String,
82
+ default: "top",
83
+ },
84
+ labelWidth: {
85
+ type: String,
86
+ default: "80px",
87
+ },
88
+ closeOnClick: {
89
+ default: () => false,
90
+ },
91
+ closeOnEsc: {
92
+ default: () => false,
93
+ },
94
+ footerText: {
95
+ default: () => {
96
+ // 默认底部按钮组文案
97
+ return {
98
+ confirm: "确定",
99
+ exist: "取消",
100
+ };
101
+ },
102
+ },
103
+ formData: {
104
+ default: () => null,
105
+ },
106
+ rules: {
107
+ default: () => {},
108
+ },
109
+ appendBody: {
110
+ default: false,
111
+ },
112
+ modalAppendBody: {
113
+ default: true,
114
+ },
115
+ // 是否显示底部按钮区域
116
+ showFooter: {
117
+ default: true,
118
+ },
119
+ },
120
+ methods: {
121
+ open() {
122
+ this.visible = true;
123
+ },
124
+ close() {
125
+ this.visible = false;
126
+ },
127
+ submit(arg) {
128
+ // 发起请求前进行表单值校验
129
+ if (this.formData) {
130
+ this.$refs.ruleForm.validate((valid) => {
131
+ if (valid) {
132
+ this.loading = true;
133
+ this.$emit("submit", arg);
134
+ } else {
135
+ return false;
136
+ }
137
+ });
138
+ } else {
139
+ this.loading = true;
140
+ this.$emit("submit", arg);
141
+ }
142
+ },
143
+ onClose() {
144
+ this.resetRuleForm();
145
+ this.$emit("close");
146
+ },
147
+ onClosed() {
148
+ this.resetLoading(); // 防止弹窗动画结束前暴力点击确认按钮
149
+ this.$emit("closed");
150
+ },
151
+ resetLoading() {
152
+ // 常用于父组件请求失败后关闭按钮的loading状态
153
+ this.loading = false;
154
+ },
155
+ resetRuleForm() {
156
+ // 对话框关闭,还原表单值
157
+ this.formData && this.$refs.ruleForm.resetFields(); // 如果有表单则还原表单的值
158
+ },
159
+ // 重新触发验证
160
+ validate() {
161
+ this.$refs.ruleForm.validate();
162
+ },
163
+ // 清空验证
164
+ clearValidate() {
165
+ this.$nextTick(() => {
166
+ this.$refs.ruleForm && this.$refs.ruleForm.clearValidate();
167
+ });
168
+ },
169
+ // 单独触发某一项的验证
170
+ validateSomeField(fielidName) {
171
+ this.$refs.ruleForm.validateField(fielidName);
172
+ },
173
+ },
174
+ };
175
+ </script>
176
+
@@ -0,0 +1,13 @@
1
+ import HbEditarea from "./src/main.vue";
2
+ import config from "./src/config.js"
3
+
4
+ HbEditarea.install = function (Vue) {
5
+ Vue.component(HbEditarea.name, HbEditarea);
6
+ };
7
+ HbEditarea.config = function (params) {
8
+ // 空值处理策略
9
+ config.emptyClear = !!params.emptyClear
10
+
11
+ };
12
+
13
+ export default HbEditarea;
@@ -0,0 +1,3 @@
1
+ export default {
2
+ emptyClear: false, // 输入置空时失焦是否清空值
3
+ }
@@ -0,0 +1,304 @@
1
+ <template>
2
+ <!-- 常驻编辑 -->
3
+ <p v-if="keepEdit" class="hb-editarea">
4
+ <i v-if="loading" class="el-icon-loading hb-editarea__loading"></i>
5
+ <span v-else class="hb-editarea__form">
6
+ <hb-query-form
7
+ :formProp="{
8
+ prop: 'cache',
9
+ type: type,
10
+ optList: optList,
11
+ multiple: multiple,
12
+ placeholder: placeholder,
13
+ }"
14
+ :qryFormData="cache"
15
+ size="mini"
16
+ class="hb-editarea__form-item"
17
+ @[passType[type].event]="handleSave(false)"
18
+ @focus="handleFocus"
19
+ ></hb-query-form>
20
+ <el-tooltip
21
+ v-if="error"
22
+ effect="dark"
23
+ :content="error"
24
+ placement="bottom"
25
+ >
26
+ <i class="el-icon-warning hb-editarea-error hb-editarea-icon"></i>
27
+ </el-tooltip>
28
+ </span>
29
+ </p>
30
+ <!-- 双击编辑 -->
31
+ <p v-else class="hb-editarea">
32
+ <span v-if="!editing" @dblclick="handleEdit" class="hb-editarea__text"
33
+ >{{ value }}
34
+ <i class="el-icon-edit hb-editarea-icon" @click="handleEdit"></i
35
+ ></span>
36
+ <span v-else-if="!loading" class="hb-editarea__edit">
37
+ <hb-query-form
38
+ :formProp="{
39
+ prop: 'cache',
40
+ type: type,
41
+ optList: optList,
42
+ multiple: multiple,
43
+ }"
44
+ :qryFormData="cache"
45
+ size="mini"
46
+ class="hb-editarea__edit-input"
47
+ @[passType[type].event]="handleSave(false)"
48
+ @focus="handleFocus"
49
+ ></hb-query-form>
50
+ <el-tooltip
51
+ v-if="error"
52
+ effect="dark"
53
+ :content="error"
54
+ placement="bottom"
55
+ >
56
+ <i class="el-icon-warning hb-editarea-error hb-editarea-icon"></i>
57
+ </el-tooltip>
58
+ <div v-if="border" class="hb-editarea__bg hb-editarea__bg--border"></div>
59
+ <div v-else class="hb-editarea__bg"></div>
60
+ </span>
61
+ <i v-if="loading" class="el-icon-loading hb-editarea__loading"></i>
62
+ </p>
63
+ </template>
64
+
65
+ <script>
66
+ import CONFIG from "./config.js";
67
+ import { bindFocus, unBindFocus } from "./simulateEvent.js";
68
+ export default {
69
+ name: "HbEditarea",
70
+ componentName: "HbEditarea",
71
+ props: {
72
+ keepEdit: {
73
+ type: Boolean,
74
+ default: () => false,
75
+ },
76
+ /** 传递给queryForm控件的事件 */
77
+ type: {
78
+ type: String,
79
+ default: () => "input",
80
+ },
81
+ optList: {
82
+ type: Array,
83
+ default: () => [],
84
+ },
85
+ multiple: {
86
+ type: Boolean,
87
+ default: () => false,
88
+ },
89
+ value: {
90
+ default: () => "",
91
+ },
92
+ placeholder: {
93
+ default: () => "请编辑内容",
94
+ },
95
+ /** 编辑时值为空时是否保存,传入true将会在清空时保存空值 */
96
+ emptyClear: {
97
+ default: () => false,
98
+ },
99
+ /** 编辑时是否显示边框 */
100
+ border: {
101
+ type: Boolean,
102
+ default: () => false,
103
+ },
104
+ /** 回填、保存等回调 */
105
+ insert: {
106
+ type: Function,
107
+ default: null,
108
+ },
109
+ change: {
110
+ type: Function,
111
+ default: null,
112
+ },
113
+ /** 校验 */
114
+ validate: {
115
+ type: Function,
116
+ default: null,
117
+ },
118
+ },
119
+ data() {
120
+ return {
121
+ /** 状态 */
122
+ loading: false,
123
+ error: false,
124
+ editing: false,
125
+ /** 缓存值 */
126
+ cache: { cache: null },
127
+ /** 编辑可用的控件类型及对应的失焦事件、初始值 */
128
+ passType: {
129
+ input: { event: "blur", empty: "" },
130
+ select: { event: "change", empty: [] },
131
+ date: { event: "blur", empty: "" },
132
+ daterange: { event: "blur", empty: [] },
133
+ switch: { event: null, empty: null },
134
+ checkbox: { event: "change", empty: [] },
135
+ radio: { event: "change", empty: "" },
136
+ },
137
+ /** 即使不传入insert的类型,用值自动填充,除此之外会置空 */
138
+ insertType: ["input", "select", "switch", "radio", "date"],
139
+ };
140
+ },
141
+ computed: {
142
+ empty() {
143
+ const passTypeData = this.passType[this.type];
144
+ return passTypeData ? passTypeData.empty : null;
145
+ },
146
+ },
147
+ methods: {
148
+ /** api */
149
+ /**
150
+ * @function validateEdit 对外提供一个校验方法,仅在keepEdit=true时有效,会使用validate传参校验控件的输入
151
+ * @param {Function} callback 失败时传入错误
152
+ */
153
+ validateEdit(callback) {
154
+ if (this.keepEdit) {
155
+ this.cacheValidate(typeof callback === "function" ? callback : null);
156
+ } else {
157
+ typeof callback === "function" &&
158
+ callback(new Error("当前控件不支持手动校验"));
159
+ }
160
+ },
161
+ /** methods */
162
+ /**
163
+ * @function reset 重置控件,回到初始状态
164
+ */
165
+ reset() {
166
+ this.$set(this.cache, "cache", null);
167
+ this.editing = false;
168
+ this.loading = false;
169
+ this.error = "";
170
+ },
171
+ /**
172
+ * @function cacheValidate 校验cache,并显示错误
173
+ * @param {Function} callback 校验成功回调,失败时传入错误
174
+ */
175
+ cacheValidate(callback) {
176
+ const cache = this.cache.cache;
177
+ if (typeof this.validate === "function") {
178
+ this.loading = true;
179
+ this.validate((error) => {
180
+ this.loading = false;
181
+ if (Object.prototype.toString.call(error) === "[object Error]") {
182
+ this.error = String(error.message);
183
+ typeof callback === "function" && callback(error);
184
+ } else {
185
+ this.error = "";
186
+ typeof callback === "function" && callback();
187
+ }
188
+ }, cache);
189
+ } else {
190
+ typeof callback === "function" && callback();
191
+ }
192
+ },
193
+ /** events */
194
+ /**
195
+ * @event handleEdit 开始编辑单元格
196
+ */
197
+ handleEdit() {
198
+ // 进入编辑状态,清空上次的cache
199
+ if (this.editing) {
200
+ return;
201
+ }
202
+ this.reset();
203
+ this.editing = true;
204
+ // 回填值处理
205
+ if (typeof this.insert === "function") {
206
+ // 优先采用传入的insert回填值
207
+ this.$set(this.cache, "cache", this.insert(this.value));
208
+ } else if (this.insertType.indexOf(this.type) !== -1) {
209
+ // 部分类型回填value
210
+ this.$set(this.cache, "cache", this.value);
211
+ } else {
212
+ // 其他情况置空
213
+ this.$set(this.cache, "cache", this.empty);
214
+ }
215
+ },
216
+ /**
217
+ * @event handleFocus 获得焦点时清空error
218
+ */
219
+ handleFocus() {
220
+ this.error = "";
221
+ },
222
+ /**
223
+ * @event handleSave 编辑单元格完成
224
+ * @param {Boolean} simulation 模拟标记,模拟失焦触发时传入true,避免多选等控件持续触发change造成错误的保存时机
225
+ */
226
+ handleSave(simulation) {
227
+ const cache = this.cache.cache;
228
+ if (this.keepEdit) {
229
+ // keepEdit状态,true直接进行保存并同时校验
230
+ if (simulation || this.loading) {
231
+ // 不处理:全局失焦或loading状态不处理
232
+ return;
233
+ }
234
+ // 多选控件change时保存不影响
235
+ // if (this.multiple && !simulation) {
236
+ // return;
237
+ // }
238
+ this.cacheValidate(() => {
239
+ // 无论成功失败都改变值
240
+ this.$emit("update:value", cache);
241
+ });
242
+ } else {
243
+ // 非keepEdit状态完全由组件接管校验
244
+ if (!this.editing || this.loading) {
245
+ // 不处理:未处于编辑状态或loading状态不处理
246
+ return;
247
+ }
248
+ if (this.multiple && !simulation) {
249
+ // 多选类型控件仅全局失焦时处理
250
+ return;
251
+ }
252
+ // 失焦保存处理
253
+ const handler = (er) => {
254
+ if (er) {
255
+ return;
256
+ }
257
+ // 1.如果值没有变化不触发事件
258
+ if (cache === this.value) {
259
+ this.editing = false;
260
+ return;
261
+ }
262
+ // 2.值为空根据传参决定是否保存空值
263
+ if (cache === this.empty) {
264
+ if (CONFIG.emptyClear || this.emptyClear) {
265
+ this.$emit("update:value", this.empty);
266
+ }
267
+ this.editing = false;
268
+ return;
269
+ }
270
+ // 3.进行保存
271
+ if (typeof this.change === "function") {
272
+ // 3.1如果传入了change函数,将会由change接管处理,不再对value赋值
273
+ this.loading = true;
274
+ this.change(() => {
275
+ this.reset();
276
+ }, cache);
277
+ } else {
278
+ // 3.2未传入change将直接对value进行赋值;注意外面需要使用.sync修饰符绑定value
279
+ this.$emit("update:value", cache);
280
+ this.editing = false;
281
+ }
282
+ };
283
+ // 校验成功进行保存,失败进入error状态
284
+ this.cacheValidate(handler);
285
+ }
286
+ },
287
+ },
288
+ mounted() {
289
+ // 配置点击hb-editarea以外的区域触发focus
290
+ // configFocus("hb-editarea__wrap");
291
+ // if (this.$el.parentNode.className.indexOf("hb-editarea__wrap") === -1) {
292
+ // this.$el.parentNode.className += " hb-editarea__wrap";
293
+ // }
294
+ // 测试
295
+ unBindFocus(this.$el);
296
+ bindFocus(this.$el, () => {
297
+ this.handleSave(true);
298
+ });
299
+ if (this.keepEdit) {
300
+ this.$set(this.cache, "cache", this.value);
301
+ }
302
+ },
303
+ };
304
+ </script>