@kengic/uni 0.3.3-beta.1 → 0.3.3
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/dist/api/WMS/Controllers/LoginController/Logout.ts +28 -28
- package/dist/api/WMS/Controllers/LoginController/index.ts +1 -1
- package/dist/api/WMS/Controllers/WhController/ListVO.ts +89 -89
- package/dist/api/WMS/Controllers/WhController/index.ts +1 -1
- package/dist/api/WMS/Controllers/index.ts +2 -2
- package/dist/api/WMS/index.ts +2 -2
- package/dist/api/WMS/models.ts +189 -189
- package/dist/api/api.ts +1 -1
- package/dist/api/def.ts +1 -1
- package/dist/api/index.ts +2 -2
- package/dist/component/KgWarehouse/KgWarehouse.vue +83 -0
- package/dist/component/KgWarehouse/index.hooks.ts +20 -0
- package/dist/component/KgWarehouse/index.store.ts +46 -0
- package/dist/component/KgWarehouse/index.ts +4 -0
- package/dist/component/index.ts +1 -0
- package/dist/index.ts +2 -0
- package/dist/service/http-client.ts +6 -1
- package/dist/store/app.store.ts +62 -62
- package/dist/uni/uni-ui/README.md +1 -0
- package/dist/uni/uni-ui/uni-popup/popup.js +1 -1
- package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +249 -252
- package/dist/util/index.ts +1 -0
- package/dist/util/kg.util.ts +72 -0
- package/package.json +3 -5
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UniPopup ref="popupRef" :type="'dialog'">
|
|
3
|
+
<UniPopupDialog :before-close="true" title="选择仓库" @confirm="onOk">
|
|
4
|
+
<UniDataCheckbox v-model="whID" :localdata="datas" />
|
|
5
|
+
</UniPopupDialog>
|
|
6
|
+
</UniPopup>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { UniDataCheckbox, UniPopup, UniPopupDialog } from '../../uni';
|
|
11
|
+
import { API } from '../../api';
|
|
12
|
+
import { ref } from 'vue';
|
|
13
|
+
import { WhDTO } from '../../api/WMS/models';
|
|
14
|
+
import { useKgWarehouse } from './index.hooks';
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits(['ok']);
|
|
17
|
+
|
|
18
|
+
const kgWarehouse = useKgWarehouse();
|
|
19
|
+
|
|
20
|
+
const popupRef = ref<UniPopupDialog>(null);
|
|
21
|
+
/** 当前选择的仓库编号. */
|
|
22
|
+
const whID = ref<string>('');
|
|
23
|
+
/** 仓库列表. */
|
|
24
|
+
let warehouses: Array<WhDTO> = [];
|
|
25
|
+
/** 选项列表. */
|
|
26
|
+
const datas = ref<Array<{ value: string; text: string }>>([]);
|
|
27
|
+
|
|
28
|
+
/** 确定. */
|
|
29
|
+
function onOk() {
|
|
30
|
+
kgWarehouse.store.setWarehouse(warehouses.find((i) => i.whId === whID.value));
|
|
31
|
+
popupRef.value?.close();
|
|
32
|
+
emit('ok');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 打开弹窗. */
|
|
36
|
+
function open() {
|
|
37
|
+
popupRef.value?.open();
|
|
38
|
+
read();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 查询仓库列表. */
|
|
42
|
+
async function read(): Promise<void> {
|
|
43
|
+
try {
|
|
44
|
+
const { records } = await API.WMS.WhController.ListVO({ params: { pageNo: 1, pageSize: 999 } });
|
|
45
|
+
warehouses = records ?? [];
|
|
46
|
+
datas.value = warehouses.map((i: WhDTO) => ({
|
|
47
|
+
value: i.whId,
|
|
48
|
+
text: `${i.whDsc ?? ' '} - ${i.whId ?? ' '}`,
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const currentWarehouse = warehouses.find((i) => kgWarehouse.warehouse.value?.whId === i.whId);
|
|
52
|
+
// 如果当前仓库不为空, 且有效(存在于当前仓库列表中), 则继续使用
|
|
53
|
+
if (currentWarehouse) {
|
|
54
|
+
whID.value = currentWarehouse.whId;
|
|
55
|
+
}
|
|
56
|
+
// 否则, 清空当前仓库, 并默认选中第一个仓库
|
|
57
|
+
else {
|
|
58
|
+
kgWarehouse.store.setWarehouse(null);
|
|
59
|
+
if (warehouses.length > 0) {
|
|
60
|
+
whID.value = warehouses[0].whId;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error(e);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
defineExpose({ open });
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<style scoped lang="scss">
|
|
72
|
+
:deep {
|
|
73
|
+
.uni-dialog-button-group > .uni-dialog-button:first-child {
|
|
74
|
+
display: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.uni-label-pointer {
|
|
78
|
+
width: 100%;
|
|
79
|
+
margin: 0 !important;
|
|
80
|
+
padding: 12px 0 !important;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { computed, ComputedRef } from 'vue';
|
|
2
|
+
import { IKgWarehouseStore, useKgWarehouseStore } from './index.store';
|
|
3
|
+
import { WhDTO } from '../../api/WMS/models';
|
|
4
|
+
|
|
5
|
+
export type IUseKgWarehouse = {
|
|
6
|
+
store: IKgWarehouseStore;
|
|
7
|
+
/** 当前仓库. */
|
|
8
|
+
warehouse: ComputedRef<WhDTO | null>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function useKgWarehouse(): IUseKgWarehouse {
|
|
12
|
+
const store = useKgWarehouseStore();
|
|
13
|
+
|
|
14
|
+
const warehouse = computed(() => store.getWarehouse);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
store,
|
|
18
|
+
warehouse,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineStore, StoreDefinition } from 'pinia';
|
|
2
|
+
import { toRaw, unref } from 'vue';
|
|
3
|
+
import { WhDTO } from '../../api/WMS/models';
|
|
4
|
+
|
|
5
|
+
const LOCAL_STORAGE_KEY = 'KgWarehouse.warehouse';
|
|
6
|
+
|
|
7
|
+
export interface IKgWarehouseState {
|
|
8
|
+
/** 仓库对象. */
|
|
9
|
+
warehouse: WhDTO | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type IKgWarehouseStoreDefinition = StoreDefinition<
|
|
13
|
+
'KgWarehouse',
|
|
14
|
+
IKgWarehouseState,
|
|
15
|
+
{
|
|
16
|
+
getWarehouse: WhDTO | null;
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
setWarehouse(warehouse?: WhDTO | null): void;
|
|
20
|
+
}
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export type IKgWarehouseStore = ReturnType<IKgWarehouseStoreDefinition>;
|
|
24
|
+
|
|
25
|
+
export const useKgWarehouseStore = defineStore('KgWarehouse', {
|
|
26
|
+
state: (): IKgWarehouseState => ({
|
|
27
|
+
warehouse: null,
|
|
28
|
+
}),
|
|
29
|
+
getters: {
|
|
30
|
+
getWarehouse(): WhDTO | null {
|
|
31
|
+
return this.warehouse || uni.getStorageSync(LOCAL_STORAGE_KEY) || null;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
setWarehouse(warehouse?: WhDTO | null): void {
|
|
36
|
+
if (!warehouse) {
|
|
37
|
+
this.warehouse = null;
|
|
38
|
+
uni.setStorageSync(LOCAL_STORAGE_KEY, null);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.warehouse = toRaw(unref(warehouse));
|
|
43
|
+
uni.setStorageSync(LOCAL_STORAGE_KEY, this.warehouse);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './KgWarehouse';
|
package/dist/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useAppStore } from '../store/app.store';
|
|
2
|
+
import { KgUtil } from '../util';
|
|
2
3
|
|
|
3
4
|
/*
|
|
4
5
|
* 对请求做统一的拦截.
|
|
@@ -10,7 +11,9 @@ uni.addInterceptor('request', {
|
|
|
10
11
|
const appStore = useAppStore();
|
|
11
12
|
args.header['Authorization'] = appStore.getToken;
|
|
12
13
|
args.header['X-Access-Token'] = appStore.getToken;
|
|
13
|
-
args.url
|
|
14
|
+
if (!args.url?.startsWith('http')) {
|
|
15
|
+
args.url = appStore.getApiUrl + args.url;
|
|
16
|
+
}
|
|
14
17
|
|
|
15
18
|
// 如果 body 参数传的是数组, uni 会将它转换为对象, 我们需要将它重新转换回数组
|
|
16
19
|
const keys = Object.keys(args.data ?? {})
|
|
@@ -19,6 +22,8 @@ uni.addInterceptor('request', {
|
|
|
19
22
|
if (args.data?.length === undefined && keys.length > 0) {
|
|
20
23
|
args.data = keys.map((i) => args.data[i]);
|
|
21
24
|
}
|
|
25
|
+
|
|
26
|
+
args.data = KgUtil.parseParams(args.data);
|
|
22
27
|
},
|
|
23
28
|
success(args) {
|
|
24
29
|
uni.hideLoading();
|
package/dist/store/app.store.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { defineStore } from 'pinia';
|
|
2
|
-
import { STORAGE_KEYS } from '../const';
|
|
3
|
-
import { SysUser } from '../api/WMS/models';
|
|
4
|
-
import { API } from '../api';
|
|
5
|
-
|
|
6
|
-
interface IAppState {
|
|
7
|
-
apiUrl: string;
|
|
8
|
-
token: string;
|
|
9
|
-
|
|
10
|
-
/** 当前登录用户. */
|
|
11
|
-
user: SysUser | null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const useAppStore = defineStore('app', {
|
|
15
|
-
state: (): IAppState => ({
|
|
16
|
-
apiUrl: '',
|
|
17
|
-
token: '',
|
|
18
|
-
user: {},
|
|
19
|
-
}),
|
|
20
|
-
getters: {
|
|
21
|
-
getApiUrl(state) {
|
|
22
|
-
return state.apiUrl || uni.getStorageSync(STORAGE_KEYS.API_URL) || 'http://localhost:8080/kengic-boot';
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
getToken(state) {
|
|
26
|
-
return state.token || uni.getStorageSync(STORAGE_KEYS.TOKEN);
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
/** 当前登录用户. */
|
|
30
|
-
getUser(state) {
|
|
31
|
-
return state.user || uni.getStorageSync(STORAGE_KEYS.USER);
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
actions: {
|
|
35
|
-
setApiUrl(apiUrl: string) {
|
|
36
|
-
uni.setStorageSync(STORAGE_KEYS.API_URL, apiUrl);
|
|
37
|
-
this.apiUrl = apiUrl;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
setToken(token: string) {
|
|
41
|
-
uni.setStorageSync(STORAGE_KEYS.TOKEN, token);
|
|
42
|
-
this.token = token;
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
setUser(user: SysUser | null) {
|
|
46
|
-
uni.setStorageSync(STORAGE_KEYS.USER, user);
|
|
47
|
-
this.user = user;
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 退出登录.
|
|
52
|
-
*/
|
|
53
|
-
async logout() {
|
|
54
|
-
if (this.getToken) {
|
|
55
|
-
await API.WMS.LoginController.Logout({}, { header: { 'X-Access-Token': this.getToken } });
|
|
56
|
-
}
|
|
57
|
-
this.setToken('');
|
|
58
|
-
this.setUser(null);
|
|
59
|
-
uni.reLaunch({ url: '/pages/login/
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
});
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { STORAGE_KEYS } from '../const';
|
|
3
|
+
import { SysUser } from '../api/WMS/models';
|
|
4
|
+
import { API } from '../api';
|
|
5
|
+
|
|
6
|
+
interface IAppState {
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
token: string;
|
|
9
|
+
|
|
10
|
+
/** 当前登录用户. */
|
|
11
|
+
user: SysUser | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useAppStore = defineStore('app', {
|
|
15
|
+
state: (): IAppState => ({
|
|
16
|
+
apiUrl: '',
|
|
17
|
+
token: '',
|
|
18
|
+
user: {},
|
|
19
|
+
}),
|
|
20
|
+
getters: {
|
|
21
|
+
getApiUrl(state) {
|
|
22
|
+
return state.apiUrl || uni.getStorageSync(STORAGE_KEYS.API_URL) || 'http://localhost:8080/kengic-boot';
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
getToken(state) {
|
|
26
|
+
return state.token || uni.getStorageSync(STORAGE_KEYS.TOKEN);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/** 当前登录用户. */
|
|
30
|
+
getUser(state) {
|
|
31
|
+
return state.user || uni.getStorageSync(STORAGE_KEYS.USER);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
setApiUrl(apiUrl: string) {
|
|
36
|
+
uni.setStorageSync(STORAGE_KEYS.API_URL, apiUrl);
|
|
37
|
+
this.apiUrl = apiUrl;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
setToken(token: string) {
|
|
41
|
+
uni.setStorageSync(STORAGE_KEYS.TOKEN, token);
|
|
42
|
+
this.token = token;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
setUser(user: SysUser | null) {
|
|
46
|
+
uni.setStorageSync(STORAGE_KEYS.USER, user);
|
|
47
|
+
this.user = user;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 退出登录.
|
|
52
|
+
*/
|
|
53
|
+
async logout() {
|
|
54
|
+
if (this.getToken) {
|
|
55
|
+
await API.WMS.LoginController.Logout({}, { header: { 'X-Access-Token': this.getToken } });
|
|
56
|
+
}
|
|
57
|
+
this.setToken('');
|
|
58
|
+
this.setUser(null);
|
|
59
|
+
uni.reLaunch({ url: '/pages/login/Login' });
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## 最近一次同步的提交是 196a983af765287f539c071c0fbf6919e68a6a94
|