@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,74 +1,74 @@
1
- /* eslint-disable */
2
- class DateFormatService {
3
- /**
4
- * 日期时间格式自定义
5
- * @param {number|string} value 日期时间值时间戳或时间格式
6
- * @param {string} format 输出的时间格式
7
- * @returns {string} 定义好的时间格式
8
- */
9
- formatDateTime(value: any, format = 'YYYY-MM-dd HH:mm:ss'): string {
10
- const reg = /(YY|YYYY|MM|dd|HH|mm|ss|ww|WW)/g;
11
- if (!value) {
12
- return ''
13
- }
14
- if (!reg.test(format)) {
15
- throw new Error(`The defined format ${format} is incorrect,Please enter 'YYYY or YY' for year,MM for month, dd for day,ww or WW for week,HH for hours,mm for minutes,ss for seconds.`)
16
- }
17
- if (typeof value === 'string' && value.length === 8) {
18
- value = [value.substr(0, 4), value.substr(4, 2), value.substr(6, 2)].join('/')
19
- } else if (!isNaN(Number(value))) {
20
- value = Number(value);
21
- }
22
- const time = new Date(value);
23
- if (String(time) === 'Invalid Date') {
24
- throw new Error(`Time format unrecognized by ${value}, Please enter time stamp or legal time format.`);
25
- }
26
- const dayMap = ['日', '一', '二', '三', '四', '五', '六'];
27
- const year = String(time.getFullYear());
28
- const month = time.getMonth() + 1 > 9 ? String(time.getMonth() + 1) : `0${String(time.getMonth() + 1)}`;
29
- const date = time.getDate() > 9 ? String(time.getDate()) : `0${String(time.getDate())}`;
30
- const day = time.getDay();
31
- const week: any = day !== 0 ? day : '日';
32
- const hours = time.getHours() > 9 ? String(time.getHours()) : `0${String(time.getHours())}`;
33
- const minutes = time.getMinutes() > 9 ? String(time.getMinutes()) : `0${time.getMinutes()}`;
34
- const seconds = time.getSeconds() > 9 ? String(time.getSeconds()) : `0${String(time.getSeconds())}`;
35
- let str = '';
36
- if (/YYYY|YY/g.test(format)) {
37
- format.replace(/YYYY|YY/g, (reg, index, value) => {
38
- if (reg === 'YY') {
39
- str = value.replace('YY', year.slice(2))
40
- }
41
- if (reg === 'YYYY') {
42
- str = value.replace('YYYY', year)
43
- }
44
- return str
45
- })
46
- } else {
47
- str = format
48
- }
49
- str = str.replace(/MM/g, month);
50
- str = str.replace(/dd/g, date);
51
- str = str.replace(/HH/g, hours);
52
- str = str.replace(/mm/g, minutes);
53
- str = str.replace(/ss/g, seconds);
54
- str = str.replace(/ww/g, week);
55
- str = str.replace(/WW/g, dayMap[day]);
56
- return str
57
- }
58
-
59
- /**
60
- * @Description:两个日期大小比较(开始时间 > 结束时间,返回true)
61
- * @author LiuBo
62
- * @date 2022/7/15
63
- * @time 10:43
64
- * @param startTime 开始时间 (YYYY-MM-DD)
65
- * @param endTime 结束时间 (YYYY-MM-DD)
66
- * @modifyLog
67
- */
68
- dateSizeCompare(startTime: string,endTime: string): boolean {
69
- return new Date(Date.parse(startTime.replace(/-/g,"/"))).getTime() >
70
- new Date(Date.parse(endTime.replace(/-/g,"/"))).getTime();
71
- }
72
- }
73
- const dateFormat: DateFormatService = new DateFormatService();
74
- export { dateFormat };
1
+ /* eslint-disable */
2
+ class DateFormatService {
3
+ /**
4
+ * 日期时间格式自定义
5
+ * @param {number|string} value 日期时间值时间戳或时间格式
6
+ * @param {string} format 输出的时间格式
7
+ * @returns {string} 定义好的时间格式
8
+ */
9
+ formatDateTime(value: any, format = 'YYYY-MM-dd HH:mm:ss'): string {
10
+ const reg = /(YY|YYYY|MM|dd|HH|mm|ss|ww|WW)/g;
11
+ if (!value) {
12
+ return ''
13
+ }
14
+ if (!reg.test(format)) {
15
+ throw new Error(`The defined format ${format} is incorrect,Please enter 'YYYY or YY' for year,MM for month, dd for day,ww or WW for week,HH for hours,mm for minutes,ss for seconds.`)
16
+ }
17
+ if (typeof value === 'string' && value.length === 8) {
18
+ value = [value.substr(0, 4), value.substr(4, 2), value.substr(6, 2)].join('/')
19
+ } else if (!isNaN(Number(value))) {
20
+ value = Number(value);
21
+ }
22
+ const time = new Date(value);
23
+ if (String(time) === 'Invalid Date') {
24
+ throw new Error(`Time format unrecognized by ${value}, Please enter time stamp or legal time format.`);
25
+ }
26
+ const dayMap = ['日', '一', '二', '三', '四', '五', '六'];
27
+ const year = String(time.getFullYear());
28
+ const month = time.getMonth() + 1 > 9 ? String(time.getMonth() + 1) : `0${String(time.getMonth() + 1)}`;
29
+ const date = time.getDate() > 9 ? String(time.getDate()) : `0${String(time.getDate())}`;
30
+ const day = time.getDay();
31
+ const week: any = day !== 0 ? day : '日';
32
+ const hours = time.getHours() > 9 ? String(time.getHours()) : `0${String(time.getHours())}`;
33
+ const minutes = time.getMinutes() > 9 ? String(time.getMinutes()) : `0${time.getMinutes()}`;
34
+ const seconds = time.getSeconds() > 9 ? String(time.getSeconds()) : `0${String(time.getSeconds())}`;
35
+ let str = '';
36
+ if (/YYYY|YY/g.test(format)) {
37
+ format.replace(/YYYY|YY/g, (reg, index, value) => {
38
+ if (reg === 'YY') {
39
+ str = value.replace('YY', year.slice(2))
40
+ }
41
+ if (reg === 'YYYY') {
42
+ str = value.replace('YYYY', year)
43
+ }
44
+ return str
45
+ })
46
+ } else {
47
+ str = format
48
+ }
49
+ str = str.replace(/MM/g, month);
50
+ str = str.replace(/dd/g, date);
51
+ str = str.replace(/HH/g, hours);
52
+ str = str.replace(/mm/g, minutes);
53
+ str = str.replace(/ss/g, seconds);
54
+ str = str.replace(/ww/g, week);
55
+ str = str.replace(/WW/g, dayMap[day]);
56
+ return str
57
+ }
58
+
59
+ /**
60
+ * @Description:两个日期大小比较(开始时间 > 结束时间,返回true)
61
+ * @author LiuBo
62
+ * @date 2022/7/15
63
+ * @time 10:43
64
+ * @param startTime 开始时间 (YYYY-MM-DD)
65
+ * @param endTime 结束时间 (YYYY-MM-DD)
66
+ * @modifyLog
67
+ */
68
+ dateSizeCompare(startTime: string,endTime: string): boolean {
69
+ return new Date(Date.parse(startTime.replace(/-/g,"/"))).getTime() >
70
+ new Date(Date.parse(endTime.replace(/-/g,"/"))).getTime();
71
+ }
72
+ }
73
+ const dateFormat: DateFormatService = new DateFormatService();
74
+ export { dateFormat };
@@ -1,58 +1,58 @@
1
- import { FormConfig } from "../domain/FormConfig";
2
- import * as sourceLocalForage from "localforage";
3
- import { DICT_STORE_NAME, NAME } from "../constants/config/storage.config";
4
- class DictLocalForageService {
5
- localForage: any;
6
- config: any;
7
- get formConfig(): Partial<FormConfig> {
8
- if ((window as any).$app.config.globalProperties.$qlForm) {
9
- return (window as any).$app.config.globalProperties.$qlForm;
10
- }
11
- return {};
12
- }
13
-
14
- constructor() {}
15
-
16
- init(): void {
17
- const appId: string = this.formConfig.appId ? this.formConfig.appId : "";
18
- this.config = {
19
- driver: sourceLocalForage.INDEXEDDB, // Force WebSQL; same as using setDriver()
20
- name: NAME,
21
- version: 1.0,
22
- storeName: DICT_STORE_NAME + appId, // Should be alphanumeric, with underscores.
23
- description: "PC端表单数据库",
24
- };
25
- this.localForage = sourceLocalForage.createInstance(this.config);
26
- }
27
-
28
- /**
29
- * @description: 设值
30
- * @author ChenRui
31
- * @date 2021/3/12 16:31
32
- */
33
- setItem(key: string, value: any): any {
34
- this.localForage.setItem(key, value);
35
- }
36
-
37
- /**
38
- * @description: 取值
39
- * @author ChenRui
40
- * @date 2021/3/12 16:31
41
- */
42
- getItem(key: string): Promise<any> {
43
- return this.localForage.getItem(key);
44
- }
45
-
46
- /**
47
- * @description: 删除实例
48
- * @author ChenRui
49
- * @date 2021/6/22 11:08
50
- */
51
- dropInstance(): void {
52
- if (this.localForage != null) {
53
- this.localForage.dropInstance().then();
54
- }
55
- }
56
- }
57
- const dictLocalForageService: DictLocalForageService = new DictLocalForageService();
58
- export { DictLocalForageService, dictLocalForageService };
1
+ import { FormConfig } from "../domain/FormConfig";
2
+ import * as sourceLocalForage from "localforage";
3
+ import { DICT_STORE_NAME, NAME } from "../constants/config/storage.config";
4
+ class DictLocalForageService {
5
+ localForage: any;
6
+ config: any;
7
+ get formConfig(): Partial<FormConfig> {
8
+ if ((window as any).$app.config.globalProperties.$qlForm) {
9
+ return (window as any).$app.config.globalProperties.$qlForm;
10
+ }
11
+ return {};
12
+ }
13
+
14
+ constructor() {}
15
+
16
+ init(): void {
17
+ const appId: string = this.formConfig.appId ? this.formConfig.appId : "";
18
+ this.config = {
19
+ driver: sourceLocalForage.INDEXEDDB, // Force WebSQL; same as using setDriver()
20
+ name: NAME,
21
+ version: 1.0,
22
+ storeName: DICT_STORE_NAME + appId, // Should be alphanumeric, with underscores.
23
+ description: "PC端表单数据库",
24
+ };
25
+ this.localForage = sourceLocalForage.createInstance(this.config);
26
+ }
27
+
28
+ /**
29
+ * @description: 设值
30
+ * @author ChenRui
31
+ * @date 2021/3/12 16:31
32
+ */
33
+ setItem(key: string, value: any): any {
34
+ this.localForage.setItem(key, value);
35
+ }
36
+
37
+ /**
38
+ * @description: 取值
39
+ * @author ChenRui
40
+ * @date 2021/3/12 16:31
41
+ */
42
+ getItem(key: string): Promise<any> {
43
+ return this.localForage.getItem(key);
44
+ }
45
+
46
+ /**
47
+ * @description: 删除实例
48
+ * @author ChenRui
49
+ * @date 2021/6/22 11:08
50
+ */
51
+ dropInstance(): void {
52
+ if (this.localForage != null) {
53
+ this.localForage.dropInstance().then();
54
+ }
55
+ }
56
+ }
57
+ const dictLocalForageService: DictLocalForageService = new DictLocalForageService();
58
+ export { DictLocalForageService, dictLocalForageService };
@@ -1,41 +1,41 @@
1
- class FormBeanUtilsService {
2
- constructor() {}
3
-
4
- /**
5
- * @description: 对象拷贝
6
- * @author ChenRui
7
- * @date 2020/8/29 19:54
8
- */
9
- copy(obj: any): any {
10
- if (obj != null) {
11
- return JSON.parse(JSON.stringify(obj));
12
- }
13
- return "";
14
- }
15
-
16
- /**
17
- * @description: 字符串转对象
18
- * @author ChenRui
19
- * @date 2020/8/29 19:54
20
- */
21
- parse(str: string | null): any {
22
- if (str != null && str !== "") {
23
- return JSON.parse(str);
24
- }
25
- return null;
26
- }
27
-
28
- /**
29
- * @description: 对象转字符串
30
- * @author ChenRui
31
- * @date 2020/8/29 19:54
32
- */
33
- stringify(obj: any): string {
34
- if (obj != null) {
35
- return JSON.stringify(obj);
36
- }
37
- return "";
38
- }
39
- }
40
- const formBeanUtilsService = new FormBeanUtilsService();
41
- export { formBeanUtilsService };
1
+ class FormBeanUtilsService {
2
+ constructor() {}
3
+
4
+ /**
5
+ * @description: 对象拷贝
6
+ * @author ChenRui
7
+ * @date 2020/8/29 19:54
8
+ */
9
+ copy(obj: any): any {
10
+ if (obj != null) {
11
+ return JSON.parse(JSON.stringify(obj));
12
+ }
13
+ return "";
14
+ }
15
+
16
+ /**
17
+ * @description: 字符串转对象
18
+ * @author ChenRui
19
+ * @date 2020/8/29 19:54
20
+ */
21
+ parse(str: string | null): any {
22
+ if (str != null && str !== "") {
23
+ return JSON.parse(str);
24
+ }
25
+ return null;
26
+ }
27
+
28
+ /**
29
+ * @description: 对象转字符串
30
+ * @author ChenRui
31
+ * @date 2020/8/29 19:54
32
+ */
33
+ stringify(obj: any): string {
34
+ if (obj != null) {
35
+ return JSON.stringify(obj);
36
+ }
37
+ return "";
38
+ }
39
+ }
40
+ const formBeanUtilsService = new FormBeanUtilsService();
41
+ export { formBeanUtilsService };
@@ -1,59 +1,59 @@
1
- import { FormConfig } from "../domain/FormConfig";
2
- import * as sourceLocalForage from "localforage";
3
- import { NAME, STORE_NAME } from "../constants/config/storage.config";
4
-
5
- class FormLocalForageService {
6
- localForage: any;
7
- config: any;
8
- get formConfig(): Partial<FormConfig> {
9
- if ((window as any).$app.config.globalProperties.$qlForm) {
10
- return (window as any).$app.config.globalProperties.$qlForm;
11
- }
12
- return {};
13
- }
14
-
15
- constructor() {}
16
-
17
- init(): void {
18
- const appId: string = this.formConfig.appId ? this.formConfig.appId : "";
19
- this.config = {
20
- driver: sourceLocalForage.INDEXEDDB, // Force WebSQL; same as using setDriver()
21
- name: NAME,
22
- version: 1.0,
23
- storeName: STORE_NAME + appId, // Should be alphanumeric, with underscores.
24
- description: "PC端表单数据库",
25
- };
26
- this.localForage = sourceLocalForage.createInstance(this.config);
27
- }
28
-
29
- /**
30
- * @description: 设值
31
- * @author ChenRui
32
- * @date 2021/3/12 16:31
33
- */
34
- setItem(key: string, value: any): any {
35
- this.localForage.setItem(key, value);
36
- }
37
-
38
- /**
39
- * @description: 取值
40
- * @author ChenRui
41
- * @date 2021/3/12 16:31
42
- */
43
- getItem(key: string): Promise<any> {
44
- return this.localForage.getItem(key);
45
- }
46
-
47
- /**
48
- * @description: 删除实例
49
- * @author ChenRui
50
- * @date 2021/6/22 11:08
51
- */
52
- dropInstance(): void {
53
- if (this.localForage != null) {
54
- this.localForage.dropInstance().then();
55
- }
56
- }
57
- }
58
- const formLocalForageService: FormLocalForageService = new FormLocalForageService();
59
- export { FormLocalForageService, formLocalForageService };
1
+ import { FormConfig } from "../domain/FormConfig";
2
+ import * as sourceLocalForage from "localforage";
3
+ import { NAME, STORE_NAME } from "../constants/config/storage.config";
4
+
5
+ class FormLocalForageService {
6
+ localForage: any;
7
+ config: any;
8
+ get formConfig(): Partial<FormConfig> {
9
+ if ((window as any).$app.config.globalProperties.$qlForm) {
10
+ return (window as any).$app.config.globalProperties.$qlForm;
11
+ }
12
+ return {};
13
+ }
14
+
15
+ constructor() {}
16
+
17
+ init(): void {
18
+ const appId: string = this.formConfig.appId ? this.formConfig.appId : "";
19
+ this.config = {
20
+ driver: sourceLocalForage.INDEXEDDB, // Force WebSQL; same as using setDriver()
21
+ name: NAME,
22
+ version: 1.0,
23
+ storeName: STORE_NAME + appId, // Should be alphanumeric, with underscores.
24
+ description: "PC端表单数据库",
25
+ };
26
+ this.localForage = sourceLocalForage.createInstance(this.config);
27
+ }
28
+
29
+ /**
30
+ * @description: 设值
31
+ * @author ChenRui
32
+ * @date 2021/3/12 16:31
33
+ */
34
+ setItem(key: string, value: any): any {
35
+ this.localForage.setItem(key, value);
36
+ }
37
+
38
+ /**
39
+ * @description: 取值
40
+ * @author ChenRui
41
+ * @date 2021/3/12 16:31
42
+ */
43
+ getItem(key: string): Promise<any> {
44
+ return this.localForage.getItem(key);
45
+ }
46
+
47
+ /**
48
+ * @description: 删除实例
49
+ * @author ChenRui
50
+ * @date 2021/6/22 11:08
51
+ */
52
+ dropInstance(): void {
53
+ if (this.localForage != null) {
54
+ this.localForage.dropInstance().then();
55
+ }
56
+ }
57
+ }
58
+ const formLocalForageService: FormLocalForageService = new FormLocalForageService();
59
+ export { FormLocalForageService, formLocalForageService };