gi-component 0.0.2 → 0.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gi-component",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "description": "Vue3中基于Element Plus二次封装基础组件库",
6
6
  "author": "lin",
7
7
  "license": "MIT",
@@ -3,7 +3,7 @@ import ElementPlus from 'element-plus';
3
3
  import { createApp, h, ref } from 'vue';
4
4
  import GiDialog from './dialog.vue';
5
5
 
6
- type DialogOptions = Partial<DialogInstance['$props']>;
6
+ export type DialogOptions = Partial<DialogInstance['$props']>;
7
7
 
8
8
  export interface DialogReturnObject {
9
9
  close: () => void;
@@ -1,37 +1,25 @@
1
1
  <template>
2
- <div>
3
- <el-table v-bind="tableProps" :data="props.data as any[]">
4
- <TableColumn
5
- v-for="item in props.columns"
6
- :key="item.prop || item.label"
7
- :column="item"
8
- >
2
+ <div :class="b('table')">
3
+ <el-table v-bind="tableProps" ref="tableRef" :data="props.data as any[]">
4
+ <TableColumn v-for="item in props.columns" :key="item.prop || item.label" :column="item">
9
5
  <!-- 将所有插槽传递给子组件 -->
10
- <template
11
- v-for="(_, slotName) in $slots"
12
- :key="slotName"
13
- #[slotName]="scope"
14
- >
6
+ <template v-for="(_, slotName) in $slots" :key="slotName" #[slotName]="scope">
15
7
  <slot :name="slotName" v-bind="scope" />
16
8
  </template>
17
9
  </TableColumn>
18
10
  </el-table>
19
11
 
20
12
  <el-row justify="end" :class="b('table-pagination')">
21
- <el-pagination
22
- v-bind="paginationProps"
23
- v-model:current-page="paginationProps.currentPage"
24
- v-model:page-size="paginationProps.pageSize"
25
- @size-change="handleSizeChange"
26
- @current-change="handleCurrentChange"
27
- />
13
+ <el-pagination v-bind="paginationProps" v-model:current-page="paginationProps.currentPage"
14
+ v-model:page-size="paginationProps.pageSize" @size-change="handleSizeChange"
15
+ @current-change="handleCurrentChange" />
28
16
  </el-row>
29
17
  </div>
30
18
  </template>
31
19
 
32
20
  <script lang="ts" setup>
33
21
  import type { TableProps } from './type';
34
- import { computed, useAttrs } from 'vue';
22
+ import { computed, useAttrs, useTemplateRef } from 'vue';
35
23
  import { useBemClass } from '../../../hooks';
36
24
  import TableColumn from './TableColumn.vue';
37
25
 
@@ -42,6 +30,7 @@ const props = withDefaults(defineProps<TableProps>(), {
42
30
 
43
31
  const attrs = useAttrs();
44
32
  const { b } = useBemClass();
33
+ const tableRef = useTemplateRef('tableRef');
45
34
 
46
35
  const tableProps = computed(() => {
47
36
  return {
@@ -70,6 +59,10 @@ function handleCurrentChange(page: number) {
70
59
  // @ts-ignore
71
60
  props.pagination.currentPage = page;
72
61
  }
62
+
63
+ defineExpose({
64
+ tableRef
65
+ })
73
66
  </script>
74
67
 
75
68
  <style lang="scss" scoped>
@@ -79,6 +72,17 @@ function handleCurrentChange(page: number) {
79
72
  flex: auto;
80
73
  }
81
74
 
75
+ .#{a.$prefix}-table {
76
+ height: 100%;
77
+ overflow: hidden;
78
+ display: flex;
79
+ flex-direction: column;
80
+
81
+ :deep(.el-table) {
82
+ flex: 1;
83
+ }
84
+ }
85
+
82
86
  .#{a.$prefix}-table-pagination {
83
87
  margin-top: 10px;
84
88
  }
@@ -0,0 +1,3 @@
1
+ export function useTable() {
2
+
3
+ }
@@ -1,14 +1,12 @@
1
1
  import type { Component } from 'vue';
2
2
  import { ElMessage } from 'element-plus';
3
3
  import { h, ref } from 'vue';
4
- import { Dialog } from '../index';
4
+ import { Dialog, type DialogOptions } from '../index';
5
5
 
6
- type CreateSelectDialogParams = {
7
- title: string;
6
+ interface CreateSelectDialogParams extends Omit<DialogOptions, 'content' | 'onOk' | 'onBeforeOk'> {
8
7
  component: Component;
9
8
  componentProps?: Record<string, any>;
10
9
  tip?: string;
11
- bodyClass?: string;
12
10
  };
13
11
 
14
12
  interface DefOption {
@@ -35,6 +33,8 @@ export const createSelectDialog = <T, Q extends DefOption = DefOption>(
35
33
  const DialogTableRef = ref<any>();
36
34
 
37
35
  Dialog.open({
36
+ bodyClass: 'gi-p0',
37
+ ...{ ...params, component: undefined, componentProps: undefined, tip: undefined },
38
38
  title: params.title || options.title,
39
39
  content: () =>
40
40
  h(params.component, {
@@ -43,8 +43,7 @@ export const createSelectDialog = <T, Q extends DefOption = DefOption>(
43
43
  queryParams,
44
44
  ...params.componentProps
45
45
  }),
46
- style: { maxWidth: '960px' },
47
- bodyClass: params.bodyClass,
46
+ style: { maxWidth: '1000px', ...params.style },
48
47
  onBeforeOk: async () => {
49
48
  if (!DialogTableRef.value.getSelectedData) {
50
49
  ElMessage.error('组件必须暴露getSelectedData方法');