@skyfox2000/webui 0.1.0
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/.eslintrc.js +23 -0
- package/.prettierrc +11 -0
- package/.vscode/settings.json +25 -0
- package/README.md +104 -0
- package/env.d.ts +11 -0
- package/index.html +19 -0
- package/lib/AceEditor.d.ts +4 -0
- package/lib/BasicLayout.d.ts +4 -0
- package/lib/Error403.d.ts +4 -0
- package/lib/Error404.d.ts +4 -0
- package/lib/ExcelForm.d.ts +4 -0
- package/lib/UploadForm.d.ts +4 -0
- package/lib/assets/modules/basicLayout-YP_-EySb.js +726 -0
- package/lib/assets/modules/error403-Bi0E2twj.js +33 -0
- package/lib/assets/modules/error404-BF7vasR_.js +33 -0
- package/lib/assets/modules/excelForm-Dzndz-SG.js +109 -0
- package/lib/assets/modules/excelForm-WJVQmaDT.js +317 -0
- package/lib/assets/modules/index-FzWSvscZ.js +107 -0
- package/lib/assets/modules/index-ekkaExvB.js +49 -0
- package/lib/assets/modules/uploadForm-BahGnrAq.js +415 -0
- package/lib/assets/modules/uploadForm-DEnOjhwc.js +308 -0
- package/lib/components/common/button/index.vue.d.ts +42 -0
- package/lib/components/common/button/index.vue.d.ts.map +1 -0
- package/lib/components/common/icon/appicon.vue.d.ts +12 -0
- package/lib/components/common/icon/appicon.vue.d.ts.map +1 -0
- package/lib/components/common/icon/fullscreen.vue.d.ts +4 -0
- package/lib/components/common/icon/fullscreen.vue.d.ts.map +1 -0
- package/lib/components/common/icon/helper.vue.d.ts +23 -0
- package/lib/components/common/icon/helper.vue.d.ts.map +1 -0
- package/lib/components/common/icon/index.vue.d.ts +244 -0
- package/lib/components/common/icon/index.vue.d.ts.map +1 -0
- package/lib/components/common/icon/layoutIcon.vue.d.ts +44 -0
- package/lib/components/common/icon/layoutIcon.vue.d.ts.map +1 -0
- package/lib/components/common/icon/projectIcon.vue.d.ts +60 -0
- package/lib/components/common/icon/projectIcon.vue.d.ts.map +1 -0
- package/lib/components/common/icon/toolIcon.vue.d.ts +44 -0
- package/lib/components/common/icon/toolIcon.vue.d.ts.map +1 -0
- package/lib/components/common/index.d.ts +19 -0
- package/lib/components/common/index.d.ts.map +1 -0
- package/lib/components/common/tooltip/index.vue.d.ts +22 -0
- package/lib/components/common/tooltip/index.vue.d.ts.map +1 -0
- package/lib/components/content/dialog/excelForm.vue.d.ts +31 -0
- package/lib/components/content/dialog/excelForm.vue.d.ts.map +1 -0
- package/lib/components/content/dialog/index.vue.d.ts +35 -0
- package/lib/components/content/dialog/index.vue.d.ts.map +1 -0
- package/lib/components/content/dialog/uploadForm.vue.d.ts +25 -0
- package/lib/components/content/dialog/uploadForm.vue.d.ts.map +1 -0
- package/lib/components/content/drawer/index.vue.d.ts +27 -0
- package/lib/components/content/drawer/index.vue.d.ts.map +1 -0
- package/lib/components/content/form/formItem.vue.d.ts +26 -0
- package/lib/components/content/form/formItem.vue.d.ts.map +1 -0
- package/lib/components/content/form/index.vue.d.ts +26 -0
- package/lib/components/content/form/index.vue.d.ts.map +1 -0
- package/lib/components/content/index.d.ts +27 -0
- package/lib/components/content/index.d.ts.map +1 -0
- package/lib/components/content/search/index.vue.d.ts +30 -0
- package/lib/components/content/search/index.vue.d.ts.map +1 -0
- package/lib/components/content/search/searchItem.vue.d.ts +24 -0
- package/lib/components/content/search/searchItem.vue.d.ts.map +1 -0
- package/lib/components/content/table/index.vue.d.ts +37 -0
- package/lib/components/content/table/index.vue.d.ts.map +1 -0
- package/lib/components/content/table/tableOperate.vue.d.ts +19 -0
- package/lib/components/content/table/tableOperate.vue.d.ts.map +1 -0
- package/lib/components/content/toolbar/icontool.vue.d.ts +8 -0
- package/lib/components/content/toolbar/icontool.vue.d.ts.map +1 -0
- package/lib/components/content/toolbar/index.vue.d.ts +19 -0
- package/lib/components/content/toolbar/index.vue.d.ts.map +1 -0
- package/lib/components/content/tree/index.vue.d.ts +47 -0
- package/lib/components/content/tree/index.vue.d.ts.map +1 -0
- package/lib/components/error/error403.vue.d.ts +4 -0
- package/lib/components/error/error403.vue.d.ts.map +1 -0
- package/lib/components/error/error404.vue.d.ts +4 -0
- package/lib/components/error/error404.vue.d.ts.map +1 -0
- package/lib/components/form/aceEditor/aceConfig.d.ts +9 -0
- package/lib/components/form/aceEditor/aceConfig.d.ts.map +1 -0
- package/lib/components/form/aceEditor/index.vue.d.ts +13 -0
- package/lib/components/form/aceEditor/index.vue.d.ts.map +1 -0
- package/lib/components/form/autoComplete/index.vue.d.ts +140 -0
- package/lib/components/form/autoComplete/index.vue.d.ts.map +1 -0
- package/lib/components/form/cascader/index.vue.d.ts +110 -0
- package/lib/components/form/cascader/index.vue.d.ts.map +1 -0
- package/lib/components/form/checkbox/index.vue.d.ts +129 -0
- package/lib/components/form/checkbox/index.vue.d.ts.map +1 -0
- package/lib/components/form/datePicker/index.vue.d.ts +7 -0
- package/lib/components/form/datePicker/index.vue.d.ts.map +1 -0
- package/lib/components/form/index.d.ts +41 -0
- package/lib/components/form/index.d.ts.map +1 -0
- package/lib/components/form/input/index.vue.d.ts +27 -0
- package/lib/components/form/input/index.vue.d.ts.map +1 -0
- package/lib/components/form/input/inputIcon.vue.d.ts +11 -0
- package/lib/components/form/input/inputIcon.vue.d.ts.map +1 -0
- package/lib/components/form/input/inputNumber.vue.d.ts +4 -0
- package/lib/components/form/input/inputNumber.vue.d.ts.map +1 -0
- package/lib/components/form/input/inputPassword.vue.d.ts +4 -0
- package/lib/components/form/input/inputPassword.vue.d.ts.map +1 -0
- package/lib/components/form/propEditor/index.vue.d.ts +13 -0
- package/lib/components/form/propEditor/index.vue.d.ts.map +1 -0
- package/lib/components/form/radio/index.vue.d.ts +134 -0
- package/lib/components/form/radio/index.vue.d.ts.map +1 -0
- package/lib/components/form/radio/radioStatus.vue.d.ts +32 -0
- package/lib/components/form/radio/radioStatus.vue.d.ts.map +1 -0
- package/lib/components/form/rangePicker/index.vue.d.ts +17 -0
- package/lib/components/form/rangePicker/index.vue.d.ts.map +1 -0
- package/lib/components/form/select/index.vue.d.ts +143 -0
- package/lib/components/form/select/index.vue.d.ts.map +1 -0
- package/lib/components/form/switch/index.vue.d.ts +44 -0
- package/lib/components/form/switch/index.vue.d.ts.map +1 -0
- package/lib/components/form/textarea/index.vue.d.ts +4 -0
- package/lib/components/form/textarea/index.vue.d.ts.map +1 -0
- package/lib/components/form/transfer/index.vue.d.ts +39 -0
- package/lib/components/form/transfer/index.vue.d.ts.map +1 -0
- package/lib/components/form/transfer/transferTable.vue.d.ts +39 -0
- package/lib/components/form/transfer/transferTable.vue.d.ts.map +1 -0
- package/lib/components/form/treeSelect/index.vue.d.ts +39 -0
- package/lib/components/form/treeSelect/index.vue.d.ts.map +1 -0
- package/lib/components/form/upload/uploadList.vue.d.ts +477 -0
- package/lib/components/form/upload/uploadList.vue.d.ts.map +1 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/layout/breadcrumb/index.vue.d.ts +4 -0
- package/lib/components/layout/breadcrumb/index.vue.d.ts.map +1 -0
- package/lib/components/layout/content/index.vue.d.ts +23 -0
- package/lib/components/layout/content/index.vue.d.ts.map +1 -0
- package/lib/components/layout/datetime/index.vue.d.ts +4 -0
- package/lib/components/layout/datetime/index.vue.d.ts.map +1 -0
- package/lib/components/layout/header/headerExits.vue.d.ts +4 -0
- package/lib/components/layout/header/headerExits.vue.d.ts.map +1 -0
- package/lib/components/layout/header/index.vue.d.ts +4 -0
- package/lib/components/layout/header/index.vue.d.ts.map +1 -0
- package/lib/components/layout/index.d.ts +17 -0
- package/lib/components/layout/index.d.ts.map +1 -0
- package/lib/components/layout/menu/index.vue.d.ts +7 -0
- package/lib/components/layout/menu/index.vue.d.ts.map +1 -0
- package/lib/components/layout/menu/menuTabs.vue.d.ts +4 -0
- package/lib/components/layout/menu/menuTabs.vue.d.ts.map +1 -0
- package/lib/components/layout/page/basicLayout.vue.d.ts +7 -0
- package/lib/components/layout/page/basicLayout.vue.d.ts.map +1 -0
- package/lib/es/AceEditor/index.js +168 -0
- package/lib/es/BasicLayout/index.js +4 -0
- package/lib/es/Error403/index.js +4 -0
- package/lib/es/Error404/index.js +4 -0
- package/lib/es/ExcelForm/index.js +5 -0
- package/lib/es/UploadForm/index.js +5 -0
- package/lib/index.d.ts +2 -0
- package/lib/webui.css +1 -0
- package/lib/webui.es.js +3349 -0
- package/package.json +66 -0
- package/plugins/vite-plugin-auto-generate-vue.ts +105 -0
- package/postcss.config.ts +6 -0
- package/src/assets/global.css +9 -0
- package/src/components/common/button/index.vue +126 -0
- package/src/components/common/icon/appicon.vue +28 -0
- package/src/components/common/icon/fullscreen.vue +13 -0
- package/src/components/common/icon/helper.vue +30 -0
- package/src/components/common/icon/index.vue +426 -0
- package/src/components/common/icon/layoutIcon.vue +33 -0
- package/src/components/common/icon/projectIcon.vue +41 -0
- package/src/components/common/icon/toolIcon.vue +33 -0
- package/src/components/common/index.ts +19 -0
- package/src/components/common/tooltip/index.vue +25 -0
- package/src/components/content/dialog/excelForm.vue +479 -0
- package/src/components/content/dialog/index.vue +149 -0
- package/src/components/content/dialog/uploadForm.vue +228 -0
- package/src/components/content/drawer/index.vue +93 -0
- package/src/components/content/form/formItem.vue +76 -0
- package/src/components/content/form/index.vue +48 -0
- package/src/components/content/index.ts +32 -0
- package/src/components/content/search/index.vue +135 -0
- package/src/components/content/search/searchItem.vue +52 -0
- package/src/components/content/table/index.vue +215 -0
- package/src/components/content/table/tableOperate.vue +131 -0
- package/src/components/content/toolbar/icontool.vue +151 -0
- package/src/components/content/toolbar/index.vue +107 -0
- package/src/components/content/tree/index.vue +140 -0
- package/src/components/error/error403.vue +14 -0
- package/src/components/error/error404.vue +14 -0
- package/src/components/form/aceEditor/aceConfig.ts +90 -0
- package/src/components/form/aceEditor/index.vue +175 -0
- package/src/components/form/autoComplete/index.vue +171 -0
- package/src/components/form/cascader/index.vue +110 -0
- package/src/components/form/checkbox/index.vue +108 -0
- package/src/components/form/datePicker/index.vue +29 -0
- package/src/components/form/index.ts +54 -0
- package/src/components/form/input/index.vue +70 -0
- package/src/components/form/input/inputIcon.vue +39 -0
- package/src/components/form/input/inputNumber.vue +23 -0
- package/src/components/form/input/inputPassword.vue +22 -0
- package/src/components/form/propEditor/index.vue +81 -0
- package/src/components/form/radio/index.vue +132 -0
- package/src/components/form/radio/radioStatus.vue +42 -0
- package/src/components/form/rangePicker/index.vue +64 -0
- package/src/components/form/select/index.vue +186 -0
- package/src/components/form/switch/index.vue +58 -0
- package/src/components/form/textarea/index.vue +23 -0
- package/src/components/form/transfer/index.vue +95 -0
- package/src/components/form/transfer/transferTable.vue +124 -0
- package/src/components/form/treeSelect/index.vue +108 -0
- package/src/components/form/upload/uploadList.vue +235 -0
- package/src/components/index.ts +97 -0
- package/src/components/layout/breadcrumb/index.vue +38 -0
- package/src/components/layout/content/index.vue +28 -0
- package/src/components/layout/datetime/index.vue +16 -0
- package/src/components/layout/header/headerExits.vue +28 -0
- package/src/components/layout/header/index.vue +43 -0
- package/src/components/layout/index.ts +16 -0
- package/src/components/layout/menu/index.vue +64 -0
- package/src/components/layout/menu/menuTabs.vue +56 -0
- package/src/components/layout/page/basicLayout.vue +67 -0
- package/src/vite-env.d.ts +8 -0
- package/tailwind.config.ts +11 -0
- package/tsconfig.json +53 -0
- package/vite.config.ts +117 -0
- package//344/273/243/347/240/201/350/247/204/350/214/203/345/217/212/351/243/216/346/240/274/346/214/207/345/215/227.md +116 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { onMounted, Ref, ref, watch, provide, useAttrs, onActivated } from 'vue';
|
|
3
|
+
import { Table, TablePaginationConfig, TableProps } from 'ant-design-vue';
|
|
4
|
+
import {
|
|
5
|
+
gridQueryFind,
|
|
6
|
+
gridStatusUpdate,
|
|
7
|
+
PrimaryKey,
|
|
8
|
+
OPTIONS,
|
|
9
|
+
gridQueryList,
|
|
10
|
+
GridControl,
|
|
11
|
+
filterColumns,
|
|
12
|
+
} from '@skyfox2000/webbase';
|
|
13
|
+
import TableOperate from './tableOperate.vue';
|
|
14
|
+
import Toolbar from '../toolbar/index.vue';
|
|
15
|
+
import Switch from '../../form/switch/index.vue';
|
|
16
|
+
import { AnyData } from '@skyfox2000/fapi';
|
|
17
|
+
import { ProviderKeys } from '@skyfox2000/webbase';
|
|
18
|
+
|
|
19
|
+
const props = defineProps<{
|
|
20
|
+
/**
|
|
21
|
+
* 表格数据控制
|
|
22
|
+
*/
|
|
23
|
+
gridCtrl: GridControl<AnyData>;
|
|
24
|
+
/**
|
|
25
|
+
* 表格主键
|
|
26
|
+
*/
|
|
27
|
+
primaryKey?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 自定义表格数据
|
|
30
|
+
*/
|
|
31
|
+
tableData?: Record<string, AnyData>[];
|
|
32
|
+
/**
|
|
33
|
+
* 自定义行选中处理
|
|
34
|
+
*/
|
|
35
|
+
rowSelection?: TableProps['rowSelection'];
|
|
36
|
+
/**
|
|
37
|
+
* 自定义分页控制
|
|
38
|
+
*/
|
|
39
|
+
pagination?: TableProps['pagination'];
|
|
40
|
+
/**
|
|
41
|
+
* 表格大小配置
|
|
42
|
+
*/
|
|
43
|
+
scroll?: TableProps['scroll'];
|
|
44
|
+
/**
|
|
45
|
+
* 是否禁用启用状态
|
|
46
|
+
*/
|
|
47
|
+
statusDisabled?: Function;
|
|
48
|
+
}>();
|
|
49
|
+
// 关闭自动继承属性到根元素
|
|
50
|
+
defineOptions({
|
|
51
|
+
inheritAttrs: false,
|
|
52
|
+
});
|
|
53
|
+
const attrs = useAttrs(); // 手动获取 $attrs
|
|
54
|
+
|
|
55
|
+
const gridCtrl = props.gridCtrl;
|
|
56
|
+
|
|
57
|
+
if (gridCtrl) {
|
|
58
|
+
gridCtrl.pageNo.value = 1;
|
|
59
|
+
gridCtrl.total.value = 0;
|
|
60
|
+
gridCtrl.pageSize.value = gridCtrl.pageSize.value;
|
|
61
|
+
}
|
|
62
|
+
const curPageSize = ref(gridCtrl.pageSize.value);
|
|
63
|
+
const curPageNo = ref(gridCtrl.pageNo.value);
|
|
64
|
+
|
|
65
|
+
const dataList = ref<Record<string, AnyData>[]>([]);
|
|
66
|
+
const pagination: Ref<TablePaginationConfig> = ref<TablePaginationConfig>({
|
|
67
|
+
...{
|
|
68
|
+
total: 0,
|
|
69
|
+
current: 1,
|
|
70
|
+
pageSize: curPageSize.value,
|
|
71
|
+
showTotal: (total: number) => {
|
|
72
|
+
return `共 ${total} 条记录`;
|
|
73
|
+
},
|
|
74
|
+
onChange: (page: number, pageSize: number) => {
|
|
75
|
+
pagination.value.current = page;
|
|
76
|
+
pagination.value.pageSize = pageSize;
|
|
77
|
+
curPageSize.value = pageSize;
|
|
78
|
+
curPageNo.value = page;
|
|
79
|
+
if (gridCtrl) {
|
|
80
|
+
gridCtrl.pageNo.value = page;
|
|
81
|
+
gridCtrl.pageSize.value = pageSize;
|
|
82
|
+
if (gridCtrl.remotePage) gridQueryFind(gridCtrl);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
...props.pagination,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
watch(
|
|
90
|
+
() => gridCtrl.tableData.value,
|
|
91
|
+
(newVal) => {
|
|
92
|
+
if (newVal) {
|
|
93
|
+
dataList.value = newVal;
|
|
94
|
+
pagination.value.total = gridCtrl.total.value ?? 0;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{ immediate: true },
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
watch(
|
|
101
|
+
() => props.tableData,
|
|
102
|
+
(newVal) => {
|
|
103
|
+
if (newVal) {
|
|
104
|
+
dataList.value = newVal;
|
|
105
|
+
pagination.value.total = newVal.length;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{ immediate: true },
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const columns = ref<Record<string, any>[]>(gridCtrl.columns.value);
|
|
112
|
+
const selection = {
|
|
113
|
+
...{
|
|
114
|
+
onChange: (selectedRowKeys: PrimaryKey[], selectedRows: any[]) => {
|
|
115
|
+
if (gridCtrl) {
|
|
116
|
+
gridCtrl.selectKeys.value = selectedRowKeys;
|
|
117
|
+
gridCtrl.selectRows.value = selectedRows;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
columnWidth: '30px',
|
|
121
|
+
getCheckboxProps: (record: any) => ({
|
|
122
|
+
disabled: record.Enabled === 0,
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
...props.rowSelection,
|
|
126
|
+
};
|
|
127
|
+
const rowSelection: Ref<TableProps['rowSelection']> = ref<TableProps['rowSelection']>(selection);
|
|
128
|
+
watch(
|
|
129
|
+
() => gridCtrl.selectable.value,
|
|
130
|
+
(newVal) => {
|
|
131
|
+
if (gridCtrl) {
|
|
132
|
+
rowSelection.value = newVal ? selection : undefined;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{ immediate: true },
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
watch(
|
|
139
|
+
() => gridCtrl.columns.value,
|
|
140
|
+
() => {
|
|
141
|
+
columns.value = filterColumns(gridCtrl.columns.value);
|
|
142
|
+
},
|
|
143
|
+
{ deep: true, immediate: true },
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const visible = ref(false);
|
|
147
|
+
onActivated(() => {
|
|
148
|
+
if (visible.value && gridCtrl) gridCtrl.reload.value = true;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
onMounted(async () => {
|
|
152
|
+
provide(ProviderKeys.GridControl, gridCtrl);
|
|
153
|
+
|
|
154
|
+
if (gridCtrl.tableData.value) {
|
|
155
|
+
dataList.value = gridCtrl.tableData.value;
|
|
156
|
+
gridCtrl.total.value = dataList.value.length;
|
|
157
|
+
pagination.value.total = gridCtrl.total.value ?? 0;
|
|
158
|
+
} else if (gridCtrl.autoload !== false) {
|
|
159
|
+
if (gridCtrl.remotePage) {
|
|
160
|
+
dataList.value = (await gridQueryFind(gridCtrl)).rows;
|
|
161
|
+
} else {
|
|
162
|
+
dataList.value = await gridQueryList(gridCtrl);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
// 延时显示,避免表格无数据显示异常
|
|
168
|
+
visible.value = true;
|
|
169
|
+
}, 50);
|
|
170
|
+
});
|
|
171
|
+
</script>
|
|
172
|
+
<template>
|
|
173
|
+
<Toolbar
|
|
174
|
+
:grid-ctrl="gridCtrl"
|
|
175
|
+
:editor-ctrl="gridCtrl.editor!"
|
|
176
|
+
v-if="gridCtrl.buttons?.value.length || gridCtrl.tools?.length"
|
|
177
|
+
/>
|
|
178
|
+
<Table
|
|
179
|
+
v-if="visible"
|
|
180
|
+
class="w-full"
|
|
181
|
+
:row-key="props.primaryKey ?? gridCtrl.primaryKey ?? 'Id'"
|
|
182
|
+
:data-source="dataList"
|
|
183
|
+
:loading="gridCtrl.isGridLoading.value"
|
|
184
|
+
:columns="columns"
|
|
185
|
+
:pagination="pagination"
|
|
186
|
+
:row-selection="rowSelection"
|
|
187
|
+
:scroll="props.scroll || { x: 700, y: 1000 }"
|
|
188
|
+
:size="gridCtrl.tableSize.value"
|
|
189
|
+
bordered
|
|
190
|
+
v-bind="attrs"
|
|
191
|
+
>
|
|
192
|
+
<template #bodyCell="bodyCell">
|
|
193
|
+
<slot name="bodyCell" :column="bodyCell?.column" :record="bodyCell?.record"></slot>
|
|
194
|
+
<template v-if="gridCtrl && bodyCell?.column?.dataIndex === 'enabled'">
|
|
195
|
+
<Switch
|
|
196
|
+
v-model:checked="bodyCell.record.Enabled"
|
|
197
|
+
v-permit:disable="':enabled'"
|
|
198
|
+
:disabled="statusDisabled ? statusDisabled(bodyCell.record) : false"
|
|
199
|
+
:data="OPTIONS.EnableDisable"
|
|
200
|
+
@click="gridStatusUpdate(gridCtrl, bodyCell.record)"
|
|
201
|
+
:class="[
|
|
202
|
+
'w-[58px]',
|
|
203
|
+
statusDisabled && statusDisabled(bodyCell.record) ? 'cursor-not-allowed disabled' : '',
|
|
204
|
+
]"
|
|
205
|
+
:loading="bodyCell?.record.isLoading"
|
|
206
|
+
/>
|
|
207
|
+
</template>
|
|
208
|
+
<template v-if="gridCtrl && bodyCell?.column?.dataIndex === 'operation'">
|
|
209
|
+
<slot name="operate" :record="bodyCell?.record">
|
|
210
|
+
<TableOperate :record="bodyCell?.record" :grid-ctrl="gridCtrl"> </TableOperate>
|
|
211
|
+
</slot>
|
|
212
|
+
</template>
|
|
213
|
+
</template>
|
|
214
|
+
</Table>
|
|
215
|
+
</template>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T">
|
|
2
|
+
import {
|
|
3
|
+
ButtonTool,
|
|
4
|
+
getToolGroup,
|
|
5
|
+
getToolVisible,
|
|
6
|
+
getToolStatus,
|
|
7
|
+
onToolClicked,
|
|
8
|
+
onGridRowEdit,
|
|
9
|
+
onGridRowDelete,
|
|
10
|
+
GridControl,
|
|
11
|
+
} from '@skyfox2000/webbase';
|
|
12
|
+
import { ConfigProvider, Button, Space, DropdownButton, Menu, MenuItem, Popconfirm } from 'ant-design-vue';
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
/**
|
|
16
|
+
* 数据行记录
|
|
17
|
+
*/
|
|
18
|
+
record: Record<string, any>;
|
|
19
|
+
/**
|
|
20
|
+
* 表格数据控制
|
|
21
|
+
*/
|
|
22
|
+
gridCtrl: GridControl<T>;
|
|
23
|
+
}>();
|
|
24
|
+
|
|
25
|
+
const gridCtrl = props.gridCtrl;
|
|
26
|
+
|
|
27
|
+
/// 兼容其它按钮操作参数
|
|
28
|
+
const defaultOperates: ButtonTool[] = [
|
|
29
|
+
{
|
|
30
|
+
key: 'Edit',
|
|
31
|
+
label: '编辑',
|
|
32
|
+
type: 'primary',
|
|
33
|
+
visible: true,
|
|
34
|
+
permit: ':edit',
|
|
35
|
+
click: () => onGridRowEdit<T>(gridCtrl, props.record as T),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'Delete',
|
|
39
|
+
label: '删除',
|
|
40
|
+
type: 'primary',
|
|
41
|
+
visible: true,
|
|
42
|
+
danger: true,
|
|
43
|
+
permit: ':delete',
|
|
44
|
+
confirm: true,
|
|
45
|
+
confirmText: '是否删除此记录?',
|
|
46
|
+
click: () => onGridRowDelete<T>(gridCtrl, props.record as T),
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const { buttons, menus } = getToolGroup(defaultOperates, 0, gridCtrl.operates);
|
|
51
|
+
|
|
52
|
+
const disabled = (item: ButtonTool): boolean => {
|
|
53
|
+
if (typeof item.disabled == 'boolean') {
|
|
54
|
+
return item.disabled;
|
|
55
|
+
}
|
|
56
|
+
if (typeof item.disabled == 'function') {
|
|
57
|
+
return getToolStatus(item, props.record) ?? false;
|
|
58
|
+
}
|
|
59
|
+
if (props.record.hasOwnProperty('Enabled')) {
|
|
60
|
+
switch (item.key) {
|
|
61
|
+
case 'Edit':
|
|
62
|
+
return props.record.Enabled ? false : true;
|
|
63
|
+
case 'Delete':
|
|
64
|
+
return props.record.Enabled ? true : false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
70
|
+
<template>
|
|
71
|
+
<ConfigProvider
|
|
72
|
+
:theme="{
|
|
73
|
+
token: {
|
|
74
|
+
fontSize: 13,
|
|
75
|
+
},
|
|
76
|
+
}"
|
|
77
|
+
>
|
|
78
|
+
<Space>
|
|
79
|
+
<template v-for="item in buttons" :key="item.key">
|
|
80
|
+
<Popconfirm
|
|
81
|
+
v-if="getToolVisible(item, props.record)"
|
|
82
|
+
:disabled="disabled(item) || !item.confirm"
|
|
83
|
+
cancelText="否"
|
|
84
|
+
okText="是"
|
|
85
|
+
:title="item.confirmText"
|
|
86
|
+
:okButtonProps="{ size: 'small' }"
|
|
87
|
+
:cancelButtonProps="{ size: 'small' }"
|
|
88
|
+
@confirm="onToolClicked(item, gridCtrl.page, gridCtrl, props.record, true)"
|
|
89
|
+
>
|
|
90
|
+
<Button
|
|
91
|
+
:key="item.key"
|
|
92
|
+
:type="item.type ?? 'text'"
|
|
93
|
+
:danger="item.danger"
|
|
94
|
+
v-if="getToolVisible(item, props.record)"
|
|
95
|
+
:disabled="disabled(item)"
|
|
96
|
+
v-role="item.role"
|
|
97
|
+
v-permit="item.permit"
|
|
98
|
+
@click="onToolClicked(item, gridCtrl.page, gridCtrl, props.record)"
|
|
99
|
+
size="small"
|
|
100
|
+
:style="{
|
|
101
|
+
padding: item.type ?? '0px 4px',
|
|
102
|
+
}"
|
|
103
|
+
>
|
|
104
|
+
{{ item.label }}
|
|
105
|
+
</Button>
|
|
106
|
+
</Popconfirm>
|
|
107
|
+
</template>
|
|
108
|
+
|
|
109
|
+
<ConfigProvider :autoInsertSpaceInButton="false" v-if="record.Enabled == 1">
|
|
110
|
+
<DropdownButton v-if="menus.length > 0" size="small">
|
|
111
|
+
更多
|
|
112
|
+
<template #overlay>
|
|
113
|
+
<Menu>
|
|
114
|
+
<template v-for="item in menus" :key="item.key">
|
|
115
|
+
<MenuItem
|
|
116
|
+
v-if="getToolVisible(item, props.record)"
|
|
117
|
+
:disabled="disabled(item)"
|
|
118
|
+
v-role="item.role"
|
|
119
|
+
v-permit="item.permit"
|
|
120
|
+
@click="onToolClicked(item, gridCtrl.page, gridCtrl, props.record)"
|
|
121
|
+
>
|
|
122
|
+
{{ item.label }}
|
|
123
|
+
</MenuItem>
|
|
124
|
+
</template>
|
|
125
|
+
</Menu>
|
|
126
|
+
</template>
|
|
127
|
+
</DropdownButton>
|
|
128
|
+
</ConfigProvider>
|
|
129
|
+
</Space>
|
|
130
|
+
</ConfigProvider>
|
|
131
|
+
</template>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
import { VueDraggableNext as draggable } from 'vue-draggable-next';
|
|
4
|
+
import { Checkbox } from 'ant-design-vue';
|
|
5
|
+
import {
|
|
6
|
+
AppRouter,
|
|
7
|
+
filterColumns,
|
|
8
|
+
onColumnVisibleChanged,
|
|
9
|
+
useSettingInfo,
|
|
10
|
+
getToolStatus,
|
|
11
|
+
getToolByKey,
|
|
12
|
+
getToolVisible,
|
|
13
|
+
useToolFactory,
|
|
14
|
+
onToolClicked,
|
|
15
|
+
GridControl,
|
|
16
|
+
} from '@skyfox2000/webbase';
|
|
17
|
+
import { Button, ToolIcon } from '../../common';
|
|
18
|
+
import { Dropdown, Menu, MenuItem } from 'ant-design-vue';
|
|
19
|
+
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
/**
|
|
22
|
+
* 页面主数据
|
|
23
|
+
*/
|
|
24
|
+
gridCtrl: GridControl<any>;
|
|
25
|
+
}>();
|
|
26
|
+
|
|
27
|
+
const gridCtrl = props.gridCtrl;
|
|
28
|
+
const { tools } = useToolFactory(props.gridCtrl);
|
|
29
|
+
|
|
30
|
+
const settingStore = useSettingInfo();
|
|
31
|
+
|
|
32
|
+
watch(
|
|
33
|
+
() => gridCtrl.selectable.value,
|
|
34
|
+
(newVal) => {
|
|
35
|
+
if (getToolByKey(tools, 'tool.export.excel.selected'))
|
|
36
|
+
getToolByKey(tools, 'tool.export.excel.selected')!.disabled = !newVal;
|
|
37
|
+
if (getToolByKey(tools, 'tool.export.pdf.selected'))
|
|
38
|
+
getToolByKey(tools, 'tool.export.pdf.selected')!.disabled = !newVal;
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// 添加拖拽相关的响应式数据
|
|
43
|
+
const dragColumns = ref<Record<string, any>[]>([]);
|
|
44
|
+
|
|
45
|
+
watch(
|
|
46
|
+
() => gridCtrl.columns.value,
|
|
47
|
+
(newVal) => {
|
|
48
|
+
dragColumns.value = filterColumns(newVal, true);
|
|
49
|
+
},
|
|
50
|
+
{ deep: true, immediate: true },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// 处理拖拽结束事件
|
|
54
|
+
const onDragEnd = () => {
|
|
55
|
+
// 更新列的顺序
|
|
56
|
+
gridCtrl.columns.value.splice(0, gridCtrl.columns.value.length, ...dragColumns.value);
|
|
57
|
+
settingStore.setTableColumns(AppRouter.currentRoute.value.path, gridCtrl.columns.value);
|
|
58
|
+
};
|
|
59
|
+
</script>
|
|
60
|
+
<template>
|
|
61
|
+
<div class="inline-flex [&>div]:ml-[-1px] first:[&>div]:ml-0">
|
|
62
|
+
<template v-for="(item, index) in tools" :key="item.key">
|
|
63
|
+
<Dropdown placement="bottomRight" class="p-0 rounded-none" v-if="getToolVisible(item) && item.dropdown">
|
|
64
|
+
<template #overlay>
|
|
65
|
+
<div class="min-w-[100px] bg-white rounded shadow-md p-4" :class="item.dropdownClass">
|
|
66
|
+
<draggable
|
|
67
|
+
v-if="item.dropdown === 'headset'"
|
|
68
|
+
v-model="dragColumns"
|
|
69
|
+
item-key="dataIndex"
|
|
70
|
+
@end="onDragEnd"
|
|
71
|
+
handle=".drag-handle"
|
|
72
|
+
>
|
|
73
|
+
<template v-for="element in dragColumns" :key="element.name">
|
|
74
|
+
<div @click.stop class="flex items-center mb-2 last:mb-0 select-none">
|
|
75
|
+
<span class="drag-handle mr-2 text-gray-400 hover:text-gray-600 cursor-move">⋮⋮</span>
|
|
76
|
+
<Checkbox
|
|
77
|
+
:checked="element.visible !== false"
|
|
78
|
+
@change.stop.prevent="
|
|
79
|
+
(e) => {
|
|
80
|
+
onColumnVisibleChanged(element, e.target.checked);
|
|
81
|
+
}
|
|
82
|
+
"
|
|
83
|
+
class="text-gray-700 hover:text-gray-900 select-none"
|
|
84
|
+
>
|
|
85
|
+
{{ element.title }}
|
|
86
|
+
</Checkbox>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
</draggable>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
92
|
+
<Button
|
|
93
|
+
:class="[
|
|
94
|
+
'px-[8px] py-[2px] relative border-[#ccc] bg-[#fcfcfc] rounded-none text-[#666] hover:z-10',
|
|
95
|
+
index === 0 ? 'rounded-l-[5px]' : '',
|
|
96
|
+
index === tools.length - 1 ? 'rounded-r-[5px]' : '',
|
|
97
|
+
]"
|
|
98
|
+
:disabled="getToolStatus(item)"
|
|
99
|
+
:tiptext="item.label"
|
|
100
|
+
@click="onToolClicked(item, gridCtrl.page, gridCtrl)"
|
|
101
|
+
>
|
|
102
|
+
<ToolIcon :icon="item.icon" class="w-[18px] h-[18.5px]" clickable />
|
|
103
|
+
</Button>
|
|
104
|
+
</Dropdown>
|
|
105
|
+
<Button
|
|
106
|
+
v-else-if="!item.children && getToolVisible(item)"
|
|
107
|
+
:class="[
|
|
108
|
+
'px-[8px] py-[2px] relative border-[#ccc] bg-[#fcfcfc] rounded-none text-[#666] hover:z-10',
|
|
109
|
+
index === 0 ? 'rounded-l-[5px]' : '',
|
|
110
|
+
index === tools.length - 1 ? 'rounded-r-[5px]' : '',
|
|
111
|
+
]"
|
|
112
|
+
:disabled="getToolStatus(item)"
|
|
113
|
+
:tiptext="item.label"
|
|
114
|
+
@click="onToolClicked(item, gridCtrl.page, gridCtrl)"
|
|
115
|
+
>
|
|
116
|
+
<ToolIcon :icon="item.icon" class="w-[18px] h-[18.5px]" clickable />
|
|
117
|
+
</Button>
|
|
118
|
+
<Dropdown placement="bottomRight" class="p-0 rounded-none" v-else-if="getToolVisible(item)">
|
|
119
|
+
<template #overlay>
|
|
120
|
+
<Menu>
|
|
121
|
+
<MenuItem v-for="menu in item.children" :key="menu.key" :disabled="getToolStatus(menu)">
|
|
122
|
+
{{ menu.label }}
|
|
123
|
+
</MenuItem>
|
|
124
|
+
</Menu>
|
|
125
|
+
</template>
|
|
126
|
+
<Button
|
|
127
|
+
:class="[
|
|
128
|
+
'!w-[46px] px-[5px] py-[2px] relative border-[#ccc] bg-[#fcfcfc] rounded-none text-[#666] hover:z-10',
|
|
129
|
+
index === 0 ? 'rounded-l-[5px]' : '',
|
|
130
|
+
]"
|
|
131
|
+
:disabled="getToolStatus(item)"
|
|
132
|
+
:tiptext="item.label"
|
|
133
|
+
:icon="item.icon"
|
|
134
|
+
:iconProps="{ class: 'w-[19px] h-[19px]' }"
|
|
135
|
+
@click="onToolClicked(item, gridCtrl.page, gridCtrl)"
|
|
136
|
+
>
|
|
137
|
+
<template #default>
|
|
138
|
+
<ToolIcon icon="icon-down-arrow" class="w-[12px] h-[12px]" />
|
|
139
|
+
</template>
|
|
140
|
+
</Button>
|
|
141
|
+
</Dropdown>
|
|
142
|
+
</template>
|
|
143
|
+
<!--
|
|
144
|
+
导出Excel 基于表头导出
|
|
145
|
+
导出PDF
|
|
146
|
+
TODO:支持多模板导出选择
|
|
147
|
+
表头设置
|
|
148
|
+
TODO:增加保存功能,可设置个性化表头和多模式表头
|
|
149
|
+
-->
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T">
|
|
2
|
+
import {
|
|
3
|
+
ButtonTool,
|
|
4
|
+
EditorControl,
|
|
5
|
+
GridControl,
|
|
6
|
+
getToolGroup,
|
|
7
|
+
getToolStatus,
|
|
8
|
+
onToolClicked,
|
|
9
|
+
openNewForm,
|
|
10
|
+
} from '@skyfox2000/webbase';
|
|
11
|
+
import { Dropdown, Menu, MenuItem, Space } from 'ant-design-vue';
|
|
12
|
+
import { Button } from '../../common';
|
|
13
|
+
import IconTool from './icontool.vue';
|
|
14
|
+
import { ref, watch } from 'vue';
|
|
15
|
+
|
|
16
|
+
const props = defineProps<{
|
|
17
|
+
/**
|
|
18
|
+
* 表格控制器
|
|
19
|
+
*/
|
|
20
|
+
gridCtrl: GridControl<T>;
|
|
21
|
+
/**
|
|
22
|
+
* 表单控制器
|
|
23
|
+
*/
|
|
24
|
+
editorCtrl: EditorControl<T>;
|
|
25
|
+
}>();
|
|
26
|
+
|
|
27
|
+
const gridCtrl = props.gridCtrl;
|
|
28
|
+
const pageCtrl = gridCtrl.page;
|
|
29
|
+
const editorCtrl = props.editorCtrl;
|
|
30
|
+
|
|
31
|
+
const defaultButtons: ButtonTool[] = [
|
|
32
|
+
{
|
|
33
|
+
key: 'New',
|
|
34
|
+
label: '新增',
|
|
35
|
+
type: 'primary',
|
|
36
|
+
icon: 'icon-new',
|
|
37
|
+
danger: true,
|
|
38
|
+
permit: ':new', // 默认仅受权限码控制
|
|
39
|
+
click: () => {
|
|
40
|
+
return openNewForm(editorCtrl);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const MaxButtonCount = 3;
|
|
46
|
+
|
|
47
|
+
const ToolbarButtons = ref<ButtonTool[]>([]);
|
|
48
|
+
const ToolbarMenus = ref<ButtonTool[]>([]);
|
|
49
|
+
|
|
50
|
+
watch(
|
|
51
|
+
() => gridCtrl.buttons?.value,
|
|
52
|
+
() => {
|
|
53
|
+
const { buttons, menus } = getToolGroup(
|
|
54
|
+
defaultButtons,
|
|
55
|
+
gridCtrl.flat !== undefined ? gridCtrl.flat : MaxButtonCount,
|
|
56
|
+
gridCtrl.buttons?.value,
|
|
57
|
+
);
|
|
58
|
+
ToolbarButtons.value.splice(0, ToolbarButtons.value.length, ...buttons);
|
|
59
|
+
ToolbarMenus.value.splice(0, ToolbarMenus.value.length, ...menus);
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
deep: true,
|
|
63
|
+
immediate: true,
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
</script>
|
|
67
|
+
<template>
|
|
68
|
+
<div class="flex justify-between mb-[10px]">
|
|
69
|
+
<Space>
|
|
70
|
+
<Button
|
|
71
|
+
v-for="item in ToolbarButtons"
|
|
72
|
+
:key="item.key"
|
|
73
|
+
:type="item.type"
|
|
74
|
+
:danger="item.danger"
|
|
75
|
+
:disabled="getToolStatus(item)"
|
|
76
|
+
:icon="item.icon"
|
|
77
|
+
v-role="item.role"
|
|
78
|
+
v-permit="item.permit"
|
|
79
|
+
@click="onToolClicked(item, pageCtrl, gridCtrl)"
|
|
80
|
+
>
|
|
81
|
+
{{ item.label }}
|
|
82
|
+
</Button>
|
|
83
|
+
<Dropdown v-if="ToolbarMenus.length > 0">
|
|
84
|
+
<template #overlay>
|
|
85
|
+
<Menu>
|
|
86
|
+
<MenuItem
|
|
87
|
+
v-for="item in ToolbarMenus"
|
|
88
|
+
:key="item.key"
|
|
89
|
+
:disabled="getToolStatus(item)"
|
|
90
|
+
v-role="item.role"
|
|
91
|
+
v-permit="item.permit"
|
|
92
|
+
@click="onToolClicked(item, pageCtrl, gridCtrl)"
|
|
93
|
+
>
|
|
94
|
+
{{ item.label }}
|
|
95
|
+
</MenuItem>
|
|
96
|
+
</Menu>
|
|
97
|
+
</template>
|
|
98
|
+
<Button> 更多操作 </Button>
|
|
99
|
+
</Dropdown>
|
|
100
|
+
<!-- 空占位元素 -->
|
|
101
|
+
<span v-if="ToolbarButtons.length === 0 && ToolbarMenus.length === 0"></span>
|
|
102
|
+
</Space>
|
|
103
|
+
<Space class="mr-1">
|
|
104
|
+
<component :is="IconTool" :grid-ctrl="gridCtrl" />
|
|
105
|
+
</Space>
|
|
106
|
+
</div>
|
|
107
|
+
</template>
|