Skip to content

Commit c315fc7

Browse files
committed
预览增加选择租户
1 parent 7b47f78 commit c315fc7

5 files changed

Lines changed: 436 additions & 7 deletions

File tree

designer-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@opentiny/tiny-engine": "workspace:^",
1616
"@opentiny/tiny-engine-meta-register": "workspace:^",
1717
"@opentiny/tiny-engine-utils": "workspace:*",
18-
"@opentiny/utils": "~3.21.0",
18+
"@opentiny/utils": "~3.22.0",
1919
"@opentiny/vue": "~3.21.0",
2020
"@opentiny/vue-design-smb": "~3.21.0",
2121
"@opentiny/vue-icon": "~3.21.0",

packages/design-core/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"@babel/generator": "~7.23.2",
4343
"@babel/parser": "~7.23.2",
4444
"@babel/traverse": "~7.23.2",
45-
"@opentiny/tiny-schema-renderer": "1.0.0-beta.6",
4645
"@opentiny/tiny-engine-canvas": "workspace:*",
4746
"@opentiny/tiny-engine-common": "workspace:*",
4847
"@opentiny/tiny-engine-configurator": "workspace:*",
@@ -55,15 +54,15 @@
5554
"@opentiny/tiny-engine-plugin-help": "workspace:*",
5655
"@opentiny/tiny-engine-plugin-i18n": "workspace:*",
5756
"@opentiny/tiny-engine-plugin-materials": "workspace:*",
57+
"@opentiny/tiny-engine-plugin-model-manager": "workspace:*",
5858
"@opentiny/tiny-engine-plugin-page": "workspace:*",
59-
"@opentiny/tiny-engine-plugin-robot": "workspace:*",
6059
"@opentiny/tiny-engine-plugin-resource": "workspace:*",
60+
"@opentiny/tiny-engine-plugin-robot": "workspace:*",
6161
"@opentiny/tiny-engine-plugin-schema": "workspace:*",
6262
"@opentiny/tiny-engine-plugin-script": "workspace:*",
6363
"@opentiny/tiny-engine-plugin-state": "workspace:*",
6464
"@opentiny/tiny-engine-plugin-tree": "workspace:*",
6565
"@opentiny/tiny-engine-plugin-tutorial": "workspace:*",
66-
"@opentiny/tiny-engine-plugin-model-manager": "workspace:*",
6766
"@opentiny/tiny-engine-setting-design": "workspace:*",
6867
"@opentiny/tiny-engine-setting-events": "workspace:*",
6968
"@opentiny/tiny-engine-setting-props": "workspace:*",
@@ -86,14 +85,16 @@
8685
"@opentiny/tiny-engine-toolbar-save": "workspace:*",
8786
"@opentiny/tiny-engine-toolbar-setting": "workspace:*",
8887
"@opentiny/tiny-engine-toolbar-theme-switch": "workspace:*",
89-
"@opentiny/tiny-engine-toolbar-view-setting": "workspace:*",
9088
"@opentiny/tiny-engine-toolbar-user": "workspace:*",
89+
"@opentiny/tiny-engine-toolbar-view-setting": "workspace:*",
9190
"@opentiny/tiny-engine-utils": "workspace:*",
9291
"@opentiny/tiny-engine-vite-plugin-meta-comments": "workspace:*",
93-
"@opentiny/tiny-engine-workspace-template-center": "workspace:*",
9492
"@opentiny/tiny-engine-workspace-application-center": "workspace:*",
93+
"@opentiny/tiny-engine-workspace-template-center": "workspace:*",
94+
"@opentiny/tiny-schema-renderer": "1.0.0-beta.6",
9595
"@vue/repl": "4.6.1",
9696
"@vueuse/core": "^9.6.0",
97+
"crypto-js": "^4.2.0",
9798
"element-resize-detector": "^1.2.4",
9899
"eslint-linter-browserify": "8.57.0",
99100
"file-saver": "^2.0.5",
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<template>
2+
<tiny-base-select
3+
v-model="state.tenantNo"
4+
:searchable="true"
5+
placeholder="选择租户"
6+
@change="changeTenant"
7+
:options="state.tenantList"
8+
>
9+
</tiny-base-select>
10+
</template>
11+
12+
<script>
13+
import { reactive } from 'vue'
14+
import { Select } from '@opentiny/vue'
15+
import i18n from '@opentiny/tiny-engine-common/js/i18n'
16+
17+
import { request, METHOD } from './request'
18+
19+
import CryptoJS from 'crypto-js'
20+
21+
export default {
22+
components: {
23+
TinyBaseSelect: Select
24+
},
25+
26+
setup() {
27+
const { locale } = i18n.global
28+
const state = reactive({
29+
tenantNo: '',
30+
31+
tenantList: [],
32+
defaultParameters: [],
33+
selectedDefault: '',
34+
defaultValue: ''
35+
})
36+
37+
const Encrypt = (str) => {
38+
const _KEY = 'd22c46e8e6074295ba2b53fcd63ea071' //32位
39+
const _IV = 'd93b7fcd1a0e40ff' //16位
40+
const key = CryptoJS.enc.Utf8.parse(_KEY)
41+
const iv = CryptoJS.enc.Utf8.parse(_IV)
42+
43+
let encrypted = ''
44+
45+
const srcs = CryptoJS.enc.Utf8.parse(str)
46+
encrypted = CryptoJS.AES.encrypt(srcs, key, {
47+
iv: iv,
48+
mode: CryptoJS.mode.CBC,
49+
padding: CryptoJS.pad.Pkcs7
50+
})
51+
52+
return encrypted.ciphertext.toString()
53+
}
54+
55+
//解密方法
56+
const Decrypt = (word) => {
57+
const _KEY = 'd22c46e8e6074295ba2b53fcd63ea071' //32位
58+
const _IV = 'd93b7fcd1a0e40ff' //16位
59+
const key = CryptoJS.enc.Utf8.parse(_KEY)
60+
const iv = CryptoJS.enc.Utf8.parse(_IV)
61+
const encryptedHexStr = CryptoJS.enc.Hex.parse(word)
62+
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr)
63+
const decrypt = CryptoJS.AES.decrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 })
64+
const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)
65+
return decryptedStr.toString()
66+
}
67+
68+
const changeTenant = (value) => {
69+
const Args = { code: value, name: 'admin', password: '698D51A19D8A121CE581499D7B701668' }
70+
request('/System/Check', METHOD.POST, Args).then((result) => {
71+
const LOGIN_INFO_KEY = 'SHQY__LoginInfo__'
72+
const CryptLoginInfo = Encrypt(JSON.stringify(result.LoginInfo))
73+
sessionStorage.setItem(LOGIN_INFO_KEY, CryptLoginInfo)
74+
const TOKEN_KEY = 'SHQY__Token__'
75+
sessionStorage.setItem(TOKEN_KEY, result.Token)
76+
77+
location.reload()
78+
})
79+
}
80+
81+
return {
82+
state,
83+
locale,
84+
changeTenant,
85+
Encrypt,
86+
Decrypt
87+
}
88+
},
89+
mounted() {
90+
request('/System/QueryTenantList', METHOD.POST).then((result) => {
91+
this.state.tenantList = []
92+
result.forEach((item) => {
93+
this.state.tenantList.push({
94+
key: item.TenantNo,
95+
label: item.TenantName,
96+
value: item.TenantNo
97+
})
98+
})
99+
100+
const loginInfo = sessionStorage.getItem('SHQY__LoginInfo__')
101+
102+
if (loginInfo != undefined) {
103+
const loginInfoObj = JSON.parse(this.Decrypt(loginInfo))
104+
this.state.tenantNo = loginInfoObj.TenantNo
105+
}
106+
})
107+
}
108+
}
109+
</script>
110+
<style scoped></style>

packages/design-core/src/preview/src/Toolbar.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="tiny-engine-toolbar">
33
<div class="toolbar-left">
44
<component :is="Breadcrumb"></component>
5+
<SelectTenant />
56
</div>
67
<div class="toolbar-center">
78
<component :is="ToolbarMedia" :isCanvas="false" @setViewPort="setViewPort"></component>
@@ -24,9 +25,12 @@ import { BROADCAST_CHANNEL } from '../src/preview/srcFiles/constant'
2425
import { injectDebugSwitch } from './preview/debugSwitch'
2526
import { previewState } from './preview/usePreviewData'
2627
28+
import SelectTenant from './SelectTenant.vue'
29+
2730
export default {
2831
components: {
29-
TinySwitch
32+
TinySwitch,
33+
SelectTenant
3034
},
3135
setup() {
3236
const debugSwitch = injectDebugSwitch()

0 commit comments

Comments
 (0)