| | |
| | | <!-- <span v-if="data?.title" class="text-base font-bold flex-center mb-5">{{ data?.title }}</span> --> |
| | | <div class="w-full flex-column"> |
| | | <div class="flex-0 flex"> |
| | | <ColFilter class="ml-auto" :columnList="colList" @change="colFilterChange" /> |
| | | <ColFilter class="ml-auto" :columnList="colList" @change="colFilterChange" /> |
| | | </div> |
| | | <div class="flex-auto" ref="containerRef" v-resize="resizeHandler"> |
| | | <el-table |
| | |
| | | :cell-style="tableCellStyle" |
| | | :header-cell-style="tableHeaderCellStyle" |
| | | :data="chunkTableData[pager.index - 1]" |
| | | @current-change="recordSelectChange" |
| | | rowClassName="cursor-pointer" |
| | | :spanMethod="objectSpanMethod" |
| | | class="w-full h-full" |
| | | highlightCurrentRow |
| | | cellClassName="text-sm" |
| | | headerCellClassName="text-sm" |
| | | > |
| | |
| | | <template v-for="item in colList" :key="item.prop"> |
| | | <el-table-column |
| | | v-if="item.isShow ?? true" |
| | | :type="item.type" |
| | | :label="item.label" |
| | | :width="item.width" |
| | | :sortable="item.sortable" |
| | |
| | | <template v-for="item in colList" :key="item.prop"> |
| | | <el-table-column |
| | | v-if="item.isShow ?? true" |
| | | :type="item.type" |
| | | :label="item.label" |
| | | :width="item.width" |
| | | :sortable="item.sortable" |
| | |
| | | layout="total,prev,pager,next,jumper" |
| | | :total="pager.total" |
| | | /> |
| | | |
| | | <InfoDetail class="text-base" v-model="infoDetailIsShow" :item="detailMapRow" :colList="colList" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import ColFilter from '/@/components/table/colFilter/ColFilter.vue'; |
| | | import { TableCol } from '/@/components/table/colFilter/types'; |
| | | import { debounce, getTextWidth } from '/@/utils/util'; |
| | | import InfoDetail from './infoDetail/InfoDetail.vue'; |
| | | const props = defineProps({ |
| | | data: { |
| | | type: Object as PropType<any>, |
| | |
| | | const [DefineColumns, ReuseColumns] = createReusableTemplate<{ |
| | | cols: any[]; |
| | | }>(); |
| | | |
| | | const colList = ref<TableCol[]>( |
| | | props.data.cols.map((item, index) => { |
| | | let isShow = true; |
| | | if(props.data.max_cols !=null){ |
| | | if (props.data.max_cols != null) { |
| | | isShow = index < props.data.max_cols; |
| | | } |
| | | return { |
| | | ...item, |
| | | width: 0, |
| | | label: item.title, |
| | | sortable: item.type === 'time', |
| | | prop: index + '', |
| | | isShow:isShow |
| | | |
| | | } as TableCol; |
| | | ...item, |
| | | width: 0, |
| | | label: item.title, |
| | | sortable: item.type === 'time', |
| | | prop: index + '', |
| | | isShow: isShow, |
| | | } as TableCol; |
| | | }) |
| | | ); |
| | | // æææ¾ç¤ºç prop |
| | |
| | | const containerRef = ref<HTMLDivElement>(null); |
| | | const tableRef = ref<TableInstance>(null); |
| | | const measureWidthOffset = 28; |
| | | const groupIndexList = []; |
| | | (props.data?.cols ?? []).map((item, index) => { |
| | | if (item.group) { |
| | | groupIndexList.push(index); |
| | | } |
| | | |
| | | const filterGroupIndexList = computed(() => { |
| | | const groupIndexList = []; |
| | | |
| | | (props.data?.cols ?? []).map((item, index) => { |
| | | // æ¯åç»ï¼ä¸å½åå¯è§ |
| | | if (item.group && visibleColProp.value.includes(index + '')) { |
| | | groupIndexList.push(index); |
| | | } |
| | | }); |
| | | |
| | | return groupIndexList; |
| | | }); |
| | | |
| | | const chunkTableData = ref([props.data?.values]); |
| | |
| | | * @param j å½åè®°å½æå¨è¡ä½ç½® |
| | | */ |
| | | const buildGroupData = (values, i = 0, j = 0) => { |
| | | const curGroupIndex = groupIndexList[i]; |
| | | const curGroupIndex = filterGroupIndexList.value[i]; |
| | | // ä¸å¯ä»¥åç»ï¼ç´æ¥ return; |
| | | if (curGroupIndex == undefined || values.length === 1) return values; |
| | | if (curGroupIndex == undefined || values.length === 1) { |
| | | return values; |
| | | } |
| | | |
| | | const groupData = _.groupBy(values, (item, index) => { |
| | | const groupValue = item[curGroupIndex]; |
| | |
| | | } |
| | | |
| | | if (props.data?.cols?.length > 0 && props.data?.values?.length > 0) { |
| | | cellRowSpanMap.clear(); |
| | | props.data.values = buildGroupData(props.data.values); |
| | | calcColWidth(width); |
| | | nextTick(() => { |
| | |
| | | const colFilterChange = () => { |
| | | // éæ°è®¡ç®å®½åº¦ |
| | | resizeEvent({ width: containerRef.value.clientWidth, height: containerRef.value.clientHeight }); |
| | | |
| | | }; |
| | | |
| | | const tableHeight = ref(0.7 * document.body.clientHeight); |
| | | |
| | | //#region ====================== ====================== |
| | | const infoDetailIsShow = ref(false); |
| | | const detailMapRow = ref(null); |
| | | const recordSelectChange = (row) => { |
| | | detailMapRow.value = row; |
| | | infoDetailIsShow.value = true; |
| | | }; |
| | | //#endregion |
| | | onMounted(() => { |
| | | resizeEvent({ |
| | | width: containerRef.value.clientWidth, |