@qy_better_lib/pc 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.
- package/dist/@qy_better_lib/pc.min.js +1 -0
- package/lib/contextMenu/index.d.ts +3 -0
- package/lib/contextMenu/index.js +7 -0
- package/lib/contextMenu/src/index.vue.d.ts +71 -0
- package/lib/contextMenu/src/index.vue.js +108 -0
- package/lib/contextMenu/src/index.vue2.js +4 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +18 -0
- package/lib/tableExtend/index.d.ts +4 -0
- package/lib/tableExtend/index.js +7 -0
- package/lib/tableExtend/props.d.ts +52 -0
- package/lib/tableExtend/props.js +50 -0
- package/lib/tableExtend/src/colVisible.vue.d.ts +3 -0
- package/lib/tableExtend/src/colVisible.vue.js +103 -0
- package/lib/tableExtend/src/colVisible.vue2.js +4 -0
- package/lib/tableExtend/src/index.vue.d.ts +117 -0
- package/lib/tableExtend/src/index.vue.js +177 -0
- package/lib/tableExtend/src/index.vue2.js +4 -0
- package/lib/tableExtend/src/valueCol.vue.d.ts +24 -0
- package/lib/tableExtend/src/valueCol.vue.js +26 -0
- package/lib/tableExtend/src/valueCol.vue2.js +4 -0
- package/lib/tableExtend/type.d.ts +167 -0
- package/lib/tableExtend/type.js +4 -0
- package/lib/tableExtend/useTable.d.ts +64 -0
- package/lib/tableExtend/useTable.js +72 -0
- package/lib/textButton/index.d.ts +3 -0
- package/lib/textButton/index.js +7 -0
- package/lib/textButton/src/index.vue.d.ts +31 -0
- package/lib/textButton/src/index.vue.js +39 -0
- package/lib/textButton/src/index.vue2.js +4 -0
- package/package.json +56 -0
- package/src/contextMenu/index.ts +8 -0
- package/src/contextMenu/src/index.vue +131 -0
- package/src/index.ts +16 -0
- package/src/tableExtend/index.ts +10 -0
- package/src/tableExtend/props.ts +53 -0
- package/src/tableExtend/src/colVisible.vue +80 -0
- package/src/tableExtend/src/index.vue +178 -0
- package/src/tableExtend/src/valueCol.vue +25 -0
- package/src/tableExtend/type.ts +173 -0
- package/src/tableExtend/useTable.ts +136 -0
- package/src/textButton/index.ts +8 -0
- package/src/textButton/src/index.vue +39 -0
- package/tsconfig.json +5 -0
- package/types/index.d.ts +1 -0
- package/types/json.d.ts +4 -0
- package/types/vue.shim.d.ts +5 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { computed, getCurrentInstance, reactive, toRef } from "vue";
|
|
2
|
+
import {
|
|
3
|
+
ColumnConfig,
|
|
4
|
+
ImageViewer,
|
|
5
|
+
TableAttr,
|
|
6
|
+
TableColumn,
|
|
7
|
+
FileType,
|
|
8
|
+
} from "./type";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* useTable
|
|
12
|
+
*/
|
|
13
|
+
export default function useTable(i18nInstance?: (key: string) => string) {
|
|
14
|
+
/**表格实例 */
|
|
15
|
+
const currentInstance = getCurrentInstance();
|
|
16
|
+
/**表格属性 */
|
|
17
|
+
const props: any = currentInstance?.props;
|
|
18
|
+
/**
|
|
19
|
+
* 默认外观配置
|
|
20
|
+
* @type {*}
|
|
21
|
+
*/
|
|
22
|
+
const defalutTableAttr: TableAttr = {
|
|
23
|
+
rowKey: "Id",
|
|
24
|
+
"element-loading-text": "加载中…",
|
|
25
|
+
"element-loading-background": "rgba(0, 0, 0, 0.2)",
|
|
26
|
+
highlightCurrentRow: true,
|
|
27
|
+
stripe: true,
|
|
28
|
+
border: false,
|
|
29
|
+
height: "100%",
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 默认列配置
|
|
33
|
+
* @type {*}
|
|
34
|
+
*/
|
|
35
|
+
const defColSetting: TableColumn = {
|
|
36
|
+
headerAlign: undefined,
|
|
37
|
+
align: undefined,
|
|
38
|
+
prop: undefined,
|
|
39
|
+
label: undefined,
|
|
40
|
+
init: true,
|
|
41
|
+
width: undefined,
|
|
42
|
+
showOverflowTooltip: false,
|
|
43
|
+
sortable: undefined,
|
|
44
|
+
fixed: undefined,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**表格属性 */
|
|
48
|
+
const tableAttribute = computed<Record<string, any>>(() => {
|
|
49
|
+
return {
|
|
50
|
+
...defalutTableAttr,
|
|
51
|
+
...(Object.keys(props.options).length > 0 ? props.options : {}),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/** 选中行 */
|
|
56
|
+
const selectionOptions = reactive<Record<string, any>>({
|
|
57
|
+
count: 0,
|
|
58
|
+
rows: [],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**分页设置 */
|
|
62
|
+
const pagination = reactive({
|
|
63
|
+
pageIndex: props?.paging?.pageIndex ? toRef(props.paging, "pageIndex") : 1,
|
|
64
|
+
pageSize: props?.paging?.pageSize ? toRef(props.paging, "pageSize") : 10,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const hasPagination = computed(() => {
|
|
68
|
+
return props?.paging?.pageIndex > 0 && props?.paging?.pageSize > 0;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/**图片视图配置 */
|
|
72
|
+
const imageViewer = reactive<ImageViewer>({
|
|
73
|
+
/**是否显示 */
|
|
74
|
+
show: false,
|
|
75
|
+
/**图片路径 */
|
|
76
|
+
filePathList: [] as any[],
|
|
77
|
+
/**显示图片的索引 */
|
|
78
|
+
index: 0,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**显示、隐藏列 */
|
|
82
|
+
const columnConfig = reactive<ColumnConfig>({
|
|
83
|
+
showColumn: [],
|
|
84
|
+
hiddenColumn: [],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**表格显示列 */
|
|
88
|
+
const colSettingList = computed<TableColumn[]>(() => {
|
|
89
|
+
// 设置默认显示列(显示优化)
|
|
90
|
+
if (!columnConfig.showColumn || columnConfig.showColumn.length === 0) {
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
prop: "default-prop",
|
|
94
|
+
init: true,
|
|
95
|
+
label: "",
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
const colList = columnConfig.showColumn.map((item: TableColumn) => {
|
|
100
|
+
i18nInstance && item.langue && (item.label = i18nInstance(item.langue));
|
|
101
|
+
return { ...defColSetting, ...item };
|
|
102
|
+
});
|
|
103
|
+
return colList;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**是否显示工具栏按钮 */
|
|
107
|
+
const showToolPanel = computed(() => {
|
|
108
|
+
return (
|
|
109
|
+
(currentInstance?.slots["tool-left"]?.()?.length || 0) > 0 ||
|
|
110
|
+
(currentInstance?.slots["tool-right"]?.()?.length || 0) > 0
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 是否包含图片预览功能
|
|
116
|
+
* @type {*}
|
|
117
|
+
*/
|
|
118
|
+
const hasImageViewer = computed<boolean>(() => {
|
|
119
|
+
return colSettingList.value.some(
|
|
120
|
+
(f: TableColumn) => f.fileType && f.fileType == FileType.PICTURE
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
defColSetting,
|
|
126
|
+
selectionOptions,
|
|
127
|
+
tableAttribute,
|
|
128
|
+
pagination,
|
|
129
|
+
hasPagination,
|
|
130
|
+
imageViewer,
|
|
131
|
+
columnConfig,
|
|
132
|
+
colSettingList,
|
|
133
|
+
showToolPanel,
|
|
134
|
+
hasImageViewer,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-button" :class="[
|
|
3
|
+
`text-button-${type}`,
|
|
4
|
+
disabled && 'is-disabled'
|
|
5
|
+
]" @click.prevent.stop="onClick">
|
|
6
|
+
<slot></slot>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
|
|
12
|
+
defineOptions({ name: "TextButton" });
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
type: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'primary',
|
|
18
|
+
validator: (val: string) => {
|
|
19
|
+
return [
|
|
20
|
+
'default',
|
|
21
|
+
'primary',
|
|
22
|
+
'success',
|
|
23
|
+
'warning',
|
|
24
|
+
'info',
|
|
25
|
+
'danger',
|
|
26
|
+
].includes(val)
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
disabled: Boolean
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits(["click"])
|
|
33
|
+
|
|
34
|
+
function onClick(e: any): void {
|
|
35
|
+
if (props.disabled) return;
|
|
36
|
+
emit("click", e)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
</script>
|
package/tsconfig.json
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare type $TODO = any
|
package/types/json.d.ts
ADDED