vue3+element-plus動態與靜態表格數據渲染

一、表格組件:

<template>

? <el-table

? ? ref="myTable"

? ? :data="tableData"

? ? :header-cell-style="headerCellStyle"

? ? header-row-class-name="my-table-header"

? ? cell-class-name="my-td-cell"

? ? :row-style="rowStyle"

? ? :cell-style="cellStyle"

? ? :span-method="dynamic ? objectSpanMethod : handleSpanMethod"

? ? @sort-change="tableSort"

? ? @selection-change="handleSelectionChange"

? ? class="stock-table"

? ? border

? ? :max-height="height"

? ? row-key="securityID"

? ? :show-overflow-tooltip="dynamic || !showOverflowTooltip ? false : true"

? ? stripe

? >

? ? <slot name="selection"></slot>

? ? <el-table-column v-if="indexShow" label="序號" width="50" align="center">

? ? ? <template #default="scope">

? ? ? ? <span>{{ (currentPage - 1) * pageSize + scope.$index + 1 }}</span>

? ? ? </template>

? ? </el-table-column>

? ? <!-- 表頭渲染 -->

? ? <template v-for="(item, index) in tableColums" :key="index">

? ? ? <el-table-column

? ? ? ? v-if="!item.hidden"

? ? ? ? :fixed="item.fixed"

? ? ? ? :width="item.width"

? ? ? ? :min-width="item.minWidth || ''"

? ? ? ? :prop="item.prop"

? ? ? ? :sortable="item.sortable"

? ? ? ? header-align="center"

? ? ? ? :align="item.align || 'center'"

? ? ? ? :resizable="false"

? ? ? >

? ? ? ? <template #header>

? ? ? ? ? <div class="heard-text static-heard">

? ? ? ? ? ? <div class="heard-name" v-html="item.label"></div>

? ? ? ? ? </div>

? ? ? ? </template>

? ? ? ? <!-- 靜態表格表內容渲染 -->

? ? ? ? <!-- 使用 scoped slot 將列的內容交給父組件自定義 -->

? ? ? ? <template #default="scope">

? ? ? ? ? <slot :name="`column-${item.prop}`" :row="scope.row" :column="item">

? ? ? ? ? ? <!-- 處理監管處罰第一個表格鏈接跳轉問題 -->

? ? ? ? ? ? <el-link

? ? ? ? ? ? ? type="primary"

? ? ? ? ? ? ? :underline="false"

? ? ? ? ? ? ? @click="openLink(scope.row.link)"

? ? ? ? ? ? ? class="link-ellipsis"

? ? ? ? ? ? ? v-if="tableId === 'yearTable' && item.prop === 'title'"

? ? ? ? ? ? ? >{{ scope.row[item.prop] }}</el-link

? ? ? ? ? ? >

? ? ? ? ? ? <!-- 觸及ST指標的次數 懸浮查看年份 -->

? ? ? ? ? ? <div v-else-if="item.isST">

? ? ? ? ? ? ? <el-tooltip

? ? ? ? ? ? ? ? effect="dark"

? ? ? ? ? ? ? ? :content="[...new Set(scope.row[item.prop])].join('、')"

? ? ? ? ? ? ? ? placement="top"

? ? ? ? ? ? ? ? v-if="

? ? ? ? ? ? ? ? ? scope.row[item.prop] &&

? ? ? ? ? ? ? ? ? Array.isArray(scope.row[item.prop]) &&

? ? ? ? ? ? ? ? ? scope.row[item.prop].length > 0

? ? ? ? ? ? ? ? "

? ? ? ? ? ? ? >

? ? ? ? ? ? ? ? <span class="red">{{ scope.row[item.prop].length }}</span>

? ? ? ? ? ? ? </el-tooltip>

? ? ? ? ? ? ? <span v-else>{{

? ? ? ? ? ? ? ? Array.isArray(scope.row[item.prop])

? ? ? ? ? ? ? ? ? ? scope.row[item.prop].length

? ? ? ? ? ? ? ? ? : scope.row[item.prop]

? ? ? ? ? ? ? }}</span>

? ? ? ? ? ? </div>

? ? ? ? ? ? <!-- 觸及ST指標的次數為拼接的字段 懸浮查看年份 -->

? ? ? ? ? ? <div

? ? ? ? ? ? ? v-else-if="item.isJointST"

? ? ? ? ? ? ? :style="{

? ? ? ? ? ? ? ? textAlign:

? ? ? ? ? ? ? ? ? scope.row[item.prop] && scope.row[item.prop].length === 0

? ? ? ? ? ? ? ? ? ? ? 'center'

? ? ? ? ? ? ? ? ? ? : item.align

? ? ? ? ? ? ? }"

? ? ? ? ? ? >

? ? ? ? ? ? ? <template

? ? ? ? ? ? ? ? v-if="

? ? ? ? ? ? ? ? ? scope.row[item.prop] &&

? ? ? ? ? ? ? ? ? scope.row[item.prop].length > 0 &&

? ? ? ? ? ? ? ? ? !item.isNumber

? ? ? ? ? ? ? ? "

? ? ? ? ? ? ? >

? ? ? ? ? ? ? ? <span v-for="(i, idx) in scope.row[item.prop]" :key="idx">

? ? ? ? ? ? ? ? ? <!-- 轄區募投異常變更項目字段根據結構特殊處理 -->

? ? ? ? ? ? ? ? ? <span v-if="item.noShowYear"

? ? ? ? ? ? ? ? ? ? ><span class="dot">·</span>{{ i.name

? ? ? ? ? ? ? ? ? ? }}<span v-if="idx < scope.row[item.prop].length - 1"

? ? ? ? ? ? ? ? ? ? ? ><br /></span

? ? ? ? ? ? ? ? ? ></span>

? ? ? ? ? ? ? ? ? <span v-else>

? ? ? ? ? ? ? ? ? ? <span

? ? ? ? ? ? ? ? ? ? ? >{{ i.name }}

? ? ? ? ? ? ? ? ? ? ? <el-tooltip

? ? ? ? ? ? ? ? ? ? ? ? effect="dark"

? ? ? ? ? ? ? ? ? ? ? ? :content="i.years"

? ? ? ? ? ? ? ? ? ? ? ? placement="top"

? ? ? ? ? ? ? ? ? ? ? >

? ? ? ? ? ? ? ? ? ? ? ? <span class="red">{{ i.count }}</span>

? ? ? ? ? ? ? ? ? ? ? </el-tooltip></span

? ? ? ? ? ? ? ? ? ? >

? ? ? ? ? ? ? ? ? ? <!-- 只有當不是最后一個元素時才顯示頓號 -->

? ? ? ? ? ? ? ? ? ? <span v-if="idx < scope.row[item.prop].length - 1">、</span>

? ? ? ? ? ? ? ? ? </span>

? ? ? ? ? ? ? ? </span>

? ? ? ? ? ? ? </template>

? ? ? ? ? ? ? <!-- 如果是延期回復次數根據后端返回結構單獨處理 -->

? ? ? ? ? ? ? <template v-else-if="item.isNumber">

? ? ? ? ? ? ? ? <el-tooltip

? ? ? ? ? ? ? ? ? effect="dark"

? ? ? ? ? ? ? ? ? :content="scope.row[item.prop] && scope.row[item.prop].years"

? ? ? ? ? ? ? ? ? placement="top"

? ? ? ? ? ? ? ? ? v-if="

? ? ? ? ? ? ? ? ? ? scope.row[item.prop] && scope.row[item.prop].count !== 0

? ? ? ? ? ? ? ? ? "

? ? ? ? ? ? ? ? >

? ? ? ? ? ? ? ? ? <span class="red">{{ scope.row[item.prop].count }}</span>

? ? ? ? ? ? ? ? </el-tooltip>

? ? ? ? ? ? ? ? <span v-else>{{

? ? ? ? ? ? ? ? ? scope.row[item.prop] && scope.row[item.prop].count

? ? ? ? ? ? ? ? }}</span>

? ? ? ? ? ? ? </template>

? ? ? ? ? ? ? <template v-else>

? ? ? ? ? ? ? ? <span>/</span>

? ? ? ? ? ? ? </template>

? ? ? ? ? ? </div>

? ? ? ? ? ? <!-- 默認內容(文本為是,則字體顏色標紅) -->

? ? ? ? ? ? <div

? ? ? ? ? ? ? :style="{

? ? ? ? ? ? ? ? color:

? ? ? ? ? ? ? ? ? scope.row[item.prop] === '是'

? ? ? ? ? ? ? ? ? ? ? '#ff0000'

? ? ? ? ? ? ? ? ? ? : scope.row[item.prop] !== '/' &&

? ? ? ? ? ? ? ? ? ? ? scope.row.announceUrl !== null

? ? ? ? ? ? ? ? ? ? ? item.color

? ? ? ? ? ? ? ? ? ? : '',

? ? ? ? ? ? ? ? cursor:

? ? ? ? ? ? ? ? ? scope.row[item.prop] !== '/' && scope.row.announceUrl !== null

? ? ? ? ? ? ? ? ? ? ? item.cursor

? ? ? ? ? ? ? ? ? ? : '',

? ? ? ? ? ? ? ? textAlign: scope.row[item.prop] === '/' ? 'center' : item.align

? ? ? ? ? ? ? }"

? ? ? ? ? ? ? @click="

? ? ? ? ? ? ? ? item.cursor && scope.row.announceUrl !== null

? ? ? ? ? ? ? ? ? ? toPage(scope.row)

? ? ? ? ? ? ? ? ? : ''

? ? ? ? ? ? ? "

? ? ? ? ? ? ? :class="tableId === 'warnDetail2' ? '' : 'table-content'"

? ? ? ? ? ? ? v-else

? ? ? ? ? ? >

? ? ? ? ? ? ? {{

? ? ? ? ? ? ? ? (item.prop === 'declareDate' &&

? ? ? ? ? ? ? ? ? scope.row[item.prop] === null) ||

? ? ? ? ? ? ? ? (item.prop === 'guaranteeOverdueNum' &&

? ? ? ? ? ? ? ? ? scope.row[item.prop] === null)

? ? ? ? ? ? ? ? ? ? '/'

? ? ? ? ? ? ? ? ? : item.prop === 'cancelDate' && scope.row[item.prop] === null

? ? ? ? ? ? ? ? ? ? '未撤銷'

? ? ? ? ? ? ? ? ? : scope.row[item.prop]

? ? ? ? ? ? ? }}

? ? ? ? ? ? </div>

? ? ? ? ? </slot>

? ? ? ? </template>

? ? ? </el-table-column>

? ? </template>

? ? <!-- 動態表格動態表頭表內容渲染 -->

? ? <template v-if="dynamic">

? ? ? <el-table-column

? ? ? ? v-for="(item, index) in tableData && tableData[0]?.data"

? ? ? ? :key="index"

? ? ? ? :min-width="200"

? ? ? ? :prop="item.sortColumnCode || ''"

? ? ? ? :sortable="item.sortColumnCode ? 'custom' : false"

? ? ? ? header-align="center"

? ? ? >

? ? ? ? <template #header>

? ? ? ? ? <div class="heard-text">

? ? ? ? ? ? <div class="heard-name">{{ item.dataName }}</div>

? ? ? ? ? ? <div class="change-text" v-if="item.headFlag === 1">更</div>

? ? ? ? ? </div>

? ? ? ? </template>

? ? ? ? <template #default="scope">

? ? ? ? ? <!-- 默認內容(valFlag后端返回1的字段,則字體顏色標紅) -->

? ? ? ? ? <div

? ? ? ? ? ? :style="{

? ? ? ? ? ? ? color:

? ? ? ? ? ? ? ? scope.row.data &&

? ? ? ? ? ? ? ? scope.row.data[index] &&

? ? ? ? ? ? ? ? scope.row.data[index].valFlag === 1

? ? ? ? ? ? ? ? ? ? '#FF0000'

? ? ? ? ? ? ? ? ? : '',

? ? ? ? ? ? ? textAlign:

? ? ? ? ? ? ? ? scope.row.data &&

? ? ? ? ? ? ? ? scope.row.data[index] &&

? ? ? ? ? ? ? ? scope.row.data[index].textAlign === 'left' &&

? ? ? ? ? ? ? ? scope.row.data[index].dataVal !== '/'

? ? ? ? ? ? ? ? ? ? 'left'

? ? ? ? ? ? ? ? ? : 'center'

? ? ? ? ? ? }"

? ? ? ? ? >

? ? ? ? ? ? {{

? ? ? ? ? ? ? scope.row.data &&

? ? ? ? ? ? ? scope.row.data[index] &&

? ? ? ? ? ? ? scope.row.data[index].dataVal

? ? ? ? ? ? }}

? ? ? ? ? </div></template

? ? ? ? >

? ? ? </el-table-column>

? ? </template>

? </el-table>

? <!-- ?分頁組件 ?-->

? <paging

? ? v-if="paginationShow"

? ? :currentPage="currentPage"

? ? :pageSize="pageSize"

? ? layout="total, sizes, prev, pager, next, jumper"

? ? :pageSizes="[10, 20, 50, 100]"

? ? :total="total"

? ? :background="true"

? ? @handleCurrentChange="changeCurrentPage"

? ? @handleSizeChange="changePageSize"

? />

</template>

<script setup lang="ts">

import Paging from '@/views/stock-index/components/paging.vue'

import { ElMessage } from 'element-plus'

import { exportFileUrl } from '@/pages/monitor/monitorApi/stockMonitor'

import { useReportStore } from '@/store/modules/report'

// 定義合并規則的類型

interface MergeRule {

? rowIndex: number // 行索引

? columnIndex: number // 列索引

? rowspan: number // 合并的行數

? colspan: number // 合并的列數

}

const props = defineProps({

? showOverflowTooltip: {

? ? // 表格是否展示浮框

? ? type: Boolean,

? ? default: true

? },

? dynamic: {

? ? // 是否動態表格

? ? type: Boolean,

? ? default: false

? },

? paginationShow: {

? ? // 是否顯示分頁

? ? type: Boolean,

? ? default: false

? },

? currentPage: {

? ? // 當前頁

? ? type: Number,

? ? default: 1

? },

? pageSize: {

? ? // 一頁展示條數

? ? type: Number,

? ? default: 10

? },

? total: {

? ? // 總條數

? ? type: Number,

? ? default: 0

? },

? height: {

? ? type: String,

? ? default: '400'

? },

? rowHeight: {

? ? type: Number,

? ? default: 40 // 默認行高

? },

? // 靜態表格合并規則

? mergeRules: {

? ? type: Array as any,

? ? default: () => []

? },

? // 動態表格合并字段

? mergeKey: {

? ? type: String,

? ? default: ''

? },

? // 表格id

? tableId: {

? ? type: String,

? ? default: ''

? },

? // 表頭數據

? tableColums: {

? ? type: Array as () => any[],

? ? default: () => []

? },

? // 表內容數據

? tableData: {

? ? type: Array as () => any[],

? ? default: () => []

? },

? //是否顯示列表序號

? indexShow: {

? ? type: Boolean,

? ? default: false

? }

})

const emit = defineEmits([

? 'tableSort',

? 'handleSelectionChange',

? 'changeCurrentPage',

? 'changePageSize'

])

const myTable = ref()

// 設置表頭樣式

const headerCellStyle = () => {

? return {

? ? height: '34px',

? ? background: '#F9FBFD',

? ? color: '#333333',

? ? fontSize: '14px',

? ? borderRight: '1px solid #ebeef8',

? ? padding: '1px 0',

? ? fontWeight: 'normal'

? }

}

// 動態設置行高

const rowStyle = () => {

? return {

? ? height: `${props.rowHeight}px`,

? ? lineHeight: `${props.rowHeight}px`

? }

}

// 設置單元格樣式

const cellStyle = ({

? row,

? column,

? rowIndex,

? columnIndex

}: {

? row: any

? column: any

? rowIndex: number

? columnIndex: number

}) => {

? // 設置監管處罰科目(行業排名)單元格為/時居中顯示,否則居左顯示

? if (

? ? column.property === 'subject' &&

? ? row.subject === '/' &&

? ? columnIndex === 1

? ) {

? ? return {

? ? ? fontSize: '14px',

? ? ? color: '#666666',

? ? ? textAlign: 'center'

? ? }

? } else {

? ? return {

? ? ? fontSize: '14px',

? ? ? color: '#666666'

? ? }

? }

}

//監聽全局參數搜索

watch(

? () => useReportStore().topSelectObj,

? (newVal) => {

? ? myTable.value.clearSort() // 清除表格排序

? }

)

const openedWindows = new Map()

// 公告跳轉

const toPage = (row: any) => {

? if (row.announceUrl && row.announceUrl !== null) {

? ? exportFileUrl(row.announceUrl).then((res: any) => {

? ? ? if (res.code === 200) {

? ? ? ? // 檢查是否已經有一個窗口打開了該鏈接

? ? ? ? if (openedWindows.has(res.data)) {

? ? ? ? ? const windowRef = openedWindows.get(res.data)

? ? ? ? ? if (!windowRef.closed) {

? ? ? ? ? ? windowRef.focus() // 聚焦到已打開的窗口

? ? ? ? ? ? return

? ? ? ? ? }

? ? ? ? }

? ? ? ? // 如果沒有打開的窗口,則打開一個新窗口

? ? ? ? const newWindow = window.open(res.data, '_blank')

? ? ? ? openedWindows.set(res.data, newWindow) // 存儲窗口引用

? ? ? } else {

? ? ? ? ElMessage({

? ? ? ? ? type: 'error',

? ? ? ? ? message: res.message

? ? ? ? })

? ? ? }

? ? })

? }

}

// 監管處罰鏈接跳轉

const openLink = (url: any) => {

? if (url === '') return // 如果鏈接為空,直接返回

? // 如果沒有打開的窗口,則打開一個新窗口

? const newWindow = window.open(url, '_blank', 'noreferrer,noopener')

? openedWindows.set(url, newWindow) // 存儲窗口引用

}

// 動態表格合并規則

const objectSpanMethod = ({

? row,

? column,

? rowIndex,

? columnIndex

}: {

? row: any

? column: any

? rowIndex: number

? columnIndex: number

}) => {

? if (columnIndex !== 0) {

? ? return { rowspan: 1, colspan: 1 }

? }

? if (!props.mergeKey) {

? ? return { rowspan: 1, colspan: 1 }

? }

? if (

? ? rowIndex === 0 ||

? ? row[props.mergeKey] !== props.tableData[rowIndex - 1][props.mergeKey]

? ) {

? ? let rowspan = 1

? ? for (let i = rowIndex + 1; i < props.tableData.length; i++) {

? ? ? if (props.tableData[i][props.mergeKey] === row[props.mergeKey]) {

? ? ? ? rowspan++

? ? ? } else {

? ? ? ? break

? ? ? }

? ? }

? ? return { rowspan, colspan: 1 }

? } else {

? ? return { rowspan: 0, colspan: 0 }

? }

}

// 定義靜態表格合并參數字段

type TableId = 'warnDetail' | 'warnDetail1' | 'warnDetail2' | 'warnDetail3' // 定義可能的 tableId 類型

type MergeConfig = Record<TableId, Record<number, string>> // 定義 mergeConfig 的類型

const mergeConfig: MergeConfig = {

? warnDetail: { 0: 'year' },

? warnDetail1: { 0: 'name', 1: 'declareDate' },

? warnDetail2: {

? ? 0: 'correctionAccouPeri',

? ? 1: 'iserror',

? ? 2: 'declareDate',

? ? 3: 'announce'

? },

? warnDetail3: {

? ? 0: 'declareDate'

? }

}

// 靜態表格合并規則

const handleSpanMethod = ({

? row,

? column,

? rowIndex,

? columnIndex

}: {

? row: any

? column: any

? rowIndex: number

? columnIndex: number

}) => {

? const tableId = props.tableId as TableId // 使用類型斷言確保 tableId 是 TableId 類型

? const config = mergeConfig[tableId] // 現在 TypeScript 知道 config 的類型

? if (config && config[columnIndex]) {

? ? return mergeRows({ row, rowIndex, key: config[columnIndex] })

? } else {

? ? return handleMergeRules({ rowIndex, columnIndex })

? }

}

// 靜態表格統一合并方法

const mergeRows = ({

? row,

? rowIndex,

? key

}: {

? row: any

? rowIndex: number

? key: string

}) => {

? if (rowIndex === 0 || row[key] !== props.tableData[rowIndex - 1][key]) {

? ? let rowspan = 1

? ? for (let i = rowIndex + 1; i < props.tableData.length; i++) {

? ? ? if (props.tableData[i][key] === row[key]) {

? ? ? ? rowspan++

? ? ? } else {

? ? ? ? break

? ? ? }

? ? }

? ? return { rowspan, colspan: 1 }

? } else {

? ? return { rowspan: 0, colspan: 0 }

? }

}

// 外部傳進來的表格合并方法

const handleMergeRules = ({

? rowIndex,

? columnIndex

}: {

? rowIndex: number

? columnIndex: number

}) => {

? const rule = props.mergeRules.find(

? ? (rule: MergeRule) =>

? ? ? rule.rowIndex === rowIndex && rule.columnIndex === columnIndex

? )

? if (rule) {

? ? return { rowspan: rule.rowspan, colspan: rule.colspan }

? }

? for (const r of props.mergeRules) {

? ? if (

? ? ? rowIndex > r.rowIndex &&

? ? ? rowIndex < r.rowIndex + r.rowspan &&

? ? ? columnIndex >= r.columnIndex &&

? ? ? columnIndex < r.columnIndex + r.colspan

? ? ) {

? ? ? return { rowspan: 0, colspan: 0 }

? ? }

? }

? return { rowspan: 1, colspan: 1 }

}

// 表格排序

const tableSort = (dataObj: any) => {

? const col: any = props.tableColums?.filter((v: any) => {

? ? return v.prop === dataObj.prop

? })[0]

? let prop = ''

? let order = dataObj.order

? if (col) {

? ? prop = col.prop

? } else {

? ? prop = dataObj.prop

? }

? // emit('tableSort', [col.prop, dataObj.order])

? emit('tableSort', [order ? prop : '', order])

}

// 表格多選

const handleSelectionChange = (selection: any) => {

? emit('handleSelectionChange', selection)

}

// 點擊改變當前頁重新渲染表格數據

const changeCurrentPage = (current: number) => {

? emit('changeCurrentPage', current)

}

//size改變

const changePageSize = (size: number) => {

? emit('changePageSize', size)

}

//清空選中

const clearSelection = () => {

? myTable.value.clearSelection()

}

const clearTableSort = () => {

? myTable.value && myTable.value.clearSort()

}

defineExpose({

? // 暴露子組件方法給父組件調用

? clearSelection,

? clearTableSort

})

</script>

<style lang="less" scoped>

.dot {

? font-size: 40px;

? margin-right: 5px;

? vertical-align: middle;

}

.link-ellipsis {

? &:hover {

? ? color: #3a5bb7;

? }

}

.red {

? color: @text-red;

}

.table-content {

? white-space: nowrap; /* 強制文本在一行顯示 */

? overflow: hidden; /* 隱藏超出容器的內容 */

? text-overflow: ellipsis; /* 超出部分顯示省略號 */

}

:deep(.my-table-header .cell) {

? font-size: 13px;

? padding: 6px 4px;

? font-weight: 600;

}

:deep(.my-selection .cell) {

? display: flex;

? justify-content: center;

? align-items: center;

}

.heard-text {

? // display: flex;

? // justify-content: center;

? display: inline-block;

? vertical-align: middle;

? &.static-heard {

? ? max-width: calc(100% - 15px);

? }

? .heard-name {

? ? display: inline-block;

? }

? .change-text {

? ? width: 14px;

? ? height: 14px;

? ? background: #fbfdfe;

? ? border-radius: 2px;

? ? border: 1px solid #eb9c35;

? ? font-size: 12px;

? ? color: #eb9c35;

? ? // display: flex;

? ? // align-items: center;

? ? // justify-content: center;

? ? display: inline-block;

? ? line-height: 14px;

? ? text-align: center;

? ? position: relative;

? ? top: -1px;

? ? margin-left: 4px;

? ? // margin-top: 2px;

? }

? & + :deep(.caret-wrapper) {

? ? top: 1px;

? }

}

</style>

二、使用表格組件:

<template>

<!-- 靜態表格使用 -->

? ? ? ? <div class="table-box">

? ? ? ? ? <TableList

? ? ? ? ? ? :table-colums="colums"

? ? ? ? ? ? :table-data="requestParams.tableData"

? ? ? ? ? ? pagination-show

? ? ? ? ? ? index-show

? ? ? ? ? ? :show-overflow-tooltip="false"

? ? ? ? ? ? :page-size="requestParams.limit"

? ? ? ? ? ? :current-page="requestParams.page"

? ? ? ? ? ? :total="requestParams.total"

? ? ? ? ? ? @change-page-size="($event) => changePageSize($event)"

? ? ? ? ? ? @change-current-page="($event) => changeCurrentPage($event)"

? ? ? ? ? ? @table-sort="($event) => tableDataSort($event)"

? ? ? ? ? ? height="450"

? ? ? ? ? >

? ? ? ? ? ? <template v-slot:column-symbol="{ row }">

? ? ? ? ? ? ? <div class="name-symbol">

? ? ? ? ? ? ? ? <p>{{ row.shortName }}</p>

? ? ? ? ? ? ? ? <p>({{ row.symbol }})</p>

? ? ? ? ? ? ? </div>

? ? ? ? ? ? </template>

? ? ? ? ? </TableList>

<!-- 動態表格使用(mergeKey為表格合并字段) -->

????????<TableList

? ? ? ? ? :table-colums="colums"

? ? ? ? ? :table-data="tableData"

? ? ? ? ? dynamic

? ? ? ? ? height="450"

? ? ? ? ? mergeKey="indicatorType"

? ? ? ? ></TableList>

? ? ? ? </div>

</template>

<script setup lang="ts">

import { ElMessage } from 'element-plus'

import TableList from './TableList.vue'

import { queryOtherUnitsData } from '@/pages/monitor/monitorApi/jurisdiction/index'

const requestParams = ref({

? page: 1,

? limit: 10,

? total: 0,

? order: '',

? sort: '',

? abnormalCount: 0

? tableData: [], // 表格數據

? loading: false // 加載狀態

})

const colums = ref([

? {

? ? prop: 'symbol',

? ? label: '公司(代碼)',

? ? sortable: true,

? ? width: '120'

? },

? {

? ? prop: 'violationTypeList',

? ? label: '違規類型',

? ? isJointST: true,

? ? align: 'left'

? },

? {

? ? prop: 'supervisorList',

? ? label: '處罰單位',

? ? isJointST: true,

? ? align: 'left'

? }

])

//排序點擊

const tableDataSort = (arr: any) => {

? requestParams.value.page = 1

? requestParams.value.sort = arr[0]

? requestParams.value.order = arr[1]

? getOtherUnitsData()

}

//頁碼更改

const changePageSize = (val: number) => {

? requestParams.value.limit = val

? getOtherUnitsData()

}

//分頁

const changeCurrentPage = (val: number) => {

? requestParams.value.page = val

? getOtherUnitsData()

}

// 查詢交易所所有表格數據

const getOtherUnitsData = () => {

? requestParams.value.loading = true

? requestParams.value.tableData = []

? const params = {

? ? limit: requestParams.value.limit,

? ? page: requestParams.value.page,

? ? sort: requestParams.value.sort,

? ? order: requestParams.value.order

? }

? queryOtherUnitsData(params).then((res: any) => {

? ? if (res.code === 200) {

? ? ? requestParams.value.tableData = res.data.data

? ? ? requestParams.value.total = res.data.total

? ? } else {

? ? ? ElMessage({

? ? ? ? type: 'error',

? ? ? ? message: res.message

? ? ? })

? ? }

? ? requestParams.value.loading = false

? })

}

onMounted(() => {

? getOtherUnitsData()

})

</script>

<style scoped lang="less">

.item {

? border: 1px solid #ebeef8;

? border-top: none;

? .title {

? ? display: flex;

? ? align-items: center;

? ? padding-left: 26px;

? ? height: 34px;

? ? background: #f4f7fc;

? ? border: 1px solid #ebeef8;

? ? border-left: none;

? ? border-right: none;

? ? font-weight: bold;

? ? font-size: 14px;

? ? color: #333333;

? ? position: relative;

? ? &::before {

? ? ? content: '';

? ? ? position: absolute;

? ? ? left: 15px;

? ? ? top: 50%;

? ? ? margin-top: -5px;

? ? ? width: 4px;

? ? ? height: 10px;

? ? ? background: #3a5bb7;

? ? ? border-radius: 0px 2px 2px 0px;

? ? }

? ? .more {

? ? ? margin-left: auto;

? ? ? margin-right: 15px;

? ? ? font-size: 12px;

? ? ? color: #666666;

? ? ? font-weight: normal !important;

? ? ? .times {

? ? ? ? color: @text-red;

? ? ? }

? ? }

? }

? .table-box {

? ? padding: 15px;

? ? .name-symbol {

? ? ? color: @text-blue;

? ? ? cursor: pointer;

? ? }

? }

}

</style>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/74992.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/74992.shtml
英文地址,請注明出處:http://en.pswp.cn/web/74992.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Kafka 中的生產者分區策略

Kafka 中的 生產者分區策略 是決定消息如何分配到不同分區的機制。這個策略對 Kafka 的性能、負載均衡、消息順序性等有重要影響。了解它對于高效地使用 Kafka 進行消息生產和消費至關重要。 讓我們一起來看 Kafka 中 生產者的分區策略&#xff0c;它如何工作&#xff0c;以及…

《從零搭建Vue3項目實戰》(AI輔助搭建Vue3+ElemntPlus后臺管理項目)零基礎入門系列第二篇:項目創建和初始化

&#x1f91f;致敬讀者 &#x1f7e9;感謝閱讀&#x1f7e6;笑口常開&#x1f7ea;生日快樂?早點睡覺 &#x1f4d8;博主相關 &#x1f7e7;博主信息&#x1f7e8;博客首頁&#x1f7eb;專欄推薦&#x1f7e5;活動信息 文章目錄 《從零搭建Vue3項目實戰》&#xff08;AI輔助…

全國產FMC子卡-16bit 8通道2.4G

國產化FMC DA子卡&#xff0c;16bit 8通道2.4GS/s 全國產FMC子卡是一款高分辨率、高采樣率的全國產多通道標準雙寬DAC FMC子板。其接口電氣和結構設計均依據FMC標準(ANSI/VITA 57.1)&#xff0c;通過兩個高密度FMC連接器&#xff08;HPC&#xff09;連接至FPGA載板。它提供8路A…

linux-添加開機自啟動指定腳本

一、systemd 服務&#xff08;主流方法&#xff09; 適用于使用systemd的現代發行版&#xff08;Ubuntu 16.04/CentOS 7&#xff09; 創建服務文件 sudo nano /etc/systemd/system/your_script.service寫入服務配置&#xff08;示例&#xff09;&#xff1a; [Unit] Descri…

Spring MVC 返回 JSON 視圖的方式及對比(6種)

Spring MVC 返回 JSON 視圖的方式及對比&#xff08;新增 MappingJackson2JsonView&#xff09; 1. 方式一&#xff1a;ResponseBody 注解 作用&#xff1a;直接返回對象&#xff0c;由消息轉換器&#xff08;如 Jackson&#xff09;序列化為 JSON。 適用場景&#xff1a;簡單…

瑞芯微RK3568嵌入式AI項目實戰:智能家居項目(二)

RK3568智能家居項目實戰指南&#xff1a;從入門到精通的完整制作流程 瑞芯微RK3568作為一款高性能嵌入式處理器&#xff0c;憑借其四核Cortex-A55架構、1T算力NPU和豐富的外設接口&#xff0c;成為智能家居項目開發的理想平臺。下面我將推薦幾個典型的RK3568智能家居項目&…

GStreamer開發筆記(一):GStreamer介紹,在windows平臺部署安裝,打開usb攝像頭對比測試

若該文為原創文章&#xff0c;轉載請注明原文出處 本文章博客地址&#xff1a;https://blog.csdn.net/qq21497936/article/details/147049923 長沙紅胖子Qt&#xff08;長沙創微智科&#xff09;博文大全&#xff1a;開發技術集合&#xff08;包含Qt實用技術、樹莓派、三維、O…

Spring Boot 3.4.3 和 Spring Security 6.4.2 實現基于內存和 MySQL 的用戶認證

在 Web 應用開發中&#xff0c;用戶認證是保障系統安全的基礎需求。Spring Boot 3.4.3 結合 Spring Security 6.4.2 提供了強大的安全框架支持&#xff0c;可以輕松實現基于內存或數據庫的用戶認證功能。本文將詳細介紹如何在 Spring Boot 3.4.3 中集成 Spring Security 6.4.2&…

HOW - Axios 攔截器特性

目錄 Axios 介紹攔截器特性1. 統一添加 Token&#xff08;請求攔截器&#xff09;2. 處理 401 未授權&#xff08;響應攔截器&#xff09;3. 統一處理錯誤信息&#xff08;響應攔截器&#xff09;4. 請求 Loading 狀態管理5. 自動重試請求&#xff08;如 429 過載&#xff09;6…

JVM核心機制:類加載×字節碼引擎×垃圾回收機制

&#x1f680;前言 “為什么你的Spring應用啟動慢&#xff1f;為什么GC總是突然卡頓&#xff1f;答案藏在JVM的核心機制里&#xff01; 本文將用全流程圖解字節碼案例&#xff0c;帶你穿透三大核心機制&#xff1a; 類加載&#xff1a;雙親委派如何防止惡意代碼入侵&#xff…

coze生成流程圖和思維導圖工作流

需求&#xff1a;通過coze平臺實現生成流程圖和思維導圖&#xff0c;要求支持文檔上傳 最終工作流如下&#xff1a; 入參&#xff1a; 整合用戶需求文件內容的工作流&#xff1a;https://blog.csdn.net/YXWik/article/details/147040071 選擇器分發&#xff0c;不同的類型走…

網絡安全應急響應-文件痕跡排查

在Windows系統的網絡安全應急響應中&#xff0c;文件痕跡排查是識別攻擊行為的關鍵步驟。以下是針對敏感目錄的詳細排查指南及擴展建議&#xff1a; 1. 臨時目錄排查&#xff08;Temp/Tmp&#xff09; 路徑示例&#xff1a; C:\Windows\TempC:\Users\<用戶名>\AppData\L…

SpringBoot集成Redis 靈活使用 TypedTuple 和 DefaultTypedTuple 實現 Redis ZSet 的復雜操作

以下是 Spring Boot 集成 Redis 中 TypedTuple 和 DefaultTypedTuple 的詳細使用說明&#xff0c;包含代碼示例和場景說明&#xff1a; 1. 什么是 TypedTuple 和 DefaultTypedTuple&#xff1f; TypedTuple<T> 接口&#xff1a; 定義了 Redis 中有序集合&#xff08;ZSet…

遞歸實現組合型枚舉(DFS)

從 1~n 這 n 個整數中隨機選出 m 個&#xff0c;輸出所有可能的選擇方案。 輸入格式 兩個整數 n,m,在同一行用空格隔開。 輸出格式 按照從小到大的順序輸出所有方案&#xff0c;每行 1 個。 首先&#xff0c;同一行內的數升序排列&#xff0c;相鄰兩個數用一個空格隔開。…

CentOS 7 鏡像源失效解決方案(2025年)

執行 yum update 報錯&#xff1a; yum install -y yum-utils \ > device-mapper-persistent-data \ > lvm2 --skip-broken 已加載插件&#xff1a;fastestmirror, langpacks Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirror…

vue3 腳手架初始化項目生成文件的介紹

文章目錄 一、介紹二、舉例說明1.src/http/index.js2.src/router/index.js3.src/router/routes.js4.src/stores/index.js5.src/App.vue6.src/main.js7.babel.config.js8.jsconfig.json9.vue.config.js10. .env11.src/mock/index.js12.src/mock/mock-i18n.js13.src/locales/en.j…

ubuntu 20.04 編譯和運行A-LOAM

1.搭建文件目錄和clone代碼 mkdir -p A-LOAM/src cd A-LOAM/src git clone https://github.com/HKUST-Aerial-Robotics/A-LOAM cd .. 2.修改代碼文件 2.1 由于PCL版本1.10&#xff0c;將CMakeLists.txt中的C標準改為14&#xff1a; set(CMAKE_CXX_FLAGS "-stdc14"…

【教程】MacBook 安裝 VSCode 并連接遠程服務器

目錄 需求步驟問題處理 需求 在 Mac 上安裝 VSCode&#xff0c;并連接跳板機和服務器。 步驟 Step1&#xff1a;從VSCode官網&#xff08;https://code.visualstudio.com/download&#xff09;下載安裝包&#xff1a; Step2&#xff1a;下載完成之后&#xff0c;直接雙擊就能…

LabVIEW 長期項目開發

LabVIEW 憑借其圖形化編程的獨特優勢&#xff0c;在工業自動化、測試測量等領域得到了廣泛應用。對于長期運行、持續迭代的 LabVIEW 項目而言&#xff0c;其開發過程涵蓋架構設計、代碼管理、性能優化等多個關鍵環節&#xff0c;每個環節都對項目的成功起著至關重要的作用。下面…

用matlab搭建一個簡單的圖像分類網絡

文章目錄 1、數據集準備2、網絡搭建3、訓練網絡4、測試神經網絡5、進行預測6、完整代碼 1、數據集準備 首先準備一個包含十個數字文件夾的DigitsData&#xff0c;每個數字文件夾里包含1000張對應這個數字的圖片&#xff0c;圖片的尺寸都是 28281 像素的&#xff0c;如下圖所示…