@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.
@@ -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="$Method.goHome">返回首页</TButton>
9
- <TButton @click="$Method.goBack">返回上一页</TButton>
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
- const $Method = {
22
- goHome() {
23
- router.push("/");
24
- },
25
- goBack() {
26
- router.back();
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
- <TDialog v-model:visible="visible" :header="actionType === 'add' ? '添加字典项' : '编辑字典项'" width="600px" @confirm="$Method.handleSubmit" @close="$Method.handleClose">
3
- <TForm ref="formRef" :data="$Data.formData" :rules="$Data.rules" label-width="100px">
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
- </TDialog>
22
+ </PageDialog>
23
23
  </template>
24
24
 
25
25
  <script setup lang="ts">
26
26
  import { computed } from "vue";
27
27
 
28
- import { Dialog as TDialog, 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";
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 emit = defineEmits(["update:modelValue", "success"]);
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) => emit("update:modelValue", val)
46
+ set: (val) => $Emit("update:modelValue", val)
43
47
  });
44
48
 
45
- const formRef = $ref(null);
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
- const $Method = {
63
- async handleSubmit() {
64
- try {
65
- const valid = await formRef.validate();
66
- const apiUrl = props.actionType === "add" ? "/addon/admin/dict/ins" : "/addon/admin/dict/upd";
67
- const params = {
68
- typeCode: $Data.formData.typeCode,
69
- key: $Data.formData.key,
70
- label: $Data.formData.label,
71
- sort: $Data.formData.sort,
72
- remark: $Data.formData.remark
73
- };
74
- if (props.actionType === "upd") {
75
- params.id = props.rowData.id;
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
- const res = await $Http.post(apiUrl, params);
79
- if (res.code === 0) {
80
- MessagePlugin.success(props.actionType === "add" ? "添加成功" : "更新成功");
81
- visible.value = false;
82
- emit("success");
83
- } else {
84
- MessagePlugin.error(res.msg || "操作失败");
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
- handleClose() {
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
- <div class="page-dict page-table">
3
- <div class="main-tool">
4
- <div class="left">
5
- <TButton theme="primary" @click="$Method.onAction('add', {})">
6
- <template #icon>
7
- <ILucidePlus />
8
- </template>
9
- </TButton>
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
- <div class="main-detail">
61
- <DetailPanel :data="$Data.currentRow" :fields="$Data.columns" />
62
- </div>
63
- </div>
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
- <div class="main-page">
66
- <TPagination :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.limit" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @page-size-change="$Method.handleSizeChange" />
67
- </div>
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
- <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" :type-list="$Data.typeList" @success="$Method.apiDictList" />
70
- </div>
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, Table as TTable, Input as TInput, Select as TSelect, Option as TOption, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from "tdesign-vue-next";
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
- pagerConfig: {
106
- currentPage: 1,
107
- limit: 30,
108
- total: 0,
109
- align: "right",
110
- layout: "total, prev, pager, next, jumper"
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
- const $Method = {
118
- async initData() {
119
- await $Method.apiDictTypeAll();
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
- if ($Data.tableData.length > 0) {
155
- $Data.currentRow = $Data.tableData[0];
156
- $Data.activeRowKeys = [$Data.tableData[0].id];
157
- } else {
158
- $Data.currentRow = null;
159
- $Data.activeRowKeys = [];
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
- const destroy = () => {
172
- if (destroyed) return;
173
- destroyed = true;
174
- if (dialog && typeof dialog.destroy === "function") {
175
- dialog.destroy();
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
- dialog = DialogPlugin.confirm({
180
- header: "确认删除",
181
- body: `确认删除字典项“${row.label}”吗?`,
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
- try {
191
- await $Http.post("/addon/admin/dict/del", {
192
- id: row.id
193
- });
194
- MessagePlugin.success("删除成功");
195
- destroy();
196
- await $Method.apiDictList();
197
- } catch (error) {
198
- MessagePlugin.error("删除失败");
199
- } finally {
200
- if (dialog && typeof dialog.setConfirmLoading === "function") {
201
- dialog.setConfirmLoading(false);
202
- }
203
- }
204
- },
205
- onClose: () => {
206
- destroy();
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
- $Method.initData();
173
+ initData();
253
174
  });
254
175
  </script>
255
176
 
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <TDialog v-model:visible="visible" :header="actionType === 'add' ? '添加字典类型' : '编辑字典类型'" width="600px" @confirm="$Method.handleSubmit" @close="$Method.handleClose">
3
- <TForm ref="formRef" :data="$Data.formData" :rules="$Data.rules" label-width="100px">
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
- </TDialog>
17
+ </PageDialog>
18
18
  </template>
19
19
 
20
20
  <script setup lang="ts">
21
21
  import { computed } from "vue";
22
22
 
23
- import { Dialog as TDialog, Form as TForm, FormItem as TFormItem, Input as TInput, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
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 emit = defineEmits(["update:modelValue", "success"]);
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) => emit("update:modelValue", val)
40
+ set: (val) => $Emit("update:modelValue", val)
37
41
  });
38
42
 
39
- const formRef = $ref(null);
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
- const $Method = {
55
- async handleSubmit() {
56
- const valid = await formRef.validate();
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
- try {
60
- const apiUrl = props.actionType === "add" ? "/addon/admin/dictType/ins" : "/addon/admin/dictType/upd";
61
- const params = {
62
- code: $Data.formData.code,
63
- name: $Data.formData.name,
64
- description: $Data.formData.description,
65
- sort: $Data.formData.sort
66
- };
67
- if (props.actionType === "upd") {
68
- params.id = props.rowData.id;
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
- const res = await $Http.post(apiUrl, params);
72
- if (res.code === 0) {
73
- MessagePlugin.success(props.actionType === "add" ? "添加成功" : "更新成功");
74
- visible.value = false;
75
- emit("success");
76
- } else {
77
- MessagePlugin.error(res.msg || "操作失败");
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
- handleClose() {
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) {