@ningboyz/types 1.0.102 → 1.0.103

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ningboyz/types",
3
- "version": "1.0.102",
3
+ "version": "1.0.103",
4
4
  "private": false,
5
5
  "description": "宁波甬政类型库",
6
6
  "author": "nbyt-syq",
@@ -1,4 +1,4 @@
1
- import { construct } from "@aximario/json-tree";
1
+ import { construct, destruct } from "@aximario/json-tree";
2
2
  import type { IPzptItemResponse } from "./IPzptItemResponse";
3
3
  import type { IPzptTypeResponse } from "./IPzptTypeResponse";
4
4
  import { IBaseResponse, TBaseResponse } from "../base/IBaseResponse";
@@ -163,8 +163,20 @@ export class TPzptK8kmResponse extends TBaseResponse<IPzptK8kmResponse> implemen
163
163
  listType: IPzptTypeResponse[] = [];
164
164
 
165
165
  isChecked: boolean = false;
166
-
166
+ /**
167
+ * 将列表转换为树形结构
168
+ * @param listData 列表数据
169
+ * @returns 树形结构数据
170
+ */
167
171
  static toTree(listData: IPzptK8kmResponse[]) {
168
172
  return construct(listData, { id: "k8kmKmid", pid: "parentID", children: "children" }) as IPzptK8kmResponse[];
169
173
  }
174
+ /**
175
+ * 将树形结构转换为列表
176
+ * @param listData 树形结构数据
177
+ * @returns 列表数据
178
+ */
179
+ static toList(listData: IPzptK8kmResponse[]) {
180
+ return destruct(listData, { id: "k8kmKmid", pid: "parentID", children: "children" }) as IPzptK8kmResponse[];
181
+ }
170
182
  }