| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <template>
- <div class="cl-board">
- <el-table
- :data="rows"
- size="small"
- style="width:100%"
- @row-click="onRowClick"
- :row-class-name="rowClass"
- >
- <el-table-column prop="userId" label="学员ID" width="90" />
- <el-table-column prop="year" label="年度" width="80" />
- <el-table-column prop="theory" label="理论学时" width="100">
- <template slot-scope="{ row }">{{ toHours(row.theory) }}</template>
- </el-table-column>
- <el-table-column prop="practice" label="实践学时" width="100">
- <template slot-scope="{ row }">{{ toHours(row.practice) }}</template>
- </el-table-column>
- <el-table-column prop="total" label="总学时" width="100">
- <template slot-scope="{ row }">
- <b>{{ toHours(row.total) }}</b>
- </template>
- </el-table-column>
- <el-table-column prop="effectiveAt" label="生效时间" min-width="150">
- <template slot-scope="{ row }">{{ fmtTime(row.effectiveAt) }}</template>
- </el-table-column>
- <el-table-column prop="status" label="状态" width="120">
- <template slot-scope="{ row }">
- <el-tag :type="statusMap[row.status] ? statusMap[row.status].type : 'info'" size="mini">
- {{ statusMap[row.status] ? statusMap[row.status].label : row.status }}
- </el-tag>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <script>
- export default {
- name: 'CreditLedgerTable',
- props: {
- // 后端 ledgerPending 行:{ledgerId, sourceType, sourceCategory, hours, status, effectiveAt, sourceDesc, createdAt}
- // 组件按 userId×year 聚合展示(父层传已聚合数据)
- rows: {
- type: Array,
- default: function () { return [] }
- }
- },
- data: function () {
- return {
- statusMap: {
- pending: { type: 'warning', label: '待生效' },
- effective: { type: 'success', label: '已生效' },
- objected: { type: 'danger', label: '有异议' },
- rejected: { type: 'info', label: '已驳回' }
- }
- }
- },
- methods: {
- toHours: function (minutes) {
- var n = Number(minutes || 0)
- var h = Math.floor(n / 60)
- var m = n % 60
- if (h === 0) return m + '分钟'
- if (m === 0) return h + '小时'
- return h + '小时' + m + '分'
- },
- fmtTime: function (v) {
- if (!v) return '-'
- var s = String(v).replace('T', ' ')
- return s.length > 16 ? s.substring(0, 16) : s
- },
- rowClass: function (params) {
- return params.row.status === 'objected' ? 'row-objected' : ''
- },
- onRowClick: function (row) {
- this.$emit('detail', row)
- }
- }
- }
- </script>
- <style scoped>
- .row-objected {
- box-shadow: inset 3px 0 0 #C0392B;
- }
- </style>
|