gxxc-util 1.0.15 → 1.0.17

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/dist/cjs/index.js CHANGED
@@ -17,6 +17,7 @@ exports.author_router_filter = author.author_router_filter;
17
17
  exports.author_rsa = author.author_rsa;
18
18
  exports.author_strict = author.author_strict;
19
19
  exports.author_traceId = author.author_traceId;
20
+ exports.city_code_query_text = cityOptions.city_code_query_text;
20
21
  exports.city_code_text = cityOptions.city_code_text;
21
22
  exports.city_options = cityOptions.city_options;
22
23
  exports.city_two_code_text = cityOptions.city_two_code_text;
@@ -70,7 +70,31 @@ const city_code_text = (provinceId, cityId, districtId) => {
70
70
  }
71
71
  return cityName;
72
72
  };
73
+ /**
74
+ * 编码转城市,通过数组
75
+ */
76
+ const city_code_query_text = (cityIds) => {
77
+ if (cityIds == null)
78
+ cityIds = [];
79
+ const cityNames = [];
80
+ let cityList = city_options();
81
+ for (let cityId of cityIds) {
82
+ if (cityId === "000000") {
83
+ cityNames.push("全国");
84
+ break;
85
+ }
86
+ for (let cityItem of cityList) {
87
+ if (cityItem.value === cityId) {
88
+ cityNames.push(cityItem.label);
89
+ cityList = cityItem.children;
90
+ break;
91
+ }
92
+ }
93
+ }
94
+ return cityNames;
95
+ };
73
96
 
97
+ exports.city_code_query_text = city_code_query_text;
74
98
  exports.city_code_text = city_code_text;
75
99
  exports.city_options = city_options;
76
100
  exports.city_two_code_text = city_two_code_text;
@@ -180,8 +180,8 @@ const val_beforeAfter_space = (_, value) => {
180
180
  const val_address = (_rule, value) => {
181
181
  if (value) {
182
182
  const idAddressRegex = /^.{10,50}$/;
183
- if (/\s/.test(value)) {
184
- return Promise.reject(new Error("请去除文本前后及内容中的空格!"));
183
+ if (/^\s|\s$/g.test(value)) {
184
+ return Promise.reject(new Error("请去除文本前后中的空格!"));
185
185
  }
186
186
  else if (!idAddressRegex.test(value)) {
187
187
  return Promise.reject(new Error("地址格式10-50位!"));
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { author_passwordCheck, author_router_add, author_router_filter, author_rsa, author_strict, author_traceId } from './modules/author.js';
2
- export { city_code_text, city_options, city_two_code_text } from './modules/cityOptions.js';
2
+ export { city_code_query_text, city_code_text, city_options, city_two_code_text } from './modules/cityOptions.js';
3
3
  export { get_multiple_color, hex_to_rgb, reduce_opacity, rgb_to_hex, theme_change } from './modules/color.js';
4
4
  export { demo } from './modules/demo.js';
5
5
  export { file_calculate_md5, file_load, file_open } from './modules/file.js';
@@ -68,5 +68,28 @@ const city_code_text = (provinceId, cityId, districtId) => {
68
68
  }
69
69
  return cityName;
70
70
  };
71
+ /**
72
+ * 编码转城市,通过数组
73
+ */
74
+ const city_code_query_text = (cityIds) => {
75
+ if (cityIds == null)
76
+ cityIds = [];
77
+ const cityNames = [];
78
+ let cityList = city_options();
79
+ for (let cityId of cityIds) {
80
+ if (cityId === "000000") {
81
+ cityNames.push("全国");
82
+ break;
83
+ }
84
+ for (let cityItem of cityList) {
85
+ if (cityItem.value === cityId) {
86
+ cityNames.push(cityItem.label);
87
+ cityList = cityItem.children;
88
+ break;
89
+ }
90
+ }
91
+ }
92
+ return cityNames;
93
+ };
71
94
 
72
- export { city_code_text, city_options, city_two_code_text };
95
+ export { city_code_query_text, city_code_text, city_options, city_two_code_text };
@@ -178,8 +178,8 @@ const val_beforeAfter_space = (_, value) => {
178
178
  const val_address = (_rule, value) => {
179
179
  if (value) {
180
180
  const idAddressRegex = /^.{10,50}$/;
181
- if (/\s/.test(value)) {
182
- return Promise.reject(new Error("请去除文本前后及内容中的空格!"));
181
+ if (/^\s|\s$/g.test(value)) {
182
+ return Promise.reject(new Error("请去除文本前后中的空格!"));
183
183
  }
184
184
  else if (!idAddressRegex.test(value)) {
185
185
  return Promise.reject(new Error("地址格式10-50位!"));
@@ -1,5 +1,5 @@
1
1
  export { author_passwordCheck, author_router_add, author_router_filter, author_rsa, author_strict, author_traceId } from './modules/author.js';
2
- export { city_code_text, city_options, city_two_code_text } from './modules/cityOptions.js';
2
+ export { city_code_query_text, city_code_text, city_options, city_two_code_text } from './modules/cityOptions.js';
3
3
  export { get_multiple_color, hex_to_rgb, reduce_opacity, rgb_to_hex, theme_change } from './modules/color.js';
4
4
  export { demo } from './modules/demo.js';
5
5
  export { file_calculate_md5, file_load, file_open } from './modules/file.js';
@@ -22,5 +22,9 @@ declare const city_two_code_text: (provinceId: string, cityId?: string) => strin
22
22
  * 编码转城市,默认三级
23
23
  */
24
24
  declare const city_code_text: (provinceId: string, cityId?: string, districtId?: string) => string;
25
+ /**
26
+ * 编码转城市,通过数组
27
+ */
28
+ declare const city_code_query_text: (cityIds: []) => any[];
25
29
 
26
- export { city_code_text, city_options, city_two_code_text };
30
+ export { city_code_query_text, city_code_text, city_options, city_two_code_text };