|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="cus-table" :class="{'cus-table-normal': !otherStyle, 'cus-table-full': full !== false}">
|
|
|
- <div class="cus-table-main" ref="ref_tableMain">
|
|
|
+ <div class="cus-table-main" ref="ref_tableMain" :class="{'cus-table-main-no-foot': noFoot !== false}">
|
|
|
<el-table
|
|
|
v-bind="$attrs"
|
|
|
class="ct-table"
|
|
@@ -11,8 +11,8 @@
|
|
|
@filter-change="handleFilter"
|
|
|
@selection-change="v => $emit('update:selected', v)"
|
|
|
>
|
|
|
- <el-table-column v-if="selected" type="selection" :width="selectWidth" align="center" width="52" :selectable="selectable"/>
|
|
|
- <el-table-column v-if="singled" :width="singledWidth" align="center" width="52" class-name="single-column">
|
|
|
+ <el-table-column v-if="selected" type="selection" :width="selectWidth" align="center" :selectable="selectable"/>
|
|
|
+ <el-table-column v-if="singled" :width="singledWidth" align="center" class-name="single-column">
|
|
|
<template #default="scope">
|
|
|
<div class="single-circle" :class="{active: scope.row[singledKey] === singled[singledKey]}" @click.stop="$emit('update:singled', scope.row)">
|
|
|
<div class="single-circle-in"></div>
|
|
@@ -70,9 +70,12 @@
|
|
|
</template>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
- <div class="ct-page">
|
|
|
+ <div class="ct-foot" v-if="noFoot === false">
|
|
|
<div class="total">
|
|
|
- <template v-if="$util.isValue(selected?.length)">
|
|
|
+ <template v-if="$util.isValue(selectedNum)">
|
|
|
+ 已选中 {{ selectedNum }} 条 /
|
|
|
+ </template>
|
|
|
+ <template v-else-if="$util.isValue(selected?.length)">
|
|
|
已选中 {{ selected.length }} 条 /
|
|
|
</template>
|
|
|
共 {{ total }} 条
|
|
@@ -130,6 +133,9 @@ import {
|
|
|
selected: {
|
|
|
default: null
|
|
|
},
|
|
|
+ selectedNum: {
|
|
|
+ default: null
|
|
|
+ },
|
|
|
selectWidth: {
|
|
|
default: 50
|
|
|
},
|
|
@@ -157,7 +163,10 @@ import {
|
|
|
full: {
|
|
|
default: false
|
|
|
},
|
|
|
- selectable: {}
|
|
|
+ selectable: {},
|
|
|
+ noFoot: {
|
|
|
+ default: false
|
|
|
+ }
|
|
|
},
|
|
|
setup(props, { emit }) {
|
|
|
const store = useStore();
|
|
@@ -217,12 +226,35 @@ import {
|
|
|
}
|
|
|
const handleFilter = (val: any) => {
|
|
|
const key = Object.keys(val)[0]
|
|
|
- let value = val[key].length > 0 ? val[key][0] : null
|
|
|
+ const head = props.tableHead.filter(v => v.value === key)[0]
|
|
|
+ let value = null
|
|
|
+ if (val[key].length > 0) {
|
|
|
+ if (head.filterMultiple) {
|
|
|
+ value = val[key]
|
|
|
+ } else {
|
|
|
+ value = val[key][0]
|
|
|
+ }
|
|
|
+ }
|
|
|
emit('handleFilter', {key, value})
|
|
|
}
|
|
|
- const resetFilter = (key: any) => {
|
|
|
+ const resetFilter = (key: any = null) => {
|
|
|
key ? ref_table.value.clearFilter([key]) : ref_table.value.clearFilter()
|
|
|
}
|
|
|
+ const reset = (key: any = null) => {
|
|
|
+ resetFilter(key)
|
|
|
+ ref_table.value.clearSort()
|
|
|
+ }
|
|
|
+ watch(() => props.selected, (n: any) => {
|
|
|
+ if (n.length === 0) {
|
|
|
+ ref_table.value.clearSelection()
|
|
|
+ } else {
|
|
|
+ setTimeout(() => {
|
|
|
+ n.forEach(v => {
|
|
|
+ ref_table.value.toggleRowSelection(v, true)
|
|
|
+ })
|
|
|
+ }, 100)
|
|
|
+ }
|
|
|
+ })
|
|
|
onMounted(() => {
|
|
|
formatTableHead(props.tableHead)
|
|
|
})
|
|
@@ -236,7 +268,8 @@ import {
|
|
|
ref_tableMain,
|
|
|
ref_tablePage,
|
|
|
...toRefs(state),
|
|
|
- pageLayoutCpt
|
|
|
+ pageLayoutCpt,
|
|
|
+ reset
|
|
|
}
|
|
|
},
|
|
|
})
|
|
@@ -259,11 +292,14 @@ import {
|
|
|
width: 100%;
|
|
|
height: calc(100% - #{$cus-page-height} - #{$cus-page-mt}) !important;
|
|
|
position: absolute;
|
|
|
+ &.cus-table-main-no-foot {
|
|
|
+ height: 100% !important;
|
|
|
+ }
|
|
|
:deep(.ct-table) {
|
|
|
height: 100%;
|
|
|
}
|
|
|
}
|
|
|
- :deep(.ct-page) {
|
|
|
+ :deep(.ct-foot) {
|
|
|
height: $cus-page-height;
|
|
|
font-size: 14px;
|
|
|
font-family: Microsoft YaHei;
|
|
@@ -318,6 +354,10 @@ import {
|
|
|
font-family: 微软雅黑;
|
|
|
font-weight: 400;
|
|
|
color: #666666;
|
|
|
+ padding: 0 4px;
|
|
|
+ &.highlight {
|
|
|
+ color: #409eff;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
&:first-child {
|
|
@@ -346,6 +386,7 @@ import {
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
word-break: break-all;
|
|
|
+ padding: 0 6px;
|
|
|
.el-link +.el-link {
|
|
|
margin-left: 10px;
|
|
|
}
|
|
@@ -356,7 +397,7 @@ import {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- :deep(.ct-page) {
|
|
|
+ :deep(.ct-foot) {
|
|
|
margin-top: auto;
|
|
|
}
|
|
|
}
|
|
@@ -365,7 +406,7 @@ import {
|
|
|
position: unset;
|
|
|
height: 100% !important;
|
|
|
}
|
|
|
- :deep(.ct-page) {
|
|
|
+ :deep(.ct-foot) {
|
|
|
margin-top: $cus-page-mt;
|
|
|
}
|
|
|
}
|