Showing
1 changed file
with
109 additions
and
24 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-07-23 10:34:37 | 2 | * @Date: 2024-07-23 10:34:37 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-09-10 15:21:17 | 4 | + * @LastEditTime: 2024-09-11 17:00:25 |
| 5 | * @FilePath: /custom_table/src/views/index.vue | 5 | * @FilePath: /custom_table/src/views/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div class="table-container"> | 9 | <div class="table-container"> |
| 10 | - <el-row justify="space-between"> | 10 | + <el-row class="table-header" justify="space-between"> |
| 11 | <el-col :span="12"> | 11 | <el-col :span="12"> |
| 12 | <div class="table-tools"> | 12 | <div class="table-tools"> |
| 13 | - <el-button type="primary" :icon="Plus">添加</el-button> | 13 | + <el-button type="primary" :icon="Plus" @click="addItem">添加</el-button> |
| 14 | <div class="table-tools-item"> | 14 | <div class="table-tools-item"> |
| 15 | <el-icon style="vertical-align: middle"><Download /></el-icon> | 15 | <el-icon style="vertical-align: middle"><Download /></el-icon> |
| 16 | <span class="table-tools-item-text">导入</span> | 16 | <span class="table-tools-item-text">导入</span> |
| ... | @@ -28,10 +28,18 @@ | ... | @@ -28,10 +28,18 @@ |
| 28 | <el-col :span="12" style="text-align: right;"> | 28 | <el-col :span="12" style="text-align: right;"> |
| 29 | <el-input | 29 | <el-input |
| 30 | v-model="input3" | 30 | v-model="input3" |
| 31 | - style="width: 200px; margin-right: 1rem;" | 31 | + style="width: 300px; margin-right: 1rem;" |
| 32 | placeholder="搜索数据" | 32 | placeholder="搜索数据" |
| 33 | :prefix-icon="Search" | 33 | :prefix-icon="Search" |
| 34 | - /> | 34 | + > |
| 35 | + <!-- <template #append> | ||
| 36 | + <el-select v-model="select" placeholder="Select" style="width: 115px"> | ||
| 37 | + <el-option label="Restaurant" value="1" /> | ||
| 38 | + <el-option label="Order No." value="2" /> | ||
| 39 | + <el-option label="Tel" value="3" /> | ||
| 40 | + </el-select> | ||
| 41 | + </template> --> | ||
| 42 | + </el-input> | ||
| 35 | <el-popover :visible="filter_visible" :width="400" placement="bottom-end"> | 43 | <el-popover :visible="filter_visible" :width="400" placement="bottom-end"> |
| 36 | <template #reference> | 44 | <template #reference> |
| 37 | <div class="tooltip-container"> | 45 | <div class="tooltip-container"> |
| ... | @@ -40,12 +48,19 @@ | ... | @@ -40,12 +48,19 @@ |
| 40 | </div> | 48 | </div> |
| 41 | </template> | 49 | </template> |
| 42 | <el-form ref="filter_target" :model="form" label-width="auto" style="max-width: 600px"> | 50 | <el-form ref="filter_target" :model="form" label-width="auto" style="max-width: 600px"> |
| 51 | + <div style="padding: 0.5rem 0; display: flex; align-items: center; color: #C2915F; margin-bottom: 0.5rem;"> | ||
| 52 | + <el-icon size="1.5rem" style="vertical-align: middle;"><Plus /> </el-icon><span style="font-size: 0.85rem;">添加筛选条件</span> | ||
| 53 | + </div> | ||
| 43 | <el-form-item label="字段状态"> | 54 | <el-form-item label="字段状态"> |
| 44 | <el-select v-model="form.status" @visible-change="handleVisibleChange" placeholder="请选择"> | 55 | <el-select v-model="form.status" @visible-change="handleVisibleChange" placeholder="请选择"> |
| 45 | <el-option label="状态1" value="type1" /> | 56 | <el-option label="状态1" value="type1" /> |
| 46 | <el-option label="状态2" value="type2" /> | 57 | <el-option label="状态2" value="type2" /> |
| 47 | </el-select> | 58 | </el-select> |
| 48 | </el-form-item> | 59 | </el-form-item> |
| 60 | + <el-form-item style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #eee;"> | ||
| 61 | + <el-button type="primary">筛选</el-button> | ||
| 62 | + <el-button type="link">清空</el-button> | ||
| 63 | + </el-form-item> | ||
| 49 | </el-form> | 64 | </el-form> |
| 50 | </el-popover> | 65 | </el-popover> |
| 51 | | 66 | |
| ... | @@ -59,9 +74,9 @@ | ... | @@ -59,9 +74,9 @@ |
| 59 | <div> | 74 | <div> |
| 60 | <el-checkbox-group v-model="checkList"> | 75 | <el-checkbox-group v-model="checkList"> |
| 61 | <el-checkbox label="全选" value="全选" /> | 76 | <el-checkbox label="全选" value="全选" /> |
| 62 | - <el-checkbox label="Option A" value="Value A" /> | 77 | + <el-checkbox label="字段 A" value="Value A" /> |
| 63 | - <el-checkbox label="Option B" value="Value B" /> | 78 | + <el-checkbox label="字段 B" value="Value B" /> |
| 64 | - <el-checkbox label="Option C" value="Value C" /> | 79 | + <el-checkbox label="字段 C" value="Value C" /> |
| 65 | </el-checkbox-group> | 80 | </el-checkbox-group> |
| 66 | </div> | 81 | </div> |
| 67 | </el-popover> | 82 | </el-popover> |
| ... | @@ -73,11 +88,27 @@ | ... | @@ -73,11 +88,27 @@ |
| 73 | <span class="tooltip-text">排序</span> | 88 | <span class="tooltip-text">排序</span> |
| 74 | </div> | 89 | </div> |
| 75 | </template> | 90 | </template> |
| 91 | + <div style="padding: 0.5rem 0; display: flex; align-items: center; color: #C2915F; margin-bottom: 0.5rem;"> | ||
| 92 | + <el-icon size="1.5rem" style="vertical-align: middle;"><Plus /> </el-icon><span style="font-size: 0.85rem;">添加排序规则</span> | ||
| 93 | + </div> | ||
| 76 | <div> | 94 | <div> |
| 77 | - <div> | 95 | + <el-row align="middle"> |
| 78 | - 日期 | 96 | + <el-col :span="12"> |
| 79 | - <el-button type="primary" plain size="small" @click="sortBy('asc')">升序</el-button> | 97 | + <div style="font-size: 1rem;">日期</div> |
| 80 | - <el-button type="primary" plain size="small" @click="sortBy('desc')">降序</el-button> | 98 | + </el-col> |
| 99 | + <el-col :span="10"> | ||
| 100 | + <el-radio-group v-model="sortRadio" size="large"> | ||
| 101 | + <el-radio-button label="升序" value="asc" /> | ||
| 102 | + <el-radio-button label="降序" value="desc" /> | ||
| 103 | + </el-radio-group> | ||
| 104 | + </el-col> | ||
| 105 | + <el-col :span="2"> | ||
| 106 | + <el-icon size="1.25rem" style="vertical-align: middle;"><Delete /></el-icon> | ||
| 107 | + </el-col> | ||
| 108 | + </el-row> | ||
| 109 | + <div style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #eee;"> | ||
| 110 | + <el-button type="primary">排序</el-button> | ||
| 111 | + <el-button type="link">清空</el-button> | ||
| 81 | </div> | 112 | </div> |
| 82 | </div> | 113 | </div> |
| 83 | </el-popover> | 114 | </el-popover> |
| ... | @@ -90,23 +121,47 @@ | ... | @@ -90,23 +121,47 @@ |
| 90 | </el-col> | 121 | </el-col> |
| 91 | </el-row> | 122 | </el-row> |
| 92 | <el-table | 123 | <el-table |
| 93 | - :data="tableData" stripe border height="780" | 124 | + :data="tableData" stripe border :height="table_height" |
| 94 | style="width: 100%; margin: 1rem 0;" | 125 | style="width: 100%; margin: 1rem 0;" |
| 95 | @selection-change="handleSelectionChange" | 126 | @selection-change="handleSelectionChange" |
| 96 | @row-click="handleRowClick" | 127 | @row-click="handleRowClick" |
| 97 | @cell-click="handleCellClick" | 128 | @cell-click="handleCellClick" |
| 129 | + header-row-class-name="table-header-row" | ||
| 98 | > | 130 | > |
| 99 | <el-table-column type="selection" fixed width="55" /> | 131 | <el-table-column type="selection" fixed width="55" /> |
| 100 | - <el-table-column prop="date" label="Date" width="180" /> | 132 | + <el-table-column prop="date" label="Date" width="180"> |
| 101 | - <el-table-column prop="name" label="Name" width="180" /> | 133 | + <template v-if="false" #default="scope"> |
| 102 | - <el-table-column prop="address" label="Address" width="380" /> | 134 | + 123 |
| 135 | + </template> | ||
| 136 | + </el-table-column> | ||
| 137 | + <el-table-column prop="name" label="Name" width="180"> | ||
| 138 | + <template v-if="true" #default="scope"> | ||
| 139 | + <div style="display: flex; align-items: center"> | ||
| 140 | + <el-icon><Bell /></el-icon> | ||
| 141 | + <el-popover | ||
| 142 | + placement="bottom" | ||
| 143 | + title="姓名" | ||
| 144 | + :width="200" | ||
| 145 | + trigger="click" | ||
| 146 | + > | ||
| 147 | + <template #reference> | ||
| 148 | + <span class="target-name" style="margin-left: 10px; color: blueviolet;">{{ scope.row.name }}</span> | ||
| 149 | + </template> | ||
| 150 | + <template #default> | ||
| 151 | + <div>其他内容的介绍</div> | ||
| 152 | + </template> | ||
| 153 | + </el-popover> | ||
| 154 | + </div> | ||
| 155 | + </template> | ||
| 156 | + </el-table-column> | ||
| 157 | + <el-table-column prop="address" label="Address" width="180" show-overflow-tooltip /> | ||
| 103 | <el-table-column prop="text1" label="text1" width="380" /> | 158 | <el-table-column prop="text1" label="text1" width="380" /> |
| 104 | <el-table-column prop="text2" label="text2" width="380" /> | 159 | <el-table-column prop="text2" label="text2" width="380" /> |
| 105 | <el-table-column prop="text3" label="text3" width="380" /> | 160 | <el-table-column prop="text3" label="text3" width="380" /> |
| 106 | <el-table-column prop="text4" label="text4" width="380" /> | 161 | <el-table-column prop="text4" label="text4" width="380" /> |
| 107 | <el-table-column prop="text5" label="text5" width="380" /> | 162 | <el-table-column prop="text5" label="text5" width="380" /> |
| 108 | </el-table> | 163 | </el-table> |
| 109 | - <el-row justify="space-between"> | 164 | + <el-row class="table-footer" justify="space-between"> |
| 110 | <el-col :span="8"> | 165 | <el-col :span="8"> |
| 111 | <el-pagination | 166 | <el-pagination |
| 112 | v-model:current-page="currentPage4" | 167 | v-model:current-page="currentPage4" |
| ... | @@ -178,7 +233,7 @@ | ... | @@ -178,7 +233,7 @@ |
| 178 | <script setup> | 233 | <script setup> |
| 179 | import { ref, unref } from 'vue' | 234 | import { ref, unref } from 'vue' |
| 180 | import { useRoute, useRouter } from 'vue-router' | 235 | import { useRoute, useRouter } from 'vue-router' |
| 181 | -import { Plus, Download, Upload, Search } from '@element-plus/icons-vue' | 236 | +import { Plus, Download, Upload, Search, ArrowDown } from '@element-plus/icons-vue' |
| 182 | // import { ClickOutside as vClickOutside } from 'element-plus' | 237 | // import { ClickOutside as vClickOutside } from 'element-plus' |
| 183 | import { onClickOutside } from '@vueuse/core' | 238 | import { onClickOutside } from '@vueuse/core' |
| 184 | import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js' | 239 | import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js' |
| ... | @@ -197,6 +252,8 @@ const handleSelectionChange = (val) => { | ... | @@ -197,6 +252,8 @@ const handleSelectionChange = (val) => { |
| 197 | console.log("🚀 ~ file: index.vue:136 ~ handleSelectionChange ~ multipleSelection.value:", multipleSelection.value); | 252 | console.log("🚀 ~ file: index.vue:136 ~ handleSelectionChange ~ multipleSelection.value:", multipleSelection.value); |
| 198 | } | 253 | } |
| 199 | 254 | ||
| 255 | +const table_height = ref('780') | ||
| 256 | + | ||
| 200 | onMounted(() => { | 257 | onMounted(() => { |
| 201 | for (let index = 0; index < 50; index++) { | 258 | for (let index = 0; index < 50; index++) { |
| 202 | tableData.value.push({ | 259 | tableData.value.push({ |
| ... | @@ -211,7 +268,14 @@ onMounted(() => { | ... | @@ -211,7 +268,14 @@ onMounted(() => { |
| 211 | text5: 'No. 189, Grove St, Los Angeles', | 268 | text5: 'No. 189, Grove St, Los Angeles', |
| 212 | }) | 269 | }) |
| 213 | } | 270 | } |
| 214 | - | 271 | + // 表格高度 |
| 272 | + nextTick(() => { | ||
| 273 | + let height = $(window).height(); | ||
| 274 | + let header_height = $('.table-header').height(); | ||
| 275 | + let footer_height = $('.table-footer').height(); | ||
| 276 | + // 动态计算高度 | ||
| 277 | + table_height.value = height - header_height - footer_height - 70; | ||
| 278 | + }); | ||
| 215 | }); | 279 | }); |
| 216 | 280 | ||
| 217 | const currentPage4 = ref(4) | 281 | const currentPage4 = ref(4) |
| ... | @@ -225,11 +289,16 @@ const handleCurrentChange = (val) => { | ... | @@ -225,11 +289,16 @@ const handleCurrentChange = (val) => { |
| 225 | } | 289 | } |
| 226 | 290 | ||
| 227 | const handleCellClick = (row, column, cell, event) => { // 点击单元格 | 291 | const handleCellClick = (row, column, cell, event) => { // 点击单元格 |
| 228 | - // console.warn(row, column, cell, event); | 292 | + console.warn(row, column, cell, event); |
| 293 | + // TEST: 测试点击到姓名时不弹出抽屉 | ||
| 294 | + let flag = $(event.target).hasClass('target-name'); // 点击到了名字 | ||
| 295 | + if (!flag) { | ||
| 296 | + drawer.value = true; | ||
| 297 | + } | ||
| 229 | } | 298 | } |
| 230 | -const handleRowClick = (row, event, column) => { | 299 | +const handleRowClick = (row, column, event) => { |
| 231 | - console.warn(row, event, column); | 300 | + // console.warn(row, event, column); |
| 232 | - drawer.value = true; | 301 | + // drawer.value = true; |
| 233 | } | 302 | } |
| 234 | 303 | ||
| 235 | const form = ref({ | 304 | const form = ref({ |
| ... | @@ -259,6 +328,9 @@ const refresh = () => { | ... | @@ -259,6 +328,9 @@ const refresh = () => { |
| 259 | const drawer = ref(false); | 328 | const drawer = ref(false); |
| 260 | const iframe_src = ref('https://content-static.cctvnews.cctv.com/snow-book/index.html?item_id=16178737121463290737&channelId=1119&toc_style_id=feeds_default&share_to=wechat&track_id=cbcca7b0-6de2-4474-9a9f-96902fbaea50'); | 329 | const iframe_src = ref('https://content-static.cctvnews.cctv.com/snow-book/index.html?item_id=16178737121463290737&channelId=1119&toc_style_id=feeds_default&share_to=wechat&track_id=cbcca7b0-6de2-4474-9a9f-96902fbaea50'); |
| 261 | 330 | ||
| 331 | +const addItem = () => { | ||
| 332 | + drawer.value = true; | ||
| 333 | +} | ||
| 262 | 334 | ||
| 263 | watchEffect(() => { | 335 | watchEffect(() => { |
| 264 | if (drawer.value) { | 336 | if (drawer.value) { |
| ... | @@ -273,7 +345,9 @@ watchEffect(() => { | ... | @@ -273,7 +345,9 @@ watchEffect(() => { |
| 273 | $('#_iframe').height(height - header_height - tools_height); | 345 | $('#_iframe').height(height - header_height - tools_height); |
| 274 | }); | 346 | }); |
| 275 | } | 347 | } |
| 276 | -}) | 348 | +}); |
| 349 | + | ||
| 350 | +const sortRadio = ref('asc'); | ||
| 277 | </script> | 351 | </script> |
| 278 | 352 | ||
| 279 | <style lang="less"> | 353 | <style lang="less"> |
| ... | @@ -337,6 +411,17 @@ watchEffect(() => { | ... | @@ -337,6 +411,17 @@ watchEffect(() => { |
| 337 | opacity: 1; | 411 | opacity: 1; |
| 338 | } | 412 | } |
| 339 | 413 | ||
| 414 | + .target-name { | ||
| 415 | + &:hover { | ||
| 416 | + cursor: pointer; | ||
| 417 | + } | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + .table-header-row { | ||
| 421 | + } | ||
| 422 | + .el-table th.el-table__cell { | ||
| 423 | + background-color: #f6f7fa !important; | ||
| 424 | + } | ||
| 340 | } | 425 | } |
| 341 | 426 | ||
| 342 | .my_iframe { | 427 | .my_iframe { | ... | ... |
-
Please register or login to post a comment