1919 <svg-icon class =" plus-circle" name =" plus-circle" @click =" createTenant" ></svg-icon >
2020 </div >
2121 </div >
22+ <div class =" tenant-tip" v-if =" state.isShowTenantTip" >组织名不能为空</div >
2223 <div class =" user-tenant" >
2324 <div class =" tenant-label" >选择组织</div >
2425 <div class =" tenant-item" >
3839<script lang="ts">
3940import { reactive , computed } from ' vue'
4041import type { Component } from ' vue'
41- import { Popover , Select , Input } from ' @opentiny/vue'
42+ import { Popover , Select , Input , Tooltip } from ' @opentiny/vue'
4243import { getMetaApi , META_SERVICE , useModal } from ' @opentiny/tiny-engine-meta-register'
4344
4445export default {
4546 components: {
4647 TinyPopover: Popover as Component ,
4748 TinySelect: Select ,
48- TinyInput: Input
49+ TinyInput: Input ,
50+ TinyTooltip: Tooltip
4951 },
5052 props: {
5153 iconExpand: {
@@ -63,20 +65,23 @@ export default {
6365 )
6466 const state = reactive ({
6567 tenantValue: getBaseInfo ().tenantId ,
66- newTenant: ' '
68+ newTenant: ' ' ,
69+ isShowTenantTip: false
6770 })
6871
6972 const userInfo = computed (() => getUserInfo ())
7073 const tenantList = computed (() => {
7174 const info = getUserInfo ()
7275
73- return info .tenant ?.map ((item ) => {
74- return {
75- ... item ,
76- value: item .id ,
77- label: item .nameEn
78- }
79- })
76+ return Array .isArray (info ?.tenant )
77+ ? info .tenant ?.map ((item ) => {
78+ return {
79+ ... item ,
80+ value: item .id ,
81+ label: item .nameEn
82+ }
83+ })
84+ : []
8085 })
8186
8287 const logOut = () => {
@@ -85,6 +90,15 @@ export default {
8590 }
8691
8792 const createTenant = () => {
93+ if (! state .newTenant .length ) {
94+ state .isShowTenantTip = true
95+ setTimeout (() => {
96+ state .isShowTenantTip = false
97+ }, 2000 )
98+
99+ return
100+ }
101+
88102 getMetaApi (META_SERVICE .Http )
89103 .post (' /platform-center/api/tenant/create' , {
90104 nameEn: state .newTenant
@@ -158,6 +172,10 @@ export default {
158172 cursor : pointer ;
159173 }
160174 }
175+ .tenant-tip {
176+ color : var (--te-toolbars-user-text-color-error );
177+ padding-left : 60px ;
178+ }
161179 .tenant-label {
162180 font-size : 12px ;
163181 margin-right : 6px ;
0 commit comments