This commit is contained in:
张成
2026-04-13 11:16:22 +08:00
parent 75149f994f
commit c73afd2325
13 changed files with 421 additions and 30 deletions

View File

@@ -14,6 +14,13 @@
</span>
</Input>
</FormItem>
<FormItem prop="tenantCode">
<Input v-model="form.tenantCode" placeholder="租户编码,默认 default">
<span slot="prepend">
<Icon :size="14" type="ios-briefcase"></Icon>
</span>
</Input>
</FormItem>
<FormItem>
<Button style="margin-top:20px;" size="large" @click="handleSubmit" type="primary" long>登录</Button>
</FormItem>
@@ -40,7 +47,8 @@ export default {
return {
form: {
userName: '',
password: ''
password: '',
tenantCode: 'default'
}
}
},
@@ -48,7 +56,8 @@ export default {
rules() {
return {
userName: this.userNameRules,
password: this.passwordRules
password: this.passwordRules,
tenantCode: [{ required: false }]
}
}
},
@@ -58,7 +67,8 @@ export default {
if (valid) {
this.$emit('on-success-valid', {
userName: this.form.userName,
password: this.form.password
password: this.form.password,
tenantCode: (this.form.tenantCode || '').trim() || 'default'
})
}
})

View File

@@ -17,6 +17,11 @@
<Header class="header-con-main">
<headerBar class="header-con" @on-coll-change="collpasedChange" :collapsed="collapsed">
<Terminal></Terminal>
<span
v-if="currentTenant"
class="main-tenant-tag"
:title="'租户:' + currentTenant.name + '' + currentTenant.code + ''"
>{{ currentTenant.name }}</span>
<user :userName="userName" :user-avator="userAvator || ''" />
</headerBar>
</Header>
@@ -42,7 +47,7 @@ import User from './components/user'
import ABackTop from './components/a-back-top'
import Fullscreen from './components/fullscreen'
import Language from './components/language'
import { mapGetters } from 'vuex'
import { mapGetters, mapState } from 'vuex'
import headerBar from './components/header-bar'
import loadFlower from '../load-flower/index'
import Terminal from './components/terminal'
@@ -77,6 +82,7 @@ export default {
userName: 'user/userName',
userAvator: 'user/avatorImgPath'
}),
...mapState('user', ['currentTenant']),
cacheList() {
return ['ParentView']
}
@@ -149,6 +155,21 @@ export default {
z-index: 999999;
}
.main-tenant-tag {
margin-right: 16px;
padding: 0 10px;
height: 28px;
line-height: 28px;
font-size: 13px;
color: #2d8cf0;
background: rgba(45, 140, 240, 0.08);
border-radius: 4px;
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.sidebar-brand {
display: flex;
justify-content: center;

View File

@@ -13,11 +13,24 @@
<a v-if="isDown&&value&&value.length>0" class="link right-link" @click="downExecl">下载</a>
</div>
<Table :class="tbClass" ref="tablesMain" border :data="insideTableData" :width='defaultWidth' :height='defaultHeight' :columns="insideColumns" v-bind="$attrs" @on-selection-change='onSelect'>
<slot></slot>
<slot name="footer" slot="footer"></slot>
<slot name="loading" slot="loading"></slot>
</Table>
<div class="table-main">
<Table
v-bind="$attrs"
:class="tbClass"
ref="tablesMain"
border
:data="insideTableData"
:width="defaultWidth"
:height="defaultHeight"
:max-height="effectiveTableMaxHeight"
:columns="insideColumns"
@on-selection-change="onSelect"
>
<slot></slot>
<slot name="footer" slot="footer"></slot>
<slot name="loading" slot="loading"></slot>
</Table>
</div>
</div>
</div>
@@ -81,6 +94,9 @@ export default {
},
// 动态计算的偏移量
calculatedOffset: null,
/** 传给 iView Table 的 max-heightpx使表体在可视区内滚动横向条始终在视口底部 */
bodyViewportMaxHeight: null,
_tableContentResizeObserver: null,
}
},
@@ -145,6 +161,13 @@ export default {
// 使用手动指定的偏移量
return `calc(100vh - ${this.maxHeightOffset}px)`
},
/** 未传 height 时由容器测量得到,避免宽表横向滚动条落在整表最底部 */
effectiveTableMaxHeight() {
if (this.height) return undefined
if (this.bodyViewportMaxHeight == null) return undefined
return this.bodyViewportMaxHeight
},
},
methods: {
@@ -174,6 +197,7 @@ export default {
// 触发表格重新渲染
this.$refs.tablesMain.$forceUpdate()
}
this.syncTableBodyMaxHeight()
})
},
onChangePage(page) {
@@ -184,6 +208,43 @@ export default {
this.$emit('on-select', selection, row)
},
syncTableBodyMaxHeight() {
if (this.height) {
this.bodyViewportMaxHeight = null
return
}
this.$nextTick(() => {
const wrap = this.$refs.table_content
if (!wrap) return
const titleEl = wrap.querySelector('.table-title')
const titleH = (this.title || this.isDown) && titleEl ? titleEl.offsetHeight : 0
const avail = wrap.clientHeight - titleH
const next = Math.max(160, Math.floor(avail))
if (this.bodyViewportMaxHeight !== next) {
this.bodyViewportMaxHeight = next
}
this.$nextTick(() => {
const inst = this.$refs.tablesMain
if (inst && typeof inst.handleResize === 'function') {
inst.handleResize()
}
})
})
},
setupTableContentResizeObserver() {
const el = this.$refs.table_content
if (!el || typeof ResizeObserver === 'undefined') return
if (this._tableContentResizeObserver) {
this._tableContentResizeObserver.disconnect()
}
const ro = new ResizeObserver(() => {
this.syncTableBodyMaxHeight()
})
ro.observe(el)
this._tableContentResizeObserver = ro
},
// 动态计算表格容器上方所有元素的高度总和
calculateOffset() {
this.$nextTick(() => {
@@ -203,6 +264,9 @@ export default {
// 计算总偏移量
this.calculatedOffset = topOffset + pageBoxHeight + bottomPadding
this.$nextTick(() => {
this.syncTableBodyMaxHeight()
})
})
},
},
@@ -243,6 +307,7 @@ export default {
// 动态计算偏移量
this.calculateOffset()
this.setupTableContentResizeObserver()
// 如果数据或列配置为空,输出警告
if (!this.insideTableData || this.insideTableData.length === 0) {
@@ -255,11 +320,17 @@ export default {
// 监听窗口大小变化,重新计算偏移量
window.addEventListener('resize', this.calculateOffset)
window.addEventListener('resize', this.syncTableBodyMaxHeight)
},
beforeDestroy() {
// 移除窗口大小监听
window.removeEventListener('resize', this.calculateOffset)
window.removeEventListener('resize', this.syncTableBodyMaxHeight)
if (this._tableContentResizeObserver) {
this._tableContentResizeObserver.disconnect()
this._tableContentResizeObserver = null
}
},
}
</script>
@@ -268,8 +339,12 @@ export default {
width: 100%;
.table-content {
overflow-y: auto;
/* 纵向由 Table 内部表体滚动;避免与外层双滚动导致横向条在整页最底 */
overflow: hidden;
width: 100%;
min-height: 0;
display: flex;
flex-direction: column;
.table-title {
font-weight: bold;
@@ -279,10 +354,17 @@ export default {
padding: 0rem 0.15rem;
height: 50px;
line-height: 50px;
flex-shrink: 0;
.right-link {
float: right;
}
}
.table-main {
flex: 1;
min-height: 0;
overflow: hidden;
}
}
.page-box {