th-design 1.0.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.
@@ -0,0 +1,360 @@
1
+ :global {
2
+ .ant-form:has(.table-form-search-btn) {
3
+ .th-custom-select-input {
4
+ background-color: #f3f4f8;
5
+ }
6
+ }
7
+ }
8
+
9
+ .ant-form-item .ant-form-item-label > label {
10
+ height: 46px;
11
+ }
12
+
13
+ .th-customSelect {
14
+ position: relative;
15
+ display: inline-block;
16
+ width: 100%;
17
+
18
+ .th-selectInputContainer {
19
+ display: flex;
20
+ align-items: center;
21
+ width: 100%;
22
+ }
23
+
24
+ .th-selectLabel {
25
+ flex-shrink: 0;
26
+ margin-right: 10px;
27
+ color: rgba(51, 51, 51, 1);
28
+ font-size: 16px;
29
+ line-height: 36px; /* 与输入框高度保持一致 */
30
+ }
31
+
32
+ .th-vertical {
33
+ flex-direction: column;
34
+ }
35
+
36
+ .th-selectInput {
37
+ position: relative;
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: space-between;
41
+ width: 100%;
42
+ height: 36px;
43
+ padding: 4px 11px;
44
+ background-color: #fbfcff;
45
+ border: 1px solid #e1e3e6;
46
+ border-radius: 2px;
47
+ cursor: pointer;
48
+ transition: all 0.3s;
49
+
50
+ :global(.ant-input),
51
+ :global(.ant-input:hover),
52
+ :global(.ant-input:focus) {
53
+ border: 0 !important;
54
+ outline: none;
55
+ box-shadow: none !important;
56
+ }
57
+
58
+ .th-inputContent {
59
+ display: flex;
60
+ flex: 1;
61
+ gap: 8px; // 文本与输入框之间的间距
62
+ align-items: center;
63
+ min-width: 0;
64
+ }
65
+
66
+ .th-selectValue {
67
+ // display: flex;
68
+ align-items: center;
69
+ overflow: hidden;
70
+ font-size: 16px;
71
+ white-space: nowrap;
72
+ text-overflow: ellipsis;
73
+ transition: all 0.2s ease;
74
+
75
+ &.th-placeholder {
76
+ color: #bfbfbf;
77
+ }
78
+ }
79
+
80
+ // 输入框在右侧内联显示,并保持无边框
81
+ .th-customInput {
82
+ flex: 1;
83
+ min-width: 120px;
84
+ padding-left: 0;
85
+ background-color: transparent;
86
+ }
87
+
88
+ .th-selectArrow {
89
+ flex-shrink: 0;
90
+ margin-left: 8px;
91
+ color: rgba(0, 0, 0, 0.25);
92
+ font-size: 16px;
93
+ transition: transform 0.3s;
94
+
95
+ &.th-open {
96
+ transform: rotate(180deg);
97
+ }
98
+ }
99
+
100
+ .th-clearIcon {
101
+ margin-left: 8px;
102
+ color: rgba(0, 0, 0, 0.25);
103
+ font-size: 16px;
104
+ cursor: pointer;
105
+
106
+ &:hover {
107
+ color: rgba(0, 0, 0, 0.45);
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ .th-selectDropdown {
114
+ // 移除原有的 position: absolute
115
+ // 移除原有的 top, bottom, left, right 相关样式
116
+ z-index: 100000;
117
+ max-height: 400px;
118
+ padding: 10px;
119
+ overflow-y: hidden;
120
+ background: #fff;
121
+ box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.25);
122
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
123
+
124
+ // 保留动画相关样式
125
+ &.th-entering {
126
+ transform: scaleY(0.8);
127
+ opacity: 0;
128
+ }
129
+
130
+ &.th-entered {
131
+ transform: scaleY(1);
132
+ opacity: 1;
133
+ }
134
+
135
+ &.th-exiting {
136
+ transform: scaleY(0.8);
137
+ opacity: 0;
138
+ }
139
+
140
+ &.th-exited {
141
+ display: none;
142
+ }
143
+
144
+ .th-dropdownContainer {
145
+ display: flex;
146
+ justify-content: space-between;
147
+ width: 100%;
148
+ height: calc(100% - 50px);
149
+ }
150
+
151
+ .th-dropdownContent {
152
+ width: 60%;
153
+ height: 100%;
154
+ }
155
+
156
+ .th-singleDropdownContent {
157
+ width: 90%;
158
+ }
159
+
160
+ // 全局样式覆盖 Ant Design 表格
161
+ :global {
162
+ .ant-table-tbody > tr > td {
163
+ border-bottom: 0 !important;
164
+ }
165
+ }
166
+
167
+ &.th-bottom {
168
+ top: 100%;
169
+ margin-top: 4px;
170
+ }
171
+
172
+ &.th-top {
173
+ bottom: 100%;
174
+ margin-bottom: 4px;
175
+ }
176
+
177
+ .th-searchContainerWrapper {
178
+ width: 100%;
179
+
180
+ .th-searchContainer {
181
+ position: relative;
182
+ width: 90%;
183
+
184
+ .th-searchInput {
185
+ padding: 8px 12px;
186
+ background: rgba(214, 232, 253, 1);
187
+ border: 1px solid rgba(38, 105, 252, 1);
188
+ border-radius: 20px;
189
+ outline: none;
190
+
191
+ &::placeholder {
192
+ color: rgba(101, 107, 115, 1);
193
+ font-size: 16px;
194
+ font-family: Source Han Sans CN;
195
+ line-height: 24px;
196
+ }
197
+ }
198
+
199
+ .th-searchSuffix {
200
+ position: absolute;
201
+ top: 0;
202
+ right: 0;
203
+ width: 72px;
204
+ height: 100%;
205
+ border-radius: 20px;
206
+ cursor: pointer;
207
+ }
208
+ }
209
+ }
210
+
211
+ .th-closeIcon {
212
+ position: absolute;
213
+ top: 20px;
214
+ right: 10px;
215
+ width: 20px;
216
+ height: 20px;
217
+ cursor: pointer;
218
+ }
219
+
220
+ .th-optionList {
221
+ height: calc(100% - 45px);
222
+ margin-top: 5px;
223
+
224
+ .th-tableContainer {
225
+ // height: calc(100% - 30px);
226
+ overflow-y: auto;
227
+ border: 1px solid rgba(168, 185, 211, 1);
228
+
229
+ &::-webkit-scrollbar {
230
+ width: 6px;
231
+ /*高宽分别对应横竖滚动条的尺寸*/
232
+ height: 1px;
233
+ }
234
+
235
+ &::-webkit-scrollbar-thumb {
236
+ background: rgba(188, 200, 222, 1);
237
+ border-radius: 10px;
238
+ }
239
+
240
+ /* Firefox浏览器 */
241
+ & {
242
+ scrollbar-width: thin;
243
+ scrollbar-color: rgba(188, 200, 222, 1) transparent;
244
+ }
245
+ }
246
+
247
+ .th-noPaginationTableContainer {
248
+ height: 100%;
249
+ }
250
+
251
+ .th-paginationContainer {
252
+ display: flex;
253
+ align-items: center;
254
+ justify-content: flex-end;
255
+ height: 30px;
256
+ }
257
+ }
258
+
259
+ .th-noSearchOptionList {
260
+ height: 100%;
261
+ }
262
+
263
+ .th-buttonGroup {
264
+ display: flex;
265
+ gap: 15px;
266
+ align-items: center;
267
+ justify-content: center;
268
+ width: 100%;
269
+ height: 60px;
270
+
271
+ .th-confirmButton {
272
+ width: 160px;
273
+ height: 40px;
274
+ color: #fff;
275
+ background-color: rgba(0, 95, 234, 1);
276
+ cursor: pointer;
277
+ transition: all 0.3s;
278
+ }
279
+
280
+ .th-cancelButton {
281
+ width: 160px;
282
+ height: 40px;
283
+ color: rgba(230, 230, 230, 1);
284
+ background-color: rgba(82, 82, 82, 1);
285
+ cursor: pointer;
286
+ transition: all 0.3s;
287
+ }
288
+ }
289
+
290
+ .th-selectedWrapper {
291
+ width: 40%;
292
+ height: calc(100% - 75px);
293
+ margin-top: 45px;
294
+ margin-left: 10px;
295
+ overflow: hidden;
296
+
297
+ .th-selectedHeader {
298
+ display: flex;
299
+ align-items: center;
300
+ justify-content: space-between;
301
+ }
302
+
303
+ .th-selectedItemContainer {
304
+ height: 100%;
305
+ padding-right: 6px;
306
+ overflow-y: auto;
307
+
308
+ &::-webkit-scrollbar {
309
+ width: 6px;
310
+ /*高宽分别对应横竖滚动条的尺寸*/
311
+ height: 1px;
312
+ }
313
+
314
+ &::-webkit-scrollbar-thumb {
315
+ background: rgba(188, 200, 222, 1);
316
+ border-radius: 10px;
317
+ }
318
+
319
+ /* Firefox浏览器 */
320
+ & {
321
+ scrollbar-width: thin;
322
+ scrollbar-color: rgba(188, 200, 222, 1) transparent;
323
+ }
324
+
325
+ .th-selectedItem {
326
+ display: flex;
327
+ align-items: center;
328
+ justify-content: space-between;
329
+ box-sizing: border-box;
330
+ width: 100%;
331
+ height: 30px;
332
+ margin-bottom: 5px;
333
+ padding: 3px 8px 3px 11px;
334
+ color: rgba(19, 20, 20, 1);
335
+ font-size: 16px;
336
+ background-color: rgba(239, 245, 255, 1);
337
+
338
+ .th-deleteIcon {
339
+ width: 15px;
340
+ height: 15px;
341
+ cursor: pointer;
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ .th-withoutPagination {
348
+ height: calc(100% - 45px);
349
+ }
350
+
351
+ .th-singleSelectedWrapper {
352
+ display: none;
353
+ }
354
+ }
355
+
356
+ .th-disabled {
357
+ color: rgba(48, 50, 51, 1) !important;
358
+ background: rgba(226, 227, 230, 1) !important;
359
+ cursor: no-drop !important;
360
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 选择器缓存管理器:按作用域 scopeKey -> cacheKey 存储(内部使用 Map)
3
+ * scopeKey: 作用域键(路由标签)
4
+ * cacheKey: 缓存键
5
+ * 不分页数据:{ data: Array }
6
+ * 分页数据:{ data: Map(pageNumber => Array), total: number }
7
+ */
8
+ declare const selectCache: {
9
+ setNonPagedData(scopeKey?: string, cacheKey?: string, records?: any[]): void;
10
+ getNonPagedData(scopeKey?: string, cacheKey?: string): any;
11
+ setDataByPage(scopeKey?: string, cacheKey?: string, currentPage?: number, records?: any[], total?: number): void;
12
+ getDataByPage(scopeKey: string, cacheKey: string, currentNumber: number): any;
13
+ getPagination(scopeKey: string, cacheKey: string): 0 | {
14
+ total: number;
15
+ current: number;
16
+ };
17
+ clearScope(scopeKey: string): void;
18
+ clearAll(): void;
19
+ };
20
+ export default selectCache;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 选择器缓存管理器:按作用域 scopeKey -> cacheKey 存储(内部使用 Map)
3
+ * scopeKey: 作用域键(路由标签)
4
+ * cacheKey: 缓存键
5
+ * 不分页数据:{ data: Array }
6
+ * 分页数据:{ data: Map(pageNumber => Array), total: number }
7
+ */
8
+
9
+ // Map(scopeKey => Map(cacheKey => entry))
10
+ var store = new Map();
11
+
12
+ // 确保作用域存在,不存在则创建
13
+ function ensureScope(scopeKey) {
14
+ if (!store.has(scopeKey)) {
15
+ store.set(scopeKey, new Map());
16
+ }
17
+ return store.get(scopeKey);
18
+ }
19
+
20
+ // 确保缓存项存在,不存在则创建
21
+ function ensureEntry(scopeKey, cacheKey) {
22
+ var paged = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
23
+ var scopeMap = ensureScope(scopeKey);
24
+ if (!scopeMap.has(cacheKey)) {
25
+ scopeMap.set(cacheKey, paged ? {
26
+ data: new Map(),
27
+ total: 0
28
+ } // 分页结构
29
+ : {
30
+ data: []
31
+ } // 不分页结构
32
+ );
33
+ }
34
+ return scopeMap.get(cacheKey);
35
+ }
36
+ var selectCache = {
37
+ // 设置不分页数据
38
+ setNonPagedData: function setNonPagedData(scopeKey, cacheKey) {
39
+ var records = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
40
+ if (!scopeKey || !cacheKey) return;
41
+ var entry = ensureEntry(scopeKey, cacheKey, false);
42
+ entry.data = Array.isArray(records) ? records.slice() : [];
43
+ },
44
+ // 获取不分页数据
45
+ getNonPagedData: function getNonPagedData(scopeKey, cacheKey) {
46
+ if (!scopeKey || !cacheKey) return;
47
+ var scopeMap = store.get(scopeKey);
48
+ if (!scopeMap) return undefined;
49
+ var entry = scopeMap.get(cacheKey);
50
+ if (!entry) return undefined;
51
+ return Array.isArray(entry.data) ? entry.data : undefined;
52
+ },
53
+ // 设置分页数据:设置某一页并更新 total;
54
+ setDataByPage: function setDataByPage(scopeKey, cacheKey, currentPage) {
55
+ var records = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
56
+ var total = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
57
+ if (!scopeKey || !cacheKey || currentPage == null) return;
58
+ var entry = ensureEntry(scopeKey, cacheKey, true);
59
+ var pageNo = Number(currentPage);
60
+ if (!(entry.data instanceof Map)) {
61
+ entry.data = new Map();
62
+ }
63
+ entry.data.set(pageNo, Array.isArray(records) ? records.slice() : []);
64
+ if (typeof total === 'number' && total >= 0) {
65
+ entry.total = total;
66
+ }
67
+ },
68
+ // 获取某一页数据
69
+ getDataByPage: function getDataByPage(scopeKey, cacheKey, currentNumber) {
70
+ var scopeMap = store.get(scopeKey);
71
+ if (!scopeMap) return undefined;
72
+ var entry = scopeMap.get(cacheKey);
73
+ if (!entry || !(entry.data instanceof Map)) return undefined;
74
+ return entry.data.get(Number(currentNumber));
75
+ },
76
+ // 获取分页数据分页信息
77
+ getPagination: function getPagination(scopeKey, cacheKey) {
78
+ var scopeMap = store.get(scopeKey);
79
+ if (!scopeMap) return 0;
80
+ var entry = scopeMap.get(cacheKey);
81
+ if (!entry) return {
82
+ total: 0,
83
+ current: 0
84
+ };
85
+ return {
86
+ total: Number(entry.total || 0),
87
+ current: Number(entry.current || 0)
88
+ };
89
+ },
90
+ // 清理作用域缓存
91
+ clearScope: function clearScope(scopeKey) {
92
+ if (!scopeKey) return;
93
+ store.delete(scopeKey);
94
+ },
95
+ // 清理所有缓存
96
+ clearAll: function clearAll() {
97
+ store.clear();
98
+ }
99
+ };
100
+ export default selectCache;
@@ -0,0 +1,4 @@
1
+ import type { ThSelectRequestProps } from './typing';
2
+ export declare const transformParams: (params: Record<string, any>, transformSearchKey?: string, searchOpt?: unknown) => Record<string, any> | undefined;
3
+ export declare function getList(requestProps?: ThSelectRequestProps, query?: Record<string, any>): Promise<any>;
4
+ export declare function getTransDict(data: Record<string, any>): Promise<any>;
@@ -0,0 +1,122 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["queryParams"];
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
+ import { request } from ".dumi/tmp/exports";
14
+ export var transformParams = function transformParams(params, transformSearchKey, searchOpt) {
15
+ if (!params) {
16
+ return;
17
+ }
18
+ Object.keys(params).forEach(function (key) {
19
+ var value = params[key];
20
+ if (value === undefined || value === null || value === '') {
21
+ delete params[key];
22
+ } else if (key === 'keyword') {
23
+ if (transformSearchKey) {
24
+ params[transformSearchKey] = {
25
+ opt: searchOpt || 'like',
26
+ values: [value]
27
+ };
28
+ delete params[key];
29
+ } else {
30
+ params[key] = {
31
+ opt: searchOpt || 'like',
32
+ values: [value]
33
+ };
34
+ }
35
+ } else {
36
+ params[key] = {
37
+ opt: 'eq',
38
+ values: [value]
39
+ };
40
+ }
41
+ });
42
+ return params;
43
+ };
44
+ export function getList(_x, _x2) {
45
+ return _getList.apply(this, arguments);
46
+ }
47
+ function _getList() {
48
+ _getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestProps, query) {
49
+ var _ref, url, _ref$method, method, transformSearchKey, searchOpt, _ref2, queryParams, searchParams, clonedQueryParams, transformedQueryParams, params;
50
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ _ref = requestProps || {}, url = _ref.url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, transformSearchKey = _ref.transformSearchKey, searchOpt = _ref.searchOpt;
54
+ if (url) {
55
+ _context.next = 3;
56
+ break;
57
+ }
58
+ throw new Error('url is required');
59
+ case 3:
60
+ _ref2 = query || {}, queryParams = _ref2.queryParams, searchParams = _objectWithoutProperties(_ref2, _excluded); // 避免修改原始 queryParams
61
+ clonedQueryParams = queryParams ? JSON.parse(JSON.stringify(queryParams)) : {};
62
+ transformedQueryParams = transformParams(clonedQueryParams, transformSearchKey, searchOpt) || {};
63
+ if (!(method.toUpperCase() === 'POST')) {
64
+ _context.next = 12;
65
+ break;
66
+ }
67
+ _context.next = 9;
68
+ return request(url, {
69
+ method: method,
70
+ data: _objectSpread(_objectSpread({}, searchParams), {}, {
71
+ queryPrams: transformedQueryParams
72
+ })
73
+ });
74
+ case 9:
75
+ return _context.abrupt("return", _context.sent);
76
+ case 12:
77
+ params = {};
78
+ if (query) {
79
+ Object.keys(query).forEach(function (key) {
80
+ if (key === 'keyword' && transformSearchKey) {
81
+ params[transformSearchKey] = query[key];
82
+ }
83
+ });
84
+ }
85
+ _context.next = 16;
86
+ return request(url, {
87
+ method: method,
88
+ params: params
89
+ });
90
+ case 16:
91
+ return _context.abrupt("return", _context.sent);
92
+ case 17:
93
+ case "end":
94
+ return _context.stop();
95
+ }
96
+ }, _callee);
97
+ }));
98
+ return _getList.apply(this, arguments);
99
+ }
100
+ export function getTransDict(_x3) {
101
+ return _getTransDict.apply(this, arguments);
102
+ }
103
+ function _getTransDict() {
104
+ _getTransDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
105
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
106
+ while (1) switch (_context2.prev = _context2.next) {
107
+ case 0:
108
+ _context2.next = 2;
109
+ return request('/wffzpt-service/dict/transDict', {
110
+ method: 'POST',
111
+ data: data
112
+ });
113
+ case 2:
114
+ return _context2.abrupt("return", _context2.sent);
115
+ case 3:
116
+ case "end":
117
+ return _context2.stop();
118
+ }
119
+ }, _callee2);
120
+ }));
121
+ return _getTransDict.apply(this, arguments);
122
+ }