@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.
Files changed (47) hide show
  1. package/dist/@qy_better_lib/pc.min.js +1 -0
  2. package/lib/contextMenu/index.d.ts +3 -0
  3. package/lib/contextMenu/index.js +7 -0
  4. package/lib/contextMenu/src/index.vue.d.ts +71 -0
  5. package/lib/contextMenu/src/index.vue.js +108 -0
  6. package/lib/contextMenu/src/index.vue2.js +4 -0
  7. package/lib/index.d.ts +8 -0
  8. package/lib/index.js +18 -0
  9. package/lib/tableExtend/index.d.ts +4 -0
  10. package/lib/tableExtend/index.js +7 -0
  11. package/lib/tableExtend/props.d.ts +52 -0
  12. package/lib/tableExtend/props.js +50 -0
  13. package/lib/tableExtend/src/colVisible.vue.d.ts +3 -0
  14. package/lib/tableExtend/src/colVisible.vue.js +103 -0
  15. package/lib/tableExtend/src/colVisible.vue2.js +4 -0
  16. package/lib/tableExtend/src/index.vue.d.ts +117 -0
  17. package/lib/tableExtend/src/index.vue.js +177 -0
  18. package/lib/tableExtend/src/index.vue2.js +4 -0
  19. package/lib/tableExtend/src/valueCol.vue.d.ts +24 -0
  20. package/lib/tableExtend/src/valueCol.vue.js +26 -0
  21. package/lib/tableExtend/src/valueCol.vue2.js +4 -0
  22. package/lib/tableExtend/type.d.ts +167 -0
  23. package/lib/tableExtend/type.js +4 -0
  24. package/lib/tableExtend/useTable.d.ts +64 -0
  25. package/lib/tableExtend/useTable.js +72 -0
  26. package/lib/textButton/index.d.ts +3 -0
  27. package/lib/textButton/index.js +7 -0
  28. package/lib/textButton/src/index.vue.d.ts +31 -0
  29. package/lib/textButton/src/index.vue.js +39 -0
  30. package/lib/textButton/src/index.vue2.js +4 -0
  31. package/package.json +56 -0
  32. package/src/contextMenu/index.ts +8 -0
  33. package/src/contextMenu/src/index.vue +131 -0
  34. package/src/index.ts +16 -0
  35. package/src/tableExtend/index.ts +10 -0
  36. package/src/tableExtend/props.ts +53 -0
  37. package/src/tableExtend/src/colVisible.vue +80 -0
  38. package/src/tableExtend/src/index.vue +178 -0
  39. package/src/tableExtend/src/valueCol.vue +25 -0
  40. package/src/tableExtend/type.ts +173 -0
  41. package/src/tableExtend/useTable.ts +136 -0
  42. package/src/textButton/index.ts +8 -0
  43. package/src/textButton/src/index.vue +39 -0
  44. package/tsconfig.json +5 -0
  45. package/types/index.d.ts +1 -0
  46. package/types/json.d.ts +4 -0
  47. 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,8 @@
1
+ import type { App } from "vue";
2
+ import textButton from "./src/index.vue";
3
+
4
+ textButton.install = (app: App) => {
5
+ app.component("TextButton", textButton);
6
+ };
7
+
8
+ export default textButton;
@@ -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
@@ -0,0 +1,5 @@
1
+ {
2
+ "compilerOptions": {},
3
+ "extends": "../../tsconfig.json",
4
+ "include": ["./src/**/*.ts"]
5
+ }
@@ -0,0 +1 @@
1
+ declare type $TODO = any
@@ -0,0 +1,4 @@
1
+ declare module "*.json" {
2
+ const value: any;
3
+ export default value;
4
+ }
@@ -0,0 +1,5 @@
1
+ declare module '*.vue' {
2
+ import { ComponentOptions } from 'vue'
3
+ const Component: ComponentOptions
4
+ export default Component
5
+ }