@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,131 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport to="body">
|
|
3
|
+
<div class="contextmenu" v-click-outside="hide" v-if="_visible"
|
|
4
|
+
:style="{ top: position.top, left: position.left }" ref="contextMenuRef">
|
|
5
|
+
<div class="contextmenu-wrap">
|
|
6
|
+
<ul class="contextmenu-items">
|
|
7
|
+
<template v-for="item in options" :key="item.key">
|
|
8
|
+
<el-divider v-if="item?.type == 'divider'" />
|
|
9
|
+
<li v-else class="contextmenu-item" @click="onMenuClick(item)">
|
|
10
|
+
<slot :data="{ item, options }" name="items">
|
|
11
|
+
{{ item.label }}
|
|
12
|
+
</slot>
|
|
13
|
+
</li>
|
|
14
|
+
</template>
|
|
15
|
+
</ul>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</Teleport>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
import type { PropType } from 'vue';
|
|
23
|
+
import { nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
|
24
|
+
import { ClickOutside as vClickOutside } from '@qy_better_lib/core';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 通过visible显示的时候,需要提供position;
|
|
28
|
+
* 通过show显示,根据鼠标对象设置显示位置;
|
|
29
|
+
*/
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
visible: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: () => false
|
|
34
|
+
},
|
|
35
|
+
position: {
|
|
36
|
+
type: Object as PropType<{ x: number, y: number }>,
|
|
37
|
+
default: () => { }
|
|
38
|
+
},
|
|
39
|
+
options: {
|
|
40
|
+
type: Array as PropType<Record<string, any>>,
|
|
41
|
+
default: [],
|
|
42
|
+
required: true
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits(['menuClick', 'update:visible']);
|
|
47
|
+
|
|
48
|
+
defineExpose({
|
|
49
|
+
hide,
|
|
50
|
+
show
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
type Position = { left: number, top: number };
|
|
54
|
+
|
|
55
|
+
const _visible = ref<boolean>(false);
|
|
56
|
+
|
|
57
|
+
const contextMenuRef = ref<any>(null);
|
|
58
|
+
|
|
59
|
+
const position: any = reactive<Position>({
|
|
60
|
+
left: 0,
|
|
61
|
+
top: 0,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
watch(() => props.visible, (v) => {
|
|
65
|
+
if (v) {
|
|
66
|
+
_visible.value = true;
|
|
67
|
+
nextTick(() => {
|
|
68
|
+
setPosition(props.position);
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
immediate: true
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
onMounted(() => {
|
|
76
|
+
contextMenuRef.value?.addEventListener("contextmenu", show);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
onBeforeUnmount(() => {
|
|
80
|
+
removeEvent();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
function removeEvent() {
|
|
84
|
+
contextMenuRef.value?.removeEventListener("contextmenu", show);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 菜单点击
|
|
89
|
+
* @param params
|
|
90
|
+
*/
|
|
91
|
+
function onMenuClick(params: any) {
|
|
92
|
+
emit('menuClick', params)
|
|
93
|
+
hide();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 右键菜单显示
|
|
98
|
+
*/
|
|
99
|
+
async function show(e: any) {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
_visible.value = true;
|
|
102
|
+
await nextTick();
|
|
103
|
+
const { pageX: x, pageY: y } = e;
|
|
104
|
+
setPosition({ x, y });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function setPosition(pos: { x: number, y: number }) {
|
|
108
|
+
const { clientWidth, clientHeight } = contextMenuRef.value;
|
|
109
|
+
if (!clientWidth || !clientHeight) return;
|
|
110
|
+
position.top = `${calculatePosition("Y", pos.y || 0, clientHeight)}px`;
|
|
111
|
+
position.left = `${calculatePosition("X", pos.x || 0, clientWidth)}px`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function hide() {
|
|
115
|
+
removeEvent();
|
|
116
|
+
_visible.value = false;
|
|
117
|
+
nextTick(() => {
|
|
118
|
+
emit("update:visible", false);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function calculatePosition(axis: "X" | "Y", mousePos: number, elSize: number) {
|
|
123
|
+
const windowSize = axis === "X" ? window.innerWidth : window.innerHeight
|
|
124
|
+
const scrollPos = axis === "X" ? window.scrollX : window.scrollY
|
|
125
|
+
let pos = mousePos - scrollPos
|
|
126
|
+
if (pos + elSize > windowSize) {
|
|
127
|
+
pos = Math.max(0, pos - elSize)
|
|
128
|
+
}
|
|
129
|
+
return pos + scrollPos
|
|
130
|
+
}
|
|
131
|
+
</script>
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import textButton from "./textButton";
|
|
2
|
+
import tableExtend from "./tableExtend";
|
|
3
|
+
import contextMenu from "./contextMenu";
|
|
4
|
+
import type { App } from "vue";
|
|
5
|
+
|
|
6
|
+
const components: any[] = [textButton, tableExtend, contextMenu];
|
|
7
|
+
|
|
8
|
+
function install(app: App) {
|
|
9
|
+
components.forEach((component) => {
|
|
10
|
+
app.use(component);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { TableProp, TableColumn } from "./tableExtend";
|
|
15
|
+
|
|
16
|
+
export { install, textButton, tableExtend, contextMenu };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PropType } from "vue";
|
|
2
|
+
import { TableAttr, TableColumn } from "./type";
|
|
3
|
+
|
|
4
|
+
/**表单组件属性 */
|
|
5
|
+
export default function props() {
|
|
6
|
+
return {
|
|
7
|
+
/**UI选项配置 */
|
|
8
|
+
options: {
|
|
9
|
+
type: Object as PropType<TableAttr>,
|
|
10
|
+
default: () => {
|
|
11
|
+
return {};
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
/**表格数据源 */
|
|
15
|
+
tableData: {
|
|
16
|
+
type: Array,
|
|
17
|
+
default: [],
|
|
18
|
+
},
|
|
19
|
+
/**表格列(所有列) */
|
|
20
|
+
tableColums: {
|
|
21
|
+
type: Array as PropType<Array<TableColumn>>,
|
|
22
|
+
default: () => [],
|
|
23
|
+
},
|
|
24
|
+
/**loading显示状态 */
|
|
25
|
+
tableLoading: Boolean,
|
|
26
|
+
/**是否显示列check */
|
|
27
|
+
selectionCol: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: () => true,
|
|
30
|
+
},
|
|
31
|
+
/**是否显示索引列 */
|
|
32
|
+
indexCol: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: () => true,
|
|
35
|
+
},
|
|
36
|
+
/**是否能设置表格列 */
|
|
37
|
+
isSetColumn: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: () => false,
|
|
40
|
+
},
|
|
41
|
+
/**是否显示分页 */
|
|
42
|
+
paging: {
|
|
43
|
+
type: Object as PropType<{ pageIndex: number; pageSize: number }>,
|
|
44
|
+
},
|
|
45
|
+
/**总数 */
|
|
46
|
+
total: Number,
|
|
47
|
+
/**可选页面大小 */
|
|
48
|
+
sizeList: {
|
|
49
|
+
type: Array as PropType<Array<number>>,
|
|
50
|
+
default: () => [15, 20, 30, 50, 100],
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-popover placement="bottom" title="列显示设置" :width="220">
|
|
3
|
+
<template #reference>
|
|
4
|
+
<el-icon>
|
|
5
|
+
<Setting />
|
|
6
|
+
</el-icon>
|
|
7
|
+
</template>
|
|
8
|
+
<div class="set-column-list-wrap">
|
|
9
|
+
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAllColumns" @change="onCheckAllColumnChange">全选
|
|
10
|
+
</el-checkbox>
|
|
11
|
+
<el-checkbox-group class="set-column-check-group" v-model="checkColumnProp" @change="onCheckedColumnChange">
|
|
12
|
+
<div class="group-item" v-for="colum in tableColums" :key="colum.prop">
|
|
13
|
+
<el-checkbox class="set-column-check" :label="colum.prop">{{ colum.label }}</el-checkbox>
|
|
14
|
+
<div class="fixed-wrap">
|
|
15
|
+
<el-icon :class="['fixed-icon', colum.fixed === 'left' && 'active']" title="固定到左边"
|
|
16
|
+
@click="onChangeFixed('left', colum)">
|
|
17
|
+
<Upload />
|
|
18
|
+
</el-icon>
|
|
19
|
+
<el-divider direction="vertical" />
|
|
20
|
+
<el-icon :class="['fixed-icon', colum.fixed === 'right' && 'active']" title="固定到右边"
|
|
21
|
+
@click="onChangeFixed('right', colum)">
|
|
22
|
+
<Upload />
|
|
23
|
+
</el-icon>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</el-checkbox-group>
|
|
27
|
+
</div>
|
|
28
|
+
</el-popover>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script lang="ts" setup>
|
|
32
|
+
import { computed, inject, ref } from 'vue';
|
|
33
|
+
import type { TableProvies } from './../type';
|
|
34
|
+
|
|
35
|
+
const tableProps = inject<TableProvies>("table-extend");
|
|
36
|
+
/**显示列设置-全选 */
|
|
37
|
+
const checkAllColumns = ref<boolean>(true);
|
|
38
|
+
/**显示列设置-全选状态 */
|
|
39
|
+
const isIndeterminate = ref<boolean>(false);
|
|
40
|
+
/**列设置-选中列 */
|
|
41
|
+
const checkColumnProp = computed<Array<string>>(() => {
|
|
42
|
+
return tableProps && tableProps.columnConfig.showColumn.map((m) => m.prop as string) || [];
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const tableColums = computed(() => {
|
|
46
|
+
return tableProps?.tableColums.value || []
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
/**显示列全选 */
|
|
50
|
+
function onCheckAllColumnChange(e: boolean) {
|
|
51
|
+
if (e) {
|
|
52
|
+
tableProps && (
|
|
53
|
+
tableProps.columnConfig.showColumn = tableColums.value)
|
|
54
|
+
} else {
|
|
55
|
+
tableProps && (
|
|
56
|
+
tableProps.columnConfig.showColumn = []);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**显示列设置-列显示/隐藏切换 */
|
|
61
|
+
function onCheckedColumnChange(colProps: Array<string>) {
|
|
62
|
+
if (tableProps) {
|
|
63
|
+
tableProps.columnConfig.showColumn = tableColums.value.filter((f: any) => colProps.includes(f.prop));
|
|
64
|
+
const checkedCount = colProps.length;
|
|
65
|
+
checkAllColumns.value = checkedCount === tableColums.value.length;
|
|
66
|
+
isIndeterminate.value = checkedCount > 0 && checkedCount < tableColums.value.length;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**固定列 */
|
|
71
|
+
function onChangeFixed(type: 'left' | 'right', prop: any) {
|
|
72
|
+
if (prop.fixed === type) {
|
|
73
|
+
prop.fixed = undefined;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
prop.fixed = type;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
</script>
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-extend">
|
|
3
|
+
<div class="tool-panel">
|
|
4
|
+
<div class="left-panel">
|
|
5
|
+
<slot name="tool-left"></slot>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="right-panel">
|
|
8
|
+
<slot name="tool-right">
|
|
9
|
+
</slot>
|
|
10
|
+
<div class="default-tool">
|
|
11
|
+
<col-visible-setting v-if="isSetColumn"></col-visible-setting>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<el-table ref="tableRef" v-bind="tableAttribute" :data="tableData" v-loading="tableLoading" @sort-change="tableSort"
|
|
16
|
+
@selection-change="handleSelectionChange" @row-click="rowClick" @row-dblclick="rowDblClick">
|
|
17
|
+
<el-table-column v-if="selectionCol" type="selection" width="48" fixed="left"></el-table-column>
|
|
18
|
+
<el-table-column v-if="indexCol" type="index" width="58" fixed="left"></el-table-column>
|
|
19
|
+
<template v-for="item in colSettingList" :key="item.prop">
|
|
20
|
+
<el-table-column v-if="item.isHtml" v-bind="item">
|
|
21
|
+
<template #default="scope">
|
|
22
|
+
<div v-html="item.prop && scope.row[item.prop]"></div>
|
|
23
|
+
</template>
|
|
24
|
+
</el-table-column>
|
|
25
|
+
<template v-else>
|
|
26
|
+
<el-table-column v-if="item.init" v-bind="item">
|
|
27
|
+
<template #default="scope">
|
|
28
|
+
<slot :name="`col_${item.prop}`" :data="scope.row">
|
|
29
|
+
<value-col v-bind="{ row: scope.row, colCfg: item }"></value-col>
|
|
30
|
+
</slot>
|
|
31
|
+
</template>
|
|
32
|
+
</el-table-column>
|
|
33
|
+
</template>
|
|
34
|
+
</template>
|
|
35
|
+
<slot name="operatColumn"></slot>
|
|
36
|
+
<template #empty>
|
|
37
|
+
<el-empty :image-size="60"></el-empty>
|
|
38
|
+
</template>
|
|
39
|
+
</el-table>
|
|
40
|
+
<el-pagination v-if="hasPagination" background v-model:current-page="pagination.pageIndex"
|
|
41
|
+
v-model:page-size="pagination.pageSize" :page-sizes="sizeList" layout="total, sizes, prev, pager, next, jumper"
|
|
42
|
+
:total="total"></el-pagination>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script lang="ts" setup>
|
|
47
|
+
import { nextTick, onMounted, provide, ref, toRef, watch } from "vue";
|
|
48
|
+
import { useI18n } from 'vue-i18n';
|
|
49
|
+
import useTable from "./../useTable";
|
|
50
|
+
import type { TableProvies } from "./../type";
|
|
51
|
+
import useProps from './../props';
|
|
52
|
+
import ValueCol from './valueCol.vue';
|
|
53
|
+
import ColVisibleSetting from './colVisible.vue';
|
|
54
|
+
|
|
55
|
+
const props = defineProps({ ...useProps() });
|
|
56
|
+
|
|
57
|
+
const emit = defineEmits([
|
|
58
|
+
"tableSort",
|
|
59
|
+
"handleSelectionChange",
|
|
60
|
+
"currentChange",
|
|
61
|
+
"pageSizeChange",
|
|
62
|
+
"rowClick",
|
|
63
|
+
"rowDblClick"
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
const { t: i18nInstance } = useI18n();
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
selectionOptions,
|
|
70
|
+
tableAttribute,
|
|
71
|
+
pagination,
|
|
72
|
+
hasPagination,
|
|
73
|
+
columnConfig,
|
|
74
|
+
colSettingList,
|
|
75
|
+
} = useTable(i18nInstance);
|
|
76
|
+
|
|
77
|
+
provide<TableProvies>("table-extend", {
|
|
78
|
+
tableProps: props,
|
|
79
|
+
tableColums: toRef(props, "tableColums"),
|
|
80
|
+
columnConfig,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const tableRef = ref<any>(null);
|
|
84
|
+
|
|
85
|
+
const isPageSizeChange = ref<boolean>(false);
|
|
86
|
+
|
|
87
|
+
watch(
|
|
88
|
+
() => props.tableColums,
|
|
89
|
+
() => {
|
|
90
|
+
columnConfig.showColumn = props.tableColums;
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
/**页面变更 */
|
|
95
|
+
watch(
|
|
96
|
+
() => pagination.pageIndex,
|
|
97
|
+
(page_index) => {
|
|
98
|
+
if (page_index && page_index > 0) {
|
|
99
|
+
if (isPageSizeChange.value) {
|
|
100
|
+
isPageSizeChange.value = false;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
emit("currentChange", page_index);
|
|
104
|
+
tableRef.value.setScrollTop(0);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
/**分页大小变更 */
|
|
110
|
+
watch(() => pagination.pageSize,
|
|
111
|
+
(page_size) => {
|
|
112
|
+
if (page_size && page_size > 0) {
|
|
113
|
+
// pageSize变更时,取消pageIndex副作用
|
|
114
|
+
isPageSizeChange.value = true;
|
|
115
|
+
pagination.pageIndex = 1;
|
|
116
|
+
emit("pageSizeChange", page_size);
|
|
117
|
+
tableRef.value.setScrollTop(0);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
onMounted((): void => {
|
|
123
|
+
nextTick(() => {
|
|
124
|
+
props.tableColums && props.tableColums.length > 0 && (columnConfig.showColumn = props.tableColums);
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
defineExpose({
|
|
129
|
+
clearSelection,
|
|
130
|
+
toggleRowSelection
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 排序
|
|
135
|
+
*/
|
|
136
|
+
function tableSort(column: any) {
|
|
137
|
+
emit("tableSort", {
|
|
138
|
+
sortName: column.prop,
|
|
139
|
+
sortType:
|
|
140
|
+
column.order === "descending"
|
|
141
|
+
? "desc"
|
|
142
|
+
: column.order === "ascending"
|
|
143
|
+
? "asc"
|
|
144
|
+
: "",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 行勾选事件
|
|
150
|
+
*/
|
|
151
|
+
function handleSelectionChange(rows: any) {
|
|
152
|
+
selectionOptions.rows = rows;
|
|
153
|
+
selectionOptions.count = rows && rows.length;
|
|
154
|
+
emit("handleSelectionChange", rows);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 行点击事件
|
|
159
|
+
*/
|
|
160
|
+
function rowClick(rows: any) {
|
|
161
|
+
emit("rowClick", rows);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 双击事件
|
|
166
|
+
*/
|
|
167
|
+
function rowDblClick(rows: any) {
|
|
168
|
+
emit('rowDblClick', rows);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function clearSelection() {
|
|
172
|
+
tableRef.value?.clearSelection();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function toggleRowSelection(row: any) {
|
|
176
|
+
tableRef.value?.toggleRowSelection(row);
|
|
177
|
+
}
|
|
178
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span>{{ column != undefined ? column : "--" }}</span>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" setup>
|
|
6
|
+
import { computed } from 'vue';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
row: {
|
|
11
|
+
type: Object,
|
|
12
|
+
default: () => { }
|
|
13
|
+
},
|
|
14
|
+
colCfg: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default: () => { }
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const column = computed(() => {
|
|
21
|
+
const { row, colCfg } = props
|
|
22
|
+
return row[colCfg.prop]
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
// 定义可设置table属性的结构
|
|
4
|
+
export type TableAttr = {
|
|
5
|
+
/**rowKey */
|
|
6
|
+
rowKey?: string;
|
|
7
|
+
/**loading显示文本 */
|
|
8
|
+
"element-loading-text"?: string;
|
|
9
|
+
/**loading 图标 */
|
|
10
|
+
"element-loading-spinner"?: string;
|
|
11
|
+
/**loading 遮罩背景色 */
|
|
12
|
+
"element-loading-background"?: string;
|
|
13
|
+
/** 选中行高亮*/
|
|
14
|
+
highlightCurrentRow?: boolean;
|
|
15
|
+
/**斑马样式 */
|
|
16
|
+
stripe?: boolean;
|
|
17
|
+
/**边框 */
|
|
18
|
+
border?: boolean;
|
|
19
|
+
/**空数据显示文本 */
|
|
20
|
+
emptyText?: string;
|
|
21
|
+
/**列合并方法 */
|
|
22
|
+
spanMethod?: Function;
|
|
23
|
+
/**合计列计算方法 */
|
|
24
|
+
summaryMethod?: Function;
|
|
25
|
+
/**树形配置 */
|
|
26
|
+
treeProps?: { children: string; hasChildren: string };
|
|
27
|
+
/**默认展开行 */
|
|
28
|
+
expandRowKeys?: Array<string | number>;
|
|
29
|
+
/**默认展开全部 */
|
|
30
|
+
defaultExpandAll?: boolean;
|
|
31
|
+
/**表格高度,默认自适应 */
|
|
32
|
+
height?: string | number;
|
|
33
|
+
/**主轴的最小尺寸 */
|
|
34
|
+
flexible?: boolean;
|
|
35
|
+
/**是否显示表头 */
|
|
36
|
+
showHeader?: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**分页 */
|
|
40
|
+
export type Pagination = {
|
|
41
|
+
/**页码 */
|
|
42
|
+
pageIndex: number | undefined;
|
|
43
|
+
/**每页显示数量 */
|
|
44
|
+
pageSize: number | undefined;
|
|
45
|
+
has: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**列配置 */
|
|
49
|
+
export type ColumnConfig = {
|
|
50
|
+
/**显示列 */
|
|
51
|
+
showColumn: TableColumn[];
|
|
52
|
+
/**隐藏列 */
|
|
53
|
+
hiddenColumn: TableColumn[];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**注入结构 */
|
|
57
|
+
export type TableProvies = {
|
|
58
|
+
tableProps: TableProp;
|
|
59
|
+
tableColums: Ref<Array<TableColumn>>;
|
|
60
|
+
columnConfig: ColumnConfig;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type ImageViewer = {
|
|
64
|
+
/**是否显示 */
|
|
65
|
+
show: boolean;
|
|
66
|
+
/**图片路径 */
|
|
67
|
+
filePathList: any[];
|
|
68
|
+
/**显示图片的索引 */
|
|
69
|
+
index: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export enum FileType {
|
|
73
|
+
/** 图片 */
|
|
74
|
+
PICTURE = 1,
|
|
75
|
+
/** PDF */
|
|
76
|
+
PDF = 2,
|
|
77
|
+
/** 其他 */
|
|
78
|
+
OTHER = 3,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**表格属性 */
|
|
82
|
+
export interface TableProp {
|
|
83
|
+
/**UI选项配置 */
|
|
84
|
+
options?: TableAttr;
|
|
85
|
+
/**表格数据源 */
|
|
86
|
+
tableData?: Array<any>;
|
|
87
|
+
/**表格列(所有列) */
|
|
88
|
+
tableColums: Array<TableColumn>;
|
|
89
|
+
/**Loading状态 */
|
|
90
|
+
tableLoading?: boolean;
|
|
91
|
+
/**是否显示列check,默认true */
|
|
92
|
+
selectionCol?: boolean;
|
|
93
|
+
/**是否显示索引列,默认true */
|
|
94
|
+
indexCol?: boolean;
|
|
95
|
+
/**是否能设置表格列,默认false */
|
|
96
|
+
isSetColumn?: boolean;
|
|
97
|
+
/**分页配置 */
|
|
98
|
+
paging?: {
|
|
99
|
+
pageIndex: number;
|
|
100
|
+
pageSize: number;
|
|
101
|
+
};
|
|
102
|
+
/**总数 */
|
|
103
|
+
total?: number;
|
|
104
|
+
/**可选页面大小 */
|
|
105
|
+
sizeList?: Array<number>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface TableColumn {
|
|
109
|
+
/**
|
|
110
|
+
* 表头文本对齐方式
|
|
111
|
+
*/
|
|
112
|
+
headerAlign?: string;
|
|
113
|
+
/**
|
|
114
|
+
* 表格内容对齐方式
|
|
115
|
+
*/
|
|
116
|
+
align?: string;
|
|
117
|
+
/**
|
|
118
|
+
* 列绑定数据字段
|
|
119
|
+
*/
|
|
120
|
+
prop?: string;
|
|
121
|
+
/**
|
|
122
|
+
* 表头名称
|
|
123
|
+
*/
|
|
124
|
+
label?: string;
|
|
125
|
+
/**
|
|
126
|
+
* 是否显示
|
|
127
|
+
*/
|
|
128
|
+
init?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* 表格宽度
|
|
131
|
+
*/
|
|
132
|
+
width?: number;
|
|
133
|
+
/**
|
|
134
|
+
* 最小宽度
|
|
135
|
+
*/
|
|
136
|
+
minWidth?: number;
|
|
137
|
+
/**
|
|
138
|
+
* 是否显示单元格内容tooltip
|
|
139
|
+
*/
|
|
140
|
+
showOverflowTooltip?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* 是否能排序
|
|
143
|
+
*/
|
|
144
|
+
sortable?: boolean;
|
|
145
|
+
/** 是否固定 */
|
|
146
|
+
fixed?: "left" | "right";
|
|
147
|
+
/** 是否为文件 */
|
|
148
|
+
isFile?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* 图片类型
|
|
151
|
+
*/
|
|
152
|
+
fileType?: FileType;
|
|
153
|
+
/**
|
|
154
|
+
* 数据是否为HTML
|
|
155
|
+
*/
|
|
156
|
+
isHtml?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* 是否为进度条
|
|
159
|
+
*/
|
|
160
|
+
isProgress?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* 是否为工序进度
|
|
163
|
+
*/
|
|
164
|
+
isProcess?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* 组件配置列表
|
|
167
|
+
*/
|
|
168
|
+
componentOption?: any;
|
|
169
|
+
/**页面Id*/
|
|
170
|
+
// pageId?: number;
|
|
171
|
+
/**多语言配置 */
|
|
172
|
+
langue?: string;
|
|
173
|
+
}
|