@kengic/uni 0.6.3-beta.0 → 0.6.3-beta.2
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/CommonController/GetLatestApkVersion.ts +21 -28
- package/dist/api/WMS/Controllers/CommonController/index.ts +1 -1
- package/dist/api/WMS/Controllers/LoginController/GetUserInfo.ts +21 -0
- package/dist/api/WMS/Controllers/LoginController/Logout.ts +21 -28
- package/dist/api/WMS/Controllers/LoginController/index.ts +2 -1
- package/dist/api/WMS/Controllers/WhController/ListVO.ts +88 -92
- package/dist/api/WMS/Controllers/WhController/index.ts +1 -1
- package/dist/api/WMS/Controllers/WorkstationController/List.ts +45 -0
- package/dist/api/WMS/Controllers/WorkstationController/index.ts +1 -0
- package/dist/api/WMS/Controllers/index.ts +4 -3
- package/dist/api/WMS/index.ts +2 -2
- package/dist/api/WMS/models.ts +318 -192
- package/dist/api/api.ts +1 -1
- package/dist/api/def.ts +1 -1
- package/dist/api/index.ts +2 -2
- package/dist/component/KgStation/KgStation.vue +176 -0
- package/dist/component/KgStation/index.hooks.ts +62 -0
- package/dist/component/KgStation/index.store.ts +76 -0
- package/dist/component/KgStation/index.ts +4 -0
- package/dist/component/KgTabBar/KgTabBar.vue +2 -2
- package/dist/component/KgWarehouse/KgWarehouse.vue +47 -30
- package/dist/component/KgWarehouse/index.hooks.ts +24 -1
- package/dist/component/KgWarehouse/index.store.ts +8 -8
- package/dist/component/index.ts +1 -0
- package/dist/index.css +5 -0
- package/dist/service/http-client.ts +9 -2
- package/dist/store/app.store.ts +68 -49
- package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +18 -13
- package/dist/uni/uni-ui/uni-icons/uniicons_file.ts +646 -646
- package/dist/uni/uni-ui/uni-icons/uniicons_file_vue.js +646 -646
- package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
- package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +12 -7
- package/dist/uni/uni-ui/uni-rate/uni-rate.vue +1 -2
- package/dist/util/kg.ts +33 -7
- package/package.json +2 -2
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UniPopup ref="popupRef" :type="'dialog'">
|
|
3
|
+
<UniPopupDialog :before-close="true" title="选择工作站" @close="onClose" @confirm="onOk">
|
|
4
|
+
<div class="row">
|
|
5
|
+
<div class="label">工作站:</div>
|
|
6
|
+
<div class="value">
|
|
7
|
+
<UniDataSelect :localdata="stationDatas" v-model="currentDevcod" :clear="true" />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="row">
|
|
11
|
+
<div class="label">工作区:</div>
|
|
12
|
+
<div class="value">
|
|
13
|
+
<UniDataSelect :localdata="areaDatas" v-model="currentHmewrkare" :clear="true" />
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</UniPopupDialog>
|
|
17
|
+
</UniPopup>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import { UniDataSelect, UniPopup, UniPopupDialog } from '../../uni';
|
|
22
|
+
import { computed, ref, watch } from 'vue';
|
|
23
|
+
import { useKgStation } from './index.hooks';
|
|
24
|
+
import { WorkstationDTO } from '../../api/WMS/models';
|
|
25
|
+
import { API } from '../../api';
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits(['ok']);
|
|
28
|
+
|
|
29
|
+
const kgStation = useKgStation();
|
|
30
|
+
|
|
31
|
+
//region DATA
|
|
32
|
+
// ----------------------------------------------------------------------------------------------------
|
|
33
|
+
const popupRef = ref<any>(null);
|
|
34
|
+
|
|
35
|
+
/** 当前选择的工作站编号. */
|
|
36
|
+
const currentDevcod = ref<string>('');
|
|
37
|
+
|
|
38
|
+
/** 当前选择的工作区编号. */
|
|
39
|
+
const currentHmewrkare = ref<string>('');
|
|
40
|
+
|
|
41
|
+
/** 所有工作站. */
|
|
42
|
+
const stations = ref<Array<WorkstationDTO>>([]);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 工作站下拉列表.
|
|
46
|
+
*/
|
|
47
|
+
const stationDatas = computed<Array<{ value: string; text: string }>>(() => stations.value.map((i) => ({ text: i.devcod ?? '', value: i.devcod ?? '' })));
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 工作区下拉列表.
|
|
51
|
+
*/
|
|
52
|
+
const areaDatas = computed<Array<{ value: string; text: string }>>(
|
|
53
|
+
() =>
|
|
54
|
+
stations.value
|
|
55
|
+
.find((i) => i.devcod === currentDevcod.value)
|
|
56
|
+
?.workstationAreas?.map((i) => ({
|
|
57
|
+
text: i.wrkareDsc ?? i.wrkare ?? '',
|
|
58
|
+
value: i.wrkare ?? '',
|
|
59
|
+
})) ?? [],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// ----------------------------------------------------------------------------------------------------
|
|
63
|
+
//endregion
|
|
64
|
+
|
|
65
|
+
//region WATCH
|
|
66
|
+
// ----------------------------------------------------------------------------------------------------
|
|
67
|
+
watch(currentDevcod, (value) => {
|
|
68
|
+
// 当清空「当前选择的工作站编号」时, 也清空「当前选择的工作区编号」,
|
|
69
|
+
if (!value) {
|
|
70
|
+
currentHmewrkare.value = '';
|
|
71
|
+
} else {
|
|
72
|
+
console.log('11', value, currentDevcod.value);
|
|
73
|
+
// 当「当前选择的工作站编号」变更时, 选择它的默认的工作区,
|
|
74
|
+
const currentStation = stations.value.find((i) => i.devcod === currentDevcod.value);
|
|
75
|
+
if (currentStation) {
|
|
76
|
+
currentHmewrkare.value = currentStation.hmewrkare ?? '';
|
|
77
|
+
console.log('22', currentHmewrkare.value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// ----------------------------------------------------------------------------------------------------
|
|
82
|
+
//endregion
|
|
83
|
+
|
|
84
|
+
//region FUNCTION
|
|
85
|
+
// ----------------------------------------------------------------------------------------------------
|
|
86
|
+
/**
|
|
87
|
+
* 取消.
|
|
88
|
+
*/
|
|
89
|
+
function onClose() {
|
|
90
|
+
popupRef.value?.close();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 确定.
|
|
95
|
+
*/
|
|
96
|
+
function onOk() {
|
|
97
|
+
const currentStation = stations.value.find((i) => i.devcod === currentDevcod.value);
|
|
98
|
+
if (currentStation) {
|
|
99
|
+
currentStation.hmewrkare = currentHmewrkare.value;
|
|
100
|
+
kgStation.store.setStation(currentStation);
|
|
101
|
+
} else {
|
|
102
|
+
kgStation.store.setStation(null);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
popupRef.value?.close();
|
|
106
|
+
emit('ok');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 打开弹窗. */
|
|
110
|
+
function open() {
|
|
111
|
+
popupRef.value?.open();
|
|
112
|
+
|
|
113
|
+
currentDevcod.value = kgStation.station.value?.devcod ?? '';
|
|
114
|
+
currentHmewrkare.value = kgStation.station.value?.hmewrkare ?? '';
|
|
115
|
+
|
|
116
|
+
requestStations();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 获取所有工作站.
|
|
121
|
+
*/
|
|
122
|
+
async function requestStations(): Promise<void> {
|
|
123
|
+
try {
|
|
124
|
+
stations.value = (await API.WMS.WorkstationController.List({ params: { pageNo: 1, pageSize: 999 } }))?.records ?? [];
|
|
125
|
+
} catch (e) {
|
|
126
|
+
console.error(e);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// ----------------------------------------------------------------------------------------------------
|
|
130
|
+
//endregion
|
|
131
|
+
|
|
132
|
+
defineExpose({ open });
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<style scoped>
|
|
136
|
+
:deep(.uni-popup-dialog) {
|
|
137
|
+
font-size: 13px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
:deep(.uni-popup-dialog) .uni-select {
|
|
141
|
+
padding-right: 4px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
:deep(.uni-popup-dialog) .uni-label-pointer {
|
|
145
|
+
width: 100%;
|
|
146
|
+
margin: 0 !important;
|
|
147
|
+
padding: 12px 0 !important;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:deep(.uni-popup-dialog) .uni-dialog-content {
|
|
151
|
+
flex-direction: column;
|
|
152
|
+
align-items: flex-start;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:deep(.uni-popup-dialog) .uni-dialog-content > .row {
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
margin-bottom: 3px;
|
|
159
|
+
width: 100%;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
:deep(.uni-popup-dialog) .uni-dialog-content > .row:last-child {
|
|
163
|
+
margin-bottom: 0px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
:deep(.uni-popup-dialog) .uni-dialog-content > .row > .label {
|
|
167
|
+
width: 80px;
|
|
168
|
+
text-align: right;
|
|
169
|
+
margin-right: 6px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:deep(.uni-popup-dialog) .uni-dialog-content > .row > .value {
|
|
173
|
+
flex: 1;
|
|
174
|
+
min-width: 0;
|
|
175
|
+
}
|
|
176
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { computed, ComputedRef } from 'vue';
|
|
2
|
+
import { IKgStationStore, useKgStationStore } from './index.store';
|
|
3
|
+
import { useKgWarehouse } from '../KgWarehouse';
|
|
4
|
+
import { WorkstationAreaDTO, WorkstationDTO } from '../../api/WMS/models';
|
|
5
|
+
|
|
6
|
+
export type IUseKgStation = {
|
|
7
|
+
/**
|
|
8
|
+
* 当前工作区.
|
|
9
|
+
*/
|
|
10
|
+
area: ComputedRef<WorkstationAreaDTO | null>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 当前工作站.
|
|
14
|
+
*/
|
|
15
|
+
station: ComputedRef<WorkstationDTO | null>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 所有工作站.
|
|
19
|
+
*/
|
|
20
|
+
stations: ComputedRef<IKgStationStore['getStations']>;
|
|
21
|
+
|
|
22
|
+
store: IKgStationStore;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function useKgStation(): IUseKgStation {
|
|
26
|
+
const store = useKgStationStore();
|
|
27
|
+
|
|
28
|
+
const kgWarehouse = useKgWarehouse();
|
|
29
|
+
|
|
30
|
+
const station = computed<WorkstationDTO | null>(() => {
|
|
31
|
+
if (!store.getStation) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//region 如果当前工作站(可能来自浏览器的缓存)不在工作站列表中(比如数据库中的工作站有变更), 或者当前工作站不属于当前仓库, 则返回 null, 表示需要重新选择工作站,
|
|
36
|
+
// ----------------------------------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
// 当前工作站编号
|
|
39
|
+
const currentDevcod = store.getStation?.devcod;
|
|
40
|
+
|
|
41
|
+
// 如果 store.getStations 为 undefined, 表示「所有工作站」尚未完成查询,
|
|
42
|
+
if (store.getStations !== undefined && !store.getStations?.find((i) => i.devcod === currentDevcod)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (store.getStation.whId !== kgWarehouse.warehouse.value?.whId) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ----------------------------------------------------------------------------------------------------
|
|
51
|
+
//endregion
|
|
52
|
+
|
|
53
|
+
return store.getStation;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
area: computed(() => station.value?.workstationAreas?.find((i) => i.wrkare === station.value?.hmewrkare) ?? null),
|
|
58
|
+
station: station,
|
|
59
|
+
stations: computed(() => store.getStations),
|
|
60
|
+
store: store,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { defineStore, StoreDefinition } from 'pinia';
|
|
2
|
+
import { toRaw, unref } from 'vue';
|
|
3
|
+
import { API } from '../../api';
|
|
4
|
+
import { WorkstationDTO } from '../../api/WMS/models';
|
|
5
|
+
|
|
6
|
+
const LOCAL_STORAGE_KEY = 'KgStation.station';
|
|
7
|
+
|
|
8
|
+
export interface IKgStationState {
|
|
9
|
+
/**
|
|
10
|
+
* 当前工作站.
|
|
11
|
+
*/
|
|
12
|
+
station: WorkstationDTO | null;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 所有工作站.
|
|
16
|
+
*/
|
|
17
|
+
stations: Array<WorkstationDTO> | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IKgStationGetters {
|
|
21
|
+
getStation: WorkstationDTO | null;
|
|
22
|
+
|
|
23
|
+
getStations: Array<WorkstationDTO> | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IKgStationActions {
|
|
27
|
+
/**
|
|
28
|
+
* 查询所有工作站.
|
|
29
|
+
*/
|
|
30
|
+
requestStations(): Promise<void>;
|
|
31
|
+
|
|
32
|
+
setStation(station?: WorkstationDTO | null): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type IUseKgStationStore = StoreDefinition<'KgStation', IKgStationState, IKgStationGetters, IKgStationActions>;
|
|
36
|
+
|
|
37
|
+
export type IKgStationStore = ReturnType<IUseKgStationStore>;
|
|
38
|
+
|
|
39
|
+
export const useKgStationStore = defineStore('KgStation', {
|
|
40
|
+
actions: {
|
|
41
|
+
async requestStations(): Promise<void> {
|
|
42
|
+
// 已经有值, 说明已经查询过了, 不做操作,
|
|
43
|
+
if (this.stations) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.stations = (await API.WMS.WorkstationController.List({ params: { pageNo: 1, pageSize: 999 } }))?.records ?? [];
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
setStation(station?: WorkstationDTO | null): void {
|
|
51
|
+
// 未选择工作站
|
|
52
|
+
if (!station) {
|
|
53
|
+
this.station = null;
|
|
54
|
+
uni.setStorageSync(LOCAL_STORAGE_KEY, null);
|
|
55
|
+
}
|
|
56
|
+
// 有选择工作站
|
|
57
|
+
else {
|
|
58
|
+
this.station = toRaw(unref(station));
|
|
59
|
+
uni.setStorageSync(LOCAL_STORAGE_KEY, this.station);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
getters: {
|
|
64
|
+
getStation(): WorkstationDTO | null {
|
|
65
|
+
return this.station ?? null;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
getStations(): Array<WorkstationDTO> | undefined {
|
|
69
|
+
return this.stations;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
state: (): IKgStationState => ({
|
|
73
|
+
station: uni.getStorageSync(LOCAL_STORAGE_KEY) || null,
|
|
74
|
+
stations: undefined,
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<text class="text">首页</text>
|
|
6
6
|
</view>
|
|
7
7
|
|
|
8
|
-
<view :class="{ active: page?.route === 'pages/my/
|
|
8
|
+
<view :class="{ active: page?.route === 'pages/my/My' }" class="item" @tap.stop="goto('pages/my/My')">
|
|
9
9
|
<UniIcons :type="'person'" size="24"></UniIcons>
|
|
10
10
|
<text class="text">我的</text>
|
|
11
11
|
</view>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
const page = Kg.getCurrentPage();
|
|
40
40
|
|
|
41
41
|
function goto(path: string) {
|
|
42
|
-
if (path != 'pages/my/
|
|
42
|
+
if (path != 'pages/my/My') {
|
|
43
43
|
uni.redirectTo({ url: '/' + path });
|
|
44
44
|
} else {
|
|
45
45
|
uni.navigateTo({ url: '/' + path });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<UniPopup ref="popupRef" :type="'dialog'">
|
|
3
3
|
<UniPopupDialog :before-close="true" title="选择仓库" @confirm="onOk">
|
|
4
|
-
<UniDataCheckbox v-model="
|
|
4
|
+
<UniDataCheckbox v-model="currentWhId" :localdata="warehouseDatas" />
|
|
5
5
|
</UniPopupDialog>
|
|
6
6
|
</UniPopup>
|
|
7
7
|
</template>
|
|
@@ -9,25 +9,30 @@
|
|
|
9
9
|
<script lang="ts" setup>
|
|
10
10
|
import { UniDataCheckbox, UniPopup, UniPopupDialog } from '../../uni';
|
|
11
11
|
import { API } from '../../api';
|
|
12
|
-
import { ref } from 'vue';
|
|
13
|
-
import { WhDTO } from '../../api/WMS/models';
|
|
12
|
+
import { computed, ref } from 'vue';
|
|
13
|
+
import { SysUserWarehouseDTO, WhDTO } from '../../api/WMS/models';
|
|
14
14
|
import { useKgWarehouse } from './index.hooks';
|
|
15
|
+
import { useAppStore } from '../../store/app.store';
|
|
16
|
+
import { Kg } from '../../util';
|
|
15
17
|
|
|
16
18
|
const emit = defineEmits(['ok']);
|
|
17
19
|
|
|
20
|
+
const appStore = useAppStore();
|
|
18
21
|
const kgWarehouse = useKgWarehouse();
|
|
19
22
|
|
|
20
23
|
const popupRef = ref<any>(null);
|
|
21
24
|
/** 当前选择的仓库编号. */
|
|
22
|
-
const
|
|
25
|
+
const currentWhId = ref<string>('');
|
|
23
26
|
/** 仓库列表. */
|
|
24
|
-
|
|
27
|
+
const warehouses = ref<Array<WhDTO>>([]);
|
|
25
28
|
/** 选项列表. */
|
|
26
|
-
const
|
|
29
|
+
const warehouseDatas = ref<Array<{ text: string; value: string }>>([]);
|
|
30
|
+
/** 用户仓库列表. */
|
|
31
|
+
const userWarehouses = computed<Array<SysUserWarehouseDTO>>(() => appStore.getUserWarehouses);
|
|
27
32
|
|
|
28
33
|
/** 确定. */
|
|
29
34
|
function onOk() {
|
|
30
|
-
kgWarehouse.store.setWarehouse(warehouses.find((i) => i.whId ===
|
|
35
|
+
kgWarehouse.store.setWarehouse(warehouses.value.find((i) => i.whId === currentWhId.value));
|
|
31
36
|
popupRef.value?.close();
|
|
32
37
|
emit('ok');
|
|
33
38
|
}
|
|
@@ -35,30 +40,36 @@
|
|
|
35
40
|
/** 打开弹窗. */
|
|
36
41
|
function open() {
|
|
37
42
|
popupRef.value?.open();
|
|
38
|
-
|
|
43
|
+
requestWarehouses();
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
/** 查询仓库列表. */
|
|
42
|
-
async function
|
|
47
|
+
async function requestWarehouses(): Promise<void> {
|
|
43
48
|
try {
|
|
44
49
|
const { records } = await API.WMS.WhController.ListVO({ params: { pageNo: 1, pageSize: 999 } });
|
|
45
|
-
warehouses = records ?? []
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
warehouses.value = (records ?? []).filter((i) => {
|
|
51
|
+
// 管理员拥有所有仓库
|
|
52
|
+
if (Kg.isAdminUser()) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return userWarehouses.value?.find((j) => j.wh_id === i.whId);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
warehouseDatas.value = warehouses.value.map((i: WhDTO) => ({
|
|
48
60
|
text: `${i.whDsc ?? ' '} - ${i.whId ?? ' '}`,
|
|
61
|
+
value: i.whId ?? '',
|
|
49
62
|
}));
|
|
50
63
|
|
|
51
|
-
const currentWarehouse = warehouses.find((i) => kgWarehouse.warehouse.value?.whId
|
|
64
|
+
const currentWarehouse = warehouses.value.find((i) => i.whId === kgWarehouse.warehouse.value?.whId) ?? null;
|
|
52
65
|
// 如果当前仓库不为空, 且有效(存在于当前仓库列表中), 则继续使用
|
|
53
66
|
if (currentWarehouse) {
|
|
54
|
-
|
|
67
|
+
currentWhId.value = currentWarehouse.whId ?? '';
|
|
55
68
|
}
|
|
56
69
|
// 否则, 清空当前仓库, 并默认选中第一个仓库
|
|
57
70
|
else {
|
|
58
71
|
kgWarehouse.store.setWarehouse(null);
|
|
59
|
-
|
|
60
|
-
whID.value = warehouses[0].whId ?? '';
|
|
61
|
-
}
|
|
72
|
+
currentWhId.value = warehouses.value[0]?.whId ?? '';
|
|
62
73
|
}
|
|
63
74
|
} catch (e) {
|
|
64
75
|
console.error(e);
|
|
@@ -68,20 +79,26 @@
|
|
|
68
79
|
defineExpose({ open });
|
|
69
80
|
</script>
|
|
70
81
|
|
|
71
|
-
<style scoped
|
|
72
|
-
:deep {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
82
|
+
<style scoped>
|
|
83
|
+
:deep(.uni-popup-dialog) {
|
|
84
|
+
font-size: 13px;
|
|
85
|
+
}
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
:deep(.uni-popup-dialog) .uni-dialog-content {
|
|
88
|
+
padding: 0 6px;
|
|
89
|
+
}
|
|
80
90
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
:deep(.uni-popup-dialog) .uni-dialog-button-group > .uni-dialog-button:first-child {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:deep(.uni-popup-dialog) .uni-dialog-button-group > .uni-dialog-button:last-child {
|
|
96
|
+
border-left-width: 0px !important;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:deep(.uni-popup-dialog) .uni-label-pointer {
|
|
100
|
+
width: 100%;
|
|
101
|
+
margin: 0 !important;
|
|
102
|
+
padding: 6px 0 !important;
|
|
86
103
|
}
|
|
87
104
|
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, ComputedRef } from 'vue';
|
|
2
2
|
import { IKgWarehouseStore, useKgWarehouseStore } from './index.store';
|
|
3
3
|
import { WhDTO } from '../../api/WMS/models';
|
|
4
|
+
import { useAppStore } from '../../store/app.store';
|
|
4
5
|
|
|
5
6
|
export type IUseKgWarehouse = {
|
|
6
7
|
store: IKgWarehouseStore;
|
|
@@ -10,8 +11,30 @@ export type IUseKgWarehouse = {
|
|
|
10
11
|
|
|
11
12
|
export function useKgWarehouse(): IUseKgWarehouse {
|
|
12
13
|
const store = useKgWarehouseStore();
|
|
14
|
+
const appStore = useAppStore();
|
|
15
|
+
|
|
16
|
+
const warehouse = computed<WhDTO | null>(() => {
|
|
17
|
+
if (!store.getWarehouse) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//region 如果当前仓库(可能来自浏览器的缓存)不在仓库列表中, 比如切换登录用户, 或者用户可访问的仓库发生变更, 则返回 null, 表示需要重新选择仓库
|
|
22
|
+
// ----------------------------------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
// 当前仓库编号
|
|
25
|
+
const currentWarehouseID = store.getWarehouse?.whId;
|
|
26
|
+
|
|
27
|
+
// 如果 userWarehouses 为 undefined, 表示 userWarehouses 数据尚未完成初始化,
|
|
28
|
+
if (appStore.getUserWarehouses !== undefined && !appStore.getUserWarehouses?.find((i) => i.wh_id === currentWarehouseID)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ----------------------------------------------------------------------------------------------------
|
|
33
|
+
//endregion
|
|
34
|
+
|
|
35
|
+
return store.getWarehouse;
|
|
36
|
+
});
|
|
13
37
|
|
|
14
|
-
const warehouse = computed(() => store.getWarehouse);
|
|
15
38
|
|
|
16
39
|
return {
|
|
17
40
|
store,
|
|
@@ -23,14 +23,6 @@ export type IUseKgWarehouseStore = StoreDefinition<
|
|
|
23
23
|
export type IKgWarehouseStore = ReturnType<IUseKgWarehouseStore>;
|
|
24
24
|
|
|
25
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
26
|
actions: {
|
|
35
27
|
setWarehouse(warehouse?: WhDTO | null): void {
|
|
36
28
|
if (!warehouse) {
|
|
@@ -43,4 +35,12 @@ export const useKgWarehouseStore = defineStore('KgWarehouse', {
|
|
|
43
35
|
uni.setStorageSync(LOCAL_STORAGE_KEY, this.warehouse);
|
|
44
36
|
},
|
|
45
37
|
},
|
|
38
|
+
getters: {
|
|
39
|
+
getWarehouse(): WhDTO | null {
|
|
40
|
+
return this.warehouse || null;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
state: (): IKgWarehouseState => ({
|
|
44
|
+
warehouse: uni.getStorageSync(LOCAL_STORAGE_KEY),
|
|
45
|
+
}),
|
|
46
46
|
});
|
package/dist/component/index.ts
CHANGED
package/dist/index.css
CHANGED
|
@@ -74,8 +74,10 @@ type IRequestOptions = Omit<UniApp.RequestOptions, 'url'> & {
|
|
|
74
74
|
/** 是否处理请求结果. */
|
|
75
75
|
isTransformResponse?: boolean;
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
|
|
77
|
+
/**
|
|
78
|
+
* <p>模拟数据. 如果不为 undefined 则不会发起请求, 而是直接返回该模拟数据.</p>
|
|
79
|
+
*/
|
|
80
|
+
mock?: any;
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
/** 请求参数. */
|
|
@@ -143,6 +145,11 @@ const _httpClient: IHttpClient = {
|
|
|
143
145
|
},
|
|
144
146
|
options?: IRequestOptions,
|
|
145
147
|
) {
|
|
148
|
+
// 使用模拟数据, 直接返回模拟数据,
|
|
149
|
+
if (options?.mock !== undefined) {
|
|
150
|
+
return new Promise((resolve) => resolve(options?.mock));
|
|
151
|
+
}
|
|
152
|
+
|
|
146
153
|
const { method, url, params, data } = config;
|
|
147
154
|
|
|
148
155
|
return new Promise<T>((resolve, reject) => {
|