@airpower/web 0.0.37 → 0.0.39

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.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { defineComponent, computed, createBlock, openBlock, unref, mergeProps, toHandlers, withCtx, createElementBlock, Fragment, renderList, ref } from "vue";
5
- import { AirDecorator, getFieldConfig, AirClassTransformer, HttpConfig, AirI18n, QueryPageResponse, QueryPageRequest, Page, AbstractHttp, HttpResponse, HttpStatus, AbstractEntityService } from "@airpower/core";
5
+ import { AirDecorator, getFieldConfig, AirClassTransformer, AirI18n, QueryPageResponse, QueryPageRequest, Page, HttpConfig, AbstractHttp, HttpResponse, HttpStatus, AbstractEntityService } from "@airpower/core";
6
6
  export * from "@airpower/core";
7
7
  import { ElTable, ElTableColumn, ElMessageBox, ElMessage } from "element-plus";
8
8
  import axios from "axios";
@@ -88,49 +88,44 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
88
88
  };
89
89
  }
90
90
  });
91
- class WebAccessToken {
92
- /**
93
- * ### 获取AccessToken
94
- */
95
- static getAccessToken() {
96
- var _a;
97
- return ((_a = localStorage.getItem(HttpConfig.authorizationHeaderKey)) == null ? void 0 : _a.toString()) || "";
98
- }
99
- /**
100
- * ### 设置AccessToken
101
- * @param accessToken AccessToken
102
- */
103
- static setAccessToken(accessToken) {
104
- localStorage.setItem(HttpConfig.authorizationHeaderKey, accessToken);
105
- }
106
- /**
107
- * ### 移除AccessToken
108
- */
109
- static removeAccessToken() {
110
- localStorage.removeItem(HttpConfig.authorizationHeaderKey);
111
- }
112
- }
113
91
  class WebI18n extends AirI18n {
114
- static get() {
115
- return AirI18n.get();
92
+ constructor() {
93
+ super(...arguments);
94
+ __publicField(this, "Detail", "详情");
95
+ __publicField(this, "Edit", "编辑");
96
+ __publicField(this, "Add", "添加");
97
+ __publicField(this, "EditSuccess", "编辑成功");
98
+ __publicField(this, "AddSuccess", "添加成功");
99
+ __publicField(this, "DeleteSuccess", "删除成功");
100
+ __publicField(this, "SelectPlease", "请选择");
101
+ __publicField(this, "DisableSuccess", "禁用成功");
102
+ __publicField(this, "EnableSuccess", "启用成功");
103
+ __publicField(this, "Confirm", "确定");
104
+ __publicField(this, "Cancel", "取消");
105
+ __publicField(this, "ConfirmPlease", "请确认");
106
+ __publicField(this, "ConfirmToDisable", "是否确认禁用当前选择的数据?");
107
+ __publicField(this, "ConfirmToEnable", "是否确认启用当前选择的数据?");
108
+ __publicField(this, "ConfirmToDelete", "是否确认删除当前选择的数据?");
116
109
  }
117
110
  }
118
111
  class DetailController {
119
- constructor() {
112
+ /**
113
+ * ### 创建表格控制器
114
+ * @param ServiceClass 服务类
115
+ * @param props `defineProps` 的返回值
116
+ * @param option `可选` 更多的配置
117
+ */
118
+ constructor(ServiceClass, props, option = {}) {
120
119
  __publicField(this, "isLoading", ref(false));
121
120
  __publicField(this, "formData");
122
- __publicField(this, "title", ref(WebI18n.get().Detail || "详情"));
121
+ __publicField(this, "title", ref(WebI18n.get().Detail));
123
122
  __publicField(this, "service");
124
123
  __publicField(this, "option", {});
125
- }
126
- static create(props, entityClass, serviceClass, option = {}) {
127
- const instance = new this();
128
- instance.service = AirClassTransformer.newInstance(serviceClass);
129
- instance.option = option;
130
- instance.service.setLoading(instance.isLoading);
131
- instance.formData = ref(props.param ? props.param.copy() : AirClassTransformer.newInstance(entityClass));
132
- instance.getDetail();
133
- return instance;
124
+ this.service = AirClassTransformer.newInstance(ServiceClass);
125
+ this.service.setLoading(this.isLoading);
126
+ this.option = option;
127
+ this.formData = ref(props.param ? props.param.copy() : AirClassTransformer.newInstance(this.service.entityClass));
128
+ this.getDetail();
134
129
  }
135
130
  /**
136
131
  * ### 查询详情方法
@@ -140,7 +135,7 @@ class DetailController {
140
135
  this.formData.value = await this.service.getDetail(this.formData.value.id, this.option.apiUrl);
141
136
  if (this.option.afterGetDetail) {
142
137
  const result = this.option.afterGetDetail(this.formData.value);
143
- if (result !== void 0) {
138
+ if (result) {
144
139
  this.formData.value = result;
145
140
  }
146
141
  }
@@ -149,11 +144,15 @@ class DetailController {
149
144
  }
150
145
  class EditorController extends DetailController {
151
146
  async getDetail() {
152
- this.title.value = this.formData.value.id ? WebI18n.get().Edit || "编辑" : WebI18n.get().Add || "添加";
147
+ this.title.value = this.formData.value.id ? WebI18n.get().Edit : WebI18n.get().Add;
153
148
  return super.getDetail();
154
149
  }
155
150
  }
156
151
  class BaseTableController {
152
+ /**
153
+ * ### 创建表格控制器
154
+ * @param ServiceClass 服务类
155
+ */
157
156
  constructor(ServiceClass) {
158
157
  __publicField(this, "request");
159
158
  __publicField(this, "response", ref(new QueryPageResponse()));
@@ -164,7 +163,8 @@ class BaseTableController {
164
163
  __publicField(this, "option", {});
165
164
  this.service = AirClassTransformer.newInstance(ServiceClass);
166
165
  this.request = ref(new QueryPageRequest(this.service.entityClass));
167
- this.init();
166
+ this.service.setLoading(this.isLoading);
167
+ this.getList();
168
168
  }
169
169
  /**
170
170
  * ### 设置配置
@@ -268,10 +268,6 @@ class BaseTableController {
268
268
  this.request.value.page = page;
269
269
  this.getList();
270
270
  }
271
- init() {
272
- this.service.setLoading(this.isLoading);
273
- this.getList();
274
- }
275
271
  }
276
272
  class TableController extends BaseTableController {
277
273
  /**
@@ -294,7 +290,8 @@ class TableController extends BaseTableController {
294
290
  * @param row 行数据
295
291
  */
296
292
  async delete(row) {
297
- await this.service.delete(row.id, WebI18n.get().DeleteSuccess || "删除成功");
293
+ await this.confirmPlease(WebI18n.get().ConfirmToDelete);
294
+ await this.service.delete(row.id, WebI18n.get().DeleteSuccess);
298
295
  this.getList();
299
296
  }
300
297
  /**
@@ -302,16 +299,8 @@ class TableController extends BaseTableController {
302
299
  * @param row 行数据
303
300
  */
304
301
  async disable(row) {
305
- await ElMessageBox.confirm(
306
- "是否确认禁用当前选择的数据?",
307
- "禁用提醒",
308
- {
309
- confirmButtonText: "确认禁用",
310
- cancelButtonText: "取消",
311
- type: "warning"
312
- }
313
- );
314
- await this.service.disable(row.id, WebI18n.get().DisableSuccess || "禁用成功");
302
+ await this.confirmPlease(WebI18n.get().ConfirmToDisable);
303
+ await this.service.disable(row.id, WebI18n.get().DisableSuccess);
315
304
  this.getList();
316
305
  }
317
306
  /**
@@ -319,17 +308,24 @@ class TableController extends BaseTableController {
319
308
  * @param row 行数据
320
309
  */
321
310
  async enable(row) {
311
+ await this.confirmPlease(WebI18n.get().ConfirmToEnable);
312
+ await this.service.enable(row.id, WebI18n.get().EnableSuccess);
313
+ this.getList();
314
+ }
315
+ /**
316
+ * ### 确认提示
317
+ * @param message 提示信息
318
+ */
319
+ async confirmPlease(message) {
322
320
  await ElMessageBox.confirm(
323
- "是否确认启用当前选择的数据?",
324
- "启用提醒",
321
+ message,
322
+ WebI18n.get().ConfirmPlease,
325
323
  {
326
- confirmButtonText: "确认启用",
327
- cancelButtonText: "取消",
324
+ confirmButtonText: WebI18n.get().Confirm,
325
+ cancelButtonText: WebI18n.get().Cancel,
328
326
  type: "warning"
329
327
  }
330
328
  );
331
- await this.service.enable(row.id, WebI18n.get().EnableSuccess || "启用成功");
332
- this.getList();
333
329
  }
334
330
  }
335
331
  class TableTreeController extends TableController {
@@ -357,6 +353,28 @@ class TableTreeController extends TableController {
357
353
  }
358
354
  }
359
355
  }
356
+ class WebAccessToken {
357
+ /**
358
+ * ### 获取AccessToken
359
+ */
360
+ static getAccessToken() {
361
+ var _a;
362
+ return ((_a = localStorage.getItem(HttpConfig.authorizationHeaderKey)) == null ? void 0 : _a.toString()) || "";
363
+ }
364
+ /**
365
+ * ### 设置AccessToken
366
+ * @param accessToken AccessToken
367
+ */
368
+ static setAccessToken(accessToken) {
369
+ localStorage.setItem(HttpConfig.authorizationHeaderKey, accessToken);
370
+ }
371
+ /**
372
+ * ### 移除AccessToken
373
+ */
374
+ static removeAccessToken() {
375
+ localStorage.removeItem(HttpConfig.authorizationHeaderKey);
376
+ }
377
+ }
360
378
  class WebHttp extends AbstractHttp {
361
379
  constructor() {
362
380
  super(...arguments);
@@ -449,7 +467,6 @@ export {
449
467
  TableTreeController,
450
468
  WebAccessToken,
451
469
  WebHttp,
452
- WebI18n,
453
470
  _sfc_main as WebTable,
454
471
  getTableConfig,
455
472
  getTableConfigList,
@@ -1,13 +1,10 @@
1
- import { AirEntity, ClassConstructor, IJson } from '@airpower/core';
1
+ import { AirEntity, IJson } from '@airpower/core';
2
2
  import { Ref } from 'vue';
3
3
  import { AbstractWebService } from '../service';
4
4
  import { IDetailControllerOption } from './interface';
5
5
  /**
6
6
  * # 详情控制器
7
- * @param props `defineProps` 的返回值
8
- * @param entityClass 详情使用的实体类
9
- * @param serviceClass 详情使用的 `Service`
10
- * @param option `可选` 更多的配置
7
+ *
11
8
  * @author Hamm.cn
12
9
  */
13
10
  export declare class DetailController<E extends AirEntity, S extends AbstractWebService<E>, O extends IDetailControllerOption<E> = IDetailControllerOption<E>> {
@@ -16,7 +13,15 @@ export declare class DetailController<E extends AirEntity, S extends AbstractWeb
16
13
  title: Ref<string, string>;
17
14
  protected service: S;
18
15
  protected option: O;
19
- static create<T extends DetailController<E, S>, E extends AirEntity, S extends AbstractWebService<E>>(this: ClassConstructor<T>, props: IJson, entityClass: ClassConstructor<E>, serviceClass: ClassConstructor<S>, option?: IDetailControllerOption<E>): T;
16
+ /**
17
+ * ### 创建表格控制器
18
+ * @param ServiceClass 服务类
19
+ * @param props `defineProps` 的返回值
20
+ * @param option `可选` 更多的配置
21
+ */
22
+ constructor(ServiceClass: new () => S & {
23
+ entityClass: new () => E;
24
+ }, props: IJson, option?: O);
20
25
  /**
21
26
  * ### 查询详情方法
22
27
  */
@@ -3,10 +3,7 @@ import { AbstractWebService } from '../service';
3
3
  import { DetailController } from './DetailController';
4
4
  /**
5
5
  * # 编辑器控制器
6
- * @param props `defineProps` 的返回值
7
- * @param entityClass `Editor`使用的实体类
8
- * @param serviceClass `Editor`使用的`Service`
9
- * @param option `可选` 更多的配置
6
+ *
10
7
  * @author Hamm.cn
11
8
  */
12
9
  export declare class EditorController<E extends AirEntity, S extends AbstractWebService<E>> extends DetailController<E, S> {
@@ -1,6 +1,7 @@
1
1
  import { AirEntity } from '@airpower/core';
2
2
  /**
3
3
  * # 详情控制器配置项
4
+ *
4
5
  * @author Hamm.cn
5
6
  */
6
7
  export interface IDetailControllerOption<E extends AirEntity> {
@@ -2,6 +2,7 @@ import { AirEntity, QueryPageRequest } from '@airpower/core';
2
2
  import { Component } from 'vue';
3
3
  /**
4
4
  * # 表格控制器配置项
5
+ *
5
6
  * @author Hamm.cn
6
7
  */
7
8
  export interface ITableControllerOption<E extends AirEntity> {
@@ -2,6 +2,7 @@ import { AirEntity, ITree } from '@airpower/core';
2
2
  import { ITableControllerOption } from './ITableControllerOption';
3
3
  /**
4
4
  * # 表格树控制器配置项
5
+ *
5
6
  * @author Hamm.cn
6
7
  */
7
8
  export interface ITableTreeControllerOption<T extends ITree & AirEntity> extends ITableControllerOption<T> {
@@ -1,7 +1,8 @@
1
1
  import { AirEntity } from '@airpower/core';
2
2
  import { IDetailControllerOption } from './IDetailControllerOption';
3
3
  /**
4
- * # `Editor` 的 `Hook` 可选配置
4
+ * # 编辑控制器的可选配置
5
+ *
5
6
  * @author Hamm.cn
6
7
  */
7
8
  export interface IUseEditorOption<E extends AirEntity> extends IDetailControllerOption<E> {
@@ -4,6 +4,7 @@ import { AbstractWebService } from '../../service';
4
4
  import { ITableControllerOption } from '../interface';
5
5
  /**
6
6
  * # 表格控制器基类
7
+ *
7
8
  * @author Hamm.cn
8
9
  */
9
10
  export declare class BaseTableController<E extends AirEntity, S extends AbstractWebService<E>, O extends ITableControllerOption<E> = ITableControllerOption<E>> {
@@ -14,6 +15,10 @@ export declare class BaseTableController<E extends AirEntity, S extends Abstract
14
15
  isLoading: Ref<boolean, boolean>;
15
16
  protected service: S;
16
17
  protected option: O;
18
+ /**
19
+ * ### 创建表格控制器
20
+ * @param ServiceClass 服务类
21
+ */
17
22
  constructor(ServiceClass: new () => S & {
18
23
  entityClass: new () => E;
19
24
  });
@@ -60,5 +65,4 @@ export declare class BaseTableController<E extends AirEntity, S extends Abstract
60
65
  * @param page 分页对象
61
66
  */
62
67
  pageChanged(page: Page): Promise<void>;
63
- private init;
64
68
  }
@@ -4,6 +4,7 @@ import { ITableControllerOption } from '../interface';
4
4
  import { BaseTableController } from './BaseTableController';
5
5
  /**
6
6
  * # 表格控制器
7
+ *
7
8
  * @author Hamm.cn
8
9
  */
9
10
  export declare class TableController<E extends AirEntity, S extends AbstractWebService<E>, O extends ITableControllerOption<E> = ITableControllerOption<E>> extends BaseTableController<E, S, O> {
@@ -27,4 +28,9 @@ export declare class TableController<E extends AirEntity, S extends AbstractWebS
27
28
  * @param row 行数据
28
29
  */
29
30
  enable(row: E): Promise<void>;
31
+ /**
32
+ * ### 确认提示
33
+ * @param message 提示信息
34
+ */
35
+ private confirmPlease;
30
36
  }
@@ -4,9 +4,7 @@ import { ITableTreeControllerOption } from '../interface';
4
4
  import { TableController } from './TableController';
5
5
  /**
6
6
  * # 表格控制器
7
- * @param entityClass 实体类
8
- * @param serviceClass 表格使用的`Service`类
9
- * @param option `可选` 更多配置
7
+ *
10
8
  * @author Hamm.cn
11
9
  */
12
10
  export declare class TableTreeController<E extends ITree & AirEntity, S extends AbstractWebService<E>> extends TableController<E, S, ITableTreeControllerOption<E>> {
@@ -1,6 +1,7 @@
1
1
  import { TableAlign, TableFixed, TableSortable } from './TableType';
2
2
  /**
3
3
  * # ElementPlus支持的列配置项
4
+ *
4
5
  * @autho Hamm.cn
5
6
  */
6
7
  export interface IElementTableColumn {
@@ -2,6 +2,7 @@ import { AirDictionaryArray, AirEnum, ClassConstructor, IField } from '@airpower
2
2
  import { IElementTableColumn } from './IElementTableColumn';
3
3
  /**
4
4
  * # 表格的字段配置接口
5
+ *
5
6
  * @author Hamm.cn
6
7
  */
7
8
  export interface ITableFieldConfig extends IField, IElementTableColumn {
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * # 身份令牌工具类
3
+ *
3
4
  * @author Hamm.cn
4
5
  */
5
6
  export declare class WebAccessToken {
@@ -1,2 +1 @@
1
1
  export * from './WebAccessToken';
2
- export * from './WebI18n';
@@ -0,0 +1,23 @@
1
+ import { AirI18n } from '@airpower/core';
2
+ /**
3
+ * # Web端默认语言包
4
+ *
5
+ * @author Hamm.cn
6
+ */
7
+ export declare class WebI18n extends AirI18n {
8
+ Detail: string;
9
+ Edit: string;
10
+ Add: string;
11
+ EditSuccess: string;
12
+ AddSuccess: string;
13
+ DeleteSuccess: string;
14
+ SelectPlease: string;
15
+ DisableSuccess: string;
16
+ EnableSuccess: string;
17
+ Confirm: string;
18
+ Cancel: string;
19
+ ConfirmPlease: string;
20
+ ConfirmToDisable: string;
21
+ ConfirmToEnable: string;
22
+ ConfirmToDelete: string;
23
+ }
@@ -0,0 +1 @@
1
+ export * from './WebI18n';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/web",
3
3
  "type": "module",
4
- "version": "0.0.37",
4
+ "version": "0.0.39",
5
5
  "description": "AirPower-Web",
6
6
  "author": {
7
7
  "name": "Hamm",
@@ -44,7 +44,7 @@
44
44
  "vue": "^3.5.13"
45
45
  },
46
46
  "dependencies": {
47
- "@airpower/core": "^0.1.13",
47
+ "@airpower/core": "^0.1.15",
48
48
  "axios": "^1.8.4",
49
49
  "element-plus": "^2.9.7",
50
50
  "vue": "^3.5.13"
@@ -1,13 +0,0 @@
1
- import { AirI18n } from '@airpower/core';
2
- export declare abstract class WebI18n extends AirI18n {
3
- abstract Detail: string;
4
- abstract Edit: string;
5
- abstract Add: string;
6
- abstract EditSuccess: string;
7
- abstract AddSuccess: string;
8
- abstract DeleteSuccess: string;
9
- abstract SelectPlease: string;
10
- abstract DisableSuccess: string;
11
- abstract EnableSuccess: string;
12
- static get(): WebI18n;
13
- }