@elementplus-kit/uikit 1.0.1 → 1.0.3

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 (31) hide show
  1. package/components/button/index.ts +4 -0
  2. package/components/button/src/constants.ts +50 -0
  3. package/components/button/src/index.ts +91 -0
  4. package/components/dictLabel/index.ts +4 -0
  5. package/components/dictLabel/src/index.vue +21 -0
  6. package/components/form/src/index.ts +18 -3
  7. package/components/form/style/index.scss +5 -0
  8. package/components/{index.js → index.ts} +6 -0
  9. package/components/search/index.ts +2 -2
  10. package/components/search/src/{index.vue → index-/346/272/220.vue} +67 -64
  11. package/components/search/src/index.tsx +172 -0
  12. package/components/search/style/index.scss +93 -0
  13. package/components/{table2 → table}/src/TableColumn.ts +1 -1
  14. package/components/table/src/index.ts +245 -7
  15. package/components/table/src/tableDictLabel.vue +21 -0
  16. package/components/table2/src/index.ts +7 -205
  17. package/components/{table → table2}/src/types.ts +39 -39
  18. package/components/table2/style/index.scss +0 -0
  19. package/components//346/250/241/346/235/277/index.tsx +57 -0
  20. package/components//346/250/241/346/235/277/ttt.ts +3 -2
  21. package/components//346/250/241/346/235/277/ttt.vue +18 -0
  22. package/package.json +2 -2
  23. /package/components/{table → button}/style/index.scss +0 -0
  24. /package/components/{table2 → table}/src/constants.ts +0 -0
  25. /package/components/{table2 → table}/src/index2.ts +0 -0
  26. /package/components/{table2 → table}/src/index3.ts +0 -0
  27. /package/components/{table2 → table}/src/tableaa.ts +0 -0
  28. /package/components/{table2 → table}/src/type.ts +0 -0
  29. /package/components/{table2 → table}/type/index.scss +0 -0
  30. /package/components/{table → table2}/src/config.ts +0 -0
  31. /package/components/{table → table2}/src/render.ts +0 -0
@@ -0,0 +1,4 @@
1
+ import Button from "./src/index";
2
+ export * from "./src/index";
3
+ export { Button };
4
+ export default Button;
@@ -0,0 +1,50 @@
1
+ export const typeActiveMap = {
2
+ reset: {
3
+ name: "重置",
4
+ type: "info",
5
+ },
6
+ search: {
7
+ name: "查询",
8
+ type: "primary",
9
+ },
10
+ submit: {
11
+ name: "提交",
12
+ type: "primary",
13
+ },
14
+ save: {
15
+ name: "保存",
16
+ type: "primary",
17
+ },
18
+ create: {
19
+ name: "新增",
20
+ type: "primary",
21
+ },
22
+ delete: {
23
+ name: "删除",
24
+ type: "danger",
25
+ },
26
+ edit: {
27
+ name: "编辑",
28
+ type: "primary",
29
+ },
30
+ view: {
31
+ name: "查看",
32
+ type: "primary",
33
+ },
34
+ publish: {
35
+ name: "发布",
36
+ type: "primary",
37
+ },
38
+ import: {
39
+ name: "导入",
40
+ type: "primary",
41
+ },
42
+ export: {
43
+ name: "导出",
44
+ type: "primary",
45
+ },
46
+ exportAll: {
47
+ name: "导出全部",
48
+ type: "primary",
49
+ },
50
+ };
@@ -0,0 +1,91 @@
1
+ import { defineComponent, h } from "vue";
2
+ import { ElButton } from "element-plus";
3
+
4
+ // import '../style/index.scss';
5
+ import { typeActiveMap } from "./constants.ts";
6
+ import { has, isBoolean, isFunction, isArray } from "lodash-es";
7
+ export default defineComponent({
8
+ props: {
9
+ params: {
10
+ // 用于验证自定义函数的外部数据
11
+ type: Object,
12
+ default: () => ({}),
13
+ },
14
+ // modelValue: {
15
+ // type: Object,
16
+ // default: {}
17
+ // },
18
+ buttonOptions: {
19
+ type: Array,
20
+ default: () => [],
21
+ },
22
+ // 权限函数
23
+ hasPermission: {
24
+ type: Function,
25
+ default: () => true,
26
+ },
27
+ // // 权限函数
28
+ // hasRole: {
29
+ // type: Function,
30
+ // default: () => true
31
+ // },
32
+ },
33
+
34
+ setup(props, { emit, slots, attrs, expose }) {
35
+ // const slotsList = ["active", "btn-left", "btn-right"];
36
+ // console.log('slots', slots);
37
+ // console.log('attrs', attrs);
38
+
39
+ // 解析插槽
40
+ const getAttrs = (item) => {
41
+ let defaultAttrs = {};
42
+ // const { alias, hasPermission, vIf, ...p } = item;
43
+ if (item?.alias && typeActiveMap[item.alias]) {
44
+ defaultAttrs = typeActiveMap[item.alias];
45
+ }
46
+ // 过滤掉非elbutton属性
47
+ defaultAttrs = {
48
+ ...defaultAttrs,
49
+ ...item,
50
+ };
51
+ return defaultAttrs;
52
+ };
53
+ const render = () => {
54
+ console.log("render 执行");
55
+ // 过滤权限
56
+ let list = [];
57
+ props.buttonOptions.map((item) => {
58
+ if (has(item, "permission") && isArray(item.permission)) {
59
+ if (props.hasPermission && props.hasPermission(item.permission)) {
60
+ list.push(item);
61
+ }
62
+ } else {
63
+ list.push(item);
64
+ }
65
+ });
66
+
67
+ const listR = [];
68
+ list.map((item) => {
69
+ // if (has(item, "vIf")) {
70
+ if (has(item, "vIf") && isFunction(item.vIf) && item.vIf(props.params) !== undefined) {
71
+ console.log('aaaaaaaaaa', item.vIf(props.params));
72
+ if (item.vIf(props.params)) {
73
+ listR.push(item);
74
+ }
75
+ } else {
76
+ listR.push(item);
77
+ }
78
+ // } else {
79
+ // listR.push(item);
80
+ // }
81
+ });
82
+ console.log("🚀 ~ render ~ listR:", listR);
83
+ return listR.map((item) => {
84
+ return h(ElButton, getAttrs(item), {
85
+ default: () => item?.name,
86
+ });
87
+ });
88
+ };
89
+ return () => render();
90
+ },
91
+ });
@@ -0,0 +1,4 @@
1
+ import DictLabel from "./src/index.vue";
2
+ export * from "./src/index.vue";
3
+ export { DictLabel };
4
+ export default DictLabel;
@@ -0,0 +1,21 @@
1
+ <template>
2
+ {{ label }}
3
+ </template>
4
+ <script setup lang="ts">
5
+ import { computed, PropType } from 'vue'
6
+ const props = defineProps({
7
+ options: {
8
+ type: Array,
9
+ default: () => []
10
+ },
11
+ value: {
12
+ type: String as PropType<any>,
13
+ default: ''
14
+ },
15
+ })
16
+ const label = computed(() => {
17
+ // 处理value为数字的情况 后端字典都是字符串
18
+ const item = props.options?.find((item) => item.value == props.value.toString());
19
+ return item?.label || props.value;
20
+ });
21
+ </script>
@@ -14,7 +14,7 @@ import zhCn from "element-plus/es/locale/lang/zh-cn";
14
14
  import CFormItem from "./FormItem.ts";
15
15
  import { has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
16
16
  import { getEmits } from "./constants"; // 获取所有的事件
17
-
17
+ import '../style/index.scss'
18
18
  const propsAttrs = {
19
19
  // 表单数据
20
20
  model: { type: Object, default: () => ({}) },
@@ -30,6 +30,8 @@ const propsAttrs = {
30
30
  },
31
31
  // row 列数
32
32
  col: { type: Number, default: undefined },
33
+ // 额外业务全局参数
34
+ params: { type: Object, default: () => ({}) },
33
35
  };
34
36
 
35
37
  export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
@@ -81,6 +83,7 @@ export default defineComponent({
81
83
 
82
84
  // 渲染 row
83
85
  const renderRow = () => {
86
+ const formItemVdom = renderFormItem();
84
87
  if (isLayout.value) {
85
88
  return h(
86
89
  ElRow,
@@ -91,16 +94,28 @@ export default defineComponent({
91
94
  ...$attrs,
92
95
  },
93
96
  {
94
- default: () => renderFormItem(),
97
+ default: () => formItemVdom,
95
98
  }
96
99
  );
97
100
  } else {
98
- return renderFormItem();
101
+ return formItemVdom;
99
102
  }
100
103
  };
101
104
 
102
105
  // 渲染表单项
103
106
  const renderFormItem = () => {
107
+ // 过滤权限
108
+ const list = []
109
+ formOptions.value.map((item) => {
110
+ // 处理 vIf 显示隐藏
111
+ if(has(item, 'vIf')) {
112
+ if (isFunction(item.vIf) && item.vIf(props.model, props.params)) {
113
+ list.push(item)
114
+ }
115
+ } else {
116
+ list.push(item)
117
+ }
118
+ })
104
119
  return formOptions.value.map((item) => {
105
120
  // const { label, prop, type, required, col, formItem, attrs } = item
106
121
  // const { label, prop, type, required, col, formItem, attrs, ...args } = item
@@ -0,0 +1,5 @@
1
+ .c-form.el-form--inline {
2
+ .el-select {
3
+ --el-select-width: 220px;
4
+ }
5
+ }
@@ -33,6 +33,12 @@ import Search from "./search/index.ts";
33
33
  export * from "./search/index.ts";
34
34
  export const CSearch = Search;
35
35
 
36
+ // 按钮
37
+ import Button from "./button/index.ts";
38
+ export * from "./button/index.ts";
39
+ export const CButton = Button;
40
+
41
+
36
42
  // 测试单个引入-----------------------------
37
43
  // export * from "./dialog/index.ts"; // 弹窗
38
44
  // export * from "./drawer/index.ts"; // 抽屉
@@ -1,4 +1,4 @@
1
- import Search from "./src/index.vue";
2
- export * from "./src/index.vue";
1
+ import Search from "./src/index.tsx";
2
+ export * from "./src/index.tsx";
3
3
  export { Search };
4
4
  export default Search;
@@ -11,10 +11,12 @@
11
11
  </div>
12
12
  <div class="c-search-simple-btn">
13
13
  <slot name="btn-left" />
14
- <el-icon @click="handleShow" v-if="showCount < props.formOptions.length" class="c-search-icon"
14
+ <div class="c-search-simple-icon" @click="handleShow" v-if="showCount < props.formOptions.length"
15
15
  :class="{ 'icon-rotate': showSearchForm }">
16
- <ArrowUpBold />
17
- </el-icon>
16
+ <el-icon class="c-search-icon">
17
+ <ArrowUpBold />
18
+ </el-icon>
19
+ </div>
18
20
  <el-button type="primary" @click="handleSearch">搜索</el-button>
19
21
  <el-button type="primary" @click="handleReset">重置</el-button>
20
22
  <slot name="btn-right" />
@@ -23,7 +25,7 @@
23
25
  <!-- 下拉悬浮 -->
24
26
  <transition name="search-form-transition">
25
27
  <el-card class="c-search-form" v-if="showSearchForm && props.isDrawer">
26
- <c-form v-bind="getEvent()" inline :model="formData"
28
+ <c-form v-bind="getEvent(), getSlot('form')"" inline :model="formData"
27
29
  :formOptions="props.formOptions.filter((item, index) => index >= showCount)" ref="formRef">
28
30
  </c-form>
29
31
  <div style="text-align: right;">
@@ -86,6 +88,7 @@ const getEvent = (name: string) => {
86
88
  })
87
89
  return obj
88
90
  }
91
+
89
92
  // 解析插槽
90
93
  const getSlot = (type: 'form' | 'search') => {
91
94
  let searchObj: any = {}
@@ -101,18 +104,15 @@ const getSlot = (type: 'form' | 'search') => {
101
104
  }
102
105
 
103
106
  const handleSearch = () => {
104
- console.log('搜索内容:')
105
107
  emit('search')
106
108
  showSearchForm.value = false
107
109
  }
108
110
 
109
111
  const handleReset = () => {
110
- console.log('搜索重置:')
111
112
  emit('reset')
112
113
  }
113
114
 
114
115
  const handleClose = () => {
115
- console.log('搜索关闭:')
116
116
  showSearchForm.value = false
117
117
  emit('close')
118
118
  }
@@ -173,81 +173,84 @@ const handleShow = () => {
173
173
  .c-search-simple-btn {
174
174
  display: flex;
175
175
  margin-left: auto;
176
+ }
176
177
 
177
- .c-search-icon {
178
- display: inline-block;
179
- // 添加鼠标悬停效果
180
- cursor: pointer;
181
- height: 32px;
182
- width: 32px;
183
- line-height: 32px;
184
- text-align: center;
185
- margin-right: 10px;
186
- background-color: #409eff;
187
- padding-top: 2px;
188
- transition: all 0.2s;
189
- border-radius: 4px;
190
- color: #fff;
191
-
192
- &:hover {
193
- background-color: rgb(121, 187, 255);
194
- }
195
-
196
- &:active {
197
- background-color: rgb(51, 126, 204);
198
- }
178
+ .c-search-simple-icon {
179
+ display: flex;
180
+ justify-content: center;
181
+ align-items: center;
182
+ cursor: pointer;
183
+ height: 32px;
184
+ width: 32px;
185
+ margin-right: 10px;
186
+ border-radius: 4px;
187
+ background-color: #409eff;
188
+ transition: all 0.2s;
189
+
190
+ &:hover {
191
+ background-color: rgb(121, 187, 255);
199
192
  }
200
193
 
201
- .icon-rotate {
202
- transform: rotate(180deg);
194
+ &:active {
203
195
  background-color: rgb(51, 126, 204);
204
196
  }
205
197
  }
206
198
 
199
+ .c-search-icon {
200
+ // 添加鼠标悬停效果
201
+ display: inline-block;
202
+ color: #fff;
203
+ transition: all 0.2s;
204
+
205
+ }
206
+
207
+ .icon-rotate {
208
+ background-color: rgb(51, 126, 204);
209
+
210
+ .c-search-icon {
211
+ transform: rotate(180deg);
212
+ }
213
+ }
214
+
207
215
  .c-search-form {
208
- // padding: 16px;
209
- // background-color: #333;
210
216
  width: 100%;
211
217
  position: absolute;
212
218
  top: 50px;
213
219
  left: 0;
214
220
  overflow: hidden;
215
-
216
- /* 确保内容不会溢出 */
217
- :deep(.el-card__body) {
218
- // padding: 0;
219
- }
221
+ z-index: 10;
222
+ background-color: #fff;
220
223
  }
224
+ }
221
225
 
222
- /* 下拉动画效果 */
223
- .search-form-transition {
226
+ /* 下拉动画效果 */
227
+ .search-form-transition {
224
228
 
225
- &-enter-active,
226
- &-leave-active {
227
- transition: all 0.3s ease;
228
- /* 动画过渡时间和缓动函数 */
229
- overflow: hidden;
230
- max-height: 500px;
231
- /* 确保足够大的最大高度以容纳内容 */
232
- }
229
+ &-enter-active,
230
+ &-leave-active {
231
+ transition: all 0.3s ease;
232
+ /* 动画过渡时间和缓动函数 */
233
+ overflow: hidden;
234
+ max-height: 500px;
235
+ /* 确保足够大的最大高度以容纳内容 */
236
+ }
233
237
 
234
- &-enter-from {
235
- max-height: 0;
236
- /* 入场开始时高度为0 */
237
- opacity: 0;
238
- /* 可以添加透明度效果增强视觉体验 */
239
- padding-top: 0;
240
- padding-bottom: 0;
241
- }
238
+ &-enter-from {
239
+ max-height: 0;
240
+ /* 入场开始时高度为0 */
241
+ opacity: 0;
242
+ /* 可以添加透明度效果增强视觉体验 */
243
+ padding-top: 0;
244
+ padding-bottom: 0;
245
+ }
242
246
 
243
- &-leave-to {
244
- max-height: 0;
245
- /* 出场结束时高度为0 */
246
- opacity: 0;
247
- /* 可以添加透明度效果增强视觉体验 */
248
- padding-top: 0;
249
- padding-bottom: 0;
250
- }
247
+ &-leave-to {
248
+ max-height: 0;
249
+ /* 出场结束时高度为0 */
250
+ opacity: 0;
251
+ /* 可以添加透明度效果增强视觉体验 */
252
+ padding-top: 0;
253
+ padding-bottom: 0;
251
254
  }
252
255
  }
253
256
  </style>
@@ -0,0 +1,172 @@
1
+ import {
2
+ ref,
3
+ computed,
4
+ defineComponent,
5
+ } from "vue";
6
+
7
+ import { CForm, CDrawer } from "@elementplus-kit/uikit";
8
+ import { ArrowUpBold } from "@element-plus/icons-vue";
9
+ import '../style/index.scss';
10
+
11
+ export default defineComponent({
12
+ props: {
13
+ modelValue: {
14
+ type: Object,
15
+ default: {}
16
+ },
17
+ formOptions: {
18
+ type: Array,
19
+ default: () => []
20
+ },
21
+ isDrawer: {
22
+ type: Boolean,
23
+ default: false
24
+ },
25
+ },
26
+ emits: ['update:modelValue', 'search', 'reset', 'close'],
27
+
28
+ setup(props, { emit, slots, attrs, expose }) {
29
+ // 自己的 slot
30
+ const slotsList = ["active", "btn-left", "btn-right"];
31
+ // console.log('slots', slots);
32
+ // console.log('attrs', attrs);
33
+ // 解析 attrs 中的事件
34
+ const getEvent = () => {
35
+ let formObj: any = {};
36
+ Object.keys(attrs)?.forEach((name) => {
37
+ if (name.indexOf("on") === 0) {
38
+ formObj[name] = attrs[name];
39
+ }
40
+ })
41
+ return formObj
42
+ };
43
+
44
+ // 解析插槽
45
+ const getSlot = () => {
46
+ let formObj = {};
47
+ Object.keys(slots).forEach((key) => {
48
+ if (!slotsList.includes(key)) {
49
+ formObj[key] = slots[key];
50
+ }
51
+ });
52
+ return formObj
53
+ };
54
+
55
+ // 搜索
56
+ const handleSearch = () => {
57
+ emit("search");
58
+ showSearchForm.value = false;
59
+ };
60
+ // 重置
61
+ const handleReset = () => {
62
+ emit("reset");
63
+ };
64
+ // 关闭
65
+ const handleClose = () => {
66
+ showSearchForm.value = false;
67
+ emit("close");
68
+ };
69
+
70
+ const showCountC = computed(() => {
71
+ return props.showCount;
72
+ });
73
+
74
+ const showCount = ref(3); // 显示个数
75
+ const showSearchForm = ref(false); // 显示搜索表单
76
+ const handleShow = () => {
77
+ showSearchForm.value = !showSearchForm.value;
78
+ };
79
+ return () => (
80
+ <div className="c-search">
81
+ <div className="c-search-simple">
82
+ <div className="c-search-simple-form">
83
+ <CForm
84
+ {...getEvent()}
85
+ inline
86
+ model={props.modelValue}
87
+ formOptions={props.formOptions?.filter(
88
+ (item, index) => index < showCount.value
89
+ )}
90
+ ref="formRef"
91
+ >
92
+ {getSlot()}
93
+ </CForm>
94
+ </div>
95
+ <div className="c-search-simple-btn">
96
+ {slots["btn-left"]?.()}
97
+ {showCount.value < props.formOptions?.length && (
98
+ <div
99
+ className={
100
+ `c-search-simple-icon ${showSearchForm.value ? "icon-rotate" : ""}`
101
+ }
102
+ onClick={handleShow}
103
+ >
104
+ <el-icon className="el-icon c-search-icon">
105
+ <ArrowUpBold />
106
+ </el-icon>
107
+ </div>
108
+ )}
109
+ <el-button type="primary" onClick={handleSearch}>
110
+ 搜索
111
+ </el-button>
112
+ <el-button type="primary" onClick={handleReset}>
113
+ 重置
114
+ </el-button>
115
+ {slots["btn-right"]?.()}
116
+ </div>
117
+ </div>
118
+
119
+ {/* 下拉悬浮 */}
120
+ {!props.isDrawer && showSearchForm.value && (
121
+ <transition name="search-form-transition">
122
+ <el-card className="c-search-form el-card is-always-shadow">
123
+ <CForm
124
+ {...getEvent()}
125
+ inline
126
+ model={props.modelValue}
127
+ formOptions={props.formOptions.filter(
128
+ (item, index) => index >= showCount.value
129
+ )}
130
+ ref="formRef"
131
+ >
132
+ {getSlot()}
133
+ </CForm>
134
+ <div style="text-align: right;">
135
+ <el-button type="primary" onClick={handleSearch}>
136
+ 搜索
137
+ </el-button>
138
+ <el-button type="primary" onClick={handleClose}>
139
+ 关闭
140
+ </el-button>
141
+ </div>
142
+ </el-card>
143
+ </transition>
144
+ )}
145
+
146
+ {props.isDrawer && (
147
+ <CDrawer title="搜索" v-model={showSearchForm.value} size="660px">
148
+ <CForm
149
+ {...getEvent()}
150
+ col={12}
151
+ model={props.modelValue}
152
+ formOptions={props.formOptions.filter(
153
+ (item, index) => index >= showCount.value
154
+ )}
155
+ ref="formRef"
156
+ >
157
+ {getSlot()}
158
+ </CForm>
159
+ <div style="text-align: right;">
160
+ <el-button type="primary" onClick={handleSearch}>
161
+ 搜索
162
+ </el-button>
163
+ <el-button type="primary" onClick={handleClose}>
164
+ 关闭
165
+ </el-button>
166
+ </div>
167
+ </CDrawer>
168
+ )}
169
+ </div>
170
+ )
171
+ },
172
+ })