装备配置率配置问题修改

This commit is contained in:
jiang 2026-01-30 14:35:28 +08:00
parent 559a7babc4
commit 70d537e7ad
3 changed files with 103 additions and 144 deletions

View File

@ -2,9 +2,7 @@
<div class="tab-table-wrapper">
<!-- 表格头部标题自定义 + 新增按钮显隐可控 -->
<div class="table-header">
<!-- 标题父组件传递默认空 -->
<h3>{{ tableTitle }}</h3>
<!-- 新增按钮通过showAddBtn控制显隐 -->
<div>
<el-button
v-if="showAddBtn"
@ -43,7 +41,6 @@
外租新增
</el-button>
</div>
</div>
<!-- 表格滚动容器独立滚动表头固定 -->
@ -63,7 +60,6 @@
align="center"
:index="calcTableIndex"
/>
<!-- 改造后完整表格列代码兼容Vue2/Vue3 -->
<el-table-column
v-for="(column, index) in tableColumns"
:key="index"
@ -73,19 +69,15 @@
align="center"
show-overflow-tooltip
>
<!-- 作用域插槽获取当前行数据scope.row当前列配置column -->
<template slot-scope="scope"> <!-- Vue3可写v-slot="scope"效果一致 -->
<!-- 判断当前列有dictMap映射 渲染映射文字无则渲染原始值 -->
<template slot-scope="scope">
<span v-if="column.dictMap">
<!-- 若字段值可能为null/undefined添加兜底显示 -->
{{ column.dictMap[scope.row[column.prop]] || '未知' }}
</span>
{{ column.dictMap[scope.row[column.prop]] || '未知' }}
</span>
<span v-else>
{{ scope.row[column.prop] || '-' }} <!-- 原始值兜底空值显示- -->
</span>
{{ scope.row[column.prop] || '-' }}
</span>
</template>
</el-table-column>
<!-- 操作列通过showActionCol控制显隐 -->
<el-table-column
v-if="showActionCol"
label="操作"
@ -99,12 +91,12 @@
</el-table>
</div>
<!-- 分页组件无数据时隐藏 -->
<!-- 分页组件无数据时隐藏 核心修改1移除.sync绑定内部data -->
<div class="pagination-wrapper" v-if="total > 0">
<pagination
:total="total"
:page.sync="pageNum"
:limit.sync="pageSize"
:page="innerPageNum"
:limit="innerPageSize"
@pagination="handlePageChange"
background
layout="total, sizes, prev, pager, next"
@ -116,75 +108,45 @@
<script>
export default {
name: 'EquipmentTable',
//
props: {
//
tableTitle: {
type: String,
default: ''
//
tableTitle: { type: String, default: '' },
showAddBtn: { type: Boolean, default: true },
showOwnBtn: { type: Boolean, default: true },
showSharingBtn: { type: Boolean, default: true },
showRentalBtn: { type: Boolean, default: true },
showActionCol: { type: Boolean, default: true },
//
tableData: { type: Array, required: true, default: () => [] },
tableColumns: { type: Array, required: true, default: () => [] },
loading: { type: Boolean, default: false },
total: { type: Number, default: 0 },
pageNum: { type: Number, required: true, default: 1 }, // Prop
pageSize: { type: Number, required: true, default: 10 }, // Prop
emptyText: { type: String, default: '暂无数据' }
},
data() {
return {
// 2Prop
innerPageNum: this.pageNum,
innerPageSize: this.pageSize
}
},
watch: {
// 3Propdata
pageNum(newVal) {
this.innerPageNum = newVal
},
// true/false
showAddBtn: {
type: Boolean,
default: true
},
showOwnBtn: {
type: Boolean,
default: true
},
showSharingBtn: {
type: Boolean,
default: true
},
showRentalBtn: {
type: Boolean,
default: true
},
// true/false
showActionCol: {
type: Boolean,
default: true
},
//
tableData: {
type: Array,
required: true,
default: () => []
},
tableColumns: {
type: Array,
required: true,
default: () => []
},
loading: {
type: Boolean,
default: false
},
total: {
type: Number,
default: 0
},
pageNum: {
type: Number,
required: true,
default: 1
},
pageSize: {
type: Number,
required: true,
default: 10
},
emptyText: {
type: String,
default: '暂无数据'
pageSize(newVal) {
this.innerPageSize = newVal
}
},
methods: {
//
// 4data
calcTableIndex(index) {
return (this.pageNum - 1) * this.pageSize + index + 1
return (this.innerPageNum - 1) * this.innerPageSize + index + 1
},
//
//
handleAddClick() {
this.$emit('add')
},
@ -197,15 +159,18 @@ export default {
handleRentalClick() {
this.$emit('rental')
},
//
handleDeleteClick(row) {
this.$emit('delete', row)
},
//
handlePageChange() {
// 5
handlePageChange({ page, limit }) {
// 1.
this.innerPageNum = page
this.innerPageSize = limit
// 2.
this.$emit('pagination', {
pageNum: this.pageNum,
pageSize: this.pageSize
pageNum: this.innerPageNum,
pageSize: this.innerPageSize
})
}
}
@ -213,7 +178,7 @@ export default {
</script>
<style scoped lang="scss">
// /
//
.tab-table-wrapper {
display: flex;
flex-direction: column;
@ -226,7 +191,7 @@ export default {
margin-bottom: 12px;
flex-shrink: 0;
justify-content: space-between;
//
h3 {
margin: 0;
white-space: nowrap;
@ -283,7 +248,6 @@ export default {
}
}
//
:deep(.el-table__empty-text) {
color: #909399;
font-size: 14px;

View File

@ -39,7 +39,7 @@
>
<el-tab-pane
v-for="tab in mainTabList"
:key="tab.name"
:key="tab.key"
:label="tab.label"
:name="tab.name"
class="tab-pane-container"
@ -1029,7 +1029,7 @@ export default {
}
},
handleNodeClick(data) {
this.currentDeptId = data.id || data.deptId
this.currentDeptId = data.deptId
},
handleDeptSearchClear() {
this.deptName = ''
@ -1043,9 +1043,16 @@ export default {
},
handleTabClick(tab) {
this.activeTab = tab.name
const tabConfig = this.tableData[tab.key]
tabConfig.pageNum = 1
this.loadMainTabData(tab.name)
const tabKey = this.mainTabList.find(item => item.name === tab.name)
const tabConfig = this.tableData[tabKey.key]
// tabConfig
if (tabConfig && typeof tabConfig === 'object') {
tabConfig.pageNum = 1
this.loadMainTabData(tab.name)
} else {
// 便
console.warn(`未找到key为${tab.key}的标签页配置请检查tableData初始化`)
}
},
async loadMainTabData(tabName) {
if (!this.currentDeptId) return

View File

@ -44,12 +44,12 @@
</el-table>
</div>
<!-- 分页组件无数据时隐藏 -->
<!-- 分页组件无数据时隐藏 核心修改1移除.sync绑定内部data属性 -->
<div class="pagination-wrapper" v-if="total > 0">
<pagination
:total="total"
:page.sync="pageNum"
:limit.sync="pageSize"
:page="innerPageNum"
:limit="innerPageSize"
@pagination="handlePageChange"
background
layout="total, sizes, prev, pager, next"
@ -61,74 +61,63 @@
<script>
export default {
name: 'EquipmentTable',
//
//
props: {
//
tableData: {
type: Array,
required: true,
default: () => []
tableData: { type: Array, required: true, default: () => [] },
tableColumns: { type: Array, required: true, default: () => [] },
loading: { type: Boolean, default: false },
total: { type: Number, default: 0 },
pageNum: { type: Number, required: true, default: 1 }, // Prop
pageSize: { type: Number, required: true, default: 10 }, // Prop
emptyText: { type: String, default: '暂无数据' }
},
data() {
return {
// 2Prop
innerPageNum: this.pageNum,
innerPageSize: this.pageSize
}
},
watch: {
// 3Propdata
// pageNum=1
pageNum(newVal) {
this.innerPageNum = newVal
},
//
tableColumns: {
type: Array,
required: true,
default: () => []
},
//
loading: {
type: Boolean,
default: false
},
//
total: {
type: Number,
default: 0
},
//
pageNum: {
type: Number,
required: true,
default: 1
},
//
pageSize: {
type: Number,
required: true,
default: 10
},
//
emptyText: {
type: String,
default: '暂无数据'
pageSize(newVal) {
this.innerPageSize = newVal
}
},
methods: {
//
// data
calcTableIndex(index) {
return (this.pageNum - 1) * this.pageSize + index + 1
return (this.innerPageNum - 1) * this.innerPageSize + index + 1
},
//
//
handleAddClick() {
this.$emit('add')
},
//
//
handleRelateClick(row) {
this.$emit('relate', row)
},
//
//
handleEditClick(row) {
this.$emit('edit', row)
},
//
//
handleDeleteClick(row) {
this.$emit('delete', row)
},
//
handlePageChange() {
// 4data
handlePageChange({ page, limit }) {
// 1.
this.innerPageNum = page
this.innerPageSize = limit
// 2. pagination
this.$emit('pagination', {
pageNum: this.pageNum,
pageSize: this.pageSize
pageNum: this.innerPageNum,
pageSize: this.innerPageSize
})
}
}
@ -136,7 +125,7 @@ export default {
</script>
<style scoped lang="scss">
//
//
.tab-table-wrapper {
height: calc(99vh - 84px);
display: flex;
@ -202,7 +191,6 @@ export default {
}
}
//
:deep(.el-table__empty-text) {
color: #909399;
font-size: 14px;