@elementplus-kit/uikit 1.0.1 → 1.0.2

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.
@@ -29,10 +29,12 @@ export * from "./drawer/index.ts";
29
29
  export const CDrawer = Drawer;
30
30
 
31
31
  // 搜索
32
+ // import Search from "./search/index.ts";
33
+ // export * from "./search/index.ts";
34
+ // export const CSearch = Search;
32
35
  import Search from "./search/index.ts";
33
36
  export * from "./search/index.ts";
34
37
  export const CSearch = Search;
35
-
36
38
  // 测试单个引入-----------------------------
37
39
  // export * from "./dialog/index.ts"; // 弹窗
38
40
  // 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
+ })
@@ -0,0 +1,93 @@
1
+ .search-btn {
2
+ margin-right: 20px;
3
+ margin-left: auto;
4
+ }
5
+
6
+ .c-search {
7
+ position: relative;
8
+ height: 50px;
9
+
10
+ .c-search-simple {
11
+ display: flex;
12
+ justify-content: space-between;
13
+ }
14
+
15
+ .c-search-simple-btn {
16
+ display: flex;
17
+ margin-left: auto;
18
+ }
19
+
20
+ .c-search-simple-icon {
21
+ display: flex;
22
+ justify-content: center;
23
+ align-items: center;
24
+ cursor: pointer;
25
+ height: 32px;
26
+ width: 32px;
27
+ margin-right: 10px;
28
+ border-radius: 4px;
29
+ background-color: #409eff;
30
+ transition: all 0.2s;
31
+
32
+ &:hover {
33
+ background-color: rgb(121, 187, 255);
34
+ }
35
+
36
+ &:active {
37
+ background-color: rgb(51, 126, 204);
38
+ }
39
+ }
40
+
41
+ .c-search-icon {
42
+ // 添加鼠标悬停效果
43
+ color: #fff;
44
+ transition: all 0.2s;
45
+ }
46
+
47
+ .icon-rotate {
48
+ background-color: rgb(51, 126, 204);
49
+ .c-search-icon {
50
+ transform: rotate(180deg);
51
+ }
52
+ }
53
+
54
+ .c-search-form {
55
+ width: 100%;
56
+ position: absolute;
57
+ top: 50px;
58
+ left: 0;
59
+ overflow: hidden;
60
+ z-index: 10;
61
+ background-color: #fff;
62
+ }
63
+ }
64
+
65
+ /* 下拉动画效果 */
66
+ .search-form-transition {
67
+ &-enter-active,
68
+ &-leave-active {
69
+ transition: all 0.3s ease;
70
+ /* 动画过渡时间和缓动函数 */
71
+ overflow: hidden;
72
+ max-height: 500px;
73
+ /* 确保足够大的最大高度以容纳内容 */
74
+ }
75
+
76
+ &-enter-from {
77
+ max-height: 0;
78
+ /* 入场开始时高度为0 */
79
+ opacity: 0;
80
+ /* 可以添加透明度效果增强视觉体验 */
81
+ padding-top: 0;
82
+ padding-bottom: 0;
83
+ }
84
+
85
+ &-leave-to {
86
+ max-height: 0;
87
+ /* 出场结束时高度为0 */
88
+ opacity: 0;
89
+ /* 可以添加透明度效果增强视觉体验 */
90
+ padding-top: 0;
91
+ padding-bottom: 0;
92
+ }
93
+ }
@@ -1,12 +1,210 @@
1
- import { defineComponent } from "vue";
2
- import render from "./render.ts";
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ getCurrentInstance,
5
+ type ExtractPropTypes,
6
+ } from "vue";
7
+ import { ElTable, ElTableColumn } from "element-plus";
8
+ import {
9
+ defaultAttrs,
10
+ tableSlots,
11
+ tablecolumnSlots,
12
+ selectionColumn,
13
+ indexColumn,
14
+ } from "./constants.ts";
15
+ import { isArray, isObject } from "lodash-es";
16
+ const propsAttrs = {
17
+ module: {
18
+ // 公共参数用于业务判断
19
+ type: Object,
20
+ default: () => {},
21
+ },
22
+ // isRadio: { // 是否为单选框
23
+ // type: Boolean,
24
+ // default: false,
25
+ // },
26
+ // isCheckbox: { // 是否为复选框
27
+ // type: Boolean,
28
+ // default: false,
29
+ // },
30
+ columns: {
31
+ // 列数据
32
+ type: Array,
33
+ default: () => [],
34
+ },
35
+ showSelection: {
36
+ // 是否显示选择列
37
+ type: Boolean,
38
+ default: false,
39
+ },
40
+ showIndex: {
41
+ // 是否显示索引列
42
+ type: Boolean,
43
+ default: false,
44
+ },
45
+ };
46
+
47
+ export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
3
48
 
4
49
  export default defineComponent({
5
- props: ["schema", "data"],
6
- emits: [],
7
- setup(props: any, { attrs, emit, slots, expose }) {
8
- return () => {
9
- return render(props.schema, props.data, emit, slots);
50
+ props: propsAttrs,
51
+ // emits: eventList,
52
+
53
+ // attrs, emit会继承, slots需要设置
54
+ setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
55
+ // 暴露elTable组件上的方法
56
+ const vm = getCurrentInstance(); // 获取虚拟DOM实例
57
+ const cTableFnRef = (el) => {
58
+ if (!el) return;
59
+ vm.exposed = el; // 设置暴露对象
60
+ vm.exposeProxy = el; // 设置代理暴露对象
61
+ };
62
+
63
+ // 暴露方法
64
+ expose({
65
+ // tableRef,
66
+ });
67
+
68
+ // 属性处理
69
+ const getAttrs = () => {
70
+ const obj = {
71
+ ...defaultAttrs, // 设置默认值
72
+ };
73
+ return obj;
74
+ };
75
+ // 事件处理
76
+ const getEvents = () => {
77
+ const obj = {
78
+ ...defaultAttrs, // 设置默认值
79
+ };
80
+ return obj;
81
+ };
82
+
83
+ // 处理列数据-数组
84
+ const getArrayColumn = () => {
85
+ console.log("adsadsd");
86
+ // 递归处理数据
87
+ const list = [];
88
+
89
+ const c = (columns, list) => {
90
+ columns?.map((item) => {
91
+ const { children, ...p } = item;
92
+ // 递归处理子列
93
+ if (isArray(item.children)) {
94
+ item.children = c(item.children, list);
95
+ }
96
+ list.push(p);
97
+ });
98
+ };
99
+ c(props.columns, list);
100
+ console.log("🚀 ~ gggggggg:", list);
101
+ return list;
102
+ };
103
+
104
+ // 渲染表格列
105
+ const renderTableColumn = () => {
106
+ const list = [];
107
+ // 处理多选与序号列
108
+ if (props.showSelection) {
109
+ list.push(
110
+ h(ElTableColumn, {
111
+ type: "selection",
112
+ width: 55,
113
+ })
114
+ );
115
+ }
116
+ if (props.showIndex) {
117
+ list.push(
118
+ h(ElTableColumn, {
119
+ label: "序号",
120
+ type: "index",
121
+ width: 55,
122
+ })
123
+ );
124
+ }
125
+
126
+ // 列递归渲染
127
+ const rColumn = (columns, list) => {
128
+ columns.map((item) => {
129
+ const { children, ...p } = item;
130
+
131
+ // 处理多级表头
132
+ const listSub = [];
133
+ if (children?.length) {
134
+ rColumn(children, listSub);
135
+ }
136
+
137
+ // 处理插槽
138
+ const itemSlot = {};
139
+ // column 自带插槽
140
+ tablecolumnSlots.map((name) => {
141
+ const slotName = `${item.prop}.${name}`;
142
+ if (slots[slotName]) {
143
+ itemSlot[name] = slots[slotName];
144
+ }
145
+ });
146
+
147
+ // column 列插槽
148
+ if (slots[item.prop]) {
149
+ itemSlot["default"] = slots[item.prop];
150
+ }
151
+
152
+ // 赋值
153
+ if (Object.keys(itemSlot).length) {
154
+ list.push(
155
+ h(
156
+ ElTableColumn,
157
+ { ...p, class: "c-table-column" },
158
+ listSub.length
159
+ ? { ...itemSlot, default: () => listSub }
160
+ : { ...itemSlot }
161
+ )
162
+ );
163
+ } else {
164
+ list.push(
165
+ h(
166
+ ElTableColumn,
167
+ { ...p, class: "c-table-column" },
168
+ listSub.length ? { default: () => listSub } : undefined
169
+ )
170
+ );
171
+ }
172
+ });
173
+ };
174
+ rColumn(props.columns, list);
175
+ return list;
176
+ };
177
+
178
+ // 插槽处理
179
+ const getSlots = () => {
180
+ const obj = {};
181
+ tableSlots.map((name) => {
182
+ if (slots[name]) {
183
+ obj[name] = slots[name];
184
+ }
185
+ });
186
+ return obj;
187
+ };
188
+ // 渲染表格组件
189
+ const renderTable = () => {
190
+ // getColumnList();
191
+ console.log("props", props);
192
+ console.log("attrs", attrs);
193
+ return h(
194
+ ElTable,
195
+ {
196
+ ref: cTableFnRef,
197
+ ...attrs,
198
+ class: "c-table",
199
+ },
200
+ {
201
+ default: () => renderTableColumn(),
202
+ ...getSlots(),
203
+ }
204
+ );
10
205
  };
206
+
207
+ // 返回渲染函数
208
+ return () => renderTable();
11
209
  },
12
210
  });
@@ -1,210 +1,12 @@
1
- import {
2
- defineComponent,
3
- h,
4
- getCurrentInstance,
5
- type ExtractPropTypes,
6
- } from "vue";
7
- import { ElTable, ElTableColumn } from "element-plus";
8
- import {
9
- defaultAttrs,
10
- tableSlots,
11
- tablecolumnSlots,
12
- selectionColumn,
13
- indexColumn,
14
- } from "./constants.ts";
15
- import { isArray, isObject } from "lodash-es";
16
- const propsAttrs = {
17
- module: {
18
- // 公共参数用于业务判断
19
- type: Object,
20
- default: () => {},
21
- },
22
- // isRadio: { // 是否为单选框
23
- // type: Boolean,
24
- // default: false,
25
- // },
26
- // isCheckbox: { // 是否为复选框
27
- // type: Boolean,
28
- // default: false,
29
- // },
30
- columns: {
31
- // 列数据
32
- type: Array,
33
- default: () => [],
34
- },
35
- showSelection: {
36
- // 是否显示选择列
37
- type: Boolean,
38
- default: false,
39
- },
40
- showIndex: {
41
- // 是否显示索引列
42
- type: Boolean,
43
- default: false,
44
- },
45
- };
46
-
47
- export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
1
+ import { defineComponent } from "vue";
2
+ import render from "./render.ts";
48
3
 
49
4
  export default defineComponent({
50
- props: propsAttrs,
51
- // emits: eventList,
52
-
53
- // attrs, emit会继承, slots需要设置
54
- setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
55
- // 暴露elTable组件上的方法
56
- const vm = getCurrentInstance(); // 获取虚拟DOM实例
57
- const cTableFnRef = (el) => {
58
- if (!el) return;
59
- vm.exposed = el; // 设置暴露对象
60
- vm.exposeProxy = el; // 设置代理暴露对象
61
- };
62
-
63
- // 暴露方法
64
- expose({
65
- // tableRef,
66
- });
67
-
68
- // 属性处理
69
- const getAttrs = () => {
70
- const obj = {
71
- ...defaultAttrs, // 设置默认值
72
- };
73
- return obj;
74
- };
75
- // 事件处理
76
- const getEvents = () => {
77
- const obj = {
78
- ...defaultAttrs, // 设置默认值
79
- };
80
- return obj;
81
- };
82
-
83
- // 处理列数据-数组
84
- const getArrayColumn = () => {
85
- console.log("adsadsd");
86
- // 递归处理数据
87
- const list = [];
88
-
89
- const c = (columns, list) => {
90
- columns?.map((item) => {
91
- const { children, ...p } = item;
92
- // 递归处理子列
93
- if (isArray(item.children)) {
94
- item.children = c(item.children, list);
95
- }
96
- list.push(p);
97
- });
98
- };
99
- c(props.columns, list);
100
- console.log("🚀 ~ gggggggg:", list);
101
- return list;
102
- };
103
-
104
- // 渲染表格列
105
- const renderTableColumn = () => {
106
- const list = [];
107
- // 处理多选与序号列
108
- if (props.showSelection) {
109
- list.push(
110
- h(ElTableColumn, {
111
- type: "selection",
112
- width: 55,
113
- })
114
- );
115
- }
116
- if (props.showIndex) {
117
- list.push(
118
- h(ElTableColumn, {
119
- label: "序号",
120
- type: "index",
121
- width: 55,
122
- })
123
- );
124
- }
125
-
126
- // 列递归渲染
127
- const rColumn = (columns, list) => {
128
- columns.map((item) => {
129
- const { children, ...p } = item;
130
-
131
- // 处理多级表头
132
- const listSub = [];
133
- if (children?.length) {
134
- rColumn(children, listSub);
135
- }
136
-
137
- // 处理插槽
138
- const itemSlot = {};
139
- // column 自带插槽
140
- tablecolumnSlots.map((name) => {
141
- const slotName = `${item.prop}.${name}`;
142
- if (slots[slotName]) {
143
- itemSlot[name] = slots[slotName];
144
- }
145
- });
146
-
147
- // column 列插槽
148
- if (slots[item.prop]) {
149
- itemSlot["default"] = slots[item.prop];
150
- }
151
-
152
- // 赋值
153
- if (Object.keys(itemSlot).length) {
154
- list.push(
155
- h(
156
- ElTableColumn,
157
- { ...p, class: "c-table-column" },
158
- listSub.length
159
- ? { ...itemSlot, default: () => listSub }
160
- : { ...itemSlot }
161
- )
162
- );
163
- } else {
164
- list.push(
165
- h(
166
- ElTableColumn,
167
- { ...p, class: "c-table-column" },
168
- listSub.length ? { default: () => listSub } : undefined
169
- )
170
- );
171
- }
172
- });
173
- };
174
- rColumn(props.columns, list);
175
- return list;
176
- };
177
-
178
- // 插槽处理
179
- const getSlots = () => {
180
- const obj = {};
181
- tableSlots.map((name) => {
182
- if (slots[name]) {
183
- obj[name] = slots[name];
184
- }
185
- });
186
- return obj;
187
- };
188
- // 渲染表格组件
189
- const renderTable = () => {
190
- // getColumnList();
191
- console.log("props", props);
192
- console.log("attrs", attrs);
193
- return h(
194
- ElTable,
195
- {
196
- ref: cTableFnRef,
197
- ...attrs,
198
- class: "c-table",
199
- },
200
- {
201
- default: () => renderTableColumn(),
202
- ...getSlots(),
203
- }
204
- );
5
+ props: ["schema", "data"],
6
+ emits: [],
7
+ setup(props: any, { attrs, emit, slots, expose }) {
8
+ return () => {
9
+ return render(props.schema, props.data, emit, slots);
205
10
  };
206
-
207
- // 返回渲染函数
208
- return () => renderTable();
209
11
  },
210
12
  });
@@ -1,39 +1,39 @@
1
- export interface FormItemListItem {
2
- type: string
3
- label?: string
4
- prop: string
5
- required?: Boolean
6
- vIf?: boolean | ((item: FormItemListItem) => boolean)
7
- dictType?: string
8
- options?: Array<Object>
9
- col?: Number
10
- formItem?: Object
11
- attrs?: Object
12
- }
13
-
14
- export interface FormItemList {
15
- module: Object
16
- formOpsions: FormItemListItem[]
17
- readonly: boolean
18
- }
19
-
20
- export type formType =
21
- | 'input'
22
- | 'textarea'
23
- | 'input-number'
24
- | 'select'
25
- | 'select-v2'
26
- | 'cascader'
27
- | 'tree-select'
28
- | 'radio'
29
- | 'checkbox'
30
- | 'time-select'
31
- | 'date-picker'
32
- | 'time-picker'
33
- | 'rate'
34
- | 'color-picker'
35
- | 'slider'
36
- | 'switch'
37
- | 'text'
38
- | 'html'
39
- | 'slot'
1
+ export interface FormItemListItem {
2
+ type: string
3
+ label?: string
4
+ prop: string
5
+ required?: Boolean
6
+ vIf?: boolean | ((item: FormItemListItem) => boolean)
7
+ dictType?: string
8
+ options?: Array<Object>
9
+ col?: Number
10
+ formItem?: Object
11
+ attrs?: Object
12
+ }
13
+
14
+ export interface FormItemList {
15
+ module: Object
16
+ formOpsions: FormItemListItem[]
17
+ readonly: boolean
18
+ }
19
+
20
+ export type formType =
21
+ | 'input'
22
+ | 'textarea'
23
+ | 'input-number'
24
+ | 'select'
25
+ | 'select-v2'
26
+ | 'cascader'
27
+ | 'tree-select'
28
+ | 'radio'
29
+ | 'checkbox'
30
+ | 'time-select'
31
+ | 'date-picker'
32
+ | 'time-picker'
33
+ | 'rate'
34
+ | 'color-picker'
35
+ | 'slider'
36
+ | 'switch'
37
+ | 'text'
38
+ | 'html'
39
+ | 'slot'
@@ -5,6 +5,7 @@ import {
5
5
  toRefs,
6
6
  getCurrentInstance,
7
7
  provide,
8
+ defineComponent,
8
9
  type ExtractPropTypes,
9
10
  type PropType,
10
11
  } from 'vue'
@@ -22,7 +23,7 @@ const propsAttrs = {
22
23
 
23
24
  export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>
24
25
 
25
- export default {
26
+ export default defineComponent({
26
27
  props: propsAttrs,
27
28
  emits: [...getEmits()],
28
29
  setup(props: PropsAttrs, { attrs: $attrs, emit, slots, expose }) {
@@ -62,4 +63,4 @@ export default {
62
63
  // 返回渲染函数
63
64
  return () => renderForm()
64
65
  },
65
- }
66
+ })
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <div class="xxx">
3
+
4
+ </div>
5
+ </template>
6
+ <script setup lang="ts">
7
+ import { ref, computed, useAttrs, useSlots, defineModel } from 'vue'
8
+ import { ArrowUpBold } from '@element-plus/icons-vue'
9
+ const props = defineProps({
10
+ formOptions: {
11
+ type: Array,
12
+ default: () => []
13
+ },
14
+ })
15
+ const emit = defineEmits(['search', 'reset', 'close'])
16
+
17
+ </script>
18
+ <style scoped lang="scss"></style>
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@elementplus-kit/uikit",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
- "main": "./components/index.js",
5
+ "main": "./components/index.ts",
6
6
  "peerDependencies": {
7
7
  "element-plus": "^2.0.0",
8
8
  "vue": "^3.0.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes