befly-admin 3.13.25 → 3.14.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-admin",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "3.14.0",
|
|
4
|
+
"gitHead": "ccc66d5da9c6b84f8346087adc1d24412ce65bec",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly Admin - 基于 Vue3 + TDesign Vue Next 的后台管理系统",
|
|
7
7
|
"files": [
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"preview": "bunx --bun vite preview"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"befly-admin-ui": "1.8.
|
|
31
|
+
"befly-admin-ui": "1.8.27",
|
|
32
32
|
"befly-shared": "2.0.3",
|
|
33
|
-
"befly-vite": "^1.5.
|
|
33
|
+
"befly-vite": "^1.5.10",
|
|
34
34
|
"pinia": "^3.0.4",
|
|
35
35
|
"tdesign-icons-vue-next": "^0.4.0",
|
|
36
|
-
"tdesign-vue-next": "^1.18.
|
|
36
|
+
"tdesign-vue-next": "^1.18.3",
|
|
37
37
|
"vite": "^8.0.0-beta.16",
|
|
38
38
|
"vue": "^3.5.29",
|
|
39
39
|
"vue-router": "^5.0.3"
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PageDialog v-model="dialogVisible" :title="$Prop.actionType === 'upd' ? '编辑角色' : '新增角色'" :confirm-loading="$Data.submitting" @confirm="onSubmit">
|
|
3
|
+
<div class="comp-simple-role-edit">
|
|
4
|
+
<TForm :model="$Data.formData" label-width="100px" label-position="left" :rules="$Data2.formRules" ref="formRef">
|
|
5
|
+
<TFormItem label="角色名称" prop="name">
|
|
6
|
+
<TInput v-model="$Data.formData.name" placeholder="请输入角色名称" />
|
|
7
|
+
</TFormItem>
|
|
8
|
+
<TFormItem label="角色代码" prop="code">
|
|
9
|
+
<TInput v-model="$Data.formData.code" placeholder="请输入角色代码,如:operator" />
|
|
10
|
+
</TFormItem>
|
|
11
|
+
<TFormItem label="角色描述" prop="description">
|
|
12
|
+
<TInput v-model="$Data.formData.description" placeholder="请输入角色描述" />
|
|
13
|
+
</TFormItem>
|
|
14
|
+
<TFormItem label="排序" prop="sort">
|
|
15
|
+
<TInputNumber v-model="$Data.formData.sort" :min="0" :max="9999" />
|
|
16
|
+
</TFormItem>
|
|
17
|
+
</TForm>
|
|
18
|
+
</div>
|
|
19
|
+
</PageDialog>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
24
|
+
import { fieldClear } from "befly-admin-ui/utils/fieldClear";
|
|
25
|
+
|
|
26
|
+
const $Prop = defineProps({
|
|
27
|
+
modelValue: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
actionType: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "add"
|
|
34
|
+
},
|
|
35
|
+
rowData: {
|
|
36
|
+
type: Object,
|
|
37
|
+
default: {}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
42
|
+
const formRef = ref(null);
|
|
43
|
+
|
|
44
|
+
const $Data = reactive({
|
|
45
|
+
submitting: false,
|
|
46
|
+
formData: {
|
|
47
|
+
id: 0,
|
|
48
|
+
name: "",
|
|
49
|
+
code: "",
|
|
50
|
+
description: "",
|
|
51
|
+
sort: 0
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const $Data2 = reactive({
|
|
56
|
+
formRules: {
|
|
57
|
+
name: [{ required: true, message: "请输入角色名称", trigger: "blur" }],
|
|
58
|
+
code: [
|
|
59
|
+
{ required: true, message: "请输入角色代码", trigger: "blur" },
|
|
60
|
+
{ pattern: /^[a-zA-Z0-9_]+$/, message: "角色代码只能包含字母、数字和下划线", trigger: "blur" }
|
|
61
|
+
],
|
|
62
|
+
sort: [{ type: "number", message: "排序必须是数字", trigger: "blur" }]
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const dialogVisible = computed({
|
|
67
|
+
get: () => $Prop.modelValue,
|
|
68
|
+
set: (value) => {
|
|
69
|
+
$Emit("update:modelValue", value);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
function initData() {
|
|
74
|
+
if ($Prop.actionType === "upd" && $Prop.rowData.id) {
|
|
75
|
+
$Data.formData = Object.assign({}, $Prop.rowData);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
$Data.formData.id = 0;
|
|
80
|
+
$Data.formData.name = "";
|
|
81
|
+
$Data.formData.code = "";
|
|
82
|
+
$Data.formData.description = "";
|
|
83
|
+
$Data.formData.sort = 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function onSubmit(context) {
|
|
87
|
+
try {
|
|
88
|
+
const form = formRef.value;
|
|
89
|
+
if (!form) {
|
|
90
|
+
MessagePlugin.warning("表单未就绪");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const valid = await form.validate();
|
|
95
|
+
if (!valid) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
$Data.submitting = true;
|
|
100
|
+
const payload = $Prop.actionType === "upd" ? $Data.formData : fieldClear($Data.formData, { omitKeys: ["id"] });
|
|
101
|
+
const response = await $Http($Prop.actionType === "upd" ? "/core/role/upd" : "/core/role/ins", payload);
|
|
102
|
+
|
|
103
|
+
MessagePlugin.success(response.msg || "操作成功");
|
|
104
|
+
$Emit("success");
|
|
105
|
+
|
|
106
|
+
if (context && typeof context.close === "function") {
|
|
107
|
+
context.close();
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
MessagePlugin.error(error.msg || error.message || "提交失败");
|
|
111
|
+
} finally {
|
|
112
|
+
$Data.submitting = false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
initData();
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<style scoped lang="scss">
|
|
120
|
+
.comp-simple-role-edit {
|
|
121
|
+
padding-top: 6px;
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PageTableDetail class="page-simple-table page-table" :columns="$Data.columns" :endpoints="$Data.endpoints">
|
|
3
|
+
<template #toolLeft>
|
|
4
|
+
<TButton theme="primary" @click="onAdd">
|
|
5
|
+
<template #icon>
|
|
6
|
+
<AddIcon />
|
|
7
|
+
</template>
|
|
8
|
+
</TButton>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<template #toolRight="scope">
|
|
12
|
+
<TButton shape="circle" @click="onReload(scope.reload)">
|
|
13
|
+
<template #icon>
|
|
14
|
+
<RefreshIcon />
|
|
15
|
+
</template>
|
|
16
|
+
</TButton>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<template #operation="{ row, deleteRow }">
|
|
20
|
+
<TDropdown trigger="click" placement="bottom-right" @click="onDropdownAction($event, row, deleteRow)">
|
|
21
|
+
<TButton theme="primary" size="small">
|
|
22
|
+
操作
|
|
23
|
+
<template #suffix><ChevronDownIcon /></template>
|
|
24
|
+
</TButton>
|
|
25
|
+
<TDropdownMenu slot="dropdown">
|
|
26
|
+
<TDropdownItem value="upd">
|
|
27
|
+
<EditIcon />
|
|
28
|
+
编辑
|
|
29
|
+
</TDropdownItem>
|
|
30
|
+
<TDropdownItem value="del" :divider="true">
|
|
31
|
+
<DeleteIcon style="width: 14px; height: 14px; margin-right: 6px" />
|
|
32
|
+
删除
|
|
33
|
+
</TDropdownItem>
|
|
34
|
+
</TDropdownMenu>
|
|
35
|
+
</TDropdown>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<template #dialogs="scope">
|
|
39
|
+
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="onDialogSuccess(scope.reload)" />
|
|
40
|
+
</template>
|
|
41
|
+
</PageTableDetail>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
import EditDialog from "./components/edit.vue";
|
|
46
|
+
import PageTableDetail from "befly-admin-ui/components/pageTableDetail.vue";
|
|
47
|
+
import { withDefaultColumns } from "befly-admin-ui/utils/withDefaultColumns";
|
|
48
|
+
|
|
49
|
+
const $Data = reactive({
|
|
50
|
+
columns: withDefaultColumns([
|
|
51
|
+
{ colKey: "name", title: "角色名称" },
|
|
52
|
+
{ colKey: "code", title: "角色代码", width: 180 },
|
|
53
|
+
{ colKey: "description", title: "角色描述" },
|
|
54
|
+
{ colKey: "sort", title: "排序", width: 100 },
|
|
55
|
+
{ colKey: "operation", title: "操作" }
|
|
56
|
+
]),
|
|
57
|
+
endpoints: {
|
|
58
|
+
list: {
|
|
59
|
+
path: "/core/role/list",
|
|
60
|
+
dropValues: [""]
|
|
61
|
+
},
|
|
62
|
+
delete: {
|
|
63
|
+
path: "/core/role/del",
|
|
64
|
+
idKey: "id",
|
|
65
|
+
confirm: (row) => {
|
|
66
|
+
return {
|
|
67
|
+
header: "确认删除",
|
|
68
|
+
body: `确认删除角色“${row.name}”吗?`,
|
|
69
|
+
confirmBtn: "删除",
|
|
70
|
+
status: "warning"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
editVisible: false,
|
|
76
|
+
actionType: "add",
|
|
77
|
+
rowData: {}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
function onAdd() {
|
|
81
|
+
onAction("add", {});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function onReload(reload) {
|
|
85
|
+
reload({ keepSelection: true });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function onDialogSuccess(reload) {
|
|
89
|
+
reload({ keepSelection: true });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function onAction(type, row) {
|
|
93
|
+
if (type === "add") {
|
|
94
|
+
$Data.actionType = "add";
|
|
95
|
+
$Data.rowData = {};
|
|
96
|
+
$Data.editVisible = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (type === "upd") {
|
|
101
|
+
$Data.actionType = "upd";
|
|
102
|
+
$Data.rowData = Object.assign({}, row);
|
|
103
|
+
$Data.editVisible = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function onDropdownAction(data, row, deleteRow) {
|
|
108
|
+
const record = data;
|
|
109
|
+
const rawValue = record && record["value"] ? record["value"] : "";
|
|
110
|
+
const command = rawValue ? String(rawValue) : "";
|
|
111
|
+
if (command === "del") {
|
|
112
|
+
deleteRow(row);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
onAction(command, row);
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<style scoped lang="scss">
|
|
120
|
+
.page-simple-table {
|
|
121
|
+
.main-tool .right {
|
|
122
|
+
display: flex;
|
|
123
|
+
gap: 8px;
|
|
124
|
+
align-items: center;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</style>
|