jmash-region 0.1.4 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import { _ as f } from "./edit.vue_vue_type_script_setup_true_lang-GRPUbgJ5.mjs";
1
+ import { _ as f } from "./edit.vue_vue_type_script_setup_true_lang-Bl3mhGbV.mjs";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -4,7 +4,7 @@ var q = (n, i, g) => Dn(n, typeof i != "symbol" ? i + "" : i, g);
4
4
  import { ref as D, reactive as E, defineComponent as En, mergeModels as W, useModel as Nn, resolveComponent as k, openBlock as S, createBlock as A, withCtx as j, createElementVNode as Mn, createVNode as c, createTextVNode as Y, toDisplayString as H, unref as b, createElementBlock as Q, Fragment as J, renderList as X } from "vue";
5
5
  import { ElMessage as nn } from "element-plus";
6
6
  import { EnumDict as gn } from "jmash-core";
7
- import { d as I, e as Rn } from "./index-CsYjg_vi.mjs";
7
+ import { d as I, e as Rn } from "./index-20SqsuLj.mjs";
8
8
  import { useI18n as Zn } from "vue-i18n";
9
9
  class p {
10
10
  }
@@ -0,0 +1,373 @@
1
+ import { deepMerge as N, useUserStore as u, clearEmpty as m, request as g, qs as D, addViteMenus as M, i18n as B } from "jmash-core";
2
+ import { defineComponent as V, mergeModels as P, useModel as R, ref as x, watchEffect as S, resolveComponent as L, openBlock as k, createBlock as y, watch as w, mergeProps as z } from "vue";
3
+ const T = {}, A = {
4
+ common: {
5
+ delete: "删除",
6
+ confirm: "确认",
7
+ cancel: "取消",
8
+ confirmDelete: "确认删除此行吗?",
9
+ deleteSuccess: "删除成功"
10
+ },
11
+ // 地区信息
12
+ dictRegion: {
13
+ name: "地区信息",
14
+ addChild: "添加子地区",
15
+ parentId: "上级地区",
16
+ parentIdPlaceholder: "请选择上级地区",
17
+ regionCode: "地区编码",
18
+ regionCodePlaceholder: "请输入地区编码",
19
+ regionName: "地区名称",
20
+ regionNamePlaceholder: "请输入地区名称",
21
+ regionPinyin: "地区拼音",
22
+ regionPinyinPlaceholder: "请输入地区拼音",
23
+ regionType: "地区类型",
24
+ regionTypePlaceholder: "请选择地区类型",
25
+ regionCategory: "地区分类",
26
+ regionCategoryPlaceholder: "请选择地区分类",
27
+ enable: "是否启用",
28
+ enablePlaceholder: "请选择是否启用",
29
+ orderBy: "排序",
30
+ description: "描述",
31
+ descriptionPlaceholder: "请输入描述"
32
+ }
33
+ };
34
+ function E(l) {
35
+ let e = l.global.getLocaleMessage("zh-cn");
36
+ e = N(e, A);
37
+ let t = l.global.getLocaleMessage("en");
38
+ t = N(t, T), l.global.setLocaleMessage("zh-cn", e), l.global.setLocaleMessage("en", t);
39
+ }
40
+ class $ {
41
+ getKey(e) {
42
+ return {
43
+ regionId: e.regionId
44
+ };
45
+ }
46
+ // 查询列表信息地区信息
47
+ findList(e) {
48
+ const t = u().user.tenant;
49
+ return e && (e.hasEnable = (e == null ? void 0 : e.enable) !== void 0, e.hasParent = !1, ((e == null ? void 0 : e.enable) === !1 || e != null && e.likeRegionName) && (e.hasParent = !0)), m(e), g({
50
+ url: "/v1/region/dict_region/list/" + t,
51
+ method: "get",
52
+ params: e
53
+ });
54
+ }
55
+ // 根据地区编码查询地区信息
56
+ findByCode(e) {
57
+ const t = u().user.tenant;
58
+ return m(e), g({
59
+ url: `/v1/region/dict_region/code/${t}/${e.regionCode}`,
60
+ method: "get",
61
+ params: e
62
+ });
63
+ }
64
+ // 查询地区信息
65
+ findById(e) {
66
+ const t = u().user.tenant;
67
+ return m(e), g({
68
+ url: "/v1/region/dict_region/id/" + t + "/" + e.regionId,
69
+ method: "get"
70
+ });
71
+ }
72
+ // 创建实体地区信息
73
+ create(e) {
74
+ return e.tenant = u().user.tenant, m(e), g({
75
+ url: "/v1/region/dict_region",
76
+ method: "post",
77
+ data: e
78
+ });
79
+ }
80
+ // 修改实体地区信息
81
+ update(e) {
82
+ return e.tenant = u().user.tenant, m(e), g({
83
+ url: "/v1/region/dict_region",
84
+ method: "patch",
85
+ data: e
86
+ });
87
+ }
88
+ // 上移下移
89
+ move(e, t) {
90
+ const n = { ...e };
91
+ return n.tenant = u().user.tenant, n.up = t, m(n), g({
92
+ url: "/v1/region/dict_region/move",
93
+ method: "put",
94
+ data: n
95
+ });
96
+ }
97
+ // 启用/禁用
98
+ enable(e, t) {
99
+ const n = { ...e };
100
+ return n.tenant = u().user.tenant, n.enable = t, m(n), g({
101
+ url: "/v1/region/dict_region/enable",
102
+ method: "put",
103
+ data: n
104
+ });
105
+ }
106
+ // 删除地区信息
107
+ delete(e) {
108
+ return e.tenant = u().user.tenant, m(e), g({
109
+ url: "/v1/region/dict_region/id",
110
+ method: "delete",
111
+ params: e
112
+ });
113
+ }
114
+ // 下载导入模板地区信息
115
+ downloadTemplate() {
116
+ const e = u().user.tenant;
117
+ return g({
118
+ url: "/v1/region/dict_region/" + e + "/template.xlsx",
119
+ method: "get",
120
+ responseType: "blob",
121
+ params: {
122
+ tenant: u().user.tenant
123
+ }
124
+ });
125
+ }
126
+ // 导入地区信息
127
+ importExcel(e) {
128
+ return e.tenant = u().user.tenant, m(e), g({
129
+ url: "/v1/region/dict_region/import",
130
+ method: "patch",
131
+ data: e
132
+ });
133
+ }
134
+ // 导出地区信息Excel文件
135
+ exportExcel(e) {
136
+ const t = u().user.tenant;
137
+ m(e), e.req.hasParent = !0;
138
+ const n = D.stringify(e, {
139
+ arrayFormat: "brackets",
140
+ allowDots: !0
141
+ });
142
+ return g({
143
+ url: "/v1/region/dict_region/" + t + "/dict_regions.xlsx?" + n,
144
+ method: "get",
145
+ responseType: "blob"
146
+ });
147
+ }
148
+ }
149
+ const C = new $(), O = (l) => {
150
+ const e = {
151
+ regionIds: [],
152
+ regionCodes: []
153
+ }, t = (n) => {
154
+ e.regionIds.push(n.regionId), e.regionCodes.push(n.regionCode), n.children && n.children.length > 0 && n.children.forEach((p) => t(p));
155
+ };
156
+ return t(l), e;
157
+ }, U = /* @__PURE__ */ V({
158
+ __name: "index",
159
+ props: /* @__PURE__ */ P({
160
+ maxDepth: {
161
+ type: Number,
162
+ default: 10
163
+ }
164
+ }, {
165
+ modelValue: {},
166
+ modelModifiers: {}
167
+ }),
168
+ emits: ["update:modelValue"],
169
+ setup(l) {
170
+ const e = R(l, "modelValue"), t = l, n = x([]), p = () => {
171
+ C.findByCode({ regionCode: e.value }).then(({ data: r }) => {
172
+ const s = O(r);
173
+ n.value = s.regionCodes;
174
+ });
175
+ };
176
+ S(
177
+ () => e.value && !n.value.length && p()
178
+ );
179
+ const c = x([]), v = (r) => {
180
+ C.findList({
181
+ likeRegionName: r
182
+ }).then(({ data: s }) => {
183
+ c.value = s.results.map((i) => (i.hasChildren = !i.hasChildren || i.depth >= t.maxDepth, i));
184
+ });
185
+ }, b = () => {
186
+ n.value = [];
187
+ }, h = (r, s) => {
188
+ C.findList({
189
+ parentId: r.data.regionId
190
+ }).then(({ data: i }) => {
191
+ const _ = i.results.map((o) => (o.hasChildren = !o.hasChildren || o.depth >= t.maxDepth, o));
192
+ !r.data.regionId && (c.value = _), s(_);
193
+ });
194
+ };
195
+ return (r, s) => {
196
+ const i = L("el-tree-select");
197
+ return k(), y(i, {
198
+ lazy: "",
199
+ filterable: "",
200
+ modelValue: e.value,
201
+ "onUpdate:modelValue": s[0] || (s[0] = (_) => e.value = _),
202
+ "node-key": "regionCode",
203
+ load: h,
204
+ data: c.value,
205
+ "default-expanded-keys": n.value,
206
+ "filter-method": v,
207
+ onClear: b,
208
+ props: {
209
+ value: "regionCode",
210
+ label: "regionName",
211
+ isLeaf: "hasChildren",
212
+ children: "children"
213
+ }
214
+ }, null, 8, ["modelValue", "data", "default-expanded-keys"]);
215
+ };
216
+ }
217
+ }), F = /* @__PURE__ */ V({
218
+ __name: "index",
219
+ props: /* @__PURE__ */ P({
220
+ checkStrictly: {
221
+ type: Boolean,
222
+ default: !0
223
+ },
224
+ maxDepth: {
225
+ type: Number,
226
+ default: 10
227
+ }
228
+ }, {
229
+ modelValue: {},
230
+ modelModifiers: {}
231
+ }),
232
+ emits: ["update:modelValue"],
233
+ setup(l) {
234
+ const e = R(l, "modelValue"), t = l, n = {
235
+ lazy: !0,
236
+ // 开启懒加载
237
+ checkStrictly: t.checkStrictly,
238
+ // 选择任意一级选项
239
+ lazyLoad(h, r) {
240
+ var s;
241
+ C.findList({
242
+ parentId: (s = h.data) == null ? void 0 : s.regionId
243
+ }).then(({ data: i }) => {
244
+ r(b(i.results));
245
+ });
246
+ }
247
+ }, p = () => {
248
+ e.value = [], c.value = [];
249
+ }, c = x([]), v = (h) => (C.findList({
250
+ likeRegionName: h
251
+ }).then(({ data: r }) => {
252
+ c.value = b(r.results);
253
+ }), !1), b = (h) => h.map((r) => ({
254
+ label: r.regionName,
255
+ value: r.regionCode,
256
+ regionId: r.regionId,
257
+ leaf: !r.hasChildren || r.depth >= t.maxDepth
258
+ }));
259
+ return (h, r) => {
260
+ const s = L("el-cascader");
261
+ return k(), y(s, {
262
+ modelValue: e.value,
263
+ "onUpdate:modelValue": r[0] || (r[0] = (i) => e.value = i),
264
+ props: n,
265
+ options: c.value,
266
+ filterable: "",
267
+ onClear: p,
268
+ "before-filter": v
269
+ }, null, 8, ["modelValue", "options"]);
270
+ };
271
+ }
272
+ }), J = /* @__PURE__ */ V({
273
+ inheritAttrs: !1,
274
+ __name: "index",
275
+ props: {
276
+ checkStrictly: {
277
+ type: Boolean,
278
+ default: !0
279
+ },
280
+ modelValue: {
281
+ type: String,
282
+ default: ""
283
+ },
284
+ maxDepth: {
285
+ type: Number,
286
+ default: 10
287
+ }
288
+ },
289
+ setup(l, { emit: e }) {
290
+ const t = l, n = e, p = x([]), c = x([]);
291
+ w(
292
+ () => t.modelValue,
293
+ (o) => {
294
+ p.value = _(o);
295
+ },
296
+ { immediate: !0 }
297
+ // 初始化时执行一次
298
+ );
299
+ const v = x(), b = (o) => {
300
+ if (!o) {
301
+ n("update:modelValue", ""), n("change", [""]);
302
+ return;
303
+ }
304
+ if (n("update:modelValue", o[o.length - 1]), v.value.presentText) {
305
+ const a = v.value.presentText.split("/").map((d) => d.trim()).filter((d) => d);
306
+ n("change", a);
307
+ } else
308
+ n("change", [""]);
309
+ }, h = {
310
+ lazy: !0,
311
+ checkStrictly: t.checkStrictly,
312
+ lazyLoad(o, a) {
313
+ var I;
314
+ const d = ((I = o.data) == null ? void 0 : I.regionId) || "";
315
+ C.findList({ parentId: d }).then(({ data: f }) => {
316
+ a(i(f.results));
317
+ }).catch((f) => {
318
+ console.error("懒加载区域数据失败:", f), a([]);
319
+ });
320
+ }
321
+ }, r = () => {
322
+ p.value = [], n("update:modelValue", ""), n("change", [""]);
323
+ }, s = (o) => o.trim() ? (C.findList({ likeRegionName: o }).then(({ data: a }) => {
324
+ c.value = i(a.results);
325
+ }).catch((a) => {
326
+ console.error("过滤区域数据失败:", a), c.value = [];
327
+ }), !1) : (c.value = [], !1), i = (o) => o.map((a) => ({
328
+ label: a.regionName,
329
+ value: a.regionCode,
330
+ regionId: a.regionId,
331
+ leaf: !a.hasChildren || a.depth >= t.maxDepth
332
+ }));
333
+ function _(o = "", a = [2, 4, 6, 9, 12]) {
334
+ if (typeof o != "string" || o.length === 0)
335
+ return [];
336
+ (!Array.isArray(a) || a.some((f) => !Number.isInteger(f) || f < 1)) && (console.warn("拆分位置必须是正整数数组,已使用默认值"), a = [2, 4, 6, 9, 12]);
337
+ const d = [];
338
+ for (const f of a) {
339
+ if (f > o.length) break;
340
+ d.push(o.substring(0, f));
341
+ }
342
+ return d[d.length - 1] !== o && d.push(o), d;
343
+ }
344
+ return (o, a) => {
345
+ const d = L("el-cascader");
346
+ return k(), y(d, z({
347
+ modelValue: p.value,
348
+ "onUpdate:modelValue": a[0] || (a[0] = (I) => p.value = I),
349
+ props: h,
350
+ options: c.value,
351
+ filterable: "",
352
+ onClear: r,
353
+ "before-filter": s
354
+ }, o.$attrs, {
355
+ onChange: b,
356
+ ref_key: "cascaderRef",
357
+ ref: v
358
+ }), null, 16, ["modelValue", "options"]);
359
+ };
360
+ }
361
+ }), K = /* @__PURE__ */ Object.assign({ "./views/region/os-dict-region/edit.vue": () => import("./edit-B4wR0hYe.mjs"), "./views/region/os-dict-region/index.vue": () => import("./index-DI8rZY6z.mjs"), "./views/region/os-region-component/index.vue": () => import("./index-DP_DAk_H.mjs") }), H = {
362
+ install(l) {
363
+ M(K, 7), E(B), l.component("JmashRegionTree", U), l.component("JmashRegionCascader", F), l.component("JmashRegionCascader2", J);
364
+ }
365
+ };
366
+ export {
367
+ U as _,
368
+ F as a,
369
+ J as b,
370
+ H as c,
371
+ C as d,
372
+ O as e
373
+ };