@lambo-design/shared 1.0.0-beta.85 → 1.0.0-beta.87

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/package.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "name": "@lambo-design/shared",
3
- "version": "1.0.0-beta.85",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {},
7
- "author": "lambo",
8
- "license": "ISC",
9
- "publishConfig": {
10
- "access": "public",
11
- "registry": "https://registry.npmjs.org/"
12
- },
13
- "dependencies": {
14
- "axios": "^0.24.0",
15
- "axios-cache-plugin": "^0.1.0",
16
- "classnames": "^2.3.1",
17
- "css-vars-ponyfill": "^2.4.8",
18
- "moment": "2.29.4",
19
- "qs": "^6.11.0",
20
- "xlsx": "http://cicd.lambo.top/package/cdn/xlsx-0.19.1.tgz",
21
- "xlsx-style": "^0.8.13"
22
- }
23
- }
1
+ {
2
+ "name": "@lambo-design/shared",
3
+ "version": "1.0.0-beta.87",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "author": "lambo",
7
+ "license": "ISC",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "registry": "https://registry.npmjs.org/"
11
+ },
12
+ "dependencies": {
13
+ "axios": "^0.24.0",
14
+ "axios-cache-plugin": "^0.1.0",
15
+ "classnames": "^2.3.1",
16
+ "css-vars-ponyfill": "^2.4.8",
17
+ "moment": "2.29.4",
18
+ "qs": "^6.11.0",
19
+ "xlsx": "http://cicd.lambo.top/package/cdn/xlsx-0.19.1.tgz",
20
+ "xlsx-style": "^0.8.13"
21
+ },
22
+ "scripts": {}
23
+ }
package/utils/date.js CHANGED
@@ -376,3 +376,20 @@ export const formatDate = function(value) {
376
376
  return '-'
377
377
  }
378
378
  }
379
+
380
+ export const formatTimestamp = function(value,format) {
381
+ if (!format) {
382
+ format = 'YYYYMMDDHHmmss';
383
+ }
384
+ return moment(value).format(format)
385
+ }
386
+
387
+ export const formatStringDate = function(value,sourceFormat,targetFormat) {
388
+ if (!sourceFormat) {
389
+ sourceFormat = 'YYYY-MM-DD HH:mm:ss';
390
+ }
391
+ if (!targetFormat) {
392
+ targetFormat = 'YYYY-MM-DD HH:mm:ss';
393
+ }
394
+ return moment(value,sourceFormat).format(targetFormat)
395
+ }
@@ -1,20 +1,20 @@
1
- export const builtInDictKeys = [
2
- 'SEX_ENUM',
3
- 'WHETHER_ENUM'
4
- ]
5
-
6
- export const builtInDictMap = {
7
- 'SEX_ENUM' : { '0': '女', '1': '男' },
8
- 'WHETHER_ENUM' : { '0': '否', '1': '是' }
9
- }
10
-
11
- export const builtInDictList = {
12
- 'SEX_ENUM' : [
13
- { K: '0', V: '女' },
14
- { K: '1', V: '男' },
15
- ],
16
- 'WHETHER_ENUM' : [
17
- { K: '0', V: '否' },
18
- { K: '1', V: '是' },
19
- ]
20
- }
1
+ export const builtInDictKeys = [
2
+ 'SEX_ENUM',
3
+ 'WHETHER_ENUM'
4
+ ]
5
+
6
+ export const builtInDictMap = {
7
+ 'SEX_ENUM' : { '0': '女', '1': '男' },
8
+ 'WHETHER_ENUM' : { '0': '否', '1': '是' }
9
+ }
10
+
11
+ export const builtInDictList = {
12
+ 'SEX_ENUM' : [
13
+ { K: '0', V: '女' },
14
+ { K: '1', V: '男' },
15
+ ],
16
+ 'WHETHER_ENUM' : [
17
+ { K: '0', V: '否' },
18
+ { K: '1', V: '是' },
19
+ ]
20
+ }
@@ -1,75 +1,75 @@
1
- import config from '../../config/config'
2
- import ajax from '../ajax'
3
- import { builtInDictKeys, builtInDictMap, builtInDictList} from './built-in-dict'
4
- import { setSessionStorage, getSessionStorage} from "../platform";
5
-
6
- export async function getAllDict(dictIdArray) {
7
- if (dictIdArray.length > 0) {
8
- try {
9
- const { data } = await ajax.get(`${config.upmsServerContext}/manage/acDict/getDictsForMulti`, { params: { dictIds : dictIdArray.join(",") } })
10
- let result = {}
11
- if (data.code == 1) {
12
- let dictList = data.data;
13
- for (let key in dictList) {
14
- let dicts = dictList[key]
15
- result[key] = {};
16
- if (dicts.length > 0) {
17
- result[key]['enumList'] = dicts
18
- setSessionStorage(key + '_LIST', dicts)
19
- let dictMap = {}
20
- for(let dict of dicts) {
21
- dictMap[dict.K] = dict.V;
22
- }
23
- result[key]['enumData'] = dictMap
24
- setSessionStorage(key + '_MAP', dictMap)
25
- } else if (builtInDictKeys.includes(key)) {
26
- let dicts = builtInDictList[key]
27
- result[key]['enumList'] = dicts
28
- setSessionStorage(key + '_LIST', dicts)
29
- let dictMap = {}
30
- for(let dict of dicts) {
31
- dictMap[dict.K] = dict.V;
32
- }
33
- result[key]['enumData'] = dictMap
34
- setSessionStorage(key + '_MAP', dictMap)
35
- }
36
- }
37
- }
38
- return result
39
- } catch (error) {
40
- console.error(`getDictsForMulti error dictId=${dictIdArray}`, error)
41
- }
42
- }
43
- }
44
-
45
- export async function getDictList(dictId) {
46
- if (builtInDictKeys.includes(dictId)) {
47
- return builtInDictList[dictId]
48
- }
49
- const dictValue = getSessionStorage(dictId + '_LIST')
50
- if (!!dictValue) {
51
- return dictValue
52
- }
53
- let data = await getAllDict([dictId]);
54
- return data[dictId];
55
- }
56
-
57
- export async function getDictMap(dictId) {
58
- if (builtInDictKeys.includes(dictId)) {
59
- return builtInDictMap[dictId]
60
- }
61
- const dictValue = getSessionStorage(dictId + '_MAP')
62
- if (!!dictValue) {
63
- return dictValue
64
- }
65
-
66
- try {
67
- const { data } = await ajax.get(`${config.upmsServerContext}/manage/acDict/getDictsMap`, { params: { dictId : dictId } })
68
- if (data.code == 1) {
69
- setSessionStorage(dictId + '_MAP', data.data)
70
- }
71
- return data.data
72
- } catch (error) {
73
- console.error(`getDictsMap error dictId=${dictId}`, error)
74
- }
75
- }
1
+ import config from '../../config/config'
2
+ import ajax from '../ajax'
3
+ import { builtInDictKeys, builtInDictMap, builtInDictList} from './built-in-dict'
4
+ import { setSessionStorage, getSessionStorage} from "../platform";
5
+
6
+ export async function getAllDict(dictIdArray) {
7
+ if (dictIdArray.length > 0) {
8
+ try {
9
+ const { data } = await ajax.get(`${config.upmsServerContext}/manage/acDict/getDictsForMulti`, { params: { dictIds : dictIdArray.join(",") } })
10
+ let result = {}
11
+ if (data.code == 1) {
12
+ let dictList = data.data;
13
+ for (let key in dictList) {
14
+ let dicts = dictList[key]
15
+ result[key] = {};
16
+ if (dicts.length > 0) {
17
+ result[key]['enumList'] = dicts
18
+ setSessionStorage(key + '_LIST', dicts)
19
+ let dictMap = {}
20
+ for(let dict of dicts) {
21
+ dictMap[dict.K] = dict.V;
22
+ }
23
+ result[key]['enumData'] = dictMap
24
+ setSessionStorage(key + '_MAP', dictMap)
25
+ } else if (builtInDictKeys.includes(key)) {
26
+ let dicts = builtInDictList[key]
27
+ result[key]['enumList'] = dicts
28
+ setSessionStorage(key + '_LIST', dicts)
29
+ let dictMap = {}
30
+ for(let dict of dicts) {
31
+ dictMap[dict.K] = dict.V;
32
+ }
33
+ result[key]['enumData'] = dictMap
34
+ setSessionStorage(key + '_MAP', dictMap)
35
+ }
36
+ }
37
+ }
38
+ return result
39
+ } catch (error) {
40
+ console.error(`getDictsForMulti error dictId=${dictIdArray}`, error)
41
+ }
42
+ }
43
+ }
44
+
45
+ export async function getDictList(dictId) {
46
+ if (builtInDictKeys.includes(dictId)) {
47
+ return builtInDictList[dictId]
48
+ }
49
+ const dictValue = getSessionStorage(dictId + '_LIST')
50
+ if (!!dictValue) {
51
+ return dictValue
52
+ }
53
+ let data = await getAllDict([dictId]);
54
+ return data[dictId];
55
+ }
56
+
57
+ export async function getDictMap(dictId) {
58
+ if (builtInDictKeys.includes(dictId)) {
59
+ return builtInDictMap[dictId]
60
+ }
61
+ const dictValue = getSessionStorage(dictId + '_MAP')
62
+ if (!!dictValue) {
63
+ return dictValue
64
+ }
65
+
66
+ try {
67
+ const { data } = await ajax.get(`${config.upmsServerContext}/manage/acDict/getDictsMap`, { params: { dictId : dictId } })
68
+ if (data.code == 1) {
69
+ setSessionStorage(dictId + '_MAP', data.data)
70
+ }
71
+ return data.data
72
+ } catch (error) {
73
+ console.error(`getDictsMap error dictId=${dictId}`, error)
74
+ }
75
+ }