@lambo-design/shared 1.0.0-beta.90 → 1.0.0-beta.92

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.90",
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.92",
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
+ }
@@ -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
+ }
@@ -0,0 +1,29 @@
1
+ import ajax from '../ajax'
2
+
3
+ export const checkSingle = async (rule, value, callback, {url, formKey, formName}) => {
4
+ if (!formName) {
5
+ formName = "参数";
6
+ }
7
+ if (value) {
8
+ if (url) {
9
+ let params = {};
10
+ if (formKey) {
11
+ params[formKey] = value
12
+ }
13
+ const { data } = await ajax.get(url, {params: params});
14
+ if (data.code == 1 && data.data) {
15
+ callback(formName + "已存在");
16
+ } else {
17
+ callback();
18
+ }
19
+ } else {
20
+ callback();
21
+ }
22
+ } else {
23
+ callback(formName + "不能为空");
24
+ }
25
+ }
26
+
27
+ export default {
28
+ checkSingle
29
+ }