装备配置率配置问题修改

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

View File

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

View File

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