diff --git a/klp-ui/src/views/wms/report/components/coilTable/index.vue b/klp-ui/src/views/wms/report/components/coilTable/index.vue
index 3d93d4ac..a5a8952d 100644
--- a/klp-ui/src/views/wms/report/components/coilTable/index.vue
+++ b/klp-ui/src/views/wms/report/components/coilTable/index.vue
@@ -1,8 +1,34 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -29,15 +55,6 @@
-
@@ -67,20 +84,80 @@ export default {
return {
pageNum: 1,
pageSize: 1000,
+ // 排序相关
+ sortField: '',
+ sortDirection: 'asc',
+ // 筛选相关
+ filterKeyword: '',
+ filterColumn: [],
}
},
+ mounted() {
+ // 默认选中所有列
+ this.filterColumn = this.columns.map(column => column.prop)
+ },
computed: {
+ // 处理排序和筛选后的数据
+ processedData() {
+ let result = [...this.data]
+
+ // 筛选逻辑
+ if (this.filterColumn.length > 0 && this.filterKeyword) {
+ const keyword = this.filterKeyword.toLowerCase()
+ result = result.filter(item => {
+ // 只要有一个字段匹配,就保留该记录
+ return this.filterColumn.some(column => {
+ const value = item[column]
+ if (value === null || value === undefined) return false
+ return String(value).toLowerCase().includes(keyword)
+ })
+ })
+ }
+
+ // 排序逻辑
+ if (this.sortField) {
+ result.sort((a, b) => {
+ const aValue = a[this.sortField]
+ const bValue = b[this.sortField]
+
+ // 处理null和undefined
+ if (aValue === null || aValue === undefined) return 1
+ if (bValue === null || bValue === undefined) return -1
+
+ // 字符串比较
+ if (typeof aValue === 'string' && typeof bValue === 'string') {
+ return this.sortDirection === 'asc'
+ ? aValue.localeCompare(bValue)
+ : bValue.localeCompare(aValue)
+ }
+
+ // 数字比较
+ if (typeof aValue === 'number' && typeof bValue === 'number') {
+ return this.sortDirection === 'asc'
+ ? aValue - bValue
+ : bValue - aValue
+ }
+
+ // 其他类型比较
+ return this.sortDirection === 'asc'
+ ? String(aValue).localeCompare(String(bValue))
+ : String(bValue).localeCompare(String(aValue))
+ })
+ }
+
+ return result
+ },
// 内部实现前端分页逻辑
tableData() {
- return this.data.slice((this.pageNum - 1) * this.pageSize, this.pageNum * this.pageSize)
+ return this.processedData.slice((this.pageNum - 1) * this.pageSize, this.pageNum * this.pageSize)
},
// 计算总页数
totalPage() {
- return Math.ceil(this.data.length / this.pageSize)
+ return Math.ceil(this.processedData.length / this.pageSize)
},
// 计算总条数
total() {
- return this.data.length
+ return this.processedData.length
},
// 是否展示分页组件
showPagination() {
@@ -116,7 +193,53 @@ export default {
result += `${minutes}分钟`
}
return result
+ },
+ // 处理筛选条件变化
+ handleFilterChange() {
+ this.pageNum = 1
+ },
+ // 处理排序规则变化
+ handleSortChange() {
+ this.pageNum = 1
}
}
}
-
\ No newline at end of file
+
+
+
\ No newline at end of file