@kengic/uni 0.7.13-beta.5 → 0.7.13-beta.6
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/api/WMS/Controllers/DescriptionController/List.ts +84 -0
- package/api/WMS/Controllers/DescriptionController/index.ts +1 -0
- package/api/WMS/Controllers/VarConfigDescriptionController/ListByFormId.ts +21 -0
- package/api/WMS/Controllers/VarConfigDescriptionController/index.ts +1 -0
- package/api/WMS/Controllers/index.ts +2 -0
- package/api/WMS/models.ts +93 -0
- package/bin/{cmd.mjs → bin.mjs} +15 -2
- package/bin/bump.mjs +92 -0
- package/config/config.hooks.ts +29 -0
- package/config/config.store.ts +234 -0
- package/config/index.ts +17 -1
- package/index.ts +1 -1
- package/{const/index.vm.ts → model/index.ts} +37 -4
- package/package.json +3 -2
- package/page/{PageMy.vue → KgPageMy.vue} +23 -14
- package/service/http-client.ts +15 -15
- package/store/app.store.ts +7 -7
- package/util/kg.util.ts +20 -18
- package/config/config.ts +0 -11
- package/const/index.ts +0 -12
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// noinspection ES6UnusedImports
|
|
2
|
+
|
|
3
|
+
import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
|
|
4
|
+
import * as DEF from '../../../def';
|
|
5
|
+
import { keys } from '../../models';
|
|
6
|
+
|
|
7
|
+
/** 请求参数. */
|
|
8
|
+
export class ListQuery {
|
|
9
|
+
/** 列名(CodeName). */
|
|
10
|
+
public codnam?: string | null;
|
|
11
|
+
/** 列值(CodeValue). */
|
|
12
|
+
public codval?: string | null;
|
|
13
|
+
/** 模块(ProjectName). */
|
|
14
|
+
public grpNam?: string | null;
|
|
15
|
+
/** id. */
|
|
16
|
+
public id?: string | null;
|
|
17
|
+
/** 长描述(LongDescription). */
|
|
18
|
+
public lngDsc?: string | null;
|
|
19
|
+
/** 语言(LocaleId). */
|
|
20
|
+
public localeId?: string | null;
|
|
21
|
+
/** 修改用户编号. */
|
|
22
|
+
public modUsrCod?: string | null;
|
|
23
|
+
/** 修改日期. */
|
|
24
|
+
public moddte?: string | null;
|
|
25
|
+
/** 短描述(ShortDescription). */
|
|
26
|
+
public shortDsc?: string | null;
|
|
27
|
+
/** 短描述含列值(ShortDescriptionWithCodeValue). */
|
|
28
|
+
public shortDscWithCodval?: string | null;
|
|
29
|
+
/** 顺序号(Sequence). */
|
|
30
|
+
public srtseq?: number | null;
|
|
31
|
+
/** 系统定义. */
|
|
32
|
+
public sysDefFlg?: number | null;
|
|
33
|
+
/** 版本. */
|
|
34
|
+
public version?: number | null;
|
|
35
|
+
/** 排序字段. */
|
|
36
|
+
public column?: string | null;
|
|
37
|
+
/** 排序方式. */
|
|
38
|
+
public order?: 'asc' | 'desc' | null;
|
|
39
|
+
/** 当前页数. */
|
|
40
|
+
public pageNo?: number | null;
|
|
41
|
+
/** 每页条数. */
|
|
42
|
+
public pageSize?: number | null;
|
|
43
|
+
|
|
44
|
+
public constructor(obj?: ListQuery) {
|
|
45
|
+
keys(obj ?? {}).forEach((key: PropertyKey) => {
|
|
46
|
+
switch (key) {
|
|
47
|
+
case 'codnam':
|
|
48
|
+
case 'codval':
|
|
49
|
+
case 'grpNam':
|
|
50
|
+
case 'id':
|
|
51
|
+
case 'lngDsc':
|
|
52
|
+
case 'localeId':
|
|
53
|
+
case 'modUsrCod':
|
|
54
|
+
case 'moddte':
|
|
55
|
+
case 'shortDsc':
|
|
56
|
+
case 'shortDscWithCodval':
|
|
57
|
+
case 'srtseq':
|
|
58
|
+
case 'sysDefFlg':
|
|
59
|
+
case 'version':
|
|
60
|
+
case 'column':
|
|
61
|
+
case 'order':
|
|
62
|
+
case 'pageNo':
|
|
63
|
+
case 'pageSize':
|
|
64
|
+
Reflect.set(this, key, Reflect.get(obj ?? {}, key));
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 描述-分页列表查询.
|
|
75
|
+
*
|
|
76
|
+
* @param config 请求配置.
|
|
77
|
+
* @param option 请求选项.
|
|
78
|
+
*/
|
|
79
|
+
export function List(config?: IRequestConfig<ListQuery, {}>, option?: IRequestOptions): Promise<DEF.WMS.IPage<DEF.WMS.DescriptionDTO>> {
|
|
80
|
+
return httpClient().request({ method: List.method, url: List.url, ...(config ?? {}) }, option);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
List.method = 'GET' as const;
|
|
84
|
+
List.url = '/description/description/list';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { List, ListQuery } from './List';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// noinspection ES6UnusedImports
|
|
2
|
+
|
|
3
|
+
import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
|
|
4
|
+
import * as DEF from '../../../def';
|
|
5
|
+
import { keys } from '../../models';
|
|
6
|
+
|
|
7
|
+
/** 请求参数. */
|
|
8
|
+
export class ListByFormIdQuery {}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 根据界面标识查询「变量配置:变量翻译」列表.
|
|
12
|
+
*
|
|
13
|
+
* @param config 请求配置.
|
|
14
|
+
* @param option 请求选项.
|
|
15
|
+
*/
|
|
16
|
+
export function ListByFormId(config?: IRequestConfig<ListByFormIdQuery, DEF.WMS.VarConfigDescription>, option?: IRequestOptions): Promise<Array<DEF.WMS.VarConfigDescription>> {
|
|
17
|
+
return httpClient().request({ method: ListByFormId.method, url: ListByFormId.url, ...(config ?? {}) }, option);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ListByFormId.method = 'POST' as const;
|
|
21
|
+
ListByFormId.url = '/var/VarConfigDescription/listByFormId';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListByFormId, ListByFormIdQuery } from './ListByFormId';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * as CommonController from './CommonController';
|
|
2
|
+
export * as DescriptionController from './DescriptionController';
|
|
2
3
|
export * as LoginController from './LoginController';
|
|
4
|
+
export * as VarConfigDescriptionController from './VarConfigDescriptionController';
|
|
3
5
|
export * as WarehouseController from './WarehouseController';
|
|
4
6
|
export * as WorkstationController from './WorkstationController';
|
package/api/WMS/models.ts
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/** 描述数据传输对象(DescriptionDTO). */
|
|
2
|
+
export class DescriptionDTO {
|
|
3
|
+
/** 列名(CodeName). */
|
|
4
|
+
public codnam?: string | null;
|
|
5
|
+
/** 列值(CodeValue). */
|
|
6
|
+
public codval?: string | null;
|
|
7
|
+
/** 模块(ProjectName). */
|
|
8
|
+
public grpNam?: string | null;
|
|
9
|
+
/** id. */
|
|
10
|
+
public id?: string | null;
|
|
11
|
+
/** 长描述(LongDescription). */
|
|
12
|
+
public lngDsc?: string | null;
|
|
13
|
+
/** 语言(LocaleId). */
|
|
14
|
+
public localeId?: string | null;
|
|
15
|
+
/** 修改用户编号. */
|
|
16
|
+
public modUsrCod?: string | null;
|
|
17
|
+
/** 修改日期. */
|
|
18
|
+
public moddte?: string | null;
|
|
19
|
+
/** 短描述(ShortDescription). */
|
|
20
|
+
public shortDsc?: string | null;
|
|
21
|
+
/** 短描述含列值(ShortDescriptionWithCodeValue). */
|
|
22
|
+
public shortDscWithCodval?: string | null;
|
|
23
|
+
/** 顺序号(Sequence). */
|
|
24
|
+
public srtseq?: number | null;
|
|
25
|
+
/** 系统定义. */
|
|
26
|
+
public sysDefFlg?: number | null;
|
|
27
|
+
/** 版本. */
|
|
28
|
+
public version?: number | null;
|
|
29
|
+
|
|
30
|
+
public constructor(obj?: DescriptionDTO) {
|
|
31
|
+
keys(obj ?? {}).forEach((key: PropertyKey) => {
|
|
32
|
+
switch (key) {
|
|
33
|
+
case 'codnam':
|
|
34
|
+
case 'codval':
|
|
35
|
+
case 'grpNam':
|
|
36
|
+
case 'id':
|
|
37
|
+
case 'lngDsc':
|
|
38
|
+
case 'localeId':
|
|
39
|
+
case 'modUsrCod':
|
|
40
|
+
case 'moddte':
|
|
41
|
+
case 'shortDsc':
|
|
42
|
+
case 'shortDscWithCodval':
|
|
43
|
+
case 'srtseq':
|
|
44
|
+
case 'sysDefFlg':
|
|
45
|
+
case 'version':
|
|
46
|
+
Reflect.set(this, key, Reflect.get(obj ?? {}, key));
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
1
55
|
export class IPage<T0> {
|
|
2
56
|
/** Current. */
|
|
3
57
|
public current?: number | null;
|
|
@@ -165,6 +219,45 @@ export class SysUserWarehouseDTO {
|
|
|
165
219
|
}
|
|
166
220
|
}
|
|
167
221
|
|
|
222
|
+
/** 变量配置:变量翻译. */
|
|
223
|
+
export class VarConfigDescription {
|
|
224
|
+
/** 定制级别(CustomLevel). */
|
|
225
|
+
public cust_lvl?: number | null;
|
|
226
|
+
/** 界面标识(FormID). */
|
|
227
|
+
public frm_id?: string | null;
|
|
228
|
+
/** 分组(GroupName). */
|
|
229
|
+
public grp_nam?: string | null;
|
|
230
|
+
/** 主键. */
|
|
231
|
+
public id?: string | null;
|
|
232
|
+
/** 语言(LocaleID). */
|
|
233
|
+
public locale_id?: string | null;
|
|
234
|
+
/** 配置属性. */
|
|
235
|
+
public props?: string | null;
|
|
236
|
+
/** 变量名称(VariableName). */
|
|
237
|
+
public var_nam?: string | null;
|
|
238
|
+
/** 显示文本(Text). */
|
|
239
|
+
public var_text?: string | null;
|
|
240
|
+
|
|
241
|
+
public constructor(obj?: VarConfigDescription) {
|
|
242
|
+
keys(obj ?? {}).forEach((key: PropertyKey) => {
|
|
243
|
+
switch (key) {
|
|
244
|
+
case 'cust_lvl':
|
|
245
|
+
case 'frm_id':
|
|
246
|
+
case 'grp_nam':
|
|
247
|
+
case 'id':
|
|
248
|
+
case 'locale_id':
|
|
249
|
+
case 'props':
|
|
250
|
+
case 'var_nam':
|
|
251
|
+
case 'var_text':
|
|
252
|
+
Reflect.set(this, key, Reflect.get(obj ?? {}, key));
|
|
253
|
+
break;
|
|
254
|
+
default:
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
168
261
|
/** 仓库数据传输对象. */
|
|
169
262
|
export class WarehouseDTO {
|
|
170
263
|
/** 是否可用. */
|
package/bin/{cmd.mjs → bin.mjs}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
+
import { bump } from './bump.mjs';
|
|
3
4
|
|
|
4
5
|
const program = new Command();
|
|
5
6
|
|
|
@@ -12,7 +13,7 @@ function log(message) {
|
|
|
12
13
|
console.log(`[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] COPY-DIST-TO-ANDROID | ${message}`);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
async function
|
|
16
|
+
async function bin() {
|
|
16
17
|
try {
|
|
17
18
|
program
|
|
18
19
|
.command('copy-dist-to-android')
|
|
@@ -48,10 +49,22 @@ async function cmd() {
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
|
|
52
|
+
program
|
|
53
|
+
.command('bump')
|
|
54
|
+
.description('BUMP VERSION BUMBER')
|
|
55
|
+
.option('--type <type>', 'TYPE(major,minor,patch,beta)', '')
|
|
56
|
+
.action(async (args) => {
|
|
57
|
+
try {
|
|
58
|
+
bump(args);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.log(e);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
51
64
|
program.parse(process.argv);
|
|
52
65
|
} catch (e) {
|
|
53
66
|
console.error(e.stack);
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
|
|
57
|
-
|
|
70
|
+
bin();
|
package/bin/bump.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 打印日志.
|
|
6
|
+
*
|
|
7
|
+
* @param message 日志消息.
|
|
8
|
+
*/
|
|
9
|
+
function log(message) {
|
|
10
|
+
console.log(`[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] BUMP | ${message}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 更新版本.
|
|
15
|
+
*/
|
|
16
|
+
function bump(param) {
|
|
17
|
+
import('../src/manifest.json').then(({ default: json }) => {
|
|
18
|
+
const newVersionName = (() => {
|
|
19
|
+
switch (param.type) {
|
|
20
|
+
case 'major': {
|
|
21
|
+
return semver.inc(json.version, 'major') ?? json.version;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
case 'minor': {
|
|
25
|
+
return semver.inc(json.version, 'minor') ?? json.version;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
case 'patch': {
|
|
29
|
+
return semver.inc(json.version, 'patch') ?? json.version;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
case 'beta': {
|
|
33
|
+
return semver.inc(json.version, 'prerelease', 'beta') ?? json.version;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
default:
|
|
37
|
+
throw new Error('INVALID SEMVER TYPE');
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
const newVersionCode = Number(newVersionName.replace(/\./g, ''));
|
|
42
|
+
|
|
43
|
+
// package.json
|
|
44
|
+
{
|
|
45
|
+
let text = fs
|
|
46
|
+
.readFileSync('./package.json', {})
|
|
47
|
+
.toString()
|
|
48
|
+
.replace(/"version": "(.*)?"/, `"version": "${newVersionName}"`);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
fs.writeFileSync('./package.json', text, {});
|
|
52
|
+
log(`| package.json | 版本更新成功 | ${newVersionName}`);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.log(e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/manifest.json
|
|
59
|
+
{
|
|
60
|
+
let text = fs
|
|
61
|
+
.readFileSync('./src/manifest.json', {})
|
|
62
|
+
.toString()
|
|
63
|
+
.replace(/"versionName": "(.*)?"/, `"versionName": "${newVersionName}"`)
|
|
64
|
+
.replace(/"versionCode": "(.*)?"/, `"versionCode": "${newVersionCode}"`);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
fs.writeFileSync('./src/manifest.json', text, {});
|
|
68
|
+
log(`| src/manifest.json | 版本更新成功 | ${newVersionName}`);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.log(e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// android/app/build.gradle
|
|
75
|
+
{
|
|
76
|
+
let text = fs
|
|
77
|
+
.readFileSync('./android/app/build.gradle', {})
|
|
78
|
+
.toString()
|
|
79
|
+
.replace(/versionName "(.*)?"/, `versionName "${newVersionName}"`)
|
|
80
|
+
.replace(/versionCode (.*)?/, `versionCode ${newVersionCode}`);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
fs.writeFileSync('./android/app/build.gradle', text, {});
|
|
84
|
+
log(`| android/app/build.gradle | 版本更新成功 | ${newVersionName}`);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.log(e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { bump };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { computed, ComputedRef, unref } from 'vue';
|
|
2
|
+
import { useKgStore } from './config.store';
|
|
3
|
+
|
|
4
|
+
export type IUseKg = {
|
|
5
|
+
/**
|
|
6
|
+
* 当前语言.
|
|
7
|
+
*/
|
|
8
|
+
currentLocale$$: ComputedRef<string>;
|
|
9
|
+
} & ReturnType<typeof useKgStore>;
|
|
10
|
+
|
|
11
|
+
export function useKg(): IUseKg {
|
|
12
|
+
const store = useKgStore();
|
|
13
|
+
|
|
14
|
+
return new Proxy(
|
|
15
|
+
{
|
|
16
|
+
currentLocale$$: computed(() => unref(uni.getLocale() || 'zh_CN')),
|
|
17
|
+
} as IUseKg,
|
|
18
|
+
{
|
|
19
|
+
get(target, p): any {
|
|
20
|
+
// 将部分属性直接代理给状态管理对象(store), 这样就可以直接访问 store 上的所有属性和方法,
|
|
21
|
+
if (!(p in target) && p in store) {
|
|
22
|
+
return Reflect.get(store, p);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Reflect.get(target, p);
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { ____DEBUG____, KgCoreUtil } from '@kengic/core.core';
|
|
2
|
+
import { values } from 'lodash-es';
|
|
3
|
+
import { defineStore } from 'pinia';
|
|
4
|
+
import { computed, ref } from 'vue';
|
|
5
|
+
import { API } from '../api';
|
|
6
|
+
import { DescriptionDTO, VarConfigDescription } from '../api/WMS/models';
|
|
7
|
+
import { KG, KgStoreDefinition } from '../model';
|
|
8
|
+
import { KgUtil } from '../util';
|
|
9
|
+
import { useKg } from './config.hooks';
|
|
10
|
+
|
|
11
|
+
//region GETTERS 类型定义
|
|
12
|
+
//----------------------------------------------------------------------------------------------------
|
|
13
|
+
export interface IUseKgStoreGetters {
|
|
14
|
+
/**
|
|
15
|
+
* 根据 codeName 和 codeValue 获取当前语言下的某个描述.
|
|
16
|
+
*/
|
|
17
|
+
getDescription: (param: { codeName: string | null | undefined; codeValue: string | null | undefined }) => DescriptionDTO | null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 根据 codeName 获取当前语言下的它的所有描述.
|
|
21
|
+
*/
|
|
22
|
+
getDescriptionList: (param: { codeName: string | null | undefined }) => Array<DescriptionDTO>;
|
|
23
|
+
}
|
|
24
|
+
//----------------------------------------------------------------------------------------------------
|
|
25
|
+
//endregion
|
|
26
|
+
|
|
27
|
+
//region ACTIONS 类型定义
|
|
28
|
+
//----------------------------------------------------------------------------------------------------
|
|
29
|
+
export interface IUseKgStoreActions {
|
|
30
|
+
/**
|
|
31
|
+
* 请求某组描述数据.
|
|
32
|
+
*
|
|
33
|
+
* @param param.codeName 描述组名.
|
|
34
|
+
* @param param.isForceRequest 是否强制请求, 即无论是否已经请求过该组, 始终重新请求, 默认为 true.
|
|
35
|
+
*/
|
|
36
|
+
requestDescriptionList(param: { codeName: string | null | undefined; isForceRequest?: boolean | null | undefined }): Promise<void>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 请求某组变量描述数据.
|
|
40
|
+
*
|
|
41
|
+
* @param param.fid 界面标识.
|
|
42
|
+
*/
|
|
43
|
+
requestVarConfigDescriptionList(param: { fid: string | null | undefined }): Promise<void>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 设置某组描述的数据.
|
|
47
|
+
*
|
|
48
|
+
* @param param.codeName 描述组名.
|
|
49
|
+
* @param param.descriptions 描述数据.
|
|
50
|
+
*/
|
|
51
|
+
setDescriptionList(param: { codeName: string | null | undefined; descriptions: Array<DescriptionDTO> }): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 翻译.
|
|
55
|
+
*
|
|
56
|
+
* @param key 键.
|
|
57
|
+
* @param param 参数对象.
|
|
58
|
+
* @param defaultValue 默认翻译结果.
|
|
59
|
+
*/
|
|
60
|
+
t(key: string | null | undefined, param?: Record<string, any> | null | undefined, defaultValue?: string | null | undefined): string;
|
|
61
|
+
}
|
|
62
|
+
//----------------------------------------------------------------------------------------------------
|
|
63
|
+
//endregion
|
|
64
|
+
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = defineStore('Kg', () => {
|
|
67
|
+
//region DATA
|
|
68
|
+
//----------------------------------------------------------------------------------------------------
|
|
69
|
+
//----------------------------------------------------------------------------------------------------
|
|
70
|
+
//endregion
|
|
71
|
+
|
|
72
|
+
//region STATE
|
|
73
|
+
//----------------------------------------------------------------------------------------------------
|
|
74
|
+
const descriptionMap$ = ref<Record<string, Record<string, DescriptionDTO>>>({});
|
|
75
|
+
const isDescriptionsRequestingMap$ = ref<Record<string, boolean>>({});
|
|
76
|
+
//----------------------------------------------------------------------------------------------------
|
|
77
|
+
//endregion
|
|
78
|
+
|
|
79
|
+
//region GETTERS
|
|
80
|
+
//----------------------------------------------------------------------------------------------------
|
|
81
|
+
const getDescription$$ = computed<(param: { codeName: string | null | undefined; codeValue: string | null | undefined }) => DescriptionDTO | null>(() => (param) => {
|
|
82
|
+
const { codeName, codeValue } = param ?? {};
|
|
83
|
+
if (!codeName || !codeValue) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return descriptionMap$.value[codeName]?.[codeValue] ?? null;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const getDescriptionList$$ = computed<(param: { codeName: string | null | undefined }) => Array<DescriptionDTO>>(() => (param) => {
|
|
91
|
+
const { codeName } = param ?? {};
|
|
92
|
+
|
|
93
|
+
if (!codeName) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return [...values(descriptionMap$.value[codeName])];
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
//----------------------------------------------------------------------------------------------------
|
|
101
|
+
//endregion
|
|
102
|
+
|
|
103
|
+
//region ACTIONS
|
|
104
|
+
//----------------------------------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
async function requestDescriptionList(param: { codeName: string | null | undefined; isForceRequest?: boolean | null | undefined }): Promise<void> {
|
|
107
|
+
const { codeName, isForceRequest } = param ?? {};
|
|
108
|
+
|
|
109
|
+
if (!codeName) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 正在请求该组描述, 禁止重复请求,
|
|
114
|
+
if (isDescriptionsRequestingMap$.value[codeName]) {
|
|
115
|
+
____DEBUG____(`kg.requestDescriptionList() | 正在查询, 不许重复查询. | { codeName: ${codeName}`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 该组描述已经请求过了, 不再请求,
|
|
120
|
+
const codeNameMap = descriptionMap$.value[codeName];
|
|
121
|
+
if (codeNameMap && isForceRequest === false) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const kg = useKg();
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
isDescriptionsRequestingMap$.value[codeName] = true;
|
|
129
|
+
|
|
130
|
+
const { records } =
|
|
131
|
+
(await API.WMS.DescriptionController.List({
|
|
132
|
+
params: {
|
|
133
|
+
codnam: codeName,
|
|
134
|
+
localeId: 'TODO LT',
|
|
135
|
+
pageNo: 1,
|
|
136
|
+
pageSize: 999999,
|
|
137
|
+
},
|
|
138
|
+
})) ?? {};
|
|
139
|
+
|
|
140
|
+
setDescriptionList({ codeName: codeName, descriptions: records ?? [] });
|
|
141
|
+
} finally {
|
|
142
|
+
isDescriptionsRequestingMap$.value[codeName] = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function requestVarConfigDescriptionList(param: { fid: string | null | undefined }): Promise<void> {
|
|
147
|
+
if (!param.fid) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const varConfigDescriptionList = (await API.WMS.VarConfigDescriptionController.ListByFormId({ data: new VarConfigDescription({ frm_id: param.fid }) }).catch(() => [])) ?? [];
|
|
152
|
+
|
|
153
|
+
setDescriptionList({
|
|
154
|
+
codeName: param.fid,
|
|
155
|
+
descriptions: varConfigDescriptionList.map(
|
|
156
|
+
(i) =>
|
|
157
|
+
new DescriptionDTO({
|
|
158
|
+
codnam: param.fid,
|
|
159
|
+
codval: i.var_nam,
|
|
160
|
+
id: KgCoreUtil.uuid(),
|
|
161
|
+
lngDsc: i.var_text,
|
|
162
|
+
localeId: i.locale_id,
|
|
163
|
+
shortDsc: i.var_text,
|
|
164
|
+
}),
|
|
165
|
+
),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function setDescriptionList(param: { codeName: string | null | undefined; descriptions: Array<DescriptionDTO> }): void {
|
|
170
|
+
const { codeName, descriptions } = param ?? {};
|
|
171
|
+
if (!codeName) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let codeNameMap = descriptionMap$.value[codeName];
|
|
176
|
+
if (!codeNameMap) {
|
|
177
|
+
codeNameMap = {};
|
|
178
|
+
|
|
179
|
+
descriptionMap$.value[codeName] = codeNameMap;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
for (let description of descriptions) {
|
|
183
|
+
if (description.codval) {
|
|
184
|
+
codeNameMap[description.codval] = description;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function t(key: string | null | undefined, param?: Record<string, any> | null | undefined, defaultValue?: string | null | undefined): string {
|
|
190
|
+
if (!key) {
|
|
191
|
+
return '';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const key01 = key.replace("t('", '').replace('t("', '').replace("')", '').replace('")', '');
|
|
195
|
+
|
|
196
|
+
//region 使用描述表的翻译
|
|
197
|
+
//----------------------------------------------------------------------------------------------------
|
|
198
|
+
const description = getDescription$$.value({ codeName: KG.DESCRIPTION_KEY__KG, codeValue: key01 }) ?? getDescription$$.value({ codeName: KG.DESCRIPTION_KEY__WEB, codeValue: key01 });
|
|
199
|
+
if (description) {
|
|
200
|
+
let _text = description.shortDsc ?? defaultValue ?? key ?? '';
|
|
201
|
+
|
|
202
|
+
//region 替换参数
|
|
203
|
+
//----------------------------------------------------------------------------------------------------
|
|
204
|
+
if (_text && param) {
|
|
205
|
+
for (let paramKey of Object.keys(param)) {
|
|
206
|
+
const paramValue = param[paramKey];
|
|
207
|
+
_text = _text.replaceAll(new RegExp(`\\{${paramKey}\\}`, 'g'), paramValue);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//----------------------------------------------------------------------------------------------------
|
|
211
|
+
//endregion
|
|
212
|
+
|
|
213
|
+
return _text;
|
|
214
|
+
} else {
|
|
215
|
+
return defaultValue ?? key ?? '';
|
|
216
|
+
}
|
|
217
|
+
//----------------------------------------------------------------------------------------------------
|
|
218
|
+
//endregion
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
//----------------------------------------------------------------------------------------------------
|
|
222
|
+
//endregion
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
descriptionMap$: descriptionMap$,
|
|
226
|
+
getDescription: getDescription$$,
|
|
227
|
+
getDescriptionList: getDescriptionList$$,
|
|
228
|
+
isDescriptionsRequestingMap$: isDescriptionsRequestingMap$,
|
|
229
|
+
requestDescriptionList: requestDescriptionList,
|
|
230
|
+
requestVarConfigDescriptionList: requestVarConfigDescriptionList,
|
|
231
|
+
setDescriptionList: setDescriptionList,
|
|
232
|
+
t: t,
|
|
233
|
+
};
|
|
234
|
+
});
|
package/config/index.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
//region 配置
|
|
2
|
+
//----------------------------------------------------------------------------------------------------
|
|
3
|
+
type IKgConfigParameter = {};
|
|
2
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 初始化组件库.
|
|
7
|
+
*
|
|
8
|
+
* @param param 参数.
|
|
9
|
+
*/
|
|
10
|
+
function kgConfig(param: IKgConfigParameter): void {}
|
|
11
|
+
|
|
12
|
+
/** @deprecated 已废弃, 请使用 {@link kgConfig()} */
|
|
13
|
+
const setup = kgConfig;
|
|
14
|
+
//----------------------------------------------------------------------------------------------------
|
|
15
|
+
//endregion
|
|
16
|
+
|
|
17
|
+
export * from './config.hooks';
|
|
18
|
+
export { kgConfig, setup };
|
package/index.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Pinia, StoreOnActionListener } from 'pinia';
|
|
2
|
+
import { KGCORE } from '@kengic/core.core';
|
|
3
|
+
|
|
4
|
+
/** @deprecated 已废弃, 请使用 {@link KG} */
|
|
5
|
+
const STORAGE_KEYS = {
|
|
6
|
+
API_URL: 'API_URL',
|
|
7
|
+
TOKEN: 'TOKEN',
|
|
8
|
+
USER: 'USER',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** @deprecated 已废弃, 请使用 {@link KG} */
|
|
12
|
+
enum KG_DYNAMIC_QUERY_OPERATOR {
|
|
3
13
|
/** 等于. */
|
|
4
14
|
EQ = 'EQ',
|
|
5
15
|
|
|
@@ -34,8 +44,8 @@ export enum KG_DYNAMIC_QUERY_OPERATOR {
|
|
|
34
44
|
BETWEEN = 'BETWEEN',
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
/**
|
|
38
|
-
|
|
47
|
+
/** @deprecated 已废弃, 请使用 {@link KG} */
|
|
48
|
+
enum KG_HTTP_HEADERS {
|
|
39
49
|
/** 界面标识. */
|
|
40
50
|
KG_FORM_ID = 'Kg-Form-Id',
|
|
41
51
|
|
|
@@ -77,3 +87,26 @@ export enum KG_HTTP_HEADERS {
|
|
|
77
87
|
*/
|
|
78
88
|
KG_WORK_AREA = 'Kg-Work-Area',
|
|
79
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 常量.
|
|
93
|
+
*/
|
|
94
|
+
const KG = {
|
|
95
|
+
...KGCORE,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 本地存储的键.
|
|
99
|
+
*/
|
|
100
|
+
STORAGE_KEY: {
|
|
101
|
+
API_URL: 'ApiUrl',
|
|
102
|
+
TOKEN: 'Token',
|
|
103
|
+
USER: 'User',
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 状态管理类型定义.
|
|
109
|
+
*/
|
|
110
|
+
type KgStoreDefinition<GETTERS, ACTIONS> = (pinia?: Pinia | null | undefined) => GETTERS & ACTIONS & { $onAction(callback: StoreOnActionListener<any, any, any, any>, detached?: boolean): () => void };
|
|
111
|
+
|
|
112
|
+
export { KG, type KgStoreDefinition, STORAGE_KEYS, KG_DYNAMIC_QUERY_OPERATOR, KG_HTTP_HEADERS };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kengic/uni",
|
|
3
|
-
"version": "0.7.13-beta.
|
|
3
|
+
"version": "0.7.13-beta.6",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"postinstall": "node bin/postinstall.mjs"
|
|
6
6
|
},
|
|
7
7
|
"bin": {
|
|
8
|
-
"kg-uni": "bin/
|
|
8
|
+
"kg-uni": "bin/bin.mjs"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@dcloudio/types": "3.3.3",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@dcloudio/uni-i18n": "3.0.0-alpha-3080220230428001",
|
|
19
19
|
"@dcloudio/uni-stacktracey": "3.0.0-alpha-3080220230428001",
|
|
20
20
|
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3080220230428001",
|
|
21
|
+
"@kengic/core.core": "0.0.1",
|
|
21
22
|
"@kengic/pont": "2.1.2",
|
|
22
23
|
"@types/lodash-es": "4.17.12",
|
|
23
24
|
"@types/node": "18.16.3",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="
|
|
2
|
+
<view class="my">
|
|
3
3
|
<UniList class="uni-list-setting">
|
|
4
|
-
<UniListItem :right-text="
|
|
5
|
-
<UniListItem link title="
|
|
4
|
+
<UniListItem link title="语言" :right-text="stationRightText$$" @click="openKgStation" />
|
|
5
|
+
<UniListItem link title="仓库" :right-text="kgWarehouse.warehouse.value?.whDsc ?? kgWarehouse.warehouse.value?.whId ?? ''" @click="openKgWarehouse" />
|
|
6
|
+
<UniListItem link title="工作站 - 工作区" :right-text="stationRightText$$" @click="openKgStation" />
|
|
6
7
|
<UniListItem link title="后端服务地址" :right-text="apiUrl" />
|
|
7
8
|
|
|
8
9
|
<!--#ifdef APP-PLUS-->
|
|
@@ -38,9 +39,9 @@
|
|
|
38
39
|
//region DATA
|
|
39
40
|
// ----------------------------------------------------------------------------------------------------
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* 工作站的右侧文本.
|
|
42
43
|
*/
|
|
43
|
-
const
|
|
44
|
+
const stationRightText$$ = computed<string>(() => {
|
|
44
45
|
let text = kgStation.station.value?.devcodDsc ?? kgStation.station.value?.devcod ?? '';
|
|
45
46
|
|
|
46
47
|
// 如果选择了工作区, 才显示工作区, 否则只显示工作站,
|
|
@@ -53,7 +54,11 @@
|
|
|
53
54
|
// ----------------------------------------------------------------------------------------------------
|
|
54
55
|
//endregion
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
//region FUNCTION
|
|
58
|
+
//----------------------------------------------------------------------------------------------------
|
|
59
|
+
/**
|
|
60
|
+
* 退出登录.
|
|
61
|
+
*/
|
|
57
62
|
function logout() {
|
|
58
63
|
uni.showModal({
|
|
59
64
|
title: '是否退出系统 ?',
|
|
@@ -82,6 +87,7 @@
|
|
|
82
87
|
const apiUrl = computed<string>(() => appStore.getApiUrl ?? '');
|
|
83
88
|
|
|
84
89
|
/* #ifdef APP-PLUS */
|
|
90
|
+
//----------------------------------------------------------------------------------------------------
|
|
85
91
|
/** 当前版本. */
|
|
86
92
|
const currentVersion = computed<string>(() => plus.runtime.version ?? '');
|
|
87
93
|
|
|
@@ -91,32 +97,35 @@
|
|
|
91
97
|
function checkForUpdate() {
|
|
92
98
|
KgUtil.checkForUpdate(true, false);
|
|
93
99
|
}
|
|
94
|
-
|
|
100
|
+
//----------------------------------------------------------------------------------------------------
|
|
95
101
|
/* #endif */
|
|
102
|
+
|
|
103
|
+
//----------------------------------------------------------------------------------------------------
|
|
104
|
+
//endregion
|
|
96
105
|
</script>
|
|
97
106
|
|
|
98
|
-
<style lang="scss"
|
|
99
|
-
.uni-list-setting {
|
|
107
|
+
<style lang="scss">
|
|
108
|
+
.my .uni-list-setting {
|
|
100
109
|
background-color: #e0e0e0;
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
.list-item-check-for-update {
|
|
112
|
+
.my .list-item-check-for-update {
|
|
104
113
|
text-align: center;
|
|
105
114
|
}
|
|
106
115
|
|
|
107
|
-
.list-item-check-for-update :deep .uni-list-item__content-title {
|
|
116
|
+
.my .list-item-check-for-update :deep .uni-list-item__content-title {
|
|
108
117
|
color: #2979ff;
|
|
109
118
|
}
|
|
110
119
|
|
|
111
|
-
.list-item-logout {
|
|
120
|
+
.my .list-item-logout {
|
|
112
121
|
text-align: center;
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
.list-item-logout :deep .uni-list-item__content-title {
|
|
124
|
+
.my .list-item-logout :deep .uni-list-item__content-title {
|
|
116
125
|
color: red;
|
|
117
126
|
}
|
|
118
127
|
|
|
119
|
-
:deep .uni-list-item__content-title {
|
|
128
|
+
.my :deep .uni-list-item__content-title {
|
|
120
129
|
font-size: 13px;
|
|
121
130
|
}
|
|
122
131
|
</style>
|
package/service/http-client.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useAppStore } from '../store/app.store';
|
|
2
2
|
import { KgUtil } from '../util';
|
|
3
|
-
import { KG_DYNAMIC_QUERY_OPERATOR, KG_HTTP_HEADERS } from '../const';
|
|
4
3
|
import { useKgWarehouse } from '../component/KgWarehouse/index.hooks';
|
|
5
4
|
import { useKgStation } from '../component/KgStation';
|
|
6
5
|
import { isNil } from 'lodash-es';
|
|
7
6
|
import dayjs from 'dayjs';
|
|
7
|
+
import { KG } from '../model';
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
* 对请求做统一的拦截.
|
|
@@ -75,7 +75,7 @@ type IRequestOptions = Omit<UniApp.RequestOptions, 'url'> & {
|
|
|
75
75
|
* <p>如果该参数不为空, 表示该请求启用了高级查询.</p>
|
|
76
76
|
* <p>其中的 key 表示参数名, 对应的 value 表示该参数的高级查询操作符(>,=,<...).</p>
|
|
77
77
|
*/
|
|
78
|
-
dynamicQueryOperatorModel?: Record<string,
|
|
78
|
+
dynamicQueryOperatorModel?: Record<string, string>;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* 是否显示加载提示.
|
|
@@ -245,23 +245,23 @@ const _httpClient: IHttpClient = {
|
|
|
245
245
|
|
|
246
246
|
header = {
|
|
247
247
|
...(header ?? {}),
|
|
248
|
-
[
|
|
249
|
-
[
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
[
|
|
253
|
-
[
|
|
248
|
+
[KG.HTTP_HEADER__KG_IS_DYNAMIC_QUERY]: true,
|
|
249
|
+
[KG.HTTP_HEADER__KG_QUERY_OFFSET_SQL]: offsetSql,
|
|
250
|
+
[KG.HTTP_HEADER__KG_QUERY_OPERATOR_OBJECT]: operatorJSON,
|
|
251
|
+
[KG.HTTP_HEADER__KG_QUERY_ORDER_BY_SQL]: orderBySql,
|
|
252
|
+
[KG.HTTP_HEADER__KG_QUERY_SQL]: sql,
|
|
253
|
+
[KG.HTTP_HEADER__KG_QUERY_WHERE_SQL]: whereSql,
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
header[
|
|
258
|
-
header[
|
|
259
|
-
header[
|
|
260
|
-
header[
|
|
257
|
+
header[KG.HTTP_HEADER__KG_QUERY_WHERE_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_WHERE_SQL] ?? '')));
|
|
258
|
+
header[KG.HTTP_HEADER__KG_QUERY_ORDER_BY_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_ORDER_BY_SQL] ?? '')));
|
|
259
|
+
header[KG.HTTP_HEADER__KG_QUERY_OFFSET_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_OFFSET_SQL] ?? '')));
|
|
260
|
+
header[KG.HTTP_HEADER__KG_QUERY_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_SQL] ?? '')));
|
|
261
261
|
|
|
262
|
-
header[
|
|
263
|
-
header[
|
|
264
|
-
header[
|
|
262
|
+
header[KG.HTTP_HEADER__KG_WAREHOUSE] = encodeURIComponent(useKgWarehouse().warehouse.value?.whId ?? '');
|
|
263
|
+
header[KG.HTTP_HEADER__KG_WORK_STATION] = encodeURIComponent(useKgStation().station.value?.devcod ?? '');
|
|
264
|
+
header[KG.HTTP_HEADER__KG_WORK_AREA] = encodeURIComponent(useKgStation().station.value?.hmewrkare ?? '');
|
|
265
265
|
|
|
266
266
|
uni.request({
|
|
267
267
|
...(options ?? {}),
|
package/store/app.store.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineStore } from 'pinia';
|
|
2
|
-
import {
|
|
2
|
+
import { KG } from '../model';
|
|
3
3
|
import { SysUser, SysUserWarehouseDTO } from '../api/WMS/models';
|
|
4
4
|
import { API } from '../api';
|
|
5
5
|
|
|
@@ -68,7 +68,7 @@ export const useAppStore = defineStore('app', {
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
setApiUrl(apiUrl: string) {
|
|
71
|
-
uni.setStorageSync(
|
|
71
|
+
uni.setStorageSync(KG.STORAGE_KEY.API_URL, apiUrl);
|
|
72
72
|
this.apiUrl = apiUrl;
|
|
73
73
|
},
|
|
74
74
|
|
|
@@ -81,12 +81,12 @@ export const useAppStore = defineStore('app', {
|
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
setToken(token: string) {
|
|
84
|
-
uni.setStorageSync(
|
|
84
|
+
uni.setStorageSync(KG.STORAGE_KEY.TOKEN, token);
|
|
85
85
|
this.token = token;
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
setUser(user: SysUser | null) {
|
|
89
|
-
uni.setStorageSync(
|
|
89
|
+
uni.setStorageSync(KG.STORAGE_KEY.USER, user);
|
|
90
90
|
this.user = user;
|
|
91
91
|
},
|
|
92
92
|
},
|
|
@@ -120,11 +120,11 @@ export const useAppStore = defineStore('app', {
|
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
122
|
state: (): IAppState => ({
|
|
123
|
-
apiUrl: uni.getStorageSync(
|
|
123
|
+
apiUrl: uni.getStorageSync(KG.STORAGE_KEY.API_URL) ?? '',
|
|
124
124
|
isUpdateCancel: false,
|
|
125
125
|
locale: 'zh_CN',
|
|
126
|
-
token: uni.getStorageSync(
|
|
127
|
-
user: uni.getStorageSync(
|
|
126
|
+
token: uni.getStorageSync(KG.STORAGE_KEY.TOKEN) ?? '',
|
|
127
|
+
user: uni.getStorageSync(KG.STORAGE_KEY.USER) ?? {},
|
|
128
128
|
userWarehouses: undefined,
|
|
129
129
|
}),
|
|
130
130
|
});
|
package/util/kg.util.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { toRaw, unref } from 'vue';
|
|
|
3
3
|
import { API } from '../api';
|
|
4
4
|
import { useKgStation, useKgWarehouse } from '../component';
|
|
5
5
|
import { useAppStore } from '../store/app.store';
|
|
6
|
-
import { KG_DYNAMIC_QUERY_OPERATOR } from '../const';
|
|
7
6
|
import dayjs, { Dayjs } from 'dayjs';
|
|
7
|
+
import { KG } from '../model';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 通用工具.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
class KgUtil {
|
|
13
13
|
/**
|
|
14
14
|
* 判断当前登录用户是否是管理员.
|
|
15
15
|
* @return {} 如果当前登录用户是管理员则返回 true, 否则返回 false.
|
|
@@ -241,7 +241,7 @@ export class KgUtil {
|
|
|
241
241
|
|
|
242
242
|
let _key = key;
|
|
243
243
|
const value = _params[key];
|
|
244
|
-
let operator: string = dynamicQueryOperatorModel?.[key] ??
|
|
244
|
+
let operator: string = dynamicQueryOperatorModel?.[key] ?? KG.DYNAMIC_QUERY_OPERATOR__EQ;
|
|
245
245
|
|
|
246
246
|
switch (true) {
|
|
247
247
|
//region 日期范围
|
|
@@ -250,7 +250,7 @@ export class KgUtil {
|
|
|
250
250
|
let _stringValue = '';
|
|
251
251
|
|
|
252
252
|
switch (operator) {
|
|
253
|
-
case
|
|
253
|
+
case KG.DYNAMIC_QUERY_OPERATOR__BETWEEN:
|
|
254
254
|
default: {
|
|
255
255
|
const _leftValue = value[0] as Dayjs;
|
|
256
256
|
const _rightValue = value[1] as Dayjs;
|
|
@@ -312,27 +312,27 @@ export class KgUtil {
|
|
|
312
312
|
let _strValue = value;
|
|
313
313
|
|
|
314
314
|
switch (operator) {
|
|
315
|
-
case
|
|
315
|
+
case KG.DYNAMIC_QUERY_OPERATOR__NE: {
|
|
316
316
|
_strValue = ` AND (${_key} <> N'${_strValue}')`;
|
|
317
317
|
break;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
case
|
|
320
|
+
case KG.DYNAMIC_QUERY_OPERATOR__START_WITH: {
|
|
321
321
|
_strValue = ` AND (${_key} LIKE N'${_strValue}%')`;
|
|
322
322
|
break;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
case
|
|
325
|
+
case KG.DYNAMIC_QUERY_OPERATOR__END_WITH: {
|
|
326
326
|
_strValue = ` AND (${_key} LIKE N'%${_strValue}')`;
|
|
327
327
|
break;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
case
|
|
330
|
+
case KG.DYNAMIC_QUERY_OPERATOR__CONTAIN: {
|
|
331
331
|
_strValue = ` AND (${_key} LIKE N'%${_strValue}%')`;
|
|
332
332
|
break;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
case
|
|
335
|
+
case KG.DYNAMIC_QUERY_OPERATOR__EQ:
|
|
336
336
|
default: {
|
|
337
337
|
_strValue = ` AND (${_key} = N'${_strValue}')`;
|
|
338
338
|
break;
|
|
@@ -349,32 +349,32 @@ export class KgUtil {
|
|
|
349
349
|
let _strValue = '';
|
|
350
350
|
|
|
351
351
|
switch (operator) {
|
|
352
|
-
case
|
|
352
|
+
case KG.DYNAMIC_QUERY_OPERATOR__NE: {
|
|
353
353
|
_strValue = ` AND (${_key} <> ${value})`;
|
|
354
354
|
break;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
case
|
|
357
|
+
case KG.DYNAMIC_QUERY_OPERATOR__LT: {
|
|
358
358
|
_strValue = ` AND (${_key} < ${value})`;
|
|
359
359
|
break;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
case
|
|
362
|
+
case KG.DYNAMIC_QUERY_OPERATOR__LTE: {
|
|
363
363
|
_strValue = ` AND (${_key} <= ${value})`;
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
case
|
|
367
|
+
case KG.DYNAMIC_QUERY_OPERATOR__GT: {
|
|
368
368
|
_strValue = ` AND (${_key} > ${value})`;
|
|
369
369
|
break;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
case
|
|
372
|
+
case KG.DYNAMIC_QUERY_OPERATOR__GTE: {
|
|
373
373
|
_strValue = ` AND (${_key} >= ${value})`;
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
-
case
|
|
377
|
+
case KG.DYNAMIC_QUERY_OPERATOR__EQ:
|
|
378
378
|
default: {
|
|
379
379
|
_strValue = ` AND (${_key} = ${value})`;
|
|
380
380
|
break;
|
|
@@ -391,12 +391,12 @@ export class KgUtil {
|
|
|
391
391
|
let _strValue = '';
|
|
392
392
|
|
|
393
393
|
switch (operator) {
|
|
394
|
-
case
|
|
394
|
+
case KG.DYNAMIC_QUERY_OPERATOR__NE: {
|
|
395
395
|
_strValue = ` AND (${_key} <> ${value ? 1 : 0})`;
|
|
396
396
|
break;
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
case
|
|
399
|
+
case KG.DYNAMIC_QUERY_OPERATOR__EQ:
|
|
400
400
|
default: {
|
|
401
401
|
_strValue = ` AND (${_key} = ${value ? 1 : 0})`;
|
|
402
402
|
break;
|
|
@@ -506,4 +506,6 @@ export class KgUtil {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
/** @deprecated 已废弃, 请使用 {@link KgUtil} */
|
|
509
|
-
|
|
509
|
+
const Kg = KgUtil;
|
|
510
|
+
|
|
511
|
+
export { Kg, KgUtil };
|
package/config/config.ts
DELETED