@dhccmobile/vue3-lo-form 2.0.0 → 2.0.1

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.
Files changed (164) hide show
  1. package/README.md +70 -70
  2. package/dist/vue3-lo-form.common.js +1189 -1069
  3. package/dist/vue3-lo-form.common.js.map +1 -1
  4. package/dist/vue3-lo-form.umd.js +1189 -1069
  5. package/dist/vue3-lo-form.umd.js.map +1 -1
  6. package/dist/vue3-lo-form.umd.min.js +1 -1
  7. package/dist/vue3-lo-form.umd.min.js.map +1 -1
  8. package/package.json +73 -65
  9. package/src/App.vue +741 -741
  10. package/src/components/form/DvForm.vue +642 -642
  11. package/src/components/form/DvFormLayout.vue +1569 -1569
  12. package/src/components/form/StretchText.vue +90 -90
  13. package/src/components/index.ts +3 -3
  14. package/src/constants/config/form-template.config.ts +32 -32
  15. package/src/constants/config/form.config.ts +4 -4
  16. package/src/constants/config/storage.config.ts +4 -4
  17. package/src/constants/encode-assets/svg.ts +11 -11
  18. package/src/constants/enum/builtIn-label.enum.ts +5 -5
  19. package/src/constants/enum/cache-type.enum.ts +7 -7
  20. package/src/constants/enum/control-format-type.enum.ts +9 -9
  21. package/src/constants/enum/dynamic-option-type.enum.ts +6 -6
  22. package/src/constants/enum/form-bus-attr.enum.ts +8 -8
  23. package/src/constants/enum/form-field-class.enum.ts +7 -7
  24. package/src/constants/enum/form-field-type.enum.ts +25 -25
  25. package/src/constants/enum/form-type.enum.ts +5 -5
  26. package/src/constants/enum/index.ts +19 -19
  27. package/src/constants/enum/lateral-arrangement.enum.ts +9 -9
  28. package/src/constants/enum/money-unit.enum.ts +6 -6
  29. package/src/constants/enum/option-type.enum.ts +5 -5
  30. package/src/constants/enum/submitted-type.enum.ts +32 -32
  31. package/src/constants/enum/support-upload-type.enum.ts +5 -5
  32. package/src/constants/enum/switch.enum.ts +5 -5
  33. package/src/constants/enum/upload-type.enum.ts +17 -17
  34. package/src/constants/enum/validate-rules.enum.ts +25 -25
  35. package/src/constants/enum/validate-status.enum.ts +8 -8
  36. package/src/constants/enum/vertical-arrangement.enum.ts +7 -7
  37. package/src/constants/enum/zoom-type.ts +6 -6
  38. package/src/constants/index.ts +3 -3
  39. package/src/core/FormApi.ts +1238 -1238
  40. package/src/core/index.ts +1 -1
  41. package/src/domain/AbstractControl.ts +6 -6
  42. package/src/domain/Control.ts +14 -14
  43. package/src/domain/CustomFormat.ts +6 -6
  44. package/src/domain/DesForm.ts +48 -48
  45. package/src/domain/DesFormControl.ts +241 -241
  46. package/src/domain/DesFormLayout.ts +51 -51
  47. package/src/domain/FieldChangeHistory.ts +9 -9
  48. package/src/domain/FormConfig.ts +16 -15
  49. package/src/domain/FormControl.ts +125 -125
  50. package/src/domain/FormEnum.ts +9 -9
  51. package/src/domain/FormGroup.ts +42 -42
  52. package/src/domain/FormRestfulResponse.ts +6 -6
  53. package/src/domain/ProvideInjectData.ts +10 -10
  54. package/src/domain/SysDictDetail.ts +38 -38
  55. package/src/domain/SysDictInfo.ts +40 -40
  56. package/src/domain/SysDictTreeDetail.ts +52 -52
  57. package/src/domain/index.ts +12 -12
  58. package/src/filtres/amount-capitalization.filter.ts +154 -154
  59. package/src/filtres/extract-options.filter.ts +53 -53
  60. package/src/filtres/generate-grid-column-end.filter.ts +22 -22
  61. package/src/filtres/generate-grid-template-columns.filter.ts +24 -24
  62. package/src/filtres/switch-enum-convert.filter.ts +18 -18
  63. package/src/filtres/zoom-multiple.filter.ts +32 -32
  64. package/src/index.ts +74 -73
  65. package/src/main.ts +17 -17
  66. package/src/services/api.service.ts +73 -73
  67. package/src/services/clean-local-forage.service.ts +58 -58
  68. package/src/services/date-format.service.ts +74 -74
  69. package/src/services/dict-local-forage.service.ts +58 -58
  70. package/src/services/form-bean-utils.service.ts +41 -41
  71. package/src/services/form-local-forage.service.ts +59 -59
  72. package/src/services/form-tools.service.ts +739 -739
  73. package/src/services/form-tree-node-convert.service.ts +240 -240
  74. package/src/services/form-validate.service.ts +103 -103
  75. package/src/services/index.ts +9 -9
  76. package/src/services/router.service.ts +96 -96
  77. package/src/services/validate-generator.service.ts +710 -710
  78. package/src/shims-vue.d.ts +6 -6
  79. package/src/store/dict.store.ts +63 -63
  80. package/src/store/form.store.ts +32 -32
  81. package/src/store/index.ts +2 -2
  82. package/src/styles/datePicker.scss +125 -125
  83. package/src/styles/index.scss +195 -195
  84. package/src/styles/theme1.scss +277 -277
  85. package/src/styles/theme2.scss +376 -376
  86. package/src/styles/themes.scss +9 -9
  87. package/src/types/vfForm.ts +11 -11
  88. package/types/components/index.d.ts +3 -3
  89. package/types/constants/config/form-template.config.d.ts +30 -30
  90. package/types/constants/config/form.config.d.ts +4 -4
  91. package/types/constants/config/storage.config.d.ts +4 -4
  92. package/types/constants/encode-assets/svg.d.ts +5 -5
  93. package/types/constants/enum/builtIn-label.enum.d.ts +7 -7
  94. package/types/constants/enum/cache-type.enum.d.ts +15 -15
  95. package/types/constants/enum/control-format-type.enum.d.ts +23 -23
  96. package/types/constants/enum/dynamic-option-type.enum.d.ts +11 -11
  97. package/types/constants/enum/form-bus-attr.enum.d.ts +19 -19
  98. package/types/constants/enum/form-field-class.enum.d.ts +18 -18
  99. package/types/constants/enum/form-field-type.enum.d.ts +111 -111
  100. package/types/constants/enum/form-type.enum.d.ts +11 -11
  101. package/types/constants/enum/index.d.ts +19 -19
  102. package/types/constants/enum/lateral-arrangement.enum.d.ts +23 -23
  103. package/types/constants/enum/money-unit.enum.d.ts +15 -15
  104. package/types/constants/enum/option-type.enum.d.ts +11 -11
  105. package/types/constants/enum/submitted-type.enum.d.ts +115 -115
  106. package/types/constants/enum/support-upload-type.enum.d.ts +11 -11
  107. package/types/constants/enum/switch.enum.d.ts +11 -11
  108. package/types/constants/enum/upload-type.enum.d.ts +59 -59
  109. package/types/constants/enum/validate-rules.enum.d.ts +2 -2
  110. package/types/constants/enum/validate-status.enum.d.ts +2 -2
  111. package/types/constants/enum/vertical-arrangement.enum.d.ts +21 -21
  112. package/types/constants/enum/zoom-type.d.ts +15 -15
  113. package/types/constants/index.d.ts +3 -3
  114. package/types/core/FormApi.d.ts +376 -376
  115. package/types/core/index.d.ts +1 -1
  116. package/types/domain/AbstractControl.d.ts +5 -5
  117. package/types/domain/Control.d.ts +13 -13
  118. package/types/domain/CustomFormat.d.ts +5 -5
  119. package/types/domain/DesForm.d.ts +32 -32
  120. package/types/domain/DesFormControl.d.ts +160 -160
  121. package/types/domain/DesFormLayout.d.ts +33 -33
  122. package/types/domain/FieldChangeHistory.d.ts +9 -9
  123. package/types/domain/FormConfig.d.ts +16 -15
  124. package/types/domain/FormControl.d.ts +60 -60
  125. package/types/domain/FormEnum.d.ts +10 -10
  126. package/types/domain/FormGroup.d.ts +27 -27
  127. package/types/domain/FormRestfulResponse.d.ts +6 -6
  128. package/types/domain/ProvideInjectData.d.ts +10 -10
  129. package/types/domain/SysDictDetail.d.ts +24 -24
  130. package/types/domain/SysDictInfo.d.ts +26 -26
  131. package/types/domain/SysDictTreeDetail.d.ts +34 -34
  132. package/types/domain/index.d.ts +12 -12
  133. package/types/filtres/amount-capitalization.filter.d.ts +7 -7
  134. package/types/filtres/extract-options.filter.d.ts +13 -13
  135. package/types/filtres/generate-grid-column-end.filter.d.ts +11 -11
  136. package/types/filtres/generate-grid-template-columns.filter.d.ts +11 -11
  137. package/types/filtres/switch-enum-convert.filter.d.ts +2 -2
  138. package/types/filtres/zoom-multiple.filter.d.ts +3 -3
  139. package/types/index.d.ts +13 -13
  140. package/types/main.d.ts +2 -2
  141. package/types/services/api.service.d.ts +25 -25
  142. package/types/services/clean-local-forage.service.d.ts +28 -28
  143. package/types/services/date-format.service.d.ts +21 -21
  144. package/types/services/dict-local-forage.service.d.ts +28 -28
  145. package/types/services/form-bean-utils.service.d.ts +23 -23
  146. package/types/services/form-local-forage.service.d.ts +28 -28
  147. package/types/services/form-tools.service.d.ts +153 -153
  148. package/types/services/form-tree-node-convert.service.d.ts +104 -104
  149. package/types/services/form-validate.service.d.ts +32 -32
  150. package/types/services/index.d.ts +9 -9
  151. package/types/services/router.service.d.ts +40 -40
  152. package/types/services/validate-generator.service.d.ts +154 -154
  153. package/types/store/dict.store.d.ts +29 -29
  154. package/types/store/form.store.d.ts +17 -17
  155. package/types/store/index.d.ts +2 -2
  156. package/types/types/vfForm.d.ts +10 -10
  157. package/.env.local.bak +0 -6
  158. package/.eslintrc.js +0 -28
  159. package/babel.config.js +0 -3
  160. package/public/favicon.ico +0 -0
  161. package/public/index.html +0 -17
  162. package/public/js/pinyin.ts +0 -101
  163. package/tsconfig.json +0 -40
  164. package/vue.config.js +0 -38
@@ -1,40 +1,40 @@
1
- import { SysDictDetail } from "./SysDictDetail";
2
- import { SysDictTreeDetail } from "./SysDictTreeDetail";
3
-
4
- export class SysDictInfo {
5
- dictId: string;
6
- tenantId: string;
7
- appId: string;
8
- dictCd: string;
9
- dictNm: string;
10
- dictTp: string;
11
- useState: string;
12
- mark: string;
13
- comDictKeyValues: SysDictDetail[];
14
- treeDictKeyValues: SysDictTreeDetail[];
15
- constructor(
16
- options: {
17
- dictId?: string;
18
- tenantId?: string;
19
- appId?: string;
20
- dictCd?: string;
21
- dictNm?: string;
22
- dictTp?: string;
23
- useState?: string;
24
- mark?: string;
25
- comDictKeyValues?: SysDictDetail[];
26
- treeDictKeyValues?: SysDictTreeDetail[];
27
- } = {}
28
- ) {
29
- this.dictId = options.dictId || '';
30
- this.tenantId = options.tenantId || '';
31
- this.appId = options.appId || '';
32
- this.dictCd = options.dictCd || '';
33
- this.dictNm = options.dictNm || '';
34
- this.dictTp = options.dictTp || '';
35
- this.useState = options.useState || '';
36
- this.mark = options.mark || '';
37
- this.comDictKeyValues = options.comDictKeyValues || [];
38
- this.treeDictKeyValues = options.treeDictKeyValues || [];
39
- }
40
- }
1
+ import { SysDictDetail } from "./SysDictDetail";
2
+ import { SysDictTreeDetail } from "./SysDictTreeDetail";
3
+
4
+ export class SysDictInfo {
5
+ dictId: string;
6
+ tenantId: string;
7
+ appId: string;
8
+ dictCd: string;
9
+ dictNm: string;
10
+ dictTp: string;
11
+ useState: string;
12
+ mark: string;
13
+ comDictKeyValues: SysDictDetail[];
14
+ treeDictKeyValues: SysDictTreeDetail[];
15
+ constructor(
16
+ options: {
17
+ dictId?: string;
18
+ tenantId?: string;
19
+ appId?: string;
20
+ dictCd?: string;
21
+ dictNm?: string;
22
+ dictTp?: string;
23
+ useState?: string;
24
+ mark?: string;
25
+ comDictKeyValues?: SysDictDetail[];
26
+ treeDictKeyValues?: SysDictTreeDetail[];
27
+ } = {}
28
+ ) {
29
+ this.dictId = options.dictId || '';
30
+ this.tenantId = options.tenantId || '';
31
+ this.appId = options.appId || '';
32
+ this.dictCd = options.dictCd || '';
33
+ this.dictNm = options.dictNm || '';
34
+ this.dictTp = options.dictTp || '';
35
+ this.useState = options.useState || '';
36
+ this.mark = options.mark || '';
37
+ this.comDictKeyValues = options.comDictKeyValues || [];
38
+ this.treeDictKeyValues = options.treeDictKeyValues || [];
39
+ }
40
+ }
@@ -1,52 +1,52 @@
1
- export class SysDictTreeDetail {
2
- dictId: string;
3
- appId: string;
4
- dicEntryPk: string;
5
- dataId: string;
6
- dicEntryRank: string;
7
- dictCd: string;
8
- dictNm: string;
9
- dicKey: string;
10
- dicValue: string;
11
- suprDicPk: string;
12
- treedictLevel: string;
13
- isLeaf: string;
14
- sortNo: string;
15
- useState: string;
16
- children: SysDictTreeDetail[];
17
- constructor(
18
- options: {
19
- dictId?: string;
20
- appId?: string;
21
- dicEntryPk?: string;
22
- dataId?: string;
23
- dicEntryRank?: string;
24
- dictCd?: string;
25
- dictNm?: string;
26
- dicKey?: string;
27
- dicValue?: string;
28
- suprDicPk?: string;
29
- treedictLevel?: string;
30
- isLeaf?: string;
31
- sortNo?: string;
32
- useState?: string;
33
- children?: SysDictTreeDetail[]
34
- } = {}
35
- ) {
36
- this.dictId = options.dictId || '';
37
- this.appId = options.appId || '';
38
- this.dicEntryPk = options.dicEntryPk || '';
39
- this.dataId = options.dataId || '';
40
- this.dicEntryRank = options.dicEntryRank || '';
41
- this.dictCd = options.dictCd || '';
42
- this.dictNm = options.dictNm || '';
43
- this.dicKey = options.dicKey || '';
44
- this.dicValue = options.dicValue || '';
45
- this.suprDicPk = options.suprDicPk || '';
46
- this.treedictLevel = options.treedictLevel || '';
47
- this.isLeaf = options.isLeaf || '';
48
- this.sortNo = options.sortNo || '';
49
- this.useState = options.useState || '';
50
- this.children = options.children || [];
51
- }
52
- }
1
+ export class SysDictTreeDetail {
2
+ dictId: string;
3
+ appId: string;
4
+ dicEntryPk: string;
5
+ dataId: string;
6
+ dicEntryRank: string;
7
+ dictCd: string;
8
+ dictNm: string;
9
+ dicKey: string;
10
+ dicValue: string;
11
+ suprDicPk: string;
12
+ treedictLevel: string;
13
+ isLeaf: string;
14
+ sortNo: string;
15
+ useState: string;
16
+ children: SysDictTreeDetail[];
17
+ constructor(
18
+ options: {
19
+ dictId?: string;
20
+ appId?: string;
21
+ dicEntryPk?: string;
22
+ dataId?: string;
23
+ dicEntryRank?: string;
24
+ dictCd?: string;
25
+ dictNm?: string;
26
+ dicKey?: string;
27
+ dicValue?: string;
28
+ suprDicPk?: string;
29
+ treedictLevel?: string;
30
+ isLeaf?: string;
31
+ sortNo?: string;
32
+ useState?: string;
33
+ children?: SysDictTreeDetail[]
34
+ } = {}
35
+ ) {
36
+ this.dictId = options.dictId || '';
37
+ this.appId = options.appId || '';
38
+ this.dicEntryPk = options.dicEntryPk || '';
39
+ this.dataId = options.dataId || '';
40
+ this.dicEntryRank = options.dicEntryRank || '';
41
+ this.dictCd = options.dictCd || '';
42
+ this.dictNm = options.dictNm || '';
43
+ this.dicKey = options.dicKey || '';
44
+ this.dicValue = options.dicValue || '';
45
+ this.suprDicPk = options.suprDicPk || '';
46
+ this.treedictLevel = options.treedictLevel || '';
47
+ this.isLeaf = options.isLeaf || '';
48
+ this.sortNo = options.sortNo || '';
49
+ this.useState = options.useState || '';
50
+ this.children = options.children || [];
51
+ }
52
+ }
@@ -1,12 +1,12 @@
1
- export * from "./DesFormControl";
2
- export * from "./Control";
3
- export * from "./DesForm";
4
- export * from "./DesFormControl";
5
- export * from "./DesFormLayout";
6
- export * from "./FormConfig";
7
- export * from "./FormControl";
8
- export * from "./FormEnum";
9
- export * from "./FormGroup";
10
- export * from "./FormRestfulResponse";
11
- export * from "./CustomFormat";
12
- export * from "./FieldChangeHistory";
1
+ export * from "./DesFormControl";
2
+ export * from "./Control";
3
+ export * from "./DesForm";
4
+ export * from "./DesFormControl";
5
+ export * from "./DesFormLayout";
6
+ export * from "./FormConfig";
7
+ export * from "./FormControl";
8
+ export * from "./FormEnum";
9
+ export * from "./FormGroup";
10
+ export * from "./FormRestfulResponse";
11
+ export * from "./CustomFormat";
12
+ export * from "./FieldChangeHistory";
@@ -1,154 +1,154 @@
1
- function transform(currencyDigits: any): any {
2
- // Constants:
3
- const MAXIMUM_NUMBER = 999999999999.99;
4
- // Predefine the radix characters and currency symbols for output:
5
- const CN_ZERO = "零";
6
- const CN_ONE = "壹";
7
- const CN_TWO = "贰";
8
- const CN_THREE = "叁";
9
- const CN_FOUR = "肆";
10
- const CN_FIVE = "伍";
11
- const CN_SIX = "陆";
12
- const CN_SEVEN = "柒";
13
- const CN_EIGHT = "捌";
14
- const CN_NINE = "玖";
15
- const CN_TEN = "拾";
16
- const CN_HUNDRED = "佰";
17
- const CN_THOUSAND = "仟";
18
- const CN_TEN_THOUSAND = "万";
19
- const CN_HUNDRED_MILLION = "亿";
20
- // 满足数字大写转换需求
21
- const CN_SYMBOL = ""; // 不带前缀【金额:】
22
- const CN_DOLLAR = ""; // 元
23
- const DROP = "点"; // 点 2023年8月31日10:51:25
24
- const CN_TEN_CENT = ""; // 角
25
- const CN_CENT = ""; // 分
26
- const CN_INTEGER = ""; // 整
27
-
28
- // constiables:
29
- let integral; // Represent integral part of digit number.
30
- let decimal; // Represent decimal part of digit number.
31
- let outputCharacters; // The output result.
32
- let parts = [];
33
- let digits = [],
34
- radices = [],
35
- bigRadices = [],
36
- decimals = [];
37
- let zeroCount;
38
- let i, p, d;
39
- let quotient, modulus;
40
-
41
- // Validate input string:
42
- currencyDigits = currencyDigits != undefined ? currencyDigits.toString() : "";
43
-
44
- let prefix = "";
45
- if (currencyDigits != null && currencyDigits.indexOf("-") === 0) {
46
- prefix = "负";
47
- currencyDigits = currencyDigits.substr(1);
48
- }
49
- if (currencyDigits === "") {
50
- return "空"; // 默认提示
51
- }
52
- if (currencyDigits.match(/[^,.\d]/) != null) {
53
- return "您的输入含有无效字符";
54
- }
55
- if (currencyDigits.match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
56
- return "您的输入的数字格式不正确";
57
- }
58
-
59
- // Normalize the format of input digits:
60
- currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
61
- currencyDigits = currencyDigits.replace(/^0+/, ""); // Trim zeros at the beginning.
62
- // Assert the number is not greater than the maximum number.
63
- if (Number(currencyDigits) > MAXIMUM_NUMBER) {
64
- let divisor = 1000000000000;
65
- if (currencyDigits.indexOf(".") > -1) {
66
- const num = currencyDigits.split(".")[1].length;
67
- for (let i = 0; i < num; i++) {
68
- divisor = divisor * 10;
69
- }
70
- currencyDigits = currencyDigits.replace(".", "");
71
- }
72
- return Number(currencyDigits) / Number(divisor) + "万亿元";
73
- }
74
-
75
- // Process the coversion from currency digits to characters:
76
- // Separate integral and decimal parts before processing coversion:
77
- parts = currencyDigits.split(".");
78
- if (parts.length > 1) {
79
- integral = parts[0];
80
- decimal = parts[1];
81
- // Cut down redundant decimal digits that are after the second.
82
- decimal = decimal.substr(0, 2);
83
- } else {
84
- integral = parts[0];
85
- decimal = "";
86
- }
87
- // Prepare the characters corresponding to the digits:
88
- digits = [CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE];
89
- radices = ["", CN_TEN, CN_HUNDRED, CN_THOUSAND];
90
- bigRadices = ["", CN_TEN_THOUSAND, CN_HUNDRED_MILLION];
91
- decimals = [CN_TEN_CENT, CN_CENT];
92
- // Start processing:
93
- outputCharacters = "";
94
- // Process integral part if it is larger than 0:
95
- if (Number(integral) > 0) {
96
- zeroCount = 0;
97
- for (i = 0; i < integral.length; i++) {
98
- p = integral.length - i - 1;
99
- d = integral.substr(i, 1);
100
- quotient = p / 4;
101
- modulus = p % 4;
102
- if (d === "0") {
103
- zeroCount++;
104
- } else {
105
- if (zeroCount > 0) {
106
- outputCharacters += digits[0];
107
- }
108
- zeroCount = 0;
109
- outputCharacters += digits[Number(d)] + radices[modulus];
110
- }
111
- if (modulus === 0 && zeroCount < 4) {
112
- outputCharacters += bigRadices[quotient];
113
- zeroCount = 0;
114
- }
115
- }
116
- // outputCharacters += CN_DOLLAR; // 原来的【元】
117
- } else {
118
- //整数位为'零'
119
- outputCharacters = digits[Number(integral)];
120
- }
121
- // Process decimal part if there is:
122
- //校验小数位是否有值
123
- if (decimal !== "" && decimal !== "0" && decimal !== "00") {
124
- outputCharacters += DROP; // new 2023年8月31日10:52:54
125
- for (i = 0; i < decimal.length; i++) {
126
- d = decimal.substr(i, 1);
127
- if (d !== "0") {
128
- outputCharacters += digits[Number(d)] + decimals[i];
129
- } else if (i === 0) {
130
- //处理金额十分位数值为0时的大写转换
131
- outputCharacters += digits[Number(d)];
132
- }
133
- }
134
- }
135
- // Confirm and return the final output string:
136
- if (outputCharacters === "") {
137
- outputCharacters = CN_ZERO + CN_DOLLAR;
138
- }
139
- if (decimal === "") {
140
- outputCharacters += CN_INTEGER;
141
- }
142
- outputCharacters = CN_SYMBOL + prefix + outputCharacters;
143
- return outputCharacters;
144
- }
145
- /**
146
- * @description: 跨列计算
147
- * @author ChenRui
148
- * @date 2020/12/1 19:34
149
- */
150
- const amountCapitalization = (data: any) => {
151
- return transform(data);
152
- };
153
-
154
- export default amountCapitalization;
1
+ function transform(currencyDigits: any): any {
2
+ // Constants:
3
+ const MAXIMUM_NUMBER = 999999999999.99;
4
+ // Predefine the radix characters and currency symbols for output:
5
+ const CN_ZERO = "零";
6
+ const CN_ONE = "壹";
7
+ const CN_TWO = "贰";
8
+ const CN_THREE = "叁";
9
+ const CN_FOUR = "肆";
10
+ const CN_FIVE = "伍";
11
+ const CN_SIX = "陆";
12
+ const CN_SEVEN = "柒";
13
+ const CN_EIGHT = "捌";
14
+ const CN_NINE = "玖";
15
+ const CN_TEN = "拾";
16
+ const CN_HUNDRED = "佰";
17
+ const CN_THOUSAND = "仟";
18
+ const CN_TEN_THOUSAND = "万";
19
+ const CN_HUNDRED_MILLION = "亿";
20
+ // 满足数字大写转换需求
21
+ const CN_SYMBOL = ""; // 不带前缀【金额:】
22
+ const CN_DOLLAR = ""; // 元
23
+ const DROP = "点"; // 点 2023年8月31日10:51:25
24
+ const CN_TEN_CENT = ""; // 角
25
+ const CN_CENT = ""; // 分
26
+ const CN_INTEGER = ""; // 整
27
+
28
+ // constiables:
29
+ let integral; // Represent integral part of digit number.
30
+ let decimal; // Represent decimal part of digit number.
31
+ let outputCharacters; // The output result.
32
+ let parts = [];
33
+ let digits = [],
34
+ radices = [],
35
+ bigRadices = [],
36
+ decimals = [];
37
+ let zeroCount;
38
+ let i, p, d;
39
+ let quotient, modulus;
40
+
41
+ // Validate input string:
42
+ currencyDigits = currencyDigits != undefined ? currencyDigits.toString() : "";
43
+
44
+ let prefix = "";
45
+ if (currencyDigits != null && currencyDigits.indexOf("-") === 0) {
46
+ prefix = "负";
47
+ currencyDigits = currencyDigits.substr(1);
48
+ }
49
+ if (currencyDigits === "") {
50
+ return "空"; // 默认提示
51
+ }
52
+ if (currencyDigits.match(/[^,.\d]/) != null) {
53
+ return "您的输入含有无效字符";
54
+ }
55
+ if (currencyDigits.match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
56
+ return "您的输入的数字格式不正确";
57
+ }
58
+
59
+ // Normalize the format of input digits:
60
+ currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
61
+ currencyDigits = currencyDigits.replace(/^0+/, ""); // Trim zeros at the beginning.
62
+ // Assert the number is not greater than the maximum number.
63
+ if (Number(currencyDigits) > MAXIMUM_NUMBER) {
64
+ let divisor = 1000000000000;
65
+ if (currencyDigits.indexOf(".") > -1) {
66
+ const num = currencyDigits.split(".")[1].length;
67
+ for (let i = 0; i < num; i++) {
68
+ divisor = divisor * 10;
69
+ }
70
+ currencyDigits = currencyDigits.replace(".", "");
71
+ }
72
+ return Number(currencyDigits) / Number(divisor) + "万亿元";
73
+ }
74
+
75
+ // Process the coversion from currency digits to characters:
76
+ // Separate integral and decimal parts before processing coversion:
77
+ parts = currencyDigits.split(".");
78
+ if (parts.length > 1) {
79
+ integral = parts[0];
80
+ decimal = parts[1];
81
+ // Cut down redundant decimal digits that are after the second.
82
+ decimal = decimal.substr(0, 2);
83
+ } else {
84
+ integral = parts[0];
85
+ decimal = "";
86
+ }
87
+ // Prepare the characters corresponding to the digits:
88
+ digits = [CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE];
89
+ radices = ["", CN_TEN, CN_HUNDRED, CN_THOUSAND];
90
+ bigRadices = ["", CN_TEN_THOUSAND, CN_HUNDRED_MILLION];
91
+ decimals = [CN_TEN_CENT, CN_CENT];
92
+ // Start processing:
93
+ outputCharacters = "";
94
+ // Process integral part if it is larger than 0:
95
+ if (Number(integral) > 0) {
96
+ zeroCount = 0;
97
+ for (i = 0; i < integral.length; i++) {
98
+ p = integral.length - i - 1;
99
+ d = integral.substr(i, 1);
100
+ quotient = p / 4;
101
+ modulus = p % 4;
102
+ if (d === "0") {
103
+ zeroCount++;
104
+ } else {
105
+ if (zeroCount > 0) {
106
+ outputCharacters += digits[0];
107
+ }
108
+ zeroCount = 0;
109
+ outputCharacters += digits[Number(d)] + radices[modulus];
110
+ }
111
+ if (modulus === 0 && zeroCount < 4) {
112
+ outputCharacters += bigRadices[quotient];
113
+ zeroCount = 0;
114
+ }
115
+ }
116
+ // outputCharacters += CN_DOLLAR; // 原来的【元】
117
+ } else {
118
+ //整数位为'零'
119
+ outputCharacters = digits[Number(integral)];
120
+ }
121
+ // Process decimal part if there is:
122
+ //校验小数位是否有值
123
+ if (decimal !== "" && decimal !== "0" && decimal !== "00") {
124
+ outputCharacters += DROP; // new 2023年8月31日10:52:54
125
+ for (i = 0; i < decimal.length; i++) {
126
+ d = decimal.substr(i, 1);
127
+ if (d !== "0") {
128
+ outputCharacters += digits[Number(d)] + decimals[i];
129
+ } else if (i === 0) {
130
+ //处理金额十分位数值为0时的大写转换
131
+ outputCharacters += digits[Number(d)];
132
+ }
133
+ }
134
+ }
135
+ // Confirm and return the final output string:
136
+ if (outputCharacters === "") {
137
+ outputCharacters = CN_ZERO + CN_DOLLAR;
138
+ }
139
+ if (decimal === "") {
140
+ outputCharacters += CN_INTEGER;
141
+ }
142
+ outputCharacters = CN_SYMBOL + prefix + outputCharacters;
143
+ return outputCharacters;
144
+ }
145
+ /**
146
+ * @description: 跨列计算
147
+ * @author ChenRui
148
+ * @date 2020/12/1 19:34
149
+ */
150
+ const amountCapitalization = (data: any) => {
151
+ return transform(data);
152
+ };
153
+
154
+ export default amountCapitalization;
@@ -1,53 +1,53 @@
1
- import { OptionType } from "../constants/enum/option-type.enum";
2
- import { DynamicOptionType } from "../constants/enum/dynamic-option-type.enum";
3
-
4
- function transformReverse(controlAttr: any, data: any[]): void {
5
- if (data == null) {
6
- data = [];
7
- }
8
- if (controlAttr != null) {
9
- if (controlAttr.isOptionType === OptionType.Fixed.code) {
10
- controlAttr.optionConfig = data;
11
- } else if (controlAttr.isOptionType === OptionType.Dynamic.code) {
12
- if (controlAttr.dynamicOptionType === DynamicOptionType.GeneralDictionary.code) {
13
- controlAttr.generalDictionaryOptions = data;
14
- } else if (controlAttr.dynamicOptionType === DynamicOptionType.TreeDictionary.code) {
15
- controlAttr.treeShapeOptions = data;
16
- }
17
- }
18
- }
19
- }
20
-
21
- function transform(controlAttr: any): any[] {
22
- if (controlAttr != null) {
23
- if (controlAttr.isOptionType === OptionType.Fixed.code) {
24
- return controlAttr.optionConfig || [];
25
- } else if (controlAttr.isOptionType === OptionType.Dynamic.code) {
26
- if (controlAttr.dynamicOptionType === DynamicOptionType.GeneralDictionary.code) {
27
- return controlAttr.generalDictionaryOptions || [];
28
- } else if (controlAttr.dynamicOptionType === DynamicOptionType.TreeDictionary.code) {
29
- return controlAttr.treeShapeOptions || [];
30
- }
31
- }
32
- }
33
- return [];
34
- }
35
-
36
- /**
37
- * @description: 根据字典类型获取可选项
38
- * @author ChenRui
39
- * @date 2020/12/30 11:18
40
- */
41
- const extractOptions = (controlAttr: any, ...args: any[]): any[] => {
42
- return transform(controlAttr);
43
- };
44
-
45
- /**
46
- * @description: 保存可选项
47
- * @author ChenRui
48
- * @date 2021/1/29 16:17
49
- */
50
- const storageOptions = (controlAttr: any, data: any[]): void => {
51
- return transformReverse(controlAttr, data);
52
- };
53
- export { storageOptions, extractOptions };
1
+ import { OptionType } from "../constants/enum/option-type.enum";
2
+ import { DynamicOptionType } from "../constants/enum/dynamic-option-type.enum";
3
+
4
+ function transformReverse(controlAttr: any, data: any[]): void {
5
+ if (data == null) {
6
+ data = [];
7
+ }
8
+ if (controlAttr != null) {
9
+ if (controlAttr.isOptionType === OptionType.Fixed.code) {
10
+ controlAttr.optionConfig = data;
11
+ } else if (controlAttr.isOptionType === OptionType.Dynamic.code) {
12
+ if (controlAttr.dynamicOptionType === DynamicOptionType.GeneralDictionary.code) {
13
+ controlAttr.generalDictionaryOptions = data;
14
+ } else if (controlAttr.dynamicOptionType === DynamicOptionType.TreeDictionary.code) {
15
+ controlAttr.treeShapeOptions = data;
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ function transform(controlAttr: any): any[] {
22
+ if (controlAttr != null) {
23
+ if (controlAttr.isOptionType === OptionType.Fixed.code) {
24
+ return controlAttr.optionConfig || [];
25
+ } else if (controlAttr.isOptionType === OptionType.Dynamic.code) {
26
+ if (controlAttr.dynamicOptionType === DynamicOptionType.GeneralDictionary.code) {
27
+ return controlAttr.generalDictionaryOptions || [];
28
+ } else if (controlAttr.dynamicOptionType === DynamicOptionType.TreeDictionary.code) {
29
+ return controlAttr.treeShapeOptions || [];
30
+ }
31
+ }
32
+ }
33
+ return [];
34
+ }
35
+
36
+ /**
37
+ * @description: 根据字典类型获取可选项
38
+ * @author ChenRui
39
+ * @date 2020/12/30 11:18
40
+ */
41
+ const extractOptions = (controlAttr: any, ...args: any[]): any[] => {
42
+ return transform(controlAttr);
43
+ };
44
+
45
+ /**
46
+ * @description: 保存可选项
47
+ * @author ChenRui
48
+ * @date 2021/1/29 16:17
49
+ */
50
+ const storageOptions = (controlAttr: any, data: any[]): void => {
51
+ return transformReverse(controlAttr, data);
52
+ };
53
+ export { storageOptions, extractOptions };