123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <template>
- <div class="bg-white p-2 table_box" >
-
- <el-table :data="tableData" border class="mt-4" :header-cell-style="headerStyle" stripe :row-class-name="tableRowClassName" style="height: 90%;">
- <el-table-column v-for="item in tableColData" align="center"
- :prop="item.id"
- :label="item.name"
- :key="item.name"
-
- >
- <el-table-column v-for="item1 in item.children" align="center"
- :prop="item1.id"
- :label="item1.name"
- :key="item1.name">
-
- </el-table-column>
- </el-table-column>
- </el-table>
-
- </div>
- </template>
- <script setup>
- import {ref, watch,nextTick} from "vue";
- const props = defineProps({
- cur: {
- type: [String,Number],
- default: ''
- },
- })
- const tabsKey = ref(props.cur)
- //监听
- watch(() => [
- props.cur,
- ], ([key]) => {
- tabsKey.value = key
- console.log(key)
- })
- const tableData=ref([
- {time:'一月',beginremain:'2000'},
- {time:'二月',market:'2000',precost:1000,realcost:2000},
- {time:'三月',beginremain:'2000'},
- {time:'四月',beginremain:'2000'},
- {time:'五月',beginremain:'2000'},
- {time:'六月',beginremain:'2000'},
- {time:'七月',beginremain:'2000'},
- {time:'八月',beginremain:'2000'},
- {time:'九月',beginremain:'2000'},
- {time:'十月',beginremain:'2000'},
- {time:'十一月',beginremain:'2000'},
- {time:'十二月',beginremain:'2000'},
- {time:'总计',beginremain:'2000'},
- ])
- const tableColData=ref([
- {
- id:'time',
- name: '时间',
- children:[
- { id:'time',
- name: '时间',}
- ]
- },
-
- {
- id: 'market',
- name: '市场部',
- children:[
- {
- id: 'precost',
- name: '预算支出'
- },
- {
- id: 'realcost',
- name: '实际支出'
- },
-
- ]
- },
- {
- id: 'technology',
- name: '研发部',
- children:[
- {
- id: 'precost',
- name: '预算支出'
- },
- {
- id: 'realcost',
- name: '实际支出'
- },
-
- ]
- },
- {
- id: 'implement',
- name: '实施部',
- children:[
- {
- id: 'precost',
- name: '预算支出'
- },
- {
- id: 'realcost',
- name: '实际支出'
- },
-
- ]
- },
- {
- id: 'maintenance',
- name: '维修部',
- children:[
- {
- id: 'precost',
- name: '预算支出'
- },
- {
- id: 'realcost',
- name: '实际支出'
- },
-
- ]
- },
- {
- id: 'mannager',
- name: '管理中心',
- children:[
- {
- id: 'precost',
- name: '预算支出'
- },
- {
- id: 'realcost',
- name: '实际支出'
- },
-
- ]
- },
-
- ])
- //合并
- const headerStyle=({ row, column, rowIndex, columnIndex })=>{
- const comStyle = {fontSize:"16px" ,background: "rgb(214, 225, 255)",color:'black'}
- // 1.1 让第0行的第0列跨2行
- if (rowIndex === 0 && columnIndex === 0) {
- nextTick(() => {
- document
- .getElementsByClassName(column.id)[0]
- .setAttribute("rowSpan", 2);
- return comStyle;
- });
- }
- // 1.2 被覆盖的进行隐藏
- if (rowIndex === 1 && (columnIndex == 0 )) {
- return {
- display: "none",
- ...comStyle,
- };
- }
- return comStyle;
- }
- //指定行颜色
- const tableRowClassName=({ row, rowIndex }) =>{
- if (rowIndex ===12) {
- return 'warm-row';
- }
- }
- const costcheck=ref('1')
- </script>
- <style scoped lang="scss">
- </style>
|