@dhccmobile/vue3-lo-form 1.1.41 → 2.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.
- package/.env.local.bak +6 -6
- package/.eslintrc.js +28 -28
- package/README.md +70 -62
- package/babel.config.js +3 -3
- package/dist/vue3-lo-form.common.js +7700 -107778
- package/dist/vue3-lo-form.common.js.map +1 -1
- package/dist/vue3-lo-form.css +1 -1
- package/dist/vue3-lo-form.umd.js +7773 -107851
- package/dist/vue3-lo-form.umd.js.map +1 -1
- package/dist/vue3-lo-form.umd.min.js +1 -56
- package/dist/vue3-lo-form.umd.min.js.map +1 -1
- package/package.json +65 -61
- package/public/index.html +17 -17
- package/public/js/pinyin.ts +101 -101
- package/src/App.vue +741 -741
- package/src/components/form/DvForm.vue +642 -642
- package/src/components/form/DvFormLayout.vue +1569 -1569
- package/src/components/form/StretchText.vue +90 -90
- package/src/components/index.ts +3 -3
- package/src/constants/config/form-template.config.ts +32 -32
- package/src/constants/config/form.config.ts +4 -4
- package/src/constants/config/storage.config.ts +4 -4
- package/src/constants/encode-assets/svg.ts +11 -11
- package/src/constants/enum/builtIn-label.enum.ts +5 -5
- package/src/constants/enum/cache-type.enum.ts +7 -7
- package/src/constants/enum/control-format-type.enum.ts +9 -9
- package/src/constants/enum/dynamic-option-type.enum.ts +6 -6
- package/src/constants/enum/form-bus-attr.enum.ts +8 -8
- package/src/constants/enum/form-field-class.enum.ts +7 -7
- package/src/constants/enum/form-field-type.enum.ts +25 -25
- package/src/constants/enum/form-type.enum.ts +5 -5
- package/src/constants/enum/index.ts +19 -19
- package/src/constants/enum/lateral-arrangement.enum.ts +9 -9
- package/src/constants/enum/money-unit.enum.ts +6 -6
- package/src/constants/enum/option-type.enum.ts +5 -5
- package/src/constants/enum/submitted-type.enum.ts +32 -31
- package/src/constants/enum/support-upload-type.enum.ts +5 -5
- package/src/constants/enum/switch.enum.ts +5 -5
- package/src/constants/enum/upload-type.enum.ts +17 -17
- package/src/constants/enum/validate-rules.enum.ts +25 -25
- package/src/constants/enum/validate-status.enum.ts +8 -8
- package/src/constants/enum/vertical-arrangement.enum.ts +7 -7
- package/src/constants/enum/zoom-type.ts +6 -6
- package/src/constants/index.ts +3 -3
- package/src/core/FormApi.ts +1238 -1238
- package/src/core/index.ts +1 -1
- package/src/domain/AbstractControl.ts +6 -6
- package/src/domain/Control.ts +14 -14
- package/src/domain/CustomFormat.ts +6 -6
- package/src/domain/DesForm.ts +48 -48
- package/src/domain/DesFormControl.ts +241 -241
- package/src/domain/DesFormLayout.ts +51 -51
- package/src/domain/FieldChangeHistory.ts +9 -9
- package/src/domain/FormConfig.ts +15 -15
- package/src/domain/FormControl.ts +125 -125
- package/src/domain/FormEnum.ts +9 -9
- package/src/domain/FormGroup.ts +42 -42
- package/src/domain/FormRestfulResponse.ts +6 -6
- package/src/domain/ProvideInjectData.ts +10 -10
- package/src/domain/SysDictDetail.ts +38 -38
- package/src/domain/SysDictInfo.ts +40 -40
- package/src/domain/SysDictTreeDetail.ts +52 -52
- package/src/domain/index.ts +12 -12
- package/src/filtres/amount-capitalization.filter.ts +154 -147
- package/src/filtres/extract-options.filter.ts +53 -53
- package/src/filtres/generate-grid-column-end.filter.ts +22 -22
- package/src/filtres/generate-grid-template-columns.filter.ts +24 -24
- package/src/filtres/switch-enum-convert.filter.ts +18 -18
- package/src/filtres/zoom-multiple.filter.ts +32 -32
- package/src/index.ts +73 -73
- package/src/main.ts +17 -17
- package/src/services/api.service.ts +73 -73
- package/src/services/clean-local-forage.service.ts +58 -58
- package/src/services/date-format.service.ts +74 -74
- package/src/services/dict-local-forage.service.ts +58 -58
- package/src/services/form-bean-utils.service.ts +41 -41
- package/src/services/form-local-forage.service.ts +59 -59
- package/src/services/form-tools.service.ts +739 -659
- package/src/services/form-tree-node-convert.service.ts +240 -240
- package/src/services/form-validate.service.ts +103 -103
- package/src/services/index.ts +9 -9
- package/src/services/router.service.ts +96 -96
- package/src/services/validate-generator.service.ts +710 -710
- package/src/shims-vue.d.ts +6 -6
- package/src/store/dict.store.ts +63 -63
- package/src/store/form.store.ts +32 -32
- package/src/store/index.ts +2 -2
- package/src/styles/datePicker.scss +125 -125
- package/src/styles/index.scss +195 -195
- package/src/styles/theme1.scss +277 -277
- package/src/styles/theme2.scss +376 -376
- package/src/styles/themes.scss +9 -9
- package/src/types/vfForm.ts +11 -11
- package/tsconfig.json +40 -40
- package/types/components/index.d.ts +3 -3
- package/types/constants/config/form-template.config.d.ts +30 -30
- package/types/constants/config/form.config.d.ts +4 -4
- package/types/constants/config/storage.config.d.ts +4 -4
- package/types/constants/encode-assets/svg.d.ts +5 -5
- package/types/constants/enum/builtIn-label.enum.d.ts +7 -7
- package/types/constants/enum/cache-type.enum.d.ts +15 -15
- package/types/constants/enum/control-format-type.enum.d.ts +23 -23
- package/types/constants/enum/dynamic-option-type.enum.d.ts +11 -11
- package/types/constants/enum/form-bus-attr.enum.d.ts +19 -19
- package/types/constants/enum/form-field-class.enum.d.ts +18 -18
- package/types/constants/enum/form-field-type.enum.d.ts +111 -111
- package/types/constants/enum/form-type.enum.d.ts +11 -11
- package/types/constants/enum/index.d.ts +19 -19
- package/types/constants/enum/lateral-arrangement.enum.d.ts +23 -23
- package/types/constants/enum/money-unit.enum.d.ts +15 -15
- package/types/constants/enum/option-type.enum.d.ts +11 -11
- package/types/constants/enum/submitted-type.enum.d.ts +115 -111
- package/types/constants/enum/support-upload-type.enum.d.ts +11 -11
- package/types/constants/enum/switch.enum.d.ts +11 -11
- package/types/constants/enum/upload-type.enum.d.ts +59 -59
- package/types/constants/enum/validate-rules.enum.d.ts +2 -2
- package/types/constants/enum/validate-status.enum.d.ts +2 -2
- package/types/constants/enum/vertical-arrangement.enum.d.ts +21 -21
- package/types/constants/enum/zoom-type.d.ts +15 -15
- package/types/constants/index.d.ts +3 -3
- package/types/core/FormApi.d.ts +376 -376
- package/types/core/index.d.ts +1 -1
- package/types/domain/AbstractControl.d.ts +5 -5
- package/types/domain/Control.d.ts +13 -13
- package/types/domain/CustomFormat.d.ts +5 -5
- package/types/domain/DesForm.d.ts +32 -32
- package/types/domain/DesFormControl.d.ts +160 -160
- package/types/domain/DesFormLayout.d.ts +33 -33
- package/types/domain/FieldChangeHistory.d.ts +9 -9
- package/types/domain/FormConfig.d.ts +15 -15
- package/types/domain/FormControl.d.ts +60 -60
- package/types/domain/FormEnum.d.ts +10 -10
- package/types/domain/FormGroup.d.ts +27 -27
- package/types/domain/FormRestfulResponse.d.ts +6 -6
- package/types/domain/ProvideInjectData.d.ts +10 -10
- package/types/domain/SysDictDetail.d.ts +24 -24
- package/types/domain/SysDictInfo.d.ts +26 -26
- package/types/domain/SysDictTreeDetail.d.ts +34 -34
- package/types/domain/index.d.ts +12 -12
- package/types/filtres/amount-capitalization.filter.d.ts +7 -7
- package/types/filtres/extract-options.filter.d.ts +13 -13
- package/types/filtres/generate-grid-column-end.filter.d.ts +11 -11
- package/types/filtres/generate-grid-template-columns.filter.d.ts +11 -11
- package/types/filtres/switch-enum-convert.filter.d.ts +2 -2
- package/types/filtres/zoom-multiple.filter.d.ts +3 -3
- package/types/index.d.ts +13 -13
- package/types/main.d.ts +2 -2
- package/types/services/api.service.d.ts +25 -25
- package/types/services/clean-local-forage.service.d.ts +28 -28
- package/types/services/date-format.service.d.ts +21 -21
- package/types/services/dict-local-forage.service.d.ts +28 -28
- package/types/services/form-bean-utils.service.d.ts +23 -23
- package/types/services/form-local-forage.service.d.ts +28 -28
- package/types/services/form-tools.service.d.ts +153 -144
- package/types/services/form-tree-node-convert.service.d.ts +104 -104
- package/types/services/form-validate.service.d.ts +32 -32
- package/types/services/index.d.ts +9 -9
- package/types/services/router.service.d.ts +40 -40
- package/types/services/validate-generator.service.d.ts +154 -154
- package/types/store/dict.store.d.ts +29 -29
- package/types/store/form.store.d.ts +17 -17
- package/types/store/index.d.ts +2 -2
- package/types/types/vfForm.d.ts +10 -10
- package/vue.config.js +38 -29
- package/dhccmobile-vue3-lo-form-1.1.41.tgz +0 -0
|
@@ -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 };
|