付延余
2022-04-28 cfb813f540e11cbadf041b295c342b02da97da56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<template>
  <div class="PersonnelTalents_greenCard--warp">
    <h1 class="title">人才绿卡购房、租房补贴情况统计表</h1>
    <div class="PT_greenCard--table">
      <el-table
        :data="tableData"
        border
        style="width: 100%" :cell-style="updataCellStyle" :span-method="mergeColumnTableCell">
        <el-table-column
          prop="jyear"
          label="年份">
        </el-table-column>
        <el-table-column
          label="A卡">
          <el-table-column
            prop="acardNums"
            label="持卡总人数 (人)">
          </el-table-column>
          <el-table-column
            prop="asubsidy"
            label="补贴总发放 (万元)">
          </el-table-column>
          <el-table-column
            label="购房">
            <el-table-column
              prop="apurchaseNums"
              label="持卡人数 (人)">
            </el-table-column>
            <el-table-column
              prop="apurSubsidy"
              label="购房补贴 (万元)">
            </el-table-column>
          </el-table-column>
          <el-table-column
            label="租房">
            <el-table-column
              prop="arentNums"
              label="持卡人数 (人)">
            </el-table-column>
            <el-table-column
              prop="arentSubsidy"
              label="租房补贴 (万元)">
            </el-table-column>
          </el-table-column>
        </el-table-column>
        <el-table-column
          label="B卡">
          <el-table-column
            prop="bcardNums"
            label="持卡总人数 (人)">
          </el-table-column>
          <el-table-column
            prop="bsubsidy"
            label="补贴总发放 (万元)">
          </el-table-column>
          <el-table-column
            label="购房">
            <el-table-column
              prop="bpurchaseNums"
              label="持卡人数 (人)">
            </el-table-column>
            <el-table-column
              prop="bpurSubsidy"
              label="购房补贴 (万元)">
            </el-table-column>
          </el-table-column>
          <el-table-column
            label="租房">
            <el-table-column
              prop="brentNums"
              label="持卡人数 (人)">
            </el-table-column>
            <el-table-column
              prop="brentSubsidy"
              label="租房补贴 (万元)">
            </el-table-column>
          </el-table-column>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
 
<script>
  import {getPersonCardTable} from '@/api/personnelTalents'
export default {
  name: "PersonnelTalents_GreenCard",
  data() {
    return {
      tableData: [],
      spanArr: [],  //spanArr用于存放每一行记录的合并数
    }
  },
  mounted() {
    this.getPersonCardTable()
  },
  methods:{
    getPersonCardTable() {
        getPersonCardTable().then(res => {
            if(res.code == 1000) {
                this.tableData = res.list
                this.rowspan()
            }
        })
    },
    // 修改单个表格样式
    updataCellStyle({ rowIndex, columnIndex}){
      if(columnIndex===0){
        return {background:'#51D2FF'}
      }
    },
    rowspan() {
        let position = 0  //用于存储相同项的开始index
        this.tableData.forEach((item,index) => {
            console.log(item,'------------', + index)
            if(index === 0) {
                this.spanArr.push(1)
            }else {
                if(item.acardNums == this.tableData[index - 1].acardNums) {
                    this.spanArr[position] += 1
                    this.spanArr.push(0)
                }else {
                    position = index
                    this.spanArr.push(1)
                }
            }
        })
    },
    // 合并单元格
    mergeColumnTableCell({rowIndex,columnIndex}){
      if(columnIndex == 1 ||  columnIndex == 7) {
          const _row = this.spanArr[rowIndex]
          const _col = _row>0 ? 1 : 0
          return {
              rowspan: _row,
              colspan: _col
          }
      }
    }
  }
 
}
</script>
 
<style lang="scss">
@import "../../../../assets/css/base";
 
.PT_greenCard--table {
  .el-table tr {
    background-color: #CEF2FF;
  }
 
  .el-table th.el-table__cell {
    background-color: #51D2FF;
  }
 
  .el-table__fixed, .el-table__fixed-right, .el-table__fixed-right::before, .el-table__fixed::before {
    background-color: #51D2FF;
  }
 
  .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
    background-color: #A8E9FF;
  }
 
  .el-table thead {
    color: #111111;
  }
 
  .el-table td.el-table__cell, .el-table th.el-table__cell.is-leaf {
    border-bottom: 1Px solid #8E8E8E;
  }
 
  .el-table--border .el-table__cell, .el-table__body-wrapper .el-table--border.is-scrolling-left ~ .el-table__fixed {
    border-right: 1Px solid #8E8E8E;
  }
 
  .el-table .el-table__cell {
    padding:0.127rem 0;
    //padding:0;
  }
 
  .el-table__body tr.hover-row.current-row > td.el-table__cell, .el-table__body tr.hover-row.el-table__row--striped.current-row > td.el-table__cell, .el-table__body tr.hover-row.el-table__row--striped > td.el-table__cell, .el-table__body tr.hover-row > td.el-table__cell {
    background: transparent;
    height:0.390625rem;
  }
 
  .el-table .cell {
    font-size: $fontSize-28;
    color: $color-darkGrey;
    font-weight: 300;
    //height:0.625rem;
    line-height: 0.125rem;
    text-align: center;
  }
  // 头部团体背景颜色
  .el-table thead.is-group th.el-table__cell {
    background-color: #51D2FF;
  }
 
  // 头部团体单元格下边框颜色
  .el-table--border th.el-table__cell, .el-table__fixed-right-patch {
    border-bottom: 1px solid #8E8E8E;
  }
 
}
</style>
<style lang="scss" scoped>
@import "../../../../assets/css/base";
 
.PersonnelTalents_greenCard--warp {
  width: 100%;
  height: 90%;
  h1 {
    font-size: $fontSize-30;
    font-weight: 400;
    color: #ffffff;
    //margin-top: 0.23828125rem;
    text-align: center;
  }
  .PT_greenCard--table {
    width: 100%;
    height: 100%;
    position: relative;
    top:0.125rem;
  }
}
</style>