jmash-core-mp 0.1.76 → 0.1.78
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/.editorconfig +9 -9
- package/.gitignore +8 -0
- package/.npmignore +44 -0
- package/README.md +60 -60
- package/babel.config.json +34 -34
- package/eslint.config.mjs +7 -7
- package/lib/api/auth/index.d.ts +22 -22
- package/lib/api/auth/index.js +211 -211
- package/lib/api/auth/types.d.ts +90 -90
- package/lib/api/auth/types.js +9 -9
- package/lib/api/cms/index.d.ts +20 -20
- package/lib/api/cms/index.js +161 -161
- package/lib/api/cms/types.d.ts +201 -201
- package/lib/api/cms/types.js +1 -1
- package/lib/api/constant.d.ts +6 -6
- package/lib/api/constant.js +8 -8
- package/lib/api/dict/index.d.ts +24 -24
- package/lib/api/dict/index.js +51 -51
- package/lib/api/dict/types.d.ts +40 -40
- package/lib/api/dict/types.js +1 -1
- package/lib/api/dicts.d.ts +32 -32
- package/lib/api/dicts.js +118 -118
- package/lib/api/files/index.d.ts +25 -25
- package/lib/api/files/index.js +134 -134
- package/lib/api/files/types.d.ts +38 -38
- package/lib/api/files/types.js +1 -1
- package/lib/api/index.d.ts +5 -5
- package/lib/api/index.js +8 -8
- package/lib/api/myorgan/index.d.ts +8 -8
- package/lib/api/myorgan/index.js +24 -24
- package/lib/api/myorgan/types.d.ts +22 -22
- package/lib/api/myorgan/types.js +1 -1
- package/lib/api/region/index.d.ts +7 -7
- package/lib/api/region/index.js +20 -20
- package/lib/api/region/types.d.ts +19 -19
- package/lib/api/region/types.js +1 -1
- package/lib/api/shop/index.d.ts +11 -11
- package/lib/api/shop/index.js +53 -53
- package/lib/api/shop/types.d.ts +123 -123
- package/lib/api/shop/types.js +1 -1
- package/lib/api/storage/index.d.ts +11 -11
- package/lib/api/storage/index.js +53 -53
- package/lib/api/storage/types.d.ts +39 -39
- package/lib/api/storage/types.js +1 -1
- package/lib/api/types.d.ts +43 -43
- package/lib/api/types.js +1 -1
- package/lib/components/organ/browser-organ-list.mpx.d.ts +1 -1
- package/lib/components/organ/my-organ-list.mpx.d.ts +1 -1
- package/lib/components/{auth-user/jmash-update-user.mpx.d.ts → organ/organ-search.mpx.d.ts} +1 -1
- package/lib/components/{auth-user/jmash-user.mpx.d.ts → shop/branch-search.mpx.d.ts} +1 -1
- package/lib/components/{core/jmash-login.mpx.d.ts → shop/shop-search.mpx.d.ts} +1 -1
- package/lib/index.d.ts +28 -28
- package/lib/index.js +23 -23
- package/lib/{packages/pages/auth/setting-page.mpx.d.ts → pages/branch-search.mpx.d.ts} +1 -1
- package/lib/pages/organ-search.mpx.d.ts +1 -0
- package/lib/pages/organ.mpx.d.ts +1 -1
- package/lib/pages/shop-search.mpx.d.ts +1 -0
- package/lib/store/organ.d.ts +19 -19
- package/lib/store/organ.js +83 -83
- package/lib/store/shop.d.ts +18 -18
- package/lib/store/shop.js +104 -104
- package/lib/store/user.d.ts +35 -35
- package/lib/store/user.js +243 -243
- package/lib/utils/common.d.ts +37 -35
- package/lib/utils/common.js +178 -165
- package/lib/utils/config.d.ts +5 -5
- package/lib/utils/config.js +36 -36
- package/lib/utils/db.d.ts +52 -52
- package/lib/utils/db.js +202 -202
- package/lib/utils/grpc.d.ts +5 -5
- package/lib/utils/grpc.js +20 -20
- package/lib/utils/net.d.ts +7 -7
- package/lib/utils/net.js +15 -15
- package/lib/utils/request.d.ts +2 -2
- package/lib/utils/request.js +114 -114
- package/lib/utils/share.d.ts +16 -16
- package/lib/utils/share.js +196 -196
- package/mpx.config.js +38 -38
- package/package.json +1 -1
- package/pnpm-workspace.yaml +5 -0
- package/postcss.config.js +11 -11
- package/project.config.json +24 -24
- package/project.private.config.json +13 -13
- package/public/index.html +15 -15
- package/src/api/auth/index.ts +241 -241
- package/src/api/auth/types.ts +173 -173
- package/src/api/cms/index.ts +218 -218
- package/src/api/cms/types.ts +385 -385
- package/src/api/constant.ts +8 -8
- package/src/api/dict/index.ts +68 -68
- package/src/api/dict/types.ts +73 -73
- package/src/api/dicts.ts +132 -132
- package/src/api/files/index.ts +162 -162
- package/src/api/files/types.ts +67 -67
- package/src/api/index.ts +15 -15
- package/src/api/myorgan/index.ts +29 -29
- package/src/api/myorgan/types.ts +42 -42
- package/src/api/region/index.ts +24 -24
- package/src/api/region/types.ts +36 -36
- package/src/api/shop/index.ts +74 -74
- package/src/api/shop/types.ts +244 -244
- package/src/api/storage/index.ts +74 -74
- package/src/api/storage/types.ts +74 -74
- package/src/api/types.ts +74 -74
- package/src/app.mpx +78 -78
- package/src/components/auth-user/jmash-logout.mpx +93 -93
- package/src/components/auth-user/jmash-update-user.mpx +387 -387
- package/src/components/auth-user/jmash-update-user.web.mpx +367 -367
- package/src/components/auth-user/jmash-user.mpx +310 -310
- package/src/components/cms/jmash-cms-activity-item.mpx +207 -207
- package/src/components/cms/jmash-cms-activity-list.mpx +357 -357
- package/src/components/cms/jmash-cms-article-item.mpx +221 -221
- package/src/components/cms/jmash-cms-article-list.mpx +248 -248
- package/src/components/cms/jmash-cms-article-view.mpx +131 -131
- package/src/components/cms/jmash-cms-article.mpx +231 -231
- package/src/components/cms/jmash-cms-like.mpx +151 -151
- package/src/components/cms/jmash-cms-location-list.mpx +286 -286
- package/src/components/cms/jmash-cms-location.mpx +256 -256
- package/src/components/cms/jmash-cms-product-item.mpx +185 -185
- package/src/components/cms/jmash-cms-product-list.mpx +230 -230
- package/src/components/common/jmash-avatar-edit.mpx +154 -154
- package/src/components/common/jmash-cascader-region.mpx +118 -118
- package/src/components/common/jmash-cell-group.mpx +206 -206
- package/src/components/common/jmash-code-interest-popup.mpx +223 -223
- package/src/components/common/jmash-form-cell.mpx +491 -525
- package/src/components/common/jmash-menu.mpx +129 -129
- package/src/components/common/jmash-none-data.mpx +95 -95
- package/src/components/common/jmash-pic-swiper.mpx +72 -72
- package/src/components/common/jmash-popup.mpx +138 -138
- package/src/components/common/jmash-search.mpx +130 -130
- package/src/components/common/jmash-single-btn.mpx +53 -53
- package/src/components/common/jmash-stepper.mpx +236 -236
- package/src/components/common/jmash-swipe-cell.mpx +153 -153
- package/src/components/common/jmash-tab-bar.mpx +58 -58
- package/src/components/common/jmash-textarea.mpx +88 -88
- package/src/components/common/jmash-top-navigation.mpx +203 -203
- package/src/components/common/jmash-upload-picture.mpx +199 -199
- package/src/components/core/jmash-cms-protocol.mpx +72 -72
- package/src/components/core/jmash-login.ali.mpx +284 -284
- package/src/components/core/jmash-login.mpx +378 -378
- package/src/components/core/jmash-login.web.mpx +420 -420
- package/src/components/core/jmash-popup-login.ali.mpx +312 -312
- package/src/components/core/jmash-popup-login.mpx +414 -416
- package/src/components/core/jmash-popup-login.web.mpx +389 -389
- package/src/components/organ/browser-organ-list.mpx +66 -66
- package/src/components/organ/my-organ-list.mpx +67 -67
- package/src/components/organ/organ-item.mpx +124 -124
- package/src/components/organ/organ-search.mpx +148 -148
- package/src/components/organ/organ-selected-item.mpx +88 -88
- package/src/components/shop/branch-item.mpx +111 -111
- package/src/components/shop/branch-search.mpx +142 -142
- package/src/components/shop/shop-item.mpx +112 -112
- package/src/components/shop/shop-search.mpx +142 -142
- package/src/components/shop/shop-selected-item.mpx +89 -89
- package/src/custom-tab-bar/index.mpx +10 -10
- package/src/global.d.ts +11 -11
- package/src/index.ts +94 -94
- package/src/packages/index.mpx +16 -16
- package/src/packages/pages/auth/cms-protocol.mpx +35 -35
- package/src/packages/pages/auth/login.mpx +62 -62
- package/src/packages/pages/auth/setting-page.mpx +134 -134
- package/src/packages/pages/auth/update-user.mpx +17 -17
- package/src/packages/pages/cms/cms-activity-list.mpx +86 -86
- package/src/packages/pages/cms/cms-article-list.mpx +88 -88
- package/src/packages/pages/cms/cms-article.mpx +32 -32
- package/src/packages/pages/cms/cms-location-list.mpx +83 -83
- package/src/packages/pages/cms/cms-location.mpx +32 -32
- package/src/packages/pages/cms/cms-product-list.mpx +88 -88
- package/src/packages/pages/share/scan.mpx +103 -103
- package/src/pages/basic-component.mpx +30 -30
- package/src/pages/branch-search.mpx +60 -60
- package/src/pages/half-home.mpx +58 -58
- package/src/pages/home.mpx +54 -54
- package/src/pages/home2.mpx +45 -45
- package/src/pages/index.mpx +43 -43
- package/src/pages/organ-search.mpx +60 -60
- package/src/pages/organ.mpx +105 -105
- package/src/pages/shop-search.mpx +60 -60
- package/src/pages/tabbar/home.mpx +114 -114
- package/src/pages/tabbar/mall.mpx +87 -87
- package/src/pages/tabbar/my.mpx +79 -79
- package/src/pages/tabbar/organ.mpx +86 -86
- package/src/store/organ.ts +100 -100
- package/src/store/shop.ts +130 -130
- package/src/store/user.ts +288 -288
- package/src/styles/index.scss +20 -20
- package/src/styles/vars.scss +27 -27
- package/src/utils/common.ts +196 -178
- package/src/utils/config.ts +43 -43
- package/src/utils/db.ts +229 -229
- package/src/utils/grpc.ts +21 -21
- package/src/utils/net.ts +18 -18
- package/src/utils/request.ts +126 -126
- package/src/utils/share.ts +194 -194
- package/static/ali/mini.project.json +4 -4
- package/static/dd/project.config.json +15 -15
- package/static/swan/project.swan.json +14 -14
- package/static/tt/project.config.json +11 -11
- package/static/wx/project.config.json +40 -40
- package/uno.config.js +9 -9
- package/lib/packages/pages/share/scan.mpx.d.ts +0 -1
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="page-body">
|
|
3
|
-
<organ-selected-item></organ-selected-item>
|
|
4
|
-
<jmash-menu menuGroups="{{ menuGroups }}" bind:itemClick="handleMenuClick"></jmash-menu>
|
|
5
|
-
</view>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script>
|
|
9
|
-
import mpx, { createPage } from '@mpxjs/core'
|
|
10
|
-
import { useUserStore } from '../../store/user';
|
|
11
|
-
import { share } from "../../utils/share";
|
|
12
|
-
|
|
13
|
-
createPage({
|
|
14
|
-
data: {
|
|
15
|
-
userStore: null,
|
|
16
|
-
menuGroups: [
|
|
17
|
-
{
|
|
18
|
-
id: 1,
|
|
19
|
-
items: [
|
|
20
|
-
{ key: 'organ', title: '选择组织', icon: '🏠', iconBg: '#409eff', path: '/pages/organ' },
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
onLoad(options) {
|
|
26
|
-
share.shareOrganLoad(options).then(() => {
|
|
27
|
-
this.userStore = useUserStore();
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
onShow() {
|
|
31
|
-
if (typeof this.getTabBar === 'function' &&
|
|
32
|
-
this.getTabBar()) {
|
|
33
|
-
this.getTabBar().$refs.tabBar.activeTab("Organ");
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
methods: {
|
|
37
|
-
handleMenuClick(e) {
|
|
38
|
-
const { item } = e.detail
|
|
39
|
-
if (item.path) {
|
|
40
|
-
mpx.navigateTo({ url: item.path })
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
onShareAppMessage() {
|
|
45
|
-
return {
|
|
46
|
-
title: '组织首页-分享给好友',
|
|
47
|
-
path: share.shareOrganPath(share.getCurrentPage(), share.getCurrentQuery())
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
onShareTimeline() {
|
|
51
|
-
return {
|
|
52
|
-
title: '组织首页-分享给朋友圈',
|
|
53
|
-
query: share.shareOrganQuery(share.getCurrentQuery())
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
<style lang="scss">
|
|
61
|
-
.page-body {
|
|
62
|
-
min-height: 100vh;
|
|
63
|
-
background-color: #f5f5f5;
|
|
64
|
-
|
|
65
|
-
.logout-section {
|
|
66
|
-
display: flex;
|
|
67
|
-
justify-content: center;
|
|
68
|
-
padding: 40rpx 16rpx;
|
|
69
|
-
|
|
70
|
-
button {
|
|
71
|
-
width: 80%;
|
|
72
|
-
height: 88rpx;
|
|
73
|
-
font-size: 30rpx;
|
|
74
|
-
border-radius: 44rpx;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
</style>
|
|
79
|
-
|
|
80
|
-
<script type="application/json">
|
|
81
|
-
{
|
|
82
|
-
"usingComponents": {
|
|
83
|
-
"jmash-menu": "../../components/common/jmash-menu.mpx",
|
|
84
|
-
"organ-selected-item": "../../components/organ/organ-selected-item.mpx"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<view class="page-body">
|
|
3
|
+
<organ-selected-item></organ-selected-item>
|
|
4
|
+
<jmash-menu menuGroups="{{ menuGroups }}" bind:itemClick="handleMenuClick"></jmash-menu>
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import mpx, { createPage } from '@mpxjs/core'
|
|
10
|
+
import { useUserStore } from '../../store/user';
|
|
11
|
+
import { share } from "../../utils/share";
|
|
12
|
+
|
|
13
|
+
createPage({
|
|
14
|
+
data: {
|
|
15
|
+
userStore: null,
|
|
16
|
+
menuGroups: [
|
|
17
|
+
{
|
|
18
|
+
id: 1,
|
|
19
|
+
items: [
|
|
20
|
+
{ key: 'organ', title: '选择组织', icon: '🏠', iconBg: '#409eff', path: '/pages/organ' },
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
onLoad(options) {
|
|
26
|
+
share.shareOrganLoad(options).then(() => {
|
|
27
|
+
this.userStore = useUserStore();
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
onShow() {
|
|
31
|
+
if (typeof this.getTabBar === 'function' &&
|
|
32
|
+
this.getTabBar()) {
|
|
33
|
+
this.getTabBar().$refs.tabBar.activeTab("Organ");
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
handleMenuClick(e) {
|
|
38
|
+
const { item } = e.detail
|
|
39
|
+
if (item.path) {
|
|
40
|
+
mpx.navigateTo({ url: item.path })
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
onShareAppMessage() {
|
|
45
|
+
return {
|
|
46
|
+
title: '组织首页-分享给好友',
|
|
47
|
+
path: share.shareOrganPath(share.getCurrentPage(), share.getCurrentQuery())
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
onShareTimeline() {
|
|
51
|
+
return {
|
|
52
|
+
title: '组织首页-分享给朋友圈',
|
|
53
|
+
query: share.shareOrganQuery(share.getCurrentQuery())
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
})
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<style lang="scss">
|
|
61
|
+
.page-body {
|
|
62
|
+
min-height: 100vh;
|
|
63
|
+
background-color: #f5f5f5;
|
|
64
|
+
|
|
65
|
+
.logout-section {
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
padding: 40rpx 16rpx;
|
|
69
|
+
|
|
70
|
+
button {
|
|
71
|
+
width: 80%;
|
|
72
|
+
height: 88rpx;
|
|
73
|
+
font-size: 30rpx;
|
|
74
|
+
border-radius: 44rpx;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
79
|
+
|
|
80
|
+
<script type="application/json">
|
|
81
|
+
{
|
|
82
|
+
"usingComponents": {
|
|
83
|
+
"jmash-menu": "../../components/common/jmash-menu.mpx",
|
|
84
|
+
"organ-selected-item": "../../components/organ/organ-selected-item.mpx"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
87
|
</script>
|
package/src/store/organ.ts
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { defineStore } from "@mpxjs/pinia";
|
|
2
|
-
import { storageApi } from "../api/storage";
|
|
3
|
-
import { StorageOrganInfoModel } from "../api/storage/types";
|
|
4
|
-
import { db } from "../utils/db";
|
|
5
|
-
import { UserInfo, RolesPerms } from "../api/auth/types";
|
|
6
|
-
import { organUserApi } from "../api/myorgan";
|
|
7
|
-
|
|
8
|
-
interface OrganState {
|
|
9
|
-
//组织租户
|
|
10
|
-
organTenant: string;
|
|
11
|
-
//组织信息
|
|
12
|
-
organInfo: StorageOrganInfoModel;
|
|
13
|
-
//用户信息
|
|
14
|
-
organUserInfo: UserInfo;
|
|
15
|
-
// 角色编码
|
|
16
|
-
organRoleCodes: string[];
|
|
17
|
-
// 权限编码
|
|
18
|
-
organPermCodes: string[];
|
|
19
|
-
// 是否销售员
|
|
20
|
-
isSales: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const useOrganStore = defineStore("organ", {
|
|
24
|
-
state: (): OrganState => ({
|
|
25
|
-
organTenant: db.getOrganTenant() || "",
|
|
26
|
-
organInfo: db.getOrganInfo() || {},
|
|
27
|
-
//用户信息
|
|
28
|
-
organUserInfo: db.getOrganUserInfo() || {},
|
|
29
|
-
// 角色编码
|
|
30
|
-
organRoleCodes: db.getOrganRoleCodes() || [],
|
|
31
|
-
// 权限编码
|
|
32
|
-
organPermCodes: db.getOrganPermCodes() || [],
|
|
33
|
-
// 是否销售员
|
|
34
|
-
isSales: db.getOrganSales() || false,
|
|
35
|
-
}),
|
|
36
|
-
actions: {
|
|
37
|
-
clearOrganUser() {
|
|
38
|
-
this.organUserInfo = {} as UserInfo;
|
|
39
|
-
this.organRoleCodes = [];
|
|
40
|
-
this.organPermCodes = [];
|
|
41
|
-
this.isSales = false;
|
|
42
|
-
db.setOrganUserInfo({} as UserInfo);
|
|
43
|
-
db.setOrganRoleCodes([]);
|
|
44
|
-
db.setOrganPermCodes([]);
|
|
45
|
-
db.setOrganSales(false);
|
|
46
|
-
},
|
|
47
|
-
//设置组织信息.
|
|
48
|
-
setOrganInfo(data: StorageOrganInfoModel) {
|
|
49
|
-
this.organInfo = data;
|
|
50
|
-
this.organTenant = data.organTenant || "";
|
|
51
|
-
this.clearOrganUser();
|
|
52
|
-
db.setOrganInfo(data);
|
|
53
|
-
db.setOrganTenant(data.organTenant || "");
|
|
54
|
-
},
|
|
55
|
-
//设置组织租户和组织信息.
|
|
56
|
-
setOrganTenant(organTenant: string): Promise<boolean> {
|
|
57
|
-
this.organTenant = organTenant;
|
|
58
|
-
db.setOrganTenant(organTenant);
|
|
59
|
-
this.clearOrganUser();
|
|
60
|
-
return storageApi.findOrganTenant().then((res) => {
|
|
61
|
-
if (res.statusCode === 200) {
|
|
62
|
-
this.organInfo = res.data;
|
|
63
|
-
db.setOrganInfo(res.data);
|
|
64
|
-
return Promise.resolve(true);
|
|
65
|
-
} else {
|
|
66
|
-
return Promise.resolve(false);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
// 获取组织用户信息
|
|
71
|
-
getOrganUserInfo(): Promise<UserInfo> {
|
|
72
|
-
// 无缓存请求接口
|
|
73
|
-
return organUserApi
|
|
74
|
-
.userInfo(this.organTenant)
|
|
75
|
-
.then((resp) => {
|
|
76
|
-
this.organUserInfo = resp.data;
|
|
77
|
-
db.setOrganUserInfo(resp.data);
|
|
78
|
-
return resp.data;
|
|
79
|
-
})
|
|
80
|
-
.catch(() => Promise.reject("获取组织用户信息错误!"));
|
|
81
|
-
},
|
|
82
|
-
// 获取组织用户角色权限
|
|
83
|
-
getOrganUserRolesPerms(): Promise<RolesPerms> {
|
|
84
|
-
// 无缓存请求接口
|
|
85
|
-
return organUserApi
|
|
86
|
-
.userRolesPerms(this.organTenant)
|
|
87
|
-
.then((resp) => {
|
|
88
|
-
this.organRoleCodes = resp.data.roleCodes || [];
|
|
89
|
-
this.organPermCodes = resp.data.permCodes || [];
|
|
90
|
-
return resp.data;
|
|
91
|
-
})
|
|
92
|
-
.catch(() => Promise.reject("获取组织用户角色权限错误!"));
|
|
93
|
-
},
|
|
94
|
-
// 设置销售员
|
|
95
|
-
setSales(isSales: boolean): void {
|
|
96
|
-
this.isSales = isSales;
|
|
97
|
-
db.setOrganSales(isSales);
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
});
|
|
1
|
+
import { defineStore } from "@mpxjs/pinia";
|
|
2
|
+
import { storageApi } from "../api/storage";
|
|
3
|
+
import { StorageOrganInfoModel } from "../api/storage/types";
|
|
4
|
+
import { db } from "../utils/db";
|
|
5
|
+
import { UserInfo, RolesPerms } from "../api/auth/types";
|
|
6
|
+
import { organUserApi } from "../api/myorgan";
|
|
7
|
+
|
|
8
|
+
interface OrganState {
|
|
9
|
+
//组织租户
|
|
10
|
+
organTenant: string;
|
|
11
|
+
//组织信息
|
|
12
|
+
organInfo: StorageOrganInfoModel;
|
|
13
|
+
//用户信息
|
|
14
|
+
organUserInfo: UserInfo;
|
|
15
|
+
// 角色编码
|
|
16
|
+
organRoleCodes: string[];
|
|
17
|
+
// 权限编码
|
|
18
|
+
organPermCodes: string[];
|
|
19
|
+
// 是否销售员
|
|
20
|
+
isSales: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const useOrganStore = defineStore("organ", {
|
|
24
|
+
state: (): OrganState => ({
|
|
25
|
+
organTenant: db.getOrganTenant() || "",
|
|
26
|
+
organInfo: db.getOrganInfo() || {},
|
|
27
|
+
//用户信息
|
|
28
|
+
organUserInfo: db.getOrganUserInfo() || {},
|
|
29
|
+
// 角色编码
|
|
30
|
+
organRoleCodes: db.getOrganRoleCodes() || [],
|
|
31
|
+
// 权限编码
|
|
32
|
+
organPermCodes: db.getOrganPermCodes() || [],
|
|
33
|
+
// 是否销售员
|
|
34
|
+
isSales: db.getOrganSales() || false,
|
|
35
|
+
}),
|
|
36
|
+
actions: {
|
|
37
|
+
clearOrganUser() {
|
|
38
|
+
this.organUserInfo = {} as UserInfo;
|
|
39
|
+
this.organRoleCodes = [];
|
|
40
|
+
this.organPermCodes = [];
|
|
41
|
+
this.isSales = false;
|
|
42
|
+
db.setOrganUserInfo({} as UserInfo);
|
|
43
|
+
db.setOrganRoleCodes([]);
|
|
44
|
+
db.setOrganPermCodes([]);
|
|
45
|
+
db.setOrganSales(false);
|
|
46
|
+
},
|
|
47
|
+
//设置组织信息.
|
|
48
|
+
setOrganInfo(data: StorageOrganInfoModel) {
|
|
49
|
+
this.organInfo = data;
|
|
50
|
+
this.organTenant = data.organTenant || "";
|
|
51
|
+
this.clearOrganUser();
|
|
52
|
+
db.setOrganInfo(data);
|
|
53
|
+
db.setOrganTenant(data.organTenant || "");
|
|
54
|
+
},
|
|
55
|
+
//设置组织租户和组织信息.
|
|
56
|
+
setOrganTenant(organTenant: string): Promise<boolean> {
|
|
57
|
+
this.organTenant = organTenant;
|
|
58
|
+
db.setOrganTenant(organTenant);
|
|
59
|
+
this.clearOrganUser();
|
|
60
|
+
return storageApi.findOrganTenant().then((res) => {
|
|
61
|
+
if (res.statusCode === 200) {
|
|
62
|
+
this.organInfo = res.data;
|
|
63
|
+
db.setOrganInfo(res.data);
|
|
64
|
+
return Promise.resolve(true);
|
|
65
|
+
} else {
|
|
66
|
+
return Promise.resolve(false);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
// 获取组织用户信息
|
|
71
|
+
getOrganUserInfo(): Promise<UserInfo> {
|
|
72
|
+
// 无缓存请求接口
|
|
73
|
+
return organUserApi
|
|
74
|
+
.userInfo(this.organTenant)
|
|
75
|
+
.then((resp) => {
|
|
76
|
+
this.organUserInfo = resp.data;
|
|
77
|
+
db.setOrganUserInfo(resp.data);
|
|
78
|
+
return resp.data;
|
|
79
|
+
})
|
|
80
|
+
.catch(() => Promise.reject("获取组织用户信息错误!"));
|
|
81
|
+
},
|
|
82
|
+
// 获取组织用户角色权限
|
|
83
|
+
getOrganUserRolesPerms(): Promise<RolesPerms> {
|
|
84
|
+
// 无缓存请求接口
|
|
85
|
+
return organUserApi
|
|
86
|
+
.userRolesPerms(this.organTenant)
|
|
87
|
+
.then((resp) => {
|
|
88
|
+
this.organRoleCodes = resp.data.roleCodes || [];
|
|
89
|
+
this.organPermCodes = resp.data.permCodes || [];
|
|
90
|
+
return resp.data;
|
|
91
|
+
})
|
|
92
|
+
.catch(() => Promise.reject("获取组织用户角色权限错误!"));
|
|
93
|
+
},
|
|
94
|
+
// 设置销售员
|
|
95
|
+
setSales(isSales: boolean): void {
|
|
96
|
+
this.isSales = isSales;
|
|
97
|
+
db.setOrganSales(isSales);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
package/src/store/shop.ts
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import { defineStore } from "@mpxjs/pinia";
|
|
2
|
-
import type {
|
|
3
|
-
ShopInfoModel,
|
|
4
|
-
BranchModel,
|
|
5
|
-
ShopBranchsUsersModel,
|
|
6
|
-
} from "../api/shop/types";
|
|
7
|
-
import { db } from "../utils/db";
|
|
8
|
-
import { useOrganStore } from "./organ";
|
|
9
|
-
import { shopApi } from "../api/shop/index";
|
|
10
|
-
|
|
11
|
-
// 商户状态
|
|
12
|
-
interface ShopState {
|
|
13
|
-
//商户信息
|
|
14
|
-
shopInfo: ShopInfoModel;
|
|
15
|
-
//门店信息
|
|
16
|
-
branchInfo: BranchModel;
|
|
17
|
-
//是否是商户
|
|
18
|
-
isShop: boolean;
|
|
19
|
-
//门店员工信息
|
|
20
|
-
branchUser: ShopBranchsUsersModel;
|
|
21
|
-
//是否是门店店长
|
|
22
|
-
isBranchManage: boolean;
|
|
23
|
-
//是否是门店员工
|
|
24
|
-
isBranchEmployee: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const useShopStore = defineStore("shop", {
|
|
28
|
-
state: (): ShopState => ({
|
|
29
|
-
shopInfo: db.getShopInfo() || {},
|
|
30
|
-
branchInfo: db.getBranchInfo() || {},
|
|
31
|
-
isShop: db.getIsShop() || false,
|
|
32
|
-
//门店员工信息
|
|
33
|
-
branchUser: {} as ShopBranchsUsersModel,
|
|
34
|
-
//是否是门店店长
|
|
35
|
-
isBranchManage: false,
|
|
36
|
-
//是否是门店员工
|
|
37
|
-
isBranchEmployee: false,
|
|
38
|
-
}),
|
|
39
|
-
actions: {
|
|
40
|
-
// 获取我的门店用户信息
|
|
41
|
-
getMyBranchUserInfo(): Promise<ShopBranchsUsersModel> {
|
|
42
|
-
return shopApi
|
|
43
|
-
.findMyShopBranchUser(
|
|
44
|
-
this.branchInfo.organTenant || "",
|
|
45
|
-
this.branchInfo.branchId || ""
|
|
46
|
-
)
|
|
47
|
-
.then((resp) => {
|
|
48
|
-
if (resp.data.shopBranchId !== "") {
|
|
49
|
-
console.log("shopuser", resp.data);
|
|
50
|
-
this.branchUser = resp.data || {};
|
|
51
|
-
this.isBranchManage = resp.data.isLeader || false;
|
|
52
|
-
this.isBranchEmployee = true;
|
|
53
|
-
} else {
|
|
54
|
-
console.log("empty", resp.data);
|
|
55
|
-
this.clearBranchUser();
|
|
56
|
-
}
|
|
57
|
-
return resp.data;
|
|
58
|
-
})
|
|
59
|
-
.catch(() => Promise.reject("获取我的门店用户信息错误!"));
|
|
60
|
-
},
|
|
61
|
-
// 清除商户门店
|
|
62
|
-
clearShop() {
|
|
63
|
-
this.shopInfo = {};
|
|
64
|
-
this.branchInfo = {};
|
|
65
|
-
this.isShop = false;
|
|
66
|
-
db.removeBranchInfo();
|
|
67
|
-
db.removeShopInfo();
|
|
68
|
-
db.removeIsShop();
|
|
69
|
-
//清理门店用户
|
|
70
|
-
this.clearBranchUser();
|
|
71
|
-
},
|
|
72
|
-
// 清理门店用户
|
|
73
|
-
clearBranchUser() {
|
|
74
|
-
this.branchUser = {};
|
|
75
|
-
this.isBranchManage = false;
|
|
76
|
-
this.isBranchEmployee = false;
|
|
77
|
-
},
|
|
78
|
-
// 切换商户门店
|
|
79
|
-
switchShopBranch(
|
|
80
|
-
shopInfo: ShopInfoModel,
|
|
81
|
-
branchInfo: BranchModel
|
|
82
|
-
): Promise<boolean> {
|
|
83
|
-
this.shopInfo = shopInfo;
|
|
84
|
-
this.branchInfo = branchInfo;
|
|
85
|
-
this.isShop = false;
|
|
86
|
-
//清理门店用户
|
|
87
|
-
this.clearBranchUser();
|
|
88
|
-
// 切换商户门店
|
|
89
|
-
db.setShopInfo(shopInfo);
|
|
90
|
-
db.setBranchInfo(branchInfo);
|
|
91
|
-
db.setIsShop(false);
|
|
92
|
-
const organStore = useOrganStore();
|
|
93
|
-
return organStore.setOrganTenant(branchInfo.organTenant || "");
|
|
94
|
-
},
|
|
95
|
-
// 切换商户
|
|
96
|
-
switchShop(shopInfo: ShopInfoModel): Promise<boolean> {
|
|
97
|
-
this.shopInfo = shopInfo;
|
|
98
|
-
this.branchInfo = {};
|
|
99
|
-
this.isShop = true;
|
|
100
|
-
//清理门店用户
|
|
101
|
-
this.clearBranchUser();
|
|
102
|
-
// 切换商户
|
|
103
|
-
db.setShopInfo(shopInfo);
|
|
104
|
-
db.setBranchInfo({});
|
|
105
|
-
db.setIsShop(true);
|
|
106
|
-
const organStore = useOrganStore();
|
|
107
|
-
return organStore.setOrganTenant(shopInfo.organTenant || "");
|
|
108
|
-
},
|
|
109
|
-
// 切换门店
|
|
110
|
-
switchBranch(branchInfo: BranchModel): Promise<boolean> {
|
|
111
|
-
this.branchInfo = branchInfo;
|
|
112
|
-
this.isShop = false;
|
|
113
|
-
//清理门店用户
|
|
114
|
-
this.clearBranchUser();
|
|
115
|
-
// 切换门店
|
|
116
|
-
db.setBranchInfo(branchInfo);
|
|
117
|
-
db.setIsShop(false);
|
|
118
|
-
return shopApi.findShopInfoById(branchInfo.shopId || "").then((res) => {
|
|
119
|
-
if (res.statusCode === 200) {
|
|
120
|
-
this.shopInfo = res.data || {};
|
|
121
|
-
db.setShopInfo(this.shopInfo);
|
|
122
|
-
const organStore = useOrganStore();
|
|
123
|
-
return organStore.setOrganTenant(branchInfo.organTenant || "");
|
|
124
|
-
} else {
|
|
125
|
-
return Promise.resolve(false);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
});
|
|
1
|
+
import { defineStore } from "@mpxjs/pinia";
|
|
2
|
+
import type {
|
|
3
|
+
ShopInfoModel,
|
|
4
|
+
BranchModel,
|
|
5
|
+
ShopBranchsUsersModel,
|
|
6
|
+
} from "../api/shop/types";
|
|
7
|
+
import { db } from "../utils/db";
|
|
8
|
+
import { useOrganStore } from "./organ";
|
|
9
|
+
import { shopApi } from "../api/shop/index";
|
|
10
|
+
|
|
11
|
+
// 商户状态
|
|
12
|
+
interface ShopState {
|
|
13
|
+
//商户信息
|
|
14
|
+
shopInfo: ShopInfoModel;
|
|
15
|
+
//门店信息
|
|
16
|
+
branchInfo: BranchModel;
|
|
17
|
+
//是否是商户
|
|
18
|
+
isShop: boolean;
|
|
19
|
+
//门店员工信息
|
|
20
|
+
branchUser: ShopBranchsUsersModel;
|
|
21
|
+
//是否是门店店长
|
|
22
|
+
isBranchManage: boolean;
|
|
23
|
+
//是否是门店员工
|
|
24
|
+
isBranchEmployee: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const useShopStore = defineStore("shop", {
|
|
28
|
+
state: (): ShopState => ({
|
|
29
|
+
shopInfo: db.getShopInfo() || {},
|
|
30
|
+
branchInfo: db.getBranchInfo() || {},
|
|
31
|
+
isShop: db.getIsShop() || false,
|
|
32
|
+
//门店员工信息
|
|
33
|
+
branchUser: {} as ShopBranchsUsersModel,
|
|
34
|
+
//是否是门店店长
|
|
35
|
+
isBranchManage: false,
|
|
36
|
+
//是否是门店员工
|
|
37
|
+
isBranchEmployee: false,
|
|
38
|
+
}),
|
|
39
|
+
actions: {
|
|
40
|
+
// 获取我的门店用户信息
|
|
41
|
+
getMyBranchUserInfo(): Promise<ShopBranchsUsersModel> {
|
|
42
|
+
return shopApi
|
|
43
|
+
.findMyShopBranchUser(
|
|
44
|
+
this.branchInfo.organTenant || "",
|
|
45
|
+
this.branchInfo.branchId || ""
|
|
46
|
+
)
|
|
47
|
+
.then((resp) => {
|
|
48
|
+
if (resp.data.shopBranchId !== "") {
|
|
49
|
+
console.log("shopuser", resp.data);
|
|
50
|
+
this.branchUser = resp.data || {};
|
|
51
|
+
this.isBranchManage = resp.data.isLeader || false;
|
|
52
|
+
this.isBranchEmployee = true;
|
|
53
|
+
} else {
|
|
54
|
+
console.log("empty", resp.data);
|
|
55
|
+
this.clearBranchUser();
|
|
56
|
+
}
|
|
57
|
+
return resp.data;
|
|
58
|
+
})
|
|
59
|
+
.catch(() => Promise.reject("获取我的门店用户信息错误!"));
|
|
60
|
+
},
|
|
61
|
+
// 清除商户门店
|
|
62
|
+
clearShop() {
|
|
63
|
+
this.shopInfo = {};
|
|
64
|
+
this.branchInfo = {};
|
|
65
|
+
this.isShop = false;
|
|
66
|
+
db.removeBranchInfo();
|
|
67
|
+
db.removeShopInfo();
|
|
68
|
+
db.removeIsShop();
|
|
69
|
+
//清理门店用户
|
|
70
|
+
this.clearBranchUser();
|
|
71
|
+
},
|
|
72
|
+
// 清理门店用户
|
|
73
|
+
clearBranchUser() {
|
|
74
|
+
this.branchUser = {};
|
|
75
|
+
this.isBranchManage = false;
|
|
76
|
+
this.isBranchEmployee = false;
|
|
77
|
+
},
|
|
78
|
+
// 切换商户门店
|
|
79
|
+
switchShopBranch(
|
|
80
|
+
shopInfo: ShopInfoModel,
|
|
81
|
+
branchInfo: BranchModel
|
|
82
|
+
): Promise<boolean> {
|
|
83
|
+
this.shopInfo = shopInfo;
|
|
84
|
+
this.branchInfo = branchInfo;
|
|
85
|
+
this.isShop = false;
|
|
86
|
+
//清理门店用户
|
|
87
|
+
this.clearBranchUser();
|
|
88
|
+
// 切换商户门店
|
|
89
|
+
db.setShopInfo(shopInfo);
|
|
90
|
+
db.setBranchInfo(branchInfo);
|
|
91
|
+
db.setIsShop(false);
|
|
92
|
+
const organStore = useOrganStore();
|
|
93
|
+
return organStore.setOrganTenant(branchInfo.organTenant || "");
|
|
94
|
+
},
|
|
95
|
+
// 切换商户
|
|
96
|
+
switchShop(shopInfo: ShopInfoModel): Promise<boolean> {
|
|
97
|
+
this.shopInfo = shopInfo;
|
|
98
|
+
this.branchInfo = {};
|
|
99
|
+
this.isShop = true;
|
|
100
|
+
//清理门店用户
|
|
101
|
+
this.clearBranchUser();
|
|
102
|
+
// 切换商户
|
|
103
|
+
db.setShopInfo(shopInfo);
|
|
104
|
+
db.setBranchInfo({});
|
|
105
|
+
db.setIsShop(true);
|
|
106
|
+
const organStore = useOrganStore();
|
|
107
|
+
return organStore.setOrganTenant(shopInfo.organTenant || "");
|
|
108
|
+
},
|
|
109
|
+
// 切换门店
|
|
110
|
+
switchBranch(branchInfo: BranchModel): Promise<boolean> {
|
|
111
|
+
this.branchInfo = branchInfo;
|
|
112
|
+
this.isShop = false;
|
|
113
|
+
//清理门店用户
|
|
114
|
+
this.clearBranchUser();
|
|
115
|
+
// 切换门店
|
|
116
|
+
db.setBranchInfo(branchInfo);
|
|
117
|
+
db.setIsShop(false);
|
|
118
|
+
return shopApi.findShopInfoById(branchInfo.shopId || "").then((res) => {
|
|
119
|
+
if (res.statusCode === 200) {
|
|
120
|
+
this.shopInfo = res.data || {};
|
|
121
|
+
db.setShopInfo(this.shopInfo);
|
|
122
|
+
const organStore = useOrganStore();
|
|
123
|
+
return organStore.setOrganTenant(branchInfo.organTenant || "");
|
|
124
|
+
} else {
|
|
125
|
+
return Promise.resolve(false);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|