@befly-addon/admin 1.8.2 → 1.8.5
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/adminViews/403_1/index.vue +9 -10
- package/adminViews/config/dict/components/edit.vue +39 -36
- package/adminViews/config/dict/index.vue +127 -206
- package/adminViews/config/dictType/components/edit.vue +38 -36
- package/adminViews/config/dictType/index.vue +105 -197
- package/adminViews/config/system/components/edit.vue +75 -70
- package/adminViews/config/system/index.vue +134 -235
- package/adminViews/index/components/userInfo.vue +67 -77
- package/adminViews/log/email/index.vue +154 -230
- package/adminViews/log/login/index.vue +66 -157
- package/adminViews/log/operate/index.vue +110 -196
- package/adminViews/login_1/index.vue +29 -39
- package/adminViews/people/admin/components/edit.vue +61 -70
- package/adminViews/people/admin/index.vue +88 -204
- package/adminViews/permission/api/index.vue +52 -62
- package/adminViews/permission/menu/index.vue +43 -53
- package/adminViews/permission/role/components/api.vue +168 -169
- package/adminViews/permission/role/components/edit.vue +43 -45
- package/adminViews/permission/role/components/menu.vue +143 -151
- package/adminViews/permission/role/index.vue +129 -224
- package/adminViews/tsconfig.json +14 -0
- package/package.json +3 -3
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<h1 class="error-title">无权限访问</h1>
|
|
6
6
|
<p class="error-description">抱歉,您没有访问该页面的权限</p>
|
|
7
7
|
<div class="error-actions">
|
|
8
|
-
<TButton theme="primary" @click="
|
|
9
|
-
<TButton @click="
|
|
8
|
+
<TButton theme="primary" @click="goHome">返回首页</TButton>
|
|
9
|
+
<TButton @click="goBack">返回上一页</TButton>
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
@@ -18,14 +18,13 @@ import { Button as TButton } from "tdesign-vue-next";
|
|
|
18
18
|
|
|
19
19
|
const router = useRouter();
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
21
|
+
function goHome(): void {
|
|
22
|
+
router.push("/");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function goBack(): void {
|
|
26
|
+
router.back();
|
|
27
|
+
}
|
|
29
28
|
</script>
|
|
30
29
|
|
|
31
30
|
<style scoped lang="scss">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<TForm
|
|
2
|
+
<PageDialog v-model="visible" :title="actionType === 'add' ? '添加字典项' : '编辑字典项'" @confirm="handleSubmit">
|
|
3
|
+
<TForm :data="$Data.formData" :rules="$Data.rules" label-width="100px" :ref="(el) => ($From.form = el)">
|
|
4
4
|
<TFormItem label="字典类型" name="typeCode">
|
|
5
5
|
<TSelect v-model="$Data.formData.typeCode" placeholder="请选择字典类型" filterable>
|
|
6
6
|
<TOption v-for="item in typeList" :key="item.code" :value="item.code" :label="item.name" />
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
<TTextarea v-model="$Data.formData.remark" placeholder="请输入备注信息" :autosize="{ minRows: 3, maxRows: 6 }" />
|
|
20
20
|
</TFormItem>
|
|
21
21
|
</TForm>
|
|
22
|
-
</
|
|
22
|
+
</PageDialog>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
25
|
<script setup lang="ts">
|
|
26
26
|
import { computed } from "vue";
|
|
27
27
|
|
|
28
|
-
import {
|
|
28
|
+
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";
|
|
29
|
+
import PageDialog from "@/components/pageDialog.vue";
|
|
29
30
|
import { $Http } from "@/plugins/http";
|
|
30
31
|
|
|
31
32
|
const props = defineProps({
|
|
@@ -35,14 +36,19 @@ const props = defineProps({
|
|
|
35
36
|
typeList: Array
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
const
|
|
39
|
+
const $Emit = defineEmits<{
|
|
40
|
+
(e: "update:modelValue", value: boolean): void;
|
|
41
|
+
(e: "success"): void;
|
|
42
|
+
}>();
|
|
39
43
|
|
|
40
44
|
const visible = computed({
|
|
41
45
|
get: () => props.modelValue,
|
|
42
|
-
set: (val) =>
|
|
46
|
+
set: (val) => $Emit("update:modelValue", val)
|
|
43
47
|
});
|
|
44
48
|
|
|
45
|
-
const
|
|
49
|
+
const $From = $shallowRef({
|
|
50
|
+
form: null
|
|
51
|
+
});
|
|
46
52
|
|
|
47
53
|
const $Data = $ref({
|
|
48
54
|
formData: {
|
|
@@ -59,38 +65,35 @@ const $Data = $ref({
|
|
|
59
65
|
}
|
|
60
66
|
});
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
async function handleSubmit(): Promise<void> {
|
|
69
|
+
try {
|
|
70
|
+
const valid = await $From.form.validate();
|
|
71
|
+
if (valid !== true) return;
|
|
72
|
+
const apiUrl = props.actionType === "add" ? "/addon/admin/dict/ins" : "/addon/admin/dict/upd";
|
|
73
|
+
const params: Record<string, unknown> = {
|
|
74
|
+
typeCode: $Data.formData.typeCode,
|
|
75
|
+
key: $Data.formData.key,
|
|
76
|
+
label: $Data.formData.label,
|
|
77
|
+
sort: $Data.formData.sort,
|
|
78
|
+
remark: $Data.formData.remark
|
|
79
|
+
};
|
|
80
|
+
if (props.actionType === "upd" && props.rowData) {
|
|
81
|
+
const row = props.rowData as Record<string, unknown>;
|
|
82
|
+
params["id"] = row["id"];
|
|
83
|
+
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
} catch (error) {
|
|
87
|
-
MessagePlugin.error("操作失败");
|
|
85
|
+
const res = await $Http.post(apiUrl, params);
|
|
86
|
+
if (res.code === 0) {
|
|
87
|
+
MessagePlugin.success(props.actionType === "add" ? "添加成功" : "更新成功");
|
|
88
|
+
visible.value = false;
|
|
89
|
+
$Emit("success");
|
|
90
|
+
} else {
|
|
91
|
+
MessagePlugin.error(res.msg || "操作失败");
|
|
88
92
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
visible.value = false;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
MessagePlugin.error("操作失败");
|
|
92
95
|
}
|
|
93
|
-
}
|
|
96
|
+
}
|
|
94
97
|
|
|
95
98
|
// 该组件由父组件 v-if 控制挂载/卸载,因此无需 watch:创建时初始化一次即可
|
|
96
99
|
if (props.actionType === "upd" && props.rowData) {
|
|
@@ -1,79 +1,58 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</div>
|
|
11
|
-
<div class="right">
|
|
12
|
-
<TSelect v-model="$Data.searchTypeCode" placeholder="请选择字典类型" clearable filterable @change="$Method.handleSearch">
|
|
13
|
-
<TOption v-for="item in $Data.typeList" :key="item.code" :value="item.code" :label="item.name" />
|
|
14
|
-
</TSelect>
|
|
15
|
-
<TInput v-model="$Data.searchKeyword" placeholder="搜索键/标签" clearable @enter="$Method.handleSearch" @clear="$Method.handleSearch">
|
|
16
|
-
<template #suffix-icon>
|
|
17
|
-
<ILucideSearch />
|
|
18
|
-
</template>
|
|
19
|
-
</TInput>
|
|
20
|
-
<TButton shape="circle" @click="$Method.handleRefresh">
|
|
21
|
-
<template #icon>
|
|
22
|
-
<ILucideRotateCw />
|
|
23
|
-
</template>
|
|
24
|
-
</TButton>
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
<div class="main-content">
|
|
28
|
-
<div class="main-table">
|
|
29
|
-
<TTable
|
|
30
|
-
:data="$Data.tableData"
|
|
31
|
-
:columns="$Data.columns"
|
|
32
|
-
:loading="$Data.loading"
|
|
33
|
-
:active-row-keys="$Data.activeRowKeys"
|
|
34
|
-
row-key="id"
|
|
35
|
-
height="calc(100vh - var(--search-height) - var(--pagination-height) - var(--layout-gap) * 4)"
|
|
36
|
-
active-row-type="single"
|
|
37
|
-
@active-change="$Method.onActiveChange"
|
|
38
|
-
>
|
|
39
|
-
<template #operation="{ row }">
|
|
40
|
-
<TDropdown trigger="click" placement="bottom-right" @click="(data) => $Method.onAction(data.value, row)">
|
|
41
|
-
<TButton theme="primary" size="small">
|
|
42
|
-
操作
|
|
43
|
-
<template #suffix> <ILucideChevronDown /></template>
|
|
44
|
-
</TButton>
|
|
45
|
-
<TDropdownMenu slot="dropdown">
|
|
46
|
-
<TDropdownItem value="upd">
|
|
47
|
-
<ILucidePencil />
|
|
48
|
-
编辑
|
|
49
|
-
</TDropdownItem>
|
|
50
|
-
<TDropdownItem value="del" :divider="true">
|
|
51
|
-
<ILucideTrash2 style="width: 14px; height: 14px; margin-right: 6px" />
|
|
52
|
-
删除
|
|
53
|
-
</TDropdownItem>
|
|
54
|
-
</TDropdownMenu>
|
|
55
|
-
</TDropdown>
|
|
56
|
-
</template>
|
|
57
|
-
</TTable>
|
|
58
|
-
</div>
|
|
2
|
+
<PagedTableDetail class="page-dict page-table" :columns="$Data.columns" :endpoints="$Data.endpoints">
|
|
3
|
+
<template #toolLeft>
|
|
4
|
+
<TButton theme="primary" @click="onAdd">
|
|
5
|
+
<template #icon>
|
|
6
|
+
<ILucidePlus />
|
|
7
|
+
</template>
|
|
8
|
+
</TButton>
|
|
9
|
+
</template>
|
|
59
10
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
11
|
+
<template #toolRight="scope">
|
|
12
|
+
<TSelect v-model="$Data.searchTypeCode" placeholder="请选择字典类型" clearable filterable @change="handleSearch(scope.reload)">
|
|
13
|
+
<TOption v-for="item in $Data.typeList" :key="item.code" :value="item.code" :label="item.name" />
|
|
14
|
+
</TSelect>
|
|
15
|
+
<TInput v-model="$Data.searchKeyword" placeholder="搜索键/标签" clearable @enter="handleSearch(scope.reload)" @clear="handleSearch(scope.reload)">
|
|
16
|
+
<template #suffix-icon>
|
|
17
|
+
<ILucideSearch />
|
|
18
|
+
</template>
|
|
19
|
+
</TInput>
|
|
20
|
+
<TButton shape="circle" @click="handleRefresh(scope.reload)">
|
|
21
|
+
<template #icon>
|
|
22
|
+
<ILucideRotateCw />
|
|
23
|
+
</template>
|
|
24
|
+
</TButton>
|
|
25
|
+
</template>
|
|
64
26
|
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
|
|
27
|
+
<template #operation="{ row, deleteRow }">
|
|
28
|
+
<TDropdown trigger="click" placement="bottom-right" @click="onDropdownAction($event, row, deleteRow)">
|
|
29
|
+
<TButton theme="primary" size="small">
|
|
30
|
+
操作
|
|
31
|
+
<template #suffix> <ILucideChevronDown /></template>
|
|
32
|
+
</TButton>
|
|
33
|
+
<TDropdownMenu slot="dropdown">
|
|
34
|
+
<TDropdownItem value="upd">
|
|
35
|
+
<ILucidePencil />
|
|
36
|
+
编辑
|
|
37
|
+
</TDropdownItem>
|
|
38
|
+
<TDropdownItem value="del" :divider="true">
|
|
39
|
+
<ILucideTrash2 style="width: 14px; height: 14px; margin-right: 6px" />
|
|
40
|
+
删除
|
|
41
|
+
</TDropdownItem>
|
|
42
|
+
</TDropdownMenu>
|
|
43
|
+
</TDropdown>
|
|
44
|
+
</template>
|
|
68
45
|
|
|
69
|
-
<
|
|
70
|
-
|
|
46
|
+
<template #dialogs="scope">
|
|
47
|
+
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" :type-list="$Data.typeList" @success="onDialogSuccess(scope.reload)" />
|
|
48
|
+
</template>
|
|
49
|
+
</PagedTableDetail>
|
|
71
50
|
</template>
|
|
72
51
|
|
|
73
52
|
<script setup lang="ts">
|
|
74
53
|
import { onMounted } from "vue";
|
|
75
54
|
|
|
76
|
-
import { Button as TButton,
|
|
55
|
+
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";
|
|
77
56
|
import ILucidePlus from "~icons/lucide/plus";
|
|
78
57
|
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
79
58
|
import ILucideSearch from "~icons/lucide/search";
|
|
@@ -81,16 +60,12 @@ import ILucidePencil from "~icons/lucide/pencil";
|
|
|
81
60
|
import ILucideTrash2 from "~icons/lucide/trash-2";
|
|
82
61
|
import ILucideChevronDown from "~icons/lucide/chevron-down";
|
|
83
62
|
import EditDialog from "./components/edit.vue";
|
|
84
|
-
import DetailPanel from "@/components/DetailPanel.vue";
|
|
85
63
|
import { $Http } from "@/plugins/http";
|
|
64
|
+
import PagedTableDetail from "@/components/pagedTableDetail.vue";
|
|
86
65
|
import { withDefaultColumns } from "befly-shared/utils/withDefaultColumns";
|
|
87
66
|
|
|
88
67
|
const $Data = $ref({
|
|
89
|
-
tableData: [],
|
|
90
68
|
typeList: [],
|
|
91
|
-
loading: false,
|
|
92
|
-
activeRowKeys: [],
|
|
93
|
-
currentRow: null,
|
|
94
69
|
searchTypeCode: "",
|
|
95
70
|
searchKeyword: "",
|
|
96
71
|
columns: withDefaultColumns([
|
|
@@ -102,154 +77,100 @@ const $Data = $ref({
|
|
|
102
77
|
{ colKey: "remark", title: "备注" },
|
|
103
78
|
{ colKey: "operation", title: "操作" }
|
|
104
79
|
]),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
80
|
+
endpoints: {
|
|
81
|
+
list: {
|
|
82
|
+
path: "/addon/admin/dict/list",
|
|
83
|
+
dropValues: [""],
|
|
84
|
+
buildData: () => {
|
|
85
|
+
return {
|
|
86
|
+
typeCode: $Data.searchTypeCode,
|
|
87
|
+
keyword: $Data.searchKeyword
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
delete: {
|
|
92
|
+
path: "/addon/admin/dict/del",
|
|
93
|
+
idKey: "id",
|
|
94
|
+
confirm: (row) => {
|
|
95
|
+
return {
|
|
96
|
+
header: "确认删除",
|
|
97
|
+
body: `确认删除字典项“${row.label}”吗?`,
|
|
98
|
+
confirmBtn: "删除",
|
|
99
|
+
status: "warning"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
111
103
|
},
|
|
112
104
|
editVisible: false,
|
|
113
105
|
actionType: "add",
|
|
114
106
|
rowData: {}
|
|
115
107
|
});
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await $Method.apiDictList();
|
|
121
|
-
},
|
|
122
|
-
async apiDictTypeAll() {
|
|
123
|
-
try {
|
|
124
|
-
const res = await $Http.post(
|
|
125
|
-
"/addon/admin/dictType/all",
|
|
126
|
-
{},
|
|
127
|
-
{
|
|
128
|
-
dropValues: [""]
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
$Data.typeList = res.data.lists || [];
|
|
132
|
-
} catch (error) {
|
|
133
|
-
MessagePlugin.error("加载数据失败");
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
async apiDictList() {
|
|
137
|
-
$Data.loading = true;
|
|
138
|
-
try {
|
|
139
|
-
const res = await $Http.post(
|
|
140
|
-
"/addon/admin/dict/list",
|
|
141
|
-
{
|
|
142
|
-
page: $Data.pagerConfig.currentPage,
|
|
143
|
-
limit: $Data.pagerConfig.limit,
|
|
144
|
-
typeCode: $Data.searchTypeCode,
|
|
145
|
-
keyword: $Data.searchKeyword
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
dropValues: [""]
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
$Data.tableData = res.data.lists || [];
|
|
152
|
-
$Data.pagerConfig.total = res.data.total || 0;
|
|
109
|
+
function onAdd(): void {
|
|
110
|
+
onAction("add", {});
|
|
111
|
+
}
|
|
153
112
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
} catch (error) {
|
|
162
|
-
MessagePlugin.error("加载数据失败");
|
|
163
|
-
} finally {
|
|
164
|
-
$Data.loading = false;
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
async apiDictDel(row) {
|
|
168
|
-
let dialog = null;
|
|
169
|
-
let destroyed = false;
|
|
113
|
+
function onDialogSuccess(reload: (options: { keepSelection?: boolean }) => void): void {
|
|
114
|
+
reload({ keepSelection: true });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function initData(): Promise<void> {
|
|
118
|
+
await apiDictTypeAll();
|
|
119
|
+
}
|
|
170
120
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
121
|
+
async function apiDictTypeAll(): Promise<void> {
|
|
122
|
+
try {
|
|
123
|
+
const res = await $Http.post(
|
|
124
|
+
"/addon/admin/dictType/all",
|
|
125
|
+
{},
|
|
126
|
+
{
|
|
127
|
+
dropValues: [""]
|
|
176
128
|
}
|
|
177
|
-
|
|
129
|
+
);
|
|
130
|
+
$Data.typeList = res.data.lists || [];
|
|
131
|
+
} catch (error) {
|
|
132
|
+
MessagePlugin.error("加载数据失败");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
178
135
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
status: "warning",
|
|
183
|
-
confirmBtn: "删除",
|
|
184
|
-
cancelBtn: "取消",
|
|
185
|
-
onConfirm: async () => {
|
|
186
|
-
if (dialog && typeof dialog.setConfirmLoading === "function") {
|
|
187
|
-
dialog.setConfirmLoading(true);
|
|
188
|
-
}
|
|
136
|
+
function handleSearch(reload: (options: { keepSelection?: boolean; resetPage?: boolean }) => void): void {
|
|
137
|
+
reload({ keepSelection: false, resetPage: true });
|
|
138
|
+
}
|
|
189
139
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
handleSearch() {
|
|
211
|
-
$Data.pagerConfig.currentPage = 1;
|
|
212
|
-
$Method.apiDictList();
|
|
213
|
-
},
|
|
214
|
-
handleRefresh() {
|
|
215
|
-
$Data.searchTypeCode = "";
|
|
216
|
-
$Data.searchKeyword = "";
|
|
217
|
-
$Data.pagerConfig.currentPage = 1;
|
|
218
|
-
$Method.apiDictList();
|
|
219
|
-
},
|
|
220
|
-
onPageChange({ currentPage }) {
|
|
221
|
-
$Data.pagerConfig.currentPage = currentPage;
|
|
222
|
-
$Method.apiDictList();
|
|
223
|
-
},
|
|
224
|
-
handleSizeChange({ pageSize }) {
|
|
225
|
-
$Data.pagerConfig.limit = pageSize;
|
|
226
|
-
$Data.pagerConfig.currentPage = 1;
|
|
227
|
-
$Method.apiDictList();
|
|
228
|
-
},
|
|
229
|
-
onActiveChange(value, context) {
|
|
230
|
-
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
$Data.activeRowKeys = value;
|
|
234
|
-
$Data.currentRow = context.currentRowData;
|
|
235
|
-
},
|
|
236
|
-
onAction(type, row) {
|
|
237
|
-
if (type === "add") {
|
|
238
|
-
$Data.actionType = "add";
|
|
239
|
-
$Data.rowData = {};
|
|
240
|
-
$Data.editVisible = true;
|
|
241
|
-
} else if (type === "upd") {
|
|
242
|
-
$Data.actionType = "upd";
|
|
243
|
-
$Data.rowData = { ...row };
|
|
244
|
-
$Data.editVisible = true;
|
|
245
|
-
} else if (type === "del") {
|
|
246
|
-
$Method.apiDictDel(row);
|
|
247
|
-
}
|
|
140
|
+
function handleRefresh(reload: (options: { keepSelection?: boolean; resetPage?: boolean }) => void): void {
|
|
141
|
+
$Data.searchTypeCode = "";
|
|
142
|
+
$Data.searchKeyword = "";
|
|
143
|
+
reload({ keepSelection: false, resetPage: true });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function onAction(type: string, row: Record<string, unknown>): void {
|
|
147
|
+
if (type === "add") {
|
|
148
|
+
$Data.actionType = "add";
|
|
149
|
+
$Data.rowData = {};
|
|
150
|
+
$Data.editVisible = true;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (type === "upd") {
|
|
155
|
+
$Data.actionType = "upd";
|
|
156
|
+
$Data.rowData = Object.assign({}, row);
|
|
157
|
+
$Data.editVisible = true;
|
|
248
158
|
}
|
|
249
|
-
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function onDropdownAction(data: unknown, row: Record<string, unknown>, deleteRow: (r: Record<string, unknown>) => void): void {
|
|
162
|
+
const record = data as Record<string, unknown>;
|
|
163
|
+
const rawValue = record && record["value"] ? record["value"] : "";
|
|
164
|
+
const cmd = rawValue ? String(rawValue) : "";
|
|
165
|
+
if (cmd === "del") {
|
|
166
|
+
deleteRow(row);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
onAction(cmd, row);
|
|
170
|
+
}
|
|
250
171
|
|
|
251
172
|
onMounted(() => {
|
|
252
|
-
|
|
173
|
+
initData();
|
|
253
174
|
});
|
|
254
175
|
</script>
|
|
255
176
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<TForm
|
|
2
|
+
<PageDialog v-model="visible" :title="actionType === 'add' ? '添加字典类型' : '编辑字典类型'" @confirm="handleSubmit">
|
|
3
|
+
<TForm :data="$Data.formData" :rules="$Data.rules" label-width="100px" :ref="(el) => ($From.form = el)">
|
|
4
4
|
<TFormItem label="类型代码" name="code">
|
|
5
5
|
<TInput v-model="$Data.formData.code" placeholder="请输入类型代码(英文/数字/下划线)" :disabled="actionType === 'upd'" />
|
|
6
6
|
</TFormItem>
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
<TInputNumber v-model="$Data.formData.sort" :min="0" placeholder="请输入排序值" />
|
|
15
15
|
</TFormItem>
|
|
16
16
|
</TForm>
|
|
17
|
-
</
|
|
17
|
+
</PageDialog>
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<script setup lang="ts">
|
|
21
21
|
import { computed } from "vue";
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { Form as TForm, FormItem as TFormItem, Input as TInput, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
|
|
24
|
+
import PageDialog from "@/components/pageDialog.vue";
|
|
24
25
|
import { $Http } from "@/plugins/http";
|
|
25
26
|
|
|
26
27
|
const props = defineProps({
|
|
@@ -29,14 +30,19 @@ const props = defineProps({
|
|
|
29
30
|
rowData: Object
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
+
const $Emit = defineEmits<{
|
|
34
|
+
(e: "update:modelValue", value: boolean): void;
|
|
35
|
+
(e: "success"): void;
|
|
36
|
+
}>();
|
|
33
37
|
|
|
34
38
|
const visible = computed({
|
|
35
39
|
get: () => props.modelValue,
|
|
36
|
-
set: (val) =>
|
|
40
|
+
set: (val) => $Emit("update:modelValue", val)
|
|
37
41
|
});
|
|
38
42
|
|
|
39
|
-
const
|
|
43
|
+
const $From = $shallowRef({
|
|
44
|
+
form: null
|
|
45
|
+
});
|
|
40
46
|
|
|
41
47
|
const $Data = $ref({
|
|
42
48
|
formData: {
|
|
@@ -51,39 +57,35 @@ const $Data = $ref({
|
|
|
51
57
|
}
|
|
52
58
|
});
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!valid) return;
|
|
60
|
+
async function handleSubmit(): Promise<void> {
|
|
61
|
+
const valid = await $From.form.validate();
|
|
62
|
+
if (valid !== true) return;
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
try {
|
|
65
|
+
const apiUrl = props.actionType === "add" ? "/addon/admin/dictType/ins" : "/addon/admin/dictType/upd";
|
|
66
|
+
const params: Record<string, unknown> = {
|
|
67
|
+
code: $Data.formData.code,
|
|
68
|
+
name: $Data.formData.name,
|
|
69
|
+
description: $Data.formData.description,
|
|
70
|
+
sort: $Data.formData.sort
|
|
71
|
+
};
|
|
72
|
+
if (props.actionType === "upd" && props.rowData) {
|
|
73
|
+
const row = props.rowData as Record<string, unknown>;
|
|
74
|
+
params["id"] = row["id"];
|
|
75
|
+
}
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
} catch (error) {
|
|
80
|
-
MessagePlugin.error("操作失败");
|
|
77
|
+
const res = await $Http.post(apiUrl, params);
|
|
78
|
+
if (res.code === 0) {
|
|
79
|
+
MessagePlugin.success(props.actionType === "add" ? "添加成功" : "更新成功");
|
|
80
|
+
visible.value = false;
|
|
81
|
+
$Emit("success");
|
|
82
|
+
} else {
|
|
83
|
+
MessagePlugin.error(res.msg || "操作失败");
|
|
81
84
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
visible.value = false;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
MessagePlugin.error("操作失败");
|
|
85
87
|
}
|
|
86
|
-
}
|
|
88
|
+
}
|
|
87
89
|
|
|
88
90
|
// 该组件由父组件 v-if 控制挂载/卸载,因此无需 watch:创建时初始化一次即可
|
|
89
91
|
if (props.actionType === "upd" && props.rowData) {
|