@ditari/bsui 1.0.0 → 1.0.2
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/cjs/components/components.cjs.js +1 -1
- package/dist/cjs/components/components.d.ts +2 -1
- package/dist/cjs/components/form/grid-form/GridForm.cjs.js +1 -0
- package/dist/cjs/components/form/grid-form/GridForm.d.ts +2 -0
- package/dist/cjs/components/form/index.cjs.js +1 -1
- package/dist/cjs/components/form/index.d.ts +8 -1
- package/dist/cjs/components/grid/Grid.cjs.js +1 -0
- package/dist/cjs/components/grid/Grid.d.ts +23 -0
- package/dist/cjs/components/grid/GridItem.cjs.js +1 -0
- package/dist/cjs/components/grid/GridItem.d.ts +2 -0
- package/dist/cjs/components/grid/index.cjs.js +1 -0
- package/dist/cjs/components/grid/index.d.ts +23 -0
- package/dist/cjs/components/index.cjs.js +1 -1
- package/dist/cjs/components/layout/Breadcrumb.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/List.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Main.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Menu.cjs.js +1 -1
- package/dist/cjs/components/layout/NavTabs.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Show.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Show.vue.d.ts +11 -0
- package/dist/cjs/components/layout/index.d.ts +11 -25
- package/dist/cjs/components/table/Table.vue.cjs.js +1 -1
- package/dist/cjs/components/table/Table.vue.d.ts +1 -1
- package/dist/cjs/components/table/index.d.ts +1 -1
- package/dist/cjs/components/theme/index.cjs.js +1 -0
- package/dist/cjs/components/theme/index.d.ts +1 -0
- package/dist/cjs/hooks/http/index.cjs.js +1 -0
- package/dist/cjs/hooks/http/index.d.ts +29 -0
- package/dist/cjs/hooks/index.cjs.js +1 -0
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/route/index.cjs.js +1 -0
- package/dist/cjs/hooks/route/index.d.ts +9 -0
- package/dist/cjs/store/index.cjs.js +1 -0
- package/dist/cjs/store/index.d.ts +7 -7
- package/dist/cjs/store/modules/Breadcrumb.cjs.js +1 -1
- package/dist/cjs/store/modules/Breadcrumb.d.ts +6 -16
- package/dist/cjs/store/modules/DataDictionary.cjs.js +1 -1
- package/dist/cjs/store/modules/DataDictionary.d.ts +28 -3
- package/dist/cjs/store/modules/KeepAlive.cjs.js +1 -1
- package/dist/cjs/store/modules/KeepAlive.d.ts +3 -4
- package/dist/cjs/store/modules/Menu.cjs.js +1 -1
- package/dist/cjs/store/modules/Menu.d.ts +1 -2
- package/dist/cjs/store/modules/NavTab.cjs.js +1 -1
- package/dist/cjs/store/modules/NavTab.d.ts +3 -4
- package/dist/cjs/store/modules/Settings.cjs.js +1 -1
- package/dist/cjs/store/modules/Settings.d.ts +23 -9
- package/dist/cjs/store/modules/User.cjs.js +1 -1
- package/dist/cjs/store/modules/User.d.ts +1 -2
- package/dist/cjs/store/types.cjs.js +1 -1
- package/dist/cjs/utils/get.cjs.js +1 -0
- package/dist/css/grid/style/index.css +1 -0
- package/dist/css/index.css +1 -0
- package/dist/css/menu/style/index.css +1 -0
- package/dist/esm/components/components.d.ts +2 -1
- package/dist/esm/components/components.esm.js +10 -7
- package/dist/esm/components/form/grid-form/GridForm.d.ts +2 -0
- package/dist/esm/components/form/grid-form/GridForm.esm.js +9 -0
- package/dist/esm/components/form/index.d.ts +8 -1
- package/dist/esm/components/form/index.esm.js +5 -3
- package/dist/esm/components/grid/Grid.d.ts +23 -0
- package/dist/esm/components/grid/Grid.esm.js +55 -0
- package/dist/esm/components/grid/GridItem.d.ts +2 -0
- package/dist/esm/components/grid/GridItem.esm.js +15 -0
- package/dist/esm/components/grid/index.d.ts +23 -0
- package/dist/esm/components/grid/index.esm.js +8 -0
- package/dist/esm/components/index.esm.js +16 -13
- package/dist/esm/components/layout/Breadcrumb.vue.esm.js +13 -19
- package/dist/esm/components/layout/List.vue.esm.js +29 -35
- package/dist/esm/components/layout/Main.vue.esm.js +53 -50
- package/dist/esm/components/layout/Menu.esm.js +45 -19
- package/dist/esm/components/layout/NavTabs.vue.esm.js +27 -27
- package/dist/esm/components/layout/Show.vue.d.ts +11 -0
- package/dist/esm/components/layout/Show.vue.esm.js +70 -48
- package/dist/esm/components/layout/index.d.ts +11 -25
- package/dist/esm/components/table/Table.vue.d.ts +1 -1
- package/dist/esm/components/table/Table.vue.esm.js +2 -2
- package/dist/esm/components/table/index.d.ts +1 -1
- package/dist/esm/components/theme/index.d.ts +1 -0
- package/dist/esm/components/theme/index.esm.js +4 -0
- package/dist/esm/hooks/http/index.d.ts +29 -0
- package/dist/esm/hooks/http/index.esm.js +52 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.esm.js +6 -0
- package/dist/esm/hooks/route/index.d.ts +9 -0
- package/dist/esm/hooks/route/index.esm.js +42 -0
- package/dist/esm/store/index.d.ts +7 -7
- package/dist/esm/store/index.esm.js +16 -0
- package/dist/esm/store/modules/Breadcrumb.d.ts +6 -16
- package/dist/esm/store/modules/Breadcrumb.esm.js +4 -12
- package/dist/esm/store/modules/DataDictionary.d.ts +28 -3
- package/dist/esm/store/modules/DataDictionary.esm.js +30 -6
- package/dist/esm/store/modules/KeepAlive.d.ts +3 -4
- package/dist/esm/store/modules/KeepAlive.esm.js +4 -4
- package/dist/esm/store/modules/Menu.d.ts +1 -2
- package/dist/esm/store/modules/Menu.esm.js +1 -1
- package/dist/esm/store/modules/NavTab.d.ts +3 -4
- package/dist/esm/store/modules/NavTab.esm.js +2 -2
- package/dist/esm/store/modules/Settings.d.ts +23 -9
- package/dist/esm/store/modules/Settings.esm.js +81 -6
- package/dist/esm/store/modules/User.d.ts +1 -2
- package/dist/esm/store/modules/User.esm.js +4 -1
- package/dist/esm/store/types.esm.js +4 -4
- package/dist/esm/style.css +1 -274
- package/dist/esm/utils/get.esm.js +11 -0
- package/dist/style/grid/style/index.scss +61 -0
- package/dist/style/index.scss +15 -0
- package/dist/style/menu/style/index.scss +18 -0
- package/dist/style/theme/theme.scss +1 -0
- package/dist/style/theme/variable.scss +21 -0
- package/package.json +10 -7
- package/src/components/components.ts +4 -0
- package/src/components/config/Config.vue +8 -0
- package/src/components/form/Form.vue +10 -0
- package/src/components/form/grid-form/GridForm.jsx +10 -0
- package/src/components/form/index.ts +8 -0
- package/src/components/form/style/index.less +0 -0
- package/src/components/grid/Grid.tsx +73 -0
- package/src/components/grid/GridItem.tsx +15 -0
- package/src/components/grid/index.md +4 -0
- package/src/components/grid/index.ts +7 -0
- package/src/components/grid/style/index.scss +61 -0
- package/src/components/index.scss +15 -0
- package/src/components/index.ts +31 -0
- package/src/components/layout/Breadcrumb.vue +119 -0
- package/src/components/layout/Header.vue +0 -0
- package/src/components/layout/Layout.jsx +24 -0
- package/src/components/layout/List.vue +159 -0
- package/src/components/layout/Main.vue +187 -0
- package/src/components/layout/Menu.jsx +96 -0
- package/src/components/layout/NavTabs.vue +192 -0
- package/src/components/layout/Show.vue +157 -0
- package/src/components/layout/index.ts +19 -0
- package/src/components/menu/Menu.jsx +94 -0
- package/src/components/menu/style/index.scss +18 -0
- package/src/components/select/Select.vue +85 -0
- package/src/components/table/Field.vue +49 -0
- package/src/components/table/Table.vue +391 -0
- package/src/components/table/index.md +1 -0
- package/src/components/table/index.ts +5 -0
- package/src/components/theme/index.ts +1 -0
- package/src/components/theme/theme.scss +1 -0
- package/src/components/theme/variable.scss +21 -0
- package/src/hooks/http/index.ts +107 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/route/index.ts +84 -0
- package/src/store/index.ts +7 -0
- package/src/store/modules/Breadcrumb.ts +25 -0
- package/src/store/modules/DataDictionary.ts +49 -0
- package/src/store/modules/KeepAlive.ts +47 -0
- package/src/store/modules/Menu.ts +24 -0
- package/src/store/modules/NavTab.ts +81 -0
- package/src/store/modules/Settings.ts +120 -0
- package/src/store/modules/User.ts +23 -0
- package/src/store/types.ts +15 -0
- package/src/tsconfig.json +16 -0
- package/src/utils/get.ts +15 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/install.ts +12 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* 表单组件
|
|
4
|
+
*/
|
|
5
|
+
import { computed, ref, Ref, watch, inject } from "vue";
|
|
6
|
+
|
|
7
|
+
import Field from "./Field.vue";
|
|
8
|
+
|
|
9
|
+
type Key = string | number;
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
bordered?: boolean;
|
|
13
|
+
keys?: Ref<Key[]>;
|
|
14
|
+
columns: any; //表格配置
|
|
15
|
+
data: any; //数据源
|
|
16
|
+
rowKey?: string; //主键id
|
|
17
|
+
loading?: false; //加载状态
|
|
18
|
+
height: number; //表格高度
|
|
19
|
+
pagination?: any; //分页
|
|
20
|
+
selection?: "N" | "S" | "M"; // 无选择/单选/多选
|
|
21
|
+
config?: any; // 配置
|
|
22
|
+
keepSelected?: boolean; //切换页码保留选中的数据
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
26
|
+
bordered: false,
|
|
27
|
+
keys: undefined,
|
|
28
|
+
columns: [],
|
|
29
|
+
data: [],
|
|
30
|
+
rowKey: "id",
|
|
31
|
+
loading: false,
|
|
32
|
+
height: 0,
|
|
33
|
+
pagination: false,
|
|
34
|
+
selection: "N",
|
|
35
|
+
config: {},
|
|
36
|
+
keepSelected: false
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
interface Emits {
|
|
40
|
+
/**
|
|
41
|
+
* 更新选择的id
|
|
42
|
+
* @param e
|
|
43
|
+
* @param rowKeys
|
|
44
|
+
*/
|
|
45
|
+
(e: "update:keys", rowKeys: Ref<Key[]>): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const emits = defineEmits<Emits>();
|
|
49
|
+
//antdv配置组件注入的变量
|
|
50
|
+
const configProvider = inject("configProvider") as any;
|
|
51
|
+
|
|
52
|
+
//表格对象
|
|
53
|
+
const tableRef = ref();
|
|
54
|
+
const tableHeight = ref(0);
|
|
55
|
+
const selectedRowKeys = ref<any>(props.keys);
|
|
56
|
+
//表体对象
|
|
57
|
+
const antTableBody = ref();
|
|
58
|
+
//分页配置 监听查询页码页数变化
|
|
59
|
+
const paginationState = computed(() => props.pagination);
|
|
60
|
+
|
|
61
|
+
//分页默认配置
|
|
62
|
+
const paginationConfig = {
|
|
63
|
+
defaultPageSize: 20,
|
|
64
|
+
hideOnSinglePage: false,
|
|
65
|
+
pageSizeOptions: ["10", "20", "30", "40"],
|
|
66
|
+
responsive: true,
|
|
67
|
+
showQuickJumper: true,
|
|
68
|
+
showLessItems: true,
|
|
69
|
+
showTotal: (total: number) => {
|
|
70
|
+
return `总共 ${total} 条`;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//分页
|
|
75
|
+
const { onPageChange } = usePaging();
|
|
76
|
+
function usePaging() {
|
|
77
|
+
const {
|
|
78
|
+
keepSelected,
|
|
79
|
+
selection,
|
|
80
|
+
config: { pagingChange }
|
|
81
|
+
} = props;
|
|
82
|
+
|
|
83
|
+
//监听页码切换
|
|
84
|
+
const onPageChange = (page: number, size: number) => {
|
|
85
|
+
if (selection === "S" || !keepSelected) {
|
|
86
|
+
// 如果当前为单选或未开启分页保留数据选中的数据都会被清除
|
|
87
|
+
// 清空历史选中数据
|
|
88
|
+
selectedRowKeys.value = [];
|
|
89
|
+
emits("update:keys", selectedRowKeys.value);
|
|
90
|
+
}
|
|
91
|
+
pagingChange({ page: page, size: size });
|
|
92
|
+
// 切换分页的时候,表体滚动到顶部
|
|
93
|
+
antTableBody.value.scrollTop = 0;
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
onPageChange
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//表格
|
|
101
|
+
const { customRow, rowSelection } = useTable();
|
|
102
|
+
|
|
103
|
+
function useTable() {
|
|
104
|
+
// 表格行事件
|
|
105
|
+
const customRow = useCustomRow();
|
|
106
|
+
// 表格选项
|
|
107
|
+
const rowSelection = useRowSelection();
|
|
108
|
+
return {
|
|
109
|
+
customRow,
|
|
110
|
+
rowSelection
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//表格行配置
|
|
115
|
+
function useCustomRow() {
|
|
116
|
+
const { rowKey } = props;
|
|
117
|
+
|
|
118
|
+
return (record: { [x: string]: any }) => {
|
|
119
|
+
//当前数据的唯一id
|
|
120
|
+
const id = record[rowKey];
|
|
121
|
+
const { $OnClick, $OnDblclick } = useSelection(id);
|
|
122
|
+
try {
|
|
123
|
+
if (!rowKey) {
|
|
124
|
+
console.warn("未指定rowKey");
|
|
125
|
+
}
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 单击
|
|
132
|
+
*/
|
|
133
|
+
const onClick = () => {
|
|
134
|
+
$OnClick(record);
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* 双击
|
|
138
|
+
*/
|
|
139
|
+
const onDblclick = () => {
|
|
140
|
+
$OnDblclick(record);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
onClick,
|
|
145
|
+
onDblclick
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//表格选中配置
|
|
151
|
+
function useRowSelection() {
|
|
152
|
+
const {
|
|
153
|
+
selection,
|
|
154
|
+
rowKey,
|
|
155
|
+
config: { disabledData }
|
|
156
|
+
} = props;
|
|
157
|
+
if (selection === "N") return undefined;
|
|
158
|
+
const onSelect = (record: any, selected: any) => {
|
|
159
|
+
if (selection === "S") {
|
|
160
|
+
selectedRowKeys.value = [];
|
|
161
|
+
selectedRowKeys.value = selected ? [record[rowKey]] : [];
|
|
162
|
+
} else {
|
|
163
|
+
selectedRowKeys.value = selected
|
|
164
|
+
? selectedRowKeys.value.concat(record[rowKey])
|
|
165
|
+
: selectedRowKeys.value.filter((key: Key) => key !== record[rowKey]);
|
|
166
|
+
}
|
|
167
|
+
emits("update:keys", selectedRowKeys.value);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const onSelectAll = (selected: any, selectedRows: any, changeRows: any) => {
|
|
171
|
+
const _ids = changeRows.map((record: any) => record[rowKey]);
|
|
172
|
+
selectedRowKeys.value = selected
|
|
173
|
+
? selectedRowKeys.value.concat(_ids)
|
|
174
|
+
: selectedRowKeys.value.filter((key: Key) => !_ids.includes(key));
|
|
175
|
+
|
|
176
|
+
emits("update:keys", selectedRowKeys.value);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
selectedRowKeys,
|
|
181
|
+
onSelect,
|
|
182
|
+
onSelectAll,
|
|
183
|
+
fixed: true,
|
|
184
|
+
columnTitle: selection === "S" ? "选择" : null,
|
|
185
|
+
columnWidth: selection === "S" ? 60 : 40,
|
|
186
|
+
getCheckboxProps: (record: any) => {
|
|
187
|
+
return {
|
|
188
|
+
disabled: disabledData?.value?.includes(record[disabledData?.key]),
|
|
189
|
+
name: disabledData?.key
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//单击事件处理
|
|
196
|
+
function useSelection(id: Key) {
|
|
197
|
+
const {
|
|
198
|
+
selection,
|
|
199
|
+
config: {
|
|
200
|
+
click,
|
|
201
|
+
dbClick,
|
|
202
|
+
// value 为禁用的数据值
|
|
203
|
+
// key 为匹配那个属性
|
|
204
|
+
// { value:[], key:string }
|
|
205
|
+
disabledData
|
|
206
|
+
}
|
|
207
|
+
} = props;
|
|
208
|
+
let timeoutID: any = null;
|
|
209
|
+
/**
|
|
210
|
+
* 单击
|
|
211
|
+
*/
|
|
212
|
+
const $OnClick = (record: any) => {
|
|
213
|
+
clearTimeout(timeoutID);
|
|
214
|
+
timeoutID = setTimeout(() => {
|
|
215
|
+
click ? click(record) : undefined;
|
|
216
|
+
if (
|
|
217
|
+
selection === "N" ||
|
|
218
|
+
disabledData?.value?.includes(record[disabledData?.key])
|
|
219
|
+
) {
|
|
220
|
+
// 1.未开启复选框 则不处理数据选中操作
|
|
221
|
+
// 2. 如果当前点击的行 包含在禁用的数据项目里面 则不进行选中操作
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const haveState = selectedRowKeys.value.some((key: Key) => key === id);
|
|
225
|
+
if (haveState) {
|
|
226
|
+
//如果 当前点击行的ID 已存在 那么直接过滤掉当前的id
|
|
227
|
+
selectedRowKeys.value = selectedRowKeys.value.filter(
|
|
228
|
+
(key: Key) => key !== id
|
|
229
|
+
);
|
|
230
|
+
} else {
|
|
231
|
+
if (selection === "S") {
|
|
232
|
+
//单选的时候 清空选中的数据 再赋值新的ID
|
|
233
|
+
selectedRowKeys.value = [];
|
|
234
|
+
selectedRowKeys.value.push(id);
|
|
235
|
+
} else {
|
|
236
|
+
//多选直接追加ID
|
|
237
|
+
selectedRowKeys.value.push(id);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
emits("update:keys", selectedRowKeys.value);
|
|
241
|
+
}, 200);
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* 双击
|
|
245
|
+
*/
|
|
246
|
+
const $OnDblclick = (record: any) => {
|
|
247
|
+
clearTimeout(timeoutID);
|
|
248
|
+
dbClick ? dbClick(record) : null;
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
$OnClick,
|
|
252
|
+
$OnDblclick
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 监听父容器计算出来的表格高度
|
|
257
|
+
watch(
|
|
258
|
+
() => props.height,
|
|
259
|
+
(val) => {
|
|
260
|
+
if (val !== 0) {
|
|
261
|
+
setTimeout(() => {
|
|
262
|
+
initTable();
|
|
263
|
+
}, 100);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 监听loading加载状态
|
|
270
|
+
*
|
|
271
|
+
*/
|
|
272
|
+
watch(
|
|
273
|
+
() => props.loading,
|
|
274
|
+
(val) => {
|
|
275
|
+
if (val && props.selection === "S") {
|
|
276
|
+
//临时解决方案 单选的时候 重新请求数据,清空已选中的数据
|
|
277
|
+
selectedRowKeys.value = [];
|
|
278
|
+
emits("update:keys", selectedRowKeys.value);
|
|
279
|
+
}
|
|
280
|
+
if (val && props.selection === "M" && !props.keepSelected) {
|
|
281
|
+
// 临时解决方案 多选的时候未开启分页保存选中的数据;重新请求清空已选中的数据
|
|
282
|
+
selectedRowKeys.value = [];
|
|
283
|
+
emits("update:keys", selectedRowKeys.value);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
if (props.height > 0) {
|
|
289
|
+
setTimeout(() => {
|
|
290
|
+
initTable();
|
|
291
|
+
}, 100);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function initTable() {
|
|
295
|
+
const { height } = props;
|
|
296
|
+
const rootElement = tableRef.value.$el;
|
|
297
|
+
const headerHeight = useEleHeight(
|
|
298
|
+
rootElement.getElementsByClassName("ant-table-header")[0]
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
let paginationHeight = 0;
|
|
302
|
+
if (props.pagination) {
|
|
303
|
+
paginationHeight = useEleHeight(
|
|
304
|
+
document.getElementsByClassName("xi-pagination")[0]
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
//56 为分页高度
|
|
308
|
+
tableHeight.value = height - (headerHeight + paginationHeight);
|
|
309
|
+
|
|
310
|
+
rootElement.getElementsByClassName("ant-table-body")[0].style.height =
|
|
311
|
+
tableHeight.value - 10 + "px";
|
|
312
|
+
|
|
313
|
+
antTableBody.value = rootElement.getElementsByClassName("ant-table-body")[0];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function useEleHeight(node: Element) {
|
|
317
|
+
const list = [
|
|
318
|
+
"margin-top",
|
|
319
|
+
"margin-bottom",
|
|
320
|
+
"border-top",
|
|
321
|
+
"border-bottom",
|
|
322
|
+
"padding-top",
|
|
323
|
+
"padding-bottom",
|
|
324
|
+
"height"
|
|
325
|
+
];
|
|
326
|
+
const style = getComputedStyle(node);
|
|
327
|
+
return list
|
|
328
|
+
.map((k) => parseInt(style.getPropertyValue(k), 10))
|
|
329
|
+
.reduce((prev, cur) => prev + cur);
|
|
330
|
+
}
|
|
331
|
+
</script>
|
|
332
|
+
<script lang="ts">
|
|
333
|
+
export default {
|
|
334
|
+
name: "DTable"
|
|
335
|
+
};
|
|
336
|
+
</script>
|
|
337
|
+
<template>
|
|
338
|
+
<a-table
|
|
339
|
+
ref="tableRef"
|
|
340
|
+
:bordered="bordered"
|
|
341
|
+
:columns="columns"
|
|
342
|
+
:data-source="data"
|
|
343
|
+
:row-key="rowKey"
|
|
344
|
+
:pagination="false"
|
|
345
|
+
:custom-row="customRow"
|
|
346
|
+
:loading="loading"
|
|
347
|
+
:row-selection="rowSelection"
|
|
348
|
+
:scroll="{
|
|
349
|
+
scrollToFirstRowOnChange: true,
|
|
350
|
+
x: '100%',
|
|
351
|
+
y: tableHeight + 'px'
|
|
352
|
+
}"
|
|
353
|
+
>
|
|
354
|
+
<template #bodyCell="{ column, text, record, index }">
|
|
355
|
+
<template v-if="column.config">
|
|
356
|
+
<Field :text="text" :config="column.config" />
|
|
357
|
+
</template>
|
|
358
|
+
<!--操作-->
|
|
359
|
+
<template v-if="column.slot === 'action'">
|
|
360
|
+
<a-space @click.stop @dblclick.stop>
|
|
361
|
+
<slot name="action" :index="index" :record="record"></slot>
|
|
362
|
+
</a-space>
|
|
363
|
+
</template>
|
|
364
|
+
<!--操作-->
|
|
365
|
+
<template v-if="column.slot && column.slot !== 'action'">
|
|
366
|
+
<slot :name="column.slot" :index="index" :record="record"></slot>
|
|
367
|
+
</template>
|
|
368
|
+
</template>
|
|
369
|
+
</a-table>
|
|
370
|
+
<a-pagination
|
|
371
|
+
v-show="pagination"
|
|
372
|
+
v-model:current="paginationState.current"
|
|
373
|
+
v-model:pageSize="paginationState.pageSize"
|
|
374
|
+
class="xi-pagination"
|
|
375
|
+
:disabled="loading"
|
|
376
|
+
show-size-changer
|
|
377
|
+
:hide-on-single-page="paginationConfig.hideOnSinglePage"
|
|
378
|
+
:show-quick-jumper="paginationConfig.showQuickJumper"
|
|
379
|
+
:default-page-size="paginationConfig.defaultPageSize"
|
|
380
|
+
:page-size-options="paginationConfig.pageSizeOptions"
|
|
381
|
+
:show-total="paginationConfig.showTotal"
|
|
382
|
+
:total="paginationState.total"
|
|
383
|
+
@change="onPageChange"
|
|
384
|
+
/>
|
|
385
|
+
</template>
|
|
386
|
+
<style>
|
|
387
|
+
.xi-pagination {
|
|
388
|
+
margin-top: 24px;
|
|
389
|
+
text-align: center;
|
|
390
|
+
}
|
|
391
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# XI-Table 表格
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const prefixName = "ditari-bsui";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "./variable";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// class 前缀
|
|
2
|
+
$prefix-name: ditari-bsui;
|
|
3
|
+
// 页面背景颜色
|
|
4
|
+
$bg-color: #f0f2f5;
|
|
5
|
+
//左侧logo高度
|
|
6
|
+
$logo-height: 240px !default;
|
|
7
|
+
/******======网格变量======******/
|
|
8
|
+
//网格边框颜色
|
|
9
|
+
$grid-border-color: #4e4e4e;
|
|
10
|
+
// 网格里面输入框获取焦点时的边框颜色
|
|
11
|
+
$grid-input-focus-border-color: #1890ff;
|
|
12
|
+
//输入框校验不通过时候的颜色
|
|
13
|
+
$grid-input-error-border-color: #ff4d4f;
|
|
14
|
+
// 网格输入框边框宽度
|
|
15
|
+
$grid-input-border-width: 2px;
|
|
16
|
+
// 网格边框宽度
|
|
17
|
+
$gird-border-width: 1px;
|
|
18
|
+
|
|
19
|
+
// 左侧菜单
|
|
20
|
+
$top-header-height: 84px;
|
|
21
|
+
$logo-height: 40px !default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { computed, Ref, ref } from "vue";
|
|
2
|
+
import { usePagination } from "vue-request";
|
|
3
|
+
import { get } from "../../utils";
|
|
4
|
+
|
|
5
|
+
interface Pagination {
|
|
6
|
+
// 当前分页的key
|
|
7
|
+
currentKey: string;
|
|
8
|
+
// 每页条数的key
|
|
9
|
+
pageSizeKey: string;
|
|
10
|
+
// 总条数的key
|
|
11
|
+
totalKey: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Options {
|
|
15
|
+
//请求参数
|
|
16
|
+
params?: Ref;
|
|
17
|
+
pagination?: Pagination;
|
|
18
|
+
// 读取数据的key
|
|
19
|
+
dataKey?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 请求分页数据列表
|
|
24
|
+
* @param service 请求后台服务的接口
|
|
25
|
+
* @param options 配置
|
|
26
|
+
*/
|
|
27
|
+
const useRequestList = (service: any, options: Options = {}) => {
|
|
28
|
+
if (!options.pagination) {
|
|
29
|
+
options.pagination = {
|
|
30
|
+
currentKey: "page",
|
|
31
|
+
pageSizeKey: "limit",
|
|
32
|
+
totalKey: "data.total"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
dataKey,
|
|
38
|
+
pagination: { currentKey, pageSizeKey }
|
|
39
|
+
} = options;
|
|
40
|
+
|
|
41
|
+
const params = options.params || ref({});
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
total,
|
|
45
|
+
pageSize,
|
|
46
|
+
current,
|
|
47
|
+
loading,
|
|
48
|
+
data: listData,
|
|
49
|
+
run
|
|
50
|
+
} = usePagination(service, {
|
|
51
|
+
manual: true,
|
|
52
|
+
pagination: options.pagination,
|
|
53
|
+
loadingDelay: 400,
|
|
54
|
+
loadingKeep: 100,
|
|
55
|
+
onSuccess: () => {},
|
|
56
|
+
onError: (error: Error, params: any) => {
|
|
57
|
+
//错误处理
|
|
58
|
+
console.log(params, error);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 分页组件属性
|
|
64
|
+
*/
|
|
65
|
+
const pagination = computed(() => ({
|
|
66
|
+
total: total.value,
|
|
67
|
+
current: current.value,
|
|
68
|
+
pageSize: pageSize.value
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 列表查询数据
|
|
73
|
+
*/
|
|
74
|
+
const data = computed<any>(() =>
|
|
75
|
+
get((listData as any).value, dataKey || "data", [])
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* page和size改变时触发事件
|
|
80
|
+
* @param paging 页码对象
|
|
81
|
+
*/
|
|
82
|
+
const onPaginationChange = (paging: any) => {
|
|
83
|
+
params.value[currentKey] = paging.page;
|
|
84
|
+
params.value[pageSizeKey] = paging.size;
|
|
85
|
+
run(params.value || {});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 查询事件
|
|
90
|
+
*/
|
|
91
|
+
const onQuery = (p: any) => {
|
|
92
|
+
params.value = { ...params.value, ...p };
|
|
93
|
+
params.value[currentKey] = 1;
|
|
94
|
+
run(params.value || {});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
data,
|
|
99
|
+
pagination,
|
|
100
|
+
loading,
|
|
101
|
+
run,
|
|
102
|
+
onPaginationChange,
|
|
103
|
+
onQuery
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { useRequestList };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import {
|
|
3
|
+
createRouterMatcher,
|
|
4
|
+
RouteLocationMatched,
|
|
5
|
+
RouteLocationNormalized,
|
|
6
|
+
RouteRecord,
|
|
7
|
+
RouteRecordRaw,
|
|
8
|
+
RouterMatcher
|
|
9
|
+
} from "vue-router";
|
|
10
|
+
import { useBreadcrumbStore } from "../../store/modules/Breadcrumb";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 路由管理
|
|
14
|
+
* @param routes 未打平的路由
|
|
15
|
+
*/
|
|
16
|
+
export const useDitariRoute = (routes: RouteRecordRaw[]) => {
|
|
17
|
+
const { saveBreadcrumb } = useBreadcrumbStore();
|
|
18
|
+
// 路由匹配器
|
|
19
|
+
const routerMatcher = ref<RouterMatcher | null>(null);
|
|
20
|
+
// 匹配到的路由数据
|
|
21
|
+
const matched = ref<RouteLocationMatched[]>([]);
|
|
22
|
+
//创建匹配器
|
|
23
|
+
routerMatcher.value = createRouterMatcher(routes, {});
|
|
24
|
+
// 保存打平后的路由
|
|
25
|
+
const flatRoutes = flattenRoutes(routes, null);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 进行匹配
|
|
29
|
+
* @param to
|
|
30
|
+
* @param from
|
|
31
|
+
*/
|
|
32
|
+
const setMatched = (
|
|
33
|
+
to: RouteLocationNormalized,
|
|
34
|
+
from: RouteLocationNormalized
|
|
35
|
+
) => {
|
|
36
|
+
try {
|
|
37
|
+
const rs = routerMatcher.value?.resolve(to, from).matched ?? [];
|
|
38
|
+
matched.value = rs.reduce((preValue: any[], curValue) => {
|
|
39
|
+
const flag = preValue.some(
|
|
40
|
+
(item: RouteRecord) => item.path === curValue.path
|
|
41
|
+
);
|
|
42
|
+
if (!flag) {
|
|
43
|
+
preValue.push({
|
|
44
|
+
path: curValue.path,
|
|
45
|
+
title: curValue.meta?.title ?? "未设置标题"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return preValue;
|
|
49
|
+
}, []);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.log(e);
|
|
52
|
+
matched.value = [];
|
|
53
|
+
}
|
|
54
|
+
// 匹配到的数据保存到route store
|
|
55
|
+
saveBreadcrumb(matched.value);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
flatRoutes,
|
|
60
|
+
setMatched
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function flattenRoutes(
|
|
65
|
+
routes: RouteRecordRaw[],
|
|
66
|
+
parentRoute: RouteRecordRaw | null
|
|
67
|
+
) {
|
|
68
|
+
return routes.reduce((acc: any[], route) => {
|
|
69
|
+
if (route.children) {
|
|
70
|
+
acc.push(...flattenRoutes(route.children, route));
|
|
71
|
+
}
|
|
72
|
+
// 只有有组件的route才加入数组
|
|
73
|
+
if (route.component) {
|
|
74
|
+
// 路径 如果当前路径为空,则说明是父组件重定向的地址 则追加为""空字符串
|
|
75
|
+
const path =
|
|
76
|
+
`${parentRoute?.path}` + (route.path ? "/" + route.path : "");
|
|
77
|
+
acc.push({
|
|
78
|
+
...route,
|
|
79
|
+
path: path
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return acc;
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { useBreadcrumbStore } from "./modules/Breadcrumb";
|
|
2
|
+
export { useDataDicStore } from "./modules/DataDictionary";
|
|
3
|
+
export { useKeepAliveStore } from "./modules/KeepAlive";
|
|
4
|
+
export { useMenuStore } from "./modules/Menu";
|
|
5
|
+
export { useNavTabsStore } from "./modules/NavTab";
|
|
6
|
+
export { useSettingsStore } from "./modules/Settings";
|
|
7
|
+
export { useUserStore } from "./modules/User";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 面包屑
|
|
3
|
+
* @author 余春林
|
|
4
|
+
*/
|
|
5
|
+
import { defineStore } from "pinia";
|
|
6
|
+
import { BREADCRUMB_ID } from "../types";
|
|
7
|
+
|
|
8
|
+
export interface State {
|
|
9
|
+
breadcrumbs: [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useBreadcrumbStore = defineStore(BREADCRUMB_ID, {
|
|
13
|
+
state: (): State => ({
|
|
14
|
+
breadcrumbs: []
|
|
15
|
+
}),
|
|
16
|
+
getters: {
|
|
17
|
+
getBreadcrumb: (state) => state.breadcrumbs
|
|
18
|
+
},
|
|
19
|
+
actions: {
|
|
20
|
+
saveBreadcrumb(data: any) {
|
|
21
|
+
this.breadcrumbs = data;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
persist: true
|
|
25
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { DATA_DICTIONARY_ID } from "../types";
|
|
3
|
+
|
|
4
|
+
interface State {
|
|
5
|
+
someState: string;
|
|
6
|
+
list: any;
|
|
7
|
+
}
|
|
8
|
+
const useDataDicStore = defineStore(DATA_DICTIONARY_ID, {
|
|
9
|
+
state: (): State => ({
|
|
10
|
+
someState: "你好 pinia",
|
|
11
|
+
list: {}
|
|
12
|
+
}),
|
|
13
|
+
getters: {
|
|
14
|
+
/**
|
|
15
|
+
* 根据key获取字典列表
|
|
16
|
+
* @param state
|
|
17
|
+
*/
|
|
18
|
+
getDicByKey: (state) => {
|
|
19
|
+
return (key: string) => {
|
|
20
|
+
return state.list[key] || [];
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* 根据字典名称和字典的value 获取对应的中文
|
|
25
|
+
* @param state
|
|
26
|
+
*/
|
|
27
|
+
getDicTextByValue: (state) => {
|
|
28
|
+
return (key: string, value: string) => {
|
|
29
|
+
const rs = state.list[key] || [];
|
|
30
|
+
return rs
|
|
31
|
+
.filter((item: any) => item.value === value)
|
|
32
|
+
.map((item: any) => item.label)
|
|
33
|
+
.join("");
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
actions: {
|
|
38
|
+
/**
|
|
39
|
+
* 保存字典数据
|
|
40
|
+
* @param data 字典数据
|
|
41
|
+
*/
|
|
42
|
+
save(data: any) {
|
|
43
|
+
this.list = data;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
persist: true
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export { useDataDicStore };
|