提交 1ec9b61c 编写于 作者: 沐夕花开's avatar 沐夕花开

fix: 修复 tableData = [] 时候一直显示loading状态: tableData 为Boolean类型时,显示 loading,空数组时候显示 无数据提示

上级 ae2c8026
......@@ -95,7 +95,9 @@
mounted() {
setTimeout(() => {
this.columns = baseColumns
this.tableData = baseColumnsData
// tableData 为Boolean 时,显示loading,空数组时候显示 无数据提示
// this.tableData = baseColumnsData
this.tableData = []
this.tableData1 = baseColumnsData
this.tableDataTree = treeColumnsData
......
## 1.0.7(2022-04-14)
修复 tableData = [] 时候一直显示loading状态:
tableData 为 Boolean类型时,显示 loading,空数组时候显示 无数据提示
## 1.0.6(2022-04-10)
设置不自动格式化数字:columns[i].formatNum = false ,默认true。
原有功能,文档写漏了配置,文档已更新!!!
......
......@@ -11,7 +11,7 @@
height: computedTableHeight.height,
minHeight: computedTableHeight.minHeight
}">
<view v-if="!tableLoaded && (!dataList || !columns)" class="ztableLoading n-loading">
<view v-if="!tableLoaded && (!dataList || !columns) && showLoading" class="ztableLoading n-loading">
<view class="n-loading-animate"></view>
</view>
<view class="n-table-container">
......@@ -28,8 +28,6 @@
:isTree="isTree"
@rowSort="onRowSort"
@toggleTree="onToggleTree"></table-header>
<!-- :height="_tableOpt.itemHeight" -->
<table-body
:isOpenAll="isOpenAll"
:isShowSum="_tableOpt.isShowSum"
......@@ -47,8 +45,8 @@
</table-body>
</view>
</view>
<view v-if="dataList && dataList.length == 0 && !tableLoaded" class="table-empty">
<view v-html="showLoading ? '' : _tableOpt.emptyText"></view>
<view v-if="tableLoaded && !dataList.length" class="table-empty">
<view v-html="_tableOpt.emptyText"></view>
</view>
</view>
<!-- 内部分页处理 -->
......@@ -83,7 +81,6 @@
return {
nowSortKey: '',
sortType: 'desc', // asc/desc 升序/降序
tableLoaded: false,
dataList: [], // 遍历显示的数据列表
saveDataList: [], // 处理后的数据列表 - 用以备份 : 当分页形式无需重新计算
dataIndexs: [], //
......@@ -116,7 +113,7 @@
autoSort: { type: Boolean, default: true },
// 当前页
currentPage: { type: [Number,Boolean], default: false },
currentPage: { type: [Number, Boolean], default: false },
// 总页数
totalPage: { type: Number, default: 1 },
},
......@@ -130,7 +127,7 @@
let headerHeight = this._headerOpt.height
return {
height: this.tableHeight ? uni.upx2px(this.tableHeight - nameHeight - pageHeight) + 'px' : '100%',
minHeight: this.tableHeight ? 'auto' : uni.upx2px(headerHeight + 120 ) + 'px'
minHeight: this.tableHeight ? 'auto' : uni.upx2px(headerHeight + 120) + 'px'
}
// return this.tableHeight ? 'height: ' + uni.upx2px(this.tableHeight - nameHeight - pageHeight) + 'px' : ''
},
......@@ -167,6 +164,12 @@
minHeight: this.tableHeight ? 'auto' : uni.upx2px(nameHeight + pageHeight + headerHeight + 120) + 'px'
}
},
// 表格数据是否已经加载
tableLoaded() {
let res = typeof this.tableData === 'boolean' ? false : true
return res
}
},
watch: {
......@@ -457,17 +460,23 @@
min-height: 100%;
width: fit-content;
}
.table-empty {
position: absolute;
top: 64rpx;
height: 64rpx;
line-height: 64rpx;
top: 0;
left: 0;
z-index: 0;
display: flex;
align-items: center;
justify-content: center;
border: none;
height: 100%;
width: 100%;
text-align: center;
background: transparent;
pointer-events: none;
color: #999
}
// 1.0.5
.n-loading {
position: absolute;
......
......@@ -13,8 +13,6 @@
v-for="(col, jIndex) in dataIndexs"
:key="jIndex" @click.stop="itemClick(row, col)">
<!-- 展开 -->
<!-- height: height ? height + 'rpx' : '64rpx',
lineHeight:height ? height + 'rpx' : '64rpx', -->
<view
class="open-child"
v-if="jIndex === 0"
......@@ -74,7 +72,6 @@
name: 'tableBody',
props: {
// 单元格高度
// height: { type: Number, default: 64 },
colKey: { type: String, default: 'key' },
idKey: { type: String, default: 'id' },
dataIndexs: { type: Array, default: () => [] },
......@@ -88,6 +85,10 @@
dataList: {
type: [Array, Boolean],
default: () => []
},
empty:{
type: Boolean,
default: false
}
},
data() {
......
{
"id": "n-table",
"displayName": "n-table 多级表头、树形结构,高度配置表格组件",
"version": "1.0.6",
"version": "1.0.7",
"description": "n-table 多级表头、树形结构,高度配置表格组件",
"keywords": [
"表格,多级表头,树形结构,可配置"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册