befly-admin-ui 1.10.8 → 1.10.10
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/components/detailPanel.vue +3 -2
- package/components/pageDialog.vue +14 -15
- package/components/pageTableDetail.vue +20 -18
- package/layouts/default.vue +17 -17
- package/package.json +2 -2
- package/utils/arrayToTree.js +14 -13
- package/views/config/dict/components/edit.vue +6 -6
- package/views/config/dict/index.vue +13 -12
- package/views/config/dictType/components/edit.vue +6 -6
- package/views/config/dictType/index.vue +10 -9
- package/views/config/system/components/edit.vue +7 -7
- package/views/config/system/index.vue +10 -9
- package/views/index/components/addonList.vue +4 -3
- package/views/index/components/environmentInfo.vue +3 -2
- package/views/index/components/operationLogs.vue +3 -3
- package/views/index/components/performanceMetrics.vue +3 -2
- package/views/index/components/quickActions.vue +1 -1
- package/views/index/components/serviceStatus.vue +4 -3
- package/views/index/components/systemNotifications.vue +3 -3
- package/views/index/components/systemOverview.vue +17 -17
- package/views/index/components/systemResources.vue +3 -2
- package/views/index/components/userInfo.vue +6 -5
- package/views/index/index.vue +3 -3
- package/views/log/email/index.vue +12 -11
- package/views/log/error/index.vue +12 -12
- package/views/log/login/index.vue +3 -3
- package/views/log/operate/index.vue +5 -5
- package/views/login_1/index.vue +6 -5
- package/views/people/admin/components/edit.vue +12 -12
- package/views/people/admin/index.vue +9 -8
- package/views/permission/api/index.vue +9 -8
- package/views/permission/menu/index.vue +7 -6
- package/views/permission/role/components/api.vue +8 -8
- package/views/permission/role/components/edit.vue +8 -8
- package/views/permission/role/components/menu.vue +9 -9
- package/views/permission/role/index.vue +11 -10
- package/views/resource/gallery/index.vue +10 -10
|
@@ -31,8 +31,9 @@
|
|
|
31
31
|
</template>
|
|
32
32
|
|
|
33
33
|
<script setup>
|
|
34
|
-
import { computed, reactive } from "vue";
|
|
35
34
|
import { Tag as TTag } from "tdesign-vue-next";
|
|
35
|
+
import { computed, reactive } from "vue";
|
|
36
|
+
|
|
36
37
|
import { formatFieldValue } from "../utils/formatFieldValue.js";
|
|
37
38
|
|
|
38
39
|
const $Prop = defineProps({
|
|
@@ -68,7 +69,7 @@ const $Prop = defineProps({
|
|
|
68
69
|
});
|
|
69
70
|
|
|
70
71
|
const $Method = {
|
|
71
|
-
buildNormalizedFields() {
|
|
72
|
+
buildNormalizedFields: function () {
|
|
72
73
|
const row = $Prop.data && typeof $Prop.data === "object" ? $Prop.data : null;
|
|
73
74
|
const dataId = row && Object.hasOwn(row, "id") ? row.id : undefined;
|
|
74
75
|
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<script setup>
|
|
31
|
-
import { onBeforeUnmount, onMounted, reactive, watch } from "vue";
|
|
32
|
-
|
|
33
31
|
import { Button as TButton, Dialog as TDialog } from "tdesign-vue-next";
|
|
32
|
+
import { onBeforeUnmount, onMounted, reactive, watch } from "vue";
|
|
34
33
|
|
|
35
34
|
defineOptions({
|
|
36
35
|
inheritAttrs: false
|
|
@@ -80,16 +79,16 @@ const $Data = reactive({
|
|
|
80
79
|
});
|
|
81
80
|
|
|
82
81
|
const $Method = {
|
|
83
|
-
clearTimer(timer) {
|
|
82
|
+
clearTimer: function (timer) {
|
|
84
83
|
if (timer) {
|
|
85
84
|
clearTimeout(timer);
|
|
86
85
|
}
|
|
87
86
|
return null;
|
|
88
87
|
},
|
|
89
|
-
open() {
|
|
88
|
+
open: function () {
|
|
90
89
|
$Emit("update:modelValue", true);
|
|
91
90
|
},
|
|
92
|
-
close() {
|
|
91
|
+
close: function () {
|
|
93
92
|
$From.openDelayTimer = $Method.clearTimer($From.openDelayTimer);
|
|
94
93
|
$From.closeDelayTimer = $Method.clearTimer($From.closeDelayTimer);
|
|
95
94
|
|
|
@@ -100,14 +99,14 @@ const $Method = {
|
|
|
100
99
|
$From.closeDelayTimer = null;
|
|
101
100
|
}, $Const.closeDelay);
|
|
102
101
|
},
|
|
103
|
-
toggle() {
|
|
102
|
+
toggle: function () {
|
|
104
103
|
if ($Data.innerVisible) {
|
|
105
104
|
$Method.close();
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
108
107
|
$Method.open();
|
|
109
108
|
},
|
|
110
|
-
createEventContext(trigger) {
|
|
109
|
+
createEventContext: function (trigger) {
|
|
111
110
|
return {
|
|
112
111
|
trigger: trigger,
|
|
113
112
|
visible: $Data.innerVisible,
|
|
@@ -117,7 +116,7 @@ const $Method = {
|
|
|
117
116
|
getVisible: () => $Data.innerVisible
|
|
118
117
|
};
|
|
119
118
|
},
|
|
120
|
-
applyModelValue(value) {
|
|
119
|
+
applyModelValue: function (value) {
|
|
121
120
|
if (value) {
|
|
122
121
|
// 关键点:先渲染为 false,再延迟 true,保证 v-if + 初次 visible=true 时也能触发进入动画
|
|
123
122
|
$From.openDelayTimer = $Method.clearTimer($From.openDelayTimer);
|
|
@@ -132,7 +131,7 @@ const $Method = {
|
|
|
132
131
|
$From.openDelayTimer = $Method.clearTimer($From.openDelayTimer);
|
|
133
132
|
$Data.innerVisible = false;
|
|
134
133
|
},
|
|
135
|
-
closeByTrigger(trigger) {
|
|
134
|
+
closeByTrigger: function (trigger) {
|
|
136
135
|
// 固定交互:confirm 不自动关闭(等待异步提交成功后由调用侧 context.close() 决定关闭)
|
|
137
136
|
if (trigger === "confirm") {
|
|
138
137
|
return;
|
|
@@ -140,32 +139,32 @@ const $Method = {
|
|
|
140
139
|
// cancel/close 自动关闭
|
|
141
140
|
$Method.close();
|
|
142
141
|
},
|
|
143
|
-
onDialogClose() {
|
|
142
|
+
onDialogClose: function () {
|
|
144
143
|
const context = $Method.createEventContext("close");
|
|
145
144
|
$Method.closeByTrigger("close");
|
|
146
145
|
$Emit("close", context);
|
|
147
146
|
},
|
|
148
|
-
onDialogConfirm() {
|
|
147
|
+
onDialogConfirm: function () {
|
|
149
148
|
const context = $Method.createEventContext("confirm");
|
|
150
149
|
$Emit("confirm", context);
|
|
151
150
|
$Method.closeByTrigger("confirm");
|
|
152
151
|
},
|
|
153
|
-
onDialogCancel() {
|
|
152
|
+
onDialogCancel: function () {
|
|
154
153
|
const context = $Method.createEventContext("cancel");
|
|
155
154
|
$Emit("cancel", context);
|
|
156
155
|
$Method.closeByTrigger("cancel");
|
|
157
156
|
},
|
|
158
|
-
onFooterConfirm() {
|
|
157
|
+
onFooterConfirm: function () {
|
|
159
158
|
const context = $Method.createEventContext("confirm");
|
|
160
159
|
$Emit("confirm", context);
|
|
161
160
|
$Method.closeByTrigger("confirm");
|
|
162
161
|
},
|
|
163
|
-
onFooterClose() {
|
|
162
|
+
onFooterClose: function () {
|
|
164
163
|
const context = $Method.createEventContext("cancel");
|
|
165
164
|
$Emit("cancel", context);
|
|
166
165
|
$Method.closeByTrigger("cancel");
|
|
167
166
|
},
|
|
168
|
-
getVisible() {
|
|
167
|
+
getVisible: function () {
|
|
169
168
|
return $Data.innerVisible;
|
|
170
169
|
}
|
|
171
170
|
};
|
|
@@ -41,11 +41,13 @@
|
|
|
41
41
|
</template>
|
|
42
42
|
|
|
43
43
|
<script setup>
|
|
44
|
-
import { computed, onMounted, reactive, useSlots } from "vue";
|
|
45
44
|
import { DialogPlugin, MessagePlugin, Pagination as TPagination, Table as TTable } from "tdesign-vue-next";
|
|
46
|
-
import
|
|
45
|
+
import { computed, onMounted, reactive, useSlots } from "vue";
|
|
46
|
+
|
|
47
47
|
import { $Http } from "@/plugins/http.js";
|
|
48
|
+
|
|
48
49
|
import { formatFieldValue } from "../utils/formatFieldValue.js";
|
|
50
|
+
import DetailPanel from "./detailPanel.vue";
|
|
49
51
|
|
|
50
52
|
const $Prop = defineProps({
|
|
51
53
|
columns: {
|
|
@@ -110,14 +112,14 @@ const $Data = reactive({
|
|
|
110
112
|
});
|
|
111
113
|
|
|
112
114
|
const $Method = {
|
|
113
|
-
getColKey(col) {
|
|
115
|
+
getColKey: function (col) {
|
|
114
116
|
const record = col;
|
|
115
117
|
const rawColKey = record["colKey"];
|
|
116
118
|
if (typeof rawColKey === "string") return rawColKey;
|
|
117
119
|
if (typeof rawColKey === "number") return String(rawColKey);
|
|
118
120
|
return "";
|
|
119
121
|
},
|
|
120
|
-
filterValidColumns(input) {
|
|
122
|
+
filterValidColumns: function (input) {
|
|
121
123
|
if (!Array.isArray(input)) {
|
|
122
124
|
return [];
|
|
123
125
|
}
|
|
@@ -137,7 +139,7 @@ const $Method = {
|
|
|
137
139
|
|
|
138
140
|
return out;
|
|
139
141
|
},
|
|
140
|
-
mergeDetailColumns(mainColumns, extraColumns) {
|
|
142
|
+
mergeDetailColumns: function (mainColumns, extraColumns) {
|
|
141
143
|
const out = [];
|
|
142
144
|
const set = new Set();
|
|
143
145
|
|
|
@@ -162,17 +164,17 @@ const $Method = {
|
|
|
162
164
|
|
|
163
165
|
return out;
|
|
164
166
|
},
|
|
165
|
-
formatTableCell(row, colKey) {
|
|
167
|
+
formatTableCell: function (row, colKey) {
|
|
166
168
|
const record = row && typeof row === "object" ? row : {};
|
|
167
169
|
const value = record[colKey];
|
|
168
170
|
const field = $Computed.columnsMeta.tableColumnMap[colKey] || {};
|
|
169
171
|
return formatFieldValue(value, field);
|
|
170
172
|
},
|
|
171
|
-
setCurrentRow(row) {
|
|
173
|
+
setCurrentRow: function (row) {
|
|
172
174
|
$Data.currentRow = row;
|
|
173
175
|
$Emit("row-change", { row: row });
|
|
174
176
|
},
|
|
175
|
-
getRowKeyValue(row) {
|
|
177
|
+
getRowKeyValue: function (row) {
|
|
176
178
|
const key = $Prop.rowKey;
|
|
177
179
|
if (!key) return null;
|
|
178
180
|
|
|
@@ -182,7 +184,7 @@ const $Method = {
|
|
|
182
184
|
if (typeof raw === "number") return raw;
|
|
183
185
|
return null;
|
|
184
186
|
},
|
|
185
|
-
applyAutoSelection(list, preferKey) {
|
|
187
|
+
applyAutoSelection: function (list, preferKey) {
|
|
186
188
|
if (!Array.isArray(list) || list.length === 0) {
|
|
187
189
|
$Method.setCurrentRow(null);
|
|
188
190
|
$Data.activeRowKeys = [];
|
|
@@ -211,14 +213,14 @@ const $Method = {
|
|
|
211
213
|
|
|
212
214
|
$Data.activeRowKeys = [firstKey];
|
|
213
215
|
},
|
|
214
|
-
getLastPage(total, limit) {
|
|
216
|
+
getLastPage: function (total, limit) {
|
|
215
217
|
if (total <= 0) return 1;
|
|
216
218
|
if (limit <= 0) return 1;
|
|
217
219
|
const pages = Math.ceil(total / limit);
|
|
218
220
|
if (!Number.isFinite(pages) || pages <= 0) return 1;
|
|
219
221
|
return pages;
|
|
220
222
|
},
|
|
221
|
-
async
|
|
223
|
+
loadList: async function (options) {
|
|
222
224
|
const listEndpoint = $Prop.endpoints?.list;
|
|
223
225
|
if (!listEndpoint) {
|
|
224
226
|
return;
|
|
@@ -288,7 +290,7 @@ const $Method = {
|
|
|
288
290
|
}
|
|
289
291
|
}
|
|
290
292
|
},
|
|
291
|
-
async
|
|
293
|
+
reload: async function (options) {
|
|
292
294
|
if (options?.resetPage) {
|
|
293
295
|
$Data.pager.currentPage = 1;
|
|
294
296
|
}
|
|
@@ -297,16 +299,16 @@ const $Method = {
|
|
|
297
299
|
allowPageFallback: true
|
|
298
300
|
});
|
|
299
301
|
},
|
|
300
|
-
onPageChange(info) {
|
|
302
|
+
onPageChange: function (info) {
|
|
301
303
|
$Data.pager.currentPage = info.currentPage;
|
|
302
304
|
$Method.reload({ keepSelection: true });
|
|
303
305
|
},
|
|
304
|
-
onPageSizeChange(info) {
|
|
306
|
+
onPageSizeChange: function (info) {
|
|
305
307
|
$Data.pager.limit = info.pageSize;
|
|
306
308
|
$Data.pager.currentPage = 1;
|
|
307
309
|
$Method.reload({ keepSelection: false });
|
|
308
310
|
},
|
|
309
|
-
onActiveChange(value, context) {
|
|
311
|
+
onActiveChange: function (value, context) {
|
|
310
312
|
if (value.length === 0) {
|
|
311
313
|
if ($Data.activeRowKeys.length > 0) {
|
|
312
314
|
return;
|
|
@@ -335,7 +337,7 @@ const $Method = {
|
|
|
335
337
|
}
|
|
336
338
|
}
|
|
337
339
|
},
|
|
338
|
-
getDeleteConfirmContent(ep, row) {
|
|
340
|
+
getDeleteConfirmContent: function (ep, row) {
|
|
339
341
|
const confirm = ep.confirm;
|
|
340
342
|
if (!confirm) {
|
|
341
343
|
return {
|
|
@@ -351,7 +353,7 @@ const $Method = {
|
|
|
351
353
|
|
|
352
354
|
return confirm;
|
|
353
355
|
},
|
|
354
|
-
async
|
|
356
|
+
deleteRow: async function (row) {
|
|
355
357
|
const ep = $Prop.endpoints?.delete;
|
|
356
358
|
if (!ep) {
|
|
357
359
|
MessagePlugin.error("未配置删除接口");
|
|
@@ -423,7 +425,7 @@ const $Method = {
|
|
|
423
425
|
}
|
|
424
426
|
});
|
|
425
427
|
},
|
|
426
|
-
buildOperationSlotProps(scope) {
|
|
428
|
+
buildOperationSlotProps: function (scope) {
|
|
427
429
|
const out = {};
|
|
428
430
|
|
|
429
431
|
for (const key of Object.keys(scope)) {
|
package/layouts/default.vue
CHANGED
|
@@ -98,23 +98,23 @@
|
|
|
98
98
|
</template>
|
|
99
99
|
|
|
100
100
|
<script setup>
|
|
101
|
-
import { arrayToTree } from "befly-admin-ui/utils/arrayToTree";
|
|
102
101
|
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
102
|
+
import { arrayToTree } from "befly-admin-ui/utils/arrayToTree";
|
|
103
103
|
import { hashPassword } from "befly-admin-ui/utils/hashPassword";
|
|
104
|
-
import { DialogPlugin, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Form as TForm, FormItem as TFormItem, Input as TInput, Menu as TMenu, MenuItem as TMenuItem, MessagePlugin, Submenu as TSubmenu } from "tdesign-vue-next";
|
|
105
104
|
import { AppIcon, ChevronDownIcon, CloseCircleIcon, ControlPlatformIcon, HomeIcon, LockOnIcon, UserIcon } from "tdesign-icons-vue-next";
|
|
106
|
-
|
|
105
|
+
import { DialogPlugin, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Form as TForm, FormItem as TFormItem, Input as TInput, Menu as TMenu, MenuItem as TMenuItem, MessagePlugin, Submenu as TSubmenu } from "tdesign-vue-next";
|
|
107
106
|
import { reactive, watch } from "vue";
|
|
108
107
|
import { useRoute, useRouter } from "vue-router";
|
|
109
|
-
|
|
108
|
+
|
|
110
109
|
import { $Config } from "@/plugins/config.js";
|
|
110
|
+
import { $Http } from "@/plugins/http.js";
|
|
111
111
|
import { $Store } from "@/plugins/store.js";
|
|
112
112
|
|
|
113
113
|
const router = useRouter();
|
|
114
114
|
const route = useRoute();
|
|
115
115
|
|
|
116
116
|
const $Const = {
|
|
117
|
-
createPasswordForm() {
|
|
117
|
+
createPasswordForm: function () {
|
|
118
118
|
return {
|
|
119
119
|
password: "",
|
|
120
120
|
confirmPassword: ""
|
|
@@ -152,10 +152,10 @@ const $Data = reactive({
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
const $Method = {
|
|
155
|
-
isString(value) {
|
|
155
|
+
isString: function (value) {
|
|
156
156
|
return typeof value === "string";
|
|
157
157
|
},
|
|
158
|
-
normalizePath(path) {
|
|
158
|
+
normalizePath: function (path) {
|
|
159
159
|
if (!$Method.isString(path)) {
|
|
160
160
|
return path;
|
|
161
161
|
}
|
|
@@ -163,7 +163,7 @@ const $Method = {
|
|
|
163
163
|
const normalized = path.replace(/\/+$/, "");
|
|
164
164
|
return normalized.length === 0 ? "/" : normalized;
|
|
165
165
|
},
|
|
166
|
-
normalizeParentPath(parentPath) {
|
|
166
|
+
normalizeParentPath: function (parentPath) {
|
|
167
167
|
if (!$Method.isString(parentPath)) {
|
|
168
168
|
return "";
|
|
169
169
|
}
|
|
@@ -175,14 +175,14 @@ const $Method = {
|
|
|
175
175
|
|
|
176
176
|
return normalized;
|
|
177
177
|
},
|
|
178
|
-
normalizeAvatarUrl(value) {
|
|
178
|
+
normalizeAvatarUrl: function (value) {
|
|
179
179
|
if (!$Method.isString(value) || value.length === 0) {
|
|
180
180
|
return "";
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
return value;
|
|
184
184
|
},
|
|
185
|
-
async
|
|
185
|
+
fetchUserInfo: async function () {
|
|
186
186
|
try {
|
|
187
187
|
const res = await $Http("/core/admin/detail", {}, [""]);
|
|
188
188
|
const userInfo = res?.data && typeof res.data === "object" ? res.data : {};
|
|
@@ -196,7 +196,7 @@ const $Method = {
|
|
|
196
196
|
MessagePlugin.error(error.msg || error.message || "获取管理员信息失败");
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
|
-
async
|
|
199
|
+
fetchUserMenus: async function () {
|
|
200
200
|
try {
|
|
201
201
|
const { data } = await $Http("/core/menu/all");
|
|
202
202
|
const lists = Array.isArray(data?.lists) ? data.lists : [];
|
|
@@ -216,7 +216,7 @@ const $Method = {
|
|
|
216
216
|
MessagePlugin.error(error.msg || error.message || "获取用户菜单失败");
|
|
217
217
|
}
|
|
218
218
|
},
|
|
219
|
-
setActiveMenu() {
|
|
219
|
+
setActiveMenu: function () {
|
|
220
220
|
const currentPath = route.path;
|
|
221
221
|
const normalizedCurrentPath = $Method.normalizePath(currentPath);
|
|
222
222
|
|
|
@@ -251,12 +251,12 @@ const $Method = {
|
|
|
251
251
|
$Data.expandedKeys = expandedKeys;
|
|
252
252
|
$Data.currentMenuKey = currentPath;
|
|
253
253
|
},
|
|
254
|
-
onMenuClick(path) {
|
|
254
|
+
onMenuClick: function (path) {
|
|
255
255
|
if ($Method.isString(path) && path.startsWith("/")) {
|
|
256
256
|
router.push(path);
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
|
-
async
|
|
259
|
+
handleLogout: async function () {
|
|
260
260
|
let dialog = null;
|
|
261
261
|
let destroyed = false;
|
|
262
262
|
|
|
@@ -296,11 +296,11 @@ const $Method = {
|
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
},
|
|
299
|
-
openPasswordDialog() {
|
|
299
|
+
openPasswordDialog: function () {
|
|
300
300
|
$Data.passwordForm = $Const.createPasswordForm();
|
|
301
301
|
$Data.passwordDialogVisible = true;
|
|
302
302
|
},
|
|
303
|
-
onUserDropdownAction(data) {
|
|
303
|
+
onUserDropdownAction: function (data) {
|
|
304
304
|
const record = data;
|
|
305
305
|
const rawValue = record && record["value"] ? record["value"] : "";
|
|
306
306
|
const cmd = rawValue ? String(rawValue) : "";
|
|
@@ -314,7 +314,7 @@ const $Method = {
|
|
|
314
314
|
$Method.handleLogout();
|
|
315
315
|
}
|
|
316
316
|
},
|
|
317
|
-
async
|
|
317
|
+
onPasswordSubmit: async function (context) {
|
|
318
318
|
const form = $From.passwordFormRef;
|
|
319
319
|
if (form === null) {
|
|
320
320
|
MessagePlugin.warning("表单未就绪");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-admin-ui",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.10",
|
|
4
4
|
"gitHead": "071d17be177355cdd61f30659c6e4c5873f87d39",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly - 管理后台功能组件",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"registry": "https://registry.npmjs.org"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"dev": "vite",
|
|
46
45
|
"build": "vite build",
|
|
46
|
+
"dev": "vite",
|
|
47
47
|
"preview": "vite preview"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
package/utils/arrayToTree.js
CHANGED
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* - 内部会 clone 一份节点对象,并写入 children: []
|
|
7
7
|
* - 默认自带递归排序:按 sort 升序;sort 缺省/非法或 < 1 视为 999999;sort 相同按 id 自然序
|
|
8
8
|
*/
|
|
9
|
+
function normalizeTreeKey(value) {
|
|
10
|
+
if (typeof value === "string") {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
14
|
+
return String(value);
|
|
15
|
+
}
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
export function arrayToTree(items, id = "id", pid = "pid", children = "children", sort = "sort") {
|
|
10
20
|
const idKey = typeof id === "string" && id.length > 0 ? id : "id";
|
|
11
21
|
const pidKey = typeof pid === "string" && pid.length > 0 ? pid : "pid";
|
|
@@ -14,21 +24,12 @@ export function arrayToTree(items, id = "id", pid = "pid", children = "children"
|
|
|
14
24
|
const map = new Map();
|
|
15
25
|
const flat = [];
|
|
16
26
|
const safeItems = Array.isArray(items) ? items : [];
|
|
17
|
-
const normalizeKey = (value) => {
|
|
18
|
-
if (typeof value === "string") {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
22
|
-
return String(value);
|
|
23
|
-
}
|
|
24
|
-
return "";
|
|
25
|
-
};
|
|
26
27
|
for (const item of safeItems) {
|
|
27
28
|
const itemObj = typeof item === "object" && item !== null ? item : null;
|
|
28
29
|
const rawId = itemObj ? itemObj[idKey] : undefined;
|
|
29
30
|
const rawPid = itemObj ? itemObj[pidKey] : undefined;
|
|
30
|
-
const normalizedId =
|
|
31
|
-
const normalizedPid =
|
|
31
|
+
const normalizedId = normalizeTreeKey(rawId);
|
|
32
|
+
const normalizedPid = normalizeTreeKey(rawPid);
|
|
32
33
|
const nextNode = Object.assign({}, item);
|
|
33
34
|
const nextNodeObj = nextNode;
|
|
34
35
|
nextNodeObj[idKey] = normalizedId;
|
|
@@ -42,8 +43,8 @@ export function arrayToTree(items, id = "id", pid = "pid", children = "children"
|
|
|
42
43
|
const tree = [];
|
|
43
44
|
for (const node of flat) {
|
|
44
45
|
const nodeObj = node;
|
|
45
|
-
const selfId =
|
|
46
|
-
const parentId =
|
|
46
|
+
const selfId = normalizeTreeKey(nodeObj[idKey]);
|
|
47
|
+
const parentId = normalizeTreeKey(nodeObj[pidKey]);
|
|
47
48
|
if (parentId.length > 0 && parentId !== selfId) {
|
|
48
49
|
const parent = map.get(parentId);
|
|
49
50
|
if (parent) {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
</template>
|
|
33
33
|
|
|
34
34
|
<script setup>
|
|
35
|
+
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
36
|
+
import { Form as TForm, FormItem as TFormItem, Input as TInput, Select as TSelect, Option as TOption, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
|
|
35
37
|
import { computed, reactive } from "vue";
|
|
36
38
|
|
|
37
|
-
import { Form as TForm, FormItem as TFormItem, Input as TInput, Select as TSelect, Option as TOption, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
|
|
38
|
-
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
39
39
|
import { $Http } from "@/plugins/http.js";
|
|
40
40
|
|
|
41
41
|
const $Prop = defineProps({
|
|
@@ -48,7 +48,7 @@ const $Prop = defineProps({
|
|
|
48
48
|
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
49
49
|
|
|
50
50
|
const $Const = {
|
|
51
|
-
createDefaultFormData() {
|
|
51
|
+
createDefaultFormData: function () {
|
|
52
52
|
return {
|
|
53
53
|
typeCode: "",
|
|
54
54
|
key: "",
|
|
@@ -81,10 +81,10 @@ const $Computed = reactive({
|
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
const $Method = {
|
|
84
|
-
resetFormData() {
|
|
84
|
+
resetFormData: function () {
|
|
85
85
|
Object.assign($Data.formData, $Const.createDefaultFormData());
|
|
86
86
|
},
|
|
87
|
-
initData() {
|
|
87
|
+
initData: function () {
|
|
88
88
|
if ($Prop.actionType === "upd" && $Prop.rowData) {
|
|
89
89
|
$Data.formData.typeCode = $Prop.rowData.typeCode || "";
|
|
90
90
|
$Data.formData.key = $Prop.rowData.key || "";
|
|
@@ -96,7 +96,7 @@ const $Method = {
|
|
|
96
96
|
|
|
97
97
|
$Method.resetFormData();
|
|
98
98
|
},
|
|
99
|
-
async
|
|
99
|
+
handleSubmit: async function () {
|
|
100
100
|
try {
|
|
101
101
|
const form = $From.formRef;
|
|
102
102
|
if (!form) {
|
|
@@ -45,14 +45,15 @@
|
|
|
45
45
|
</template>
|
|
46
46
|
|
|
47
47
|
<script setup>
|
|
48
|
+
import PageTableDetail from "befly-admin-ui/components/pageTableDetail.vue";
|
|
49
|
+
import { withDefaultColumns } from "befly-admin-ui/utils/withDefaultColumns";
|
|
50
|
+
import { AddIcon, ChevronDownIcon, DeleteIcon, EditIcon, SearchIcon } from "tdesign-icons-vue-next";
|
|
51
|
+
import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Input as TInput, Option as TOption, Select as TSelect, MessagePlugin } from "tdesign-vue-next";
|
|
48
52
|
import { onMounted, reactive } from "vue";
|
|
49
53
|
|
|
50
|
-
import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Input as TInput, Option as TOption, Select as TSelect, MessagePlugin } from "tdesign-vue-next";
|
|
51
|
-
import { AddIcon, ChevronDownIcon, DeleteIcon, EditIcon, SearchIcon } from "tdesign-icons-vue-next";
|
|
52
|
-
import EditDialog from "./components/edit.vue";
|
|
53
54
|
import { $Http } from "@/plugins/http.js";
|
|
54
|
-
|
|
55
|
-
import
|
|
55
|
+
|
|
56
|
+
import EditDialog from "./components/edit.vue";
|
|
56
57
|
|
|
57
58
|
const $Data = reactive({
|
|
58
59
|
typeList: [],
|
|
@@ -97,16 +98,16 @@ const $Data = reactive({
|
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
const $Method = {
|
|
100
|
-
onAdd() {
|
|
101
|
+
onAdd: function () {
|
|
101
102
|
$Method.onAction("add", {});
|
|
102
103
|
},
|
|
103
|
-
onDialogSuccess(reload) {
|
|
104
|
+
onDialogSuccess: function (reload) {
|
|
104
105
|
reload({ keepSelection: true });
|
|
105
106
|
},
|
|
106
|
-
async
|
|
107
|
+
initData: async function () {
|
|
107
108
|
await $Method.apiDictTypeAll();
|
|
108
109
|
},
|
|
109
|
-
async
|
|
110
|
+
apiDictTypeAll: async function () {
|
|
110
111
|
try {
|
|
111
112
|
const res = await $Http("/core/dictType/all", {}, [""]);
|
|
112
113
|
$Data.typeList = res.data.lists || [];
|
|
@@ -114,10 +115,10 @@ const $Method = {
|
|
|
114
115
|
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
115
116
|
}
|
|
116
117
|
},
|
|
117
|
-
handleSearch(reload) {
|
|
118
|
+
handleSearch: function (reload) {
|
|
118
119
|
reload({ keepSelection: false, resetPage: true });
|
|
119
120
|
},
|
|
120
|
-
onAction(type, row) {
|
|
121
|
+
onAction: function (type, row) {
|
|
121
122
|
if (type === "add") {
|
|
122
123
|
$Data.actionType = "add";
|
|
123
124
|
$Data.rowData = {};
|
|
@@ -131,7 +132,7 @@ const $Method = {
|
|
|
131
132
|
$Data.editVisible = true;
|
|
132
133
|
}
|
|
133
134
|
},
|
|
134
|
-
onDropdownAction(data, row, deleteRow) {
|
|
135
|
+
onDropdownAction: function (data, row, deleteRow) {
|
|
135
136
|
const record = data;
|
|
136
137
|
const rawValue = record && record["value"] ? record["value"] : "";
|
|
137
138
|
const cmd = rawValue ? String(rawValue) : "";
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script setup>
|
|
30
|
+
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
31
|
+
import { Form as TForm, FormItem as TFormItem, Input as TInput, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
|
|
30
32
|
import { computed, reactive } from "vue";
|
|
31
33
|
|
|
32
|
-
import { Form as TForm, FormItem as TFormItem, Input as TInput, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
|
|
33
|
-
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
34
34
|
import { $Http } from "@/plugins/http.js";
|
|
35
35
|
|
|
36
36
|
const $Prop = defineProps({
|
|
@@ -42,7 +42,7 @@ const $Prop = defineProps({
|
|
|
42
42
|
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
43
43
|
|
|
44
44
|
const $Const = {
|
|
45
|
-
createDefaultFormData() {
|
|
45
|
+
createDefaultFormData: function () {
|
|
46
46
|
return {
|
|
47
47
|
code: "",
|
|
48
48
|
name: "",
|
|
@@ -73,10 +73,10 @@ const $Computed = reactive({
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
const $Method = {
|
|
76
|
-
resetFormData() {
|
|
76
|
+
resetFormData: function () {
|
|
77
77
|
Object.assign($Data.formData, $Const.createDefaultFormData());
|
|
78
78
|
},
|
|
79
|
-
initData() {
|
|
79
|
+
initData: function () {
|
|
80
80
|
if ($Prop.actionType === "upd" && $Prop.rowData) {
|
|
81
81
|
$Data.formData.code = $Prop.rowData.code || "";
|
|
82
82
|
$Data.formData.name = $Prop.rowData.name || "";
|
|
@@ -87,7 +87,7 @@ const $Method = {
|
|
|
87
87
|
|
|
88
88
|
$Method.resetFormData();
|
|
89
89
|
},
|
|
90
|
-
async
|
|
90
|
+
handleSubmit: async function () {
|
|
91
91
|
const form = $From.formRef;
|
|
92
92
|
if (!form) {
|
|
93
93
|
MessagePlugin.warning("表单未就绪");
|
|
@@ -42,12 +42,13 @@
|
|
|
42
42
|
</template>
|
|
43
43
|
|
|
44
44
|
<script setup>
|
|
45
|
-
import { reactive } from "vue";
|
|
46
|
-
import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Input as TInput } from "tdesign-vue-next";
|
|
47
|
-
import { AddIcon, ChevronDownIcon, DeleteIcon, EditIcon, SearchIcon } from "tdesign-icons-vue-next";
|
|
48
|
-
import EditDialog from "./components/edit.vue";
|
|
49
45
|
import PageTableDetail from "befly-admin-ui/components/pageTableDetail.vue";
|
|
50
46
|
import { withDefaultColumns } from "befly-admin-ui/utils/withDefaultColumns";
|
|
47
|
+
import { AddIcon, ChevronDownIcon, DeleteIcon, EditIcon, SearchIcon } from "tdesign-icons-vue-next";
|
|
48
|
+
import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Input as TInput } from "tdesign-vue-next";
|
|
49
|
+
import { reactive } from "vue";
|
|
50
|
+
|
|
51
|
+
import EditDialog from "./components/edit.vue";
|
|
51
52
|
|
|
52
53
|
const $Data = reactive({
|
|
53
54
|
searchKeyword: "",
|
|
@@ -90,16 +91,16 @@ const $Data = reactive({
|
|
|
90
91
|
});
|
|
91
92
|
|
|
92
93
|
const $Method = {
|
|
93
|
-
onAdd() {
|
|
94
|
+
onAdd: function () {
|
|
94
95
|
$Method.onAction("add", {});
|
|
95
96
|
},
|
|
96
|
-
onDialogSuccess(reload) {
|
|
97
|
+
onDialogSuccess: function (reload) {
|
|
97
98
|
reload({ keepSelection: true });
|
|
98
99
|
},
|
|
99
|
-
handleSearch(reload) {
|
|
100
|
+
handleSearch: function (reload) {
|
|
100
101
|
reload({ keepSelection: false, resetPage: true });
|
|
101
102
|
},
|
|
102
|
-
onAction(type, row) {
|
|
103
|
+
onAction: function (type, row) {
|
|
103
104
|
if (type === "add") {
|
|
104
105
|
$Data.actionType = "add";
|
|
105
106
|
$Data.rowData = {};
|
|
@@ -113,7 +114,7 @@ const $Method = {
|
|
|
113
114
|
$Data.editVisible = true;
|
|
114
115
|
}
|
|
115
116
|
},
|
|
116
|
-
onDropdownAction(data, row, deleteRow) {
|
|
117
|
+
onDropdownAction: function (data, row, deleteRow) {
|
|
117
118
|
const record = data;
|
|
118
119
|
const rawValue = record && record["value"] ? record["value"] : "";
|
|
119
120
|
const cmd = rawValue ? String(rawValue) : "";
|