j1ack 2 years ago
parent
commit
cb1a22cd13
  1. BIN
      src/assets/images/data-view-table-header-bg-large.png
  2. BIN
      src/assets/images/data-view-table-header-bg-middle.png
  3. BIN
      src/assets/images/data-view-table-header-bg.png
  4. BIN
      src/assets/images/data-view-table-header-parta.png
  5. BIN
      src/assets/images/data-view-table-header-partb.png
  6. 52
      src/utils/ruoyi.js
  7. 6
      src/views/data-view/components/data-view-layout.vue
  8. 79
      src/views/data-view/components/data-view-table.vue
  9. 83
      src/views/data-view/data-view.vue

BIN
src/assets/images/data-view-table-header-bg-large.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

BIN
src/assets/images/data-view-table-header-bg-middle.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

BIN
src/assets/images/data-view-table-header-bg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
src/assets/images/data-view-table-header-parta.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

BIN
src/assets/images/data-view-table-header-partb.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

52
src/utils/ruoyi.js

@ -365,31 +365,39 @@ export function toFixedWithOutRounded(num, s) {
* @return {string | number} * @return {string | number}
*/ */
export const amountFormat = (o) => { export const amountFormat = (o) => {
if (o.amount === undefined || o.amount === null) { // 默认参数值
return o.amount; const {
} amount,
let amount = o.amount; precision = 100,
// 如果 amount 是字符串, 则转换为数字 thousand = true,
if (typeof amount === 'string') { decimal = true,
amount = parseFloat(amount); decimalLength = 2,
} decimalSeparator = '.',
let precision = o.precision || 100; thousandSeparator = ','
let thousand = o.thousand === undefined ? true : o.thousand; } = o;
let decimal = o.decimal === undefined ? true : o.decimal;
let decimalLength = o.decimalLength || 2; // 将金额转换为数字类型
let decimalSeparator = o.decimalSeparator || '.'; const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
let thousandSeparator = o.thousandSeparator || ','; if (isNaN(numAmount)) {
amount = amount / precision; return '';
amount = toFixedWithOutRounded(amount, decimalLength);
if (thousand) {
amount = amount.replace(/(\d)(?=(\d{3})+\.)/g, '$1' + thousandSeparator);
}
if (decimal) {
amount = amount.replace('.', decimalSeparator);
} }
return amount;
// 根据精度对金额进行四舍五入
const roundedAmount = numAmount / precision;
// 格式化小数部分
let formattedAmount = decimal ? roundedAmount.toFixed(decimalLength) : Math.floor(roundedAmount).toString();
// 添加千分位分隔符
if (thousand) {
const parts = formattedAmount.split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
formattedAmount = parts.join(decimalSeparator);
} }
return formattedAmount;
};
/** /**
* 格式化金额, 自动进万, 百万 * 格式化金额, 自动进万, 百万
* @param amount * @param amount

6
src/views/data-view/components/data-view-layout.vue

@ -161,15 +161,15 @@ export default {
height: 100%; height: 100%;
.left-table { .left-table {
width: 23.5%; width: 32.5%;
} }
.middle { .middle {
width: 50%; width: 32.5%;
} }
.right-table { .right-table {
width: 23.5%; width: 32.5%;
} }
} }

79
src/views/data-view/components/data-view-table.vue

@ -4,6 +4,7 @@
<div <div
class="data-view-table" class="data-view-table"
:class="['data-view-table' + '--' + size]" :class="['data-view-table' + '--' + size]"
ref="table"
> >
<div <div
class="data-view-table-header" class="data-view-table-header"
@ -24,7 +25,7 @@
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody ref="tbody" @mouseout="mouseleave" @mouseover="mouseenter"> <tbody ref="tbody">
<tr <tr
v-for="(item, index) in data" v-for="(item, index) in data"
:key="index" :key="index"
@ -39,7 +40,9 @@
:key="column.key" :key="column.key"
:style="{width: columnSizes[index] + '%'}" :style="{width: columnSizes[index] + '%'}"
> >
<slot :name="column.key" :row="item">
{{ item[column.key] }} {{ item[column.key] }}
</slot>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -50,10 +53,8 @@
</template> </template>
<script> <script>
import DataViewTableHeaderBGLarge from '@/assets/images/data-view-table-header-bg-large.png' import DataViewTableHeaderBG from '@/assets/images/data-view-table-header-bg.png'
import DataViewTableHeaderBGMiddle from '@/assets/images/data-view-table-header-bg-middle.png' import { debounce } from '@/utils'
import DataViewTableHeaderBGPartA from '@/assets/images/data-view-table-header-parta.png'
import DataViewTableHeaderBGPartB from '@/assets/images/data-view-table-header-partb.png'
export default { export default {
components: {}, components: {},
@ -74,55 +75,33 @@ export default {
}, },
data() { data() {
return { return {
DataViewTableHeaderBGLarge, DataViewTableHeaderBG,
DataViewTableHeaderBGMiddle,
DataViewTableHeaderBGPartA,
DataViewTableHeaderBGPartB,
timer: null,
}
},
computed: {
DataViewTableHeaderBG() {
if (this.size === 'large') {
return DataViewTableHeaderBGLarge
} else if (this.size === 'middle') {
return DataViewTableHeaderBGMiddle
}
} }
}, },
watch: { watch: {
data: { data: {
handler(newValue, oldValue) { handler() {
this.$nextTick(() => { this.$nextTick(() => {
this.scroll() this.$refs.tbody.style.height = `${this.getHeight()}px`
}) })
}, },
immediate: true deep: true
} }
}, },
methods: { mounted() {
scrollReset() { console.log(this.getHeight())
// this.$refs.tbody.scroll({top: 0, behavior: "smooth"}) window.addEventListener('resize', debounce(() => {
}, this.$refs.tbody.style.height = `${this.getHeight()}px`
mouseleave() { }))
this.scroll() this.$refs.tbody.style.height = `${this.getHeight()}px`
}, },
mouseenter() { methods: {
clearTimeout(this.timer) getHeight() {
// - 51( ) - 58( )
return this.$refs.table.clientHeight - 58 - 51
}, },
scroll() { scrollReset() {
// const tbody = this.$refs.tbody this.$refs.tbody.scrollTop = 0
// if ((tbody.clientHeight + tbody.scrollTop) < tbody.scrollHeight) {
// clearInterval(this.timer)
// this.timer = setInterval(() => {
// const remainScrollTop = tbody.scrollHeight - (tbody.clientHeight + tbody.scrollTop)
// tbody.scrollTop += 1
// if (tbody.scrollTop >= remainScrollTop) {
// tbody.scrollTop = 0;
// }
// }, 50)
//
// }
} }
} }
} }
@ -166,7 +145,6 @@ export default {
-ms-overflow-style: none; /* IE 10+ */ -ms-overflow-style: none; /* IE 10+ */
overflow-x: hidden; overflow-x: hidden;
overflow-y: scroll; overflow-y: scroll;
height: 48vh;
} }
.data-view-table-body { .data-view-table-body {
@ -234,19 +212,6 @@ export default {
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
.data-view-table-header-parta {
width: 350px;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
}
.data-view-table-header-partb {
width: 100%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
}
.header-title { .header-title {
font-size: 22px; font-size: 22px;
/* identical to box height */ /* identical to box height */

83
src/views/data-view/data-view.vue

@ -32,25 +32,6 @@
</template> </template>
<template #middle-table> <template #middle-table>
<data-view-table
title="在线卡数据"
:columnSizes="[12, 12, 12, 12, 20, 20, 12]"
:columns="[
{label: '银行名称/卡号', key: 'bankName'},
{label: '收款人名称', key: 'cardHolder'},
{label: '卡商名称', key: 'username'},
{label: '已收款', key: 'todayIncomeReceived'},
{label: '剩余收款额度', key: 'todayRemainingAmount'},
{label: '出款笔数/金额', key: 'todayOutNumber'},
{label: '剩余卡余额', key: 'remainingAmount'},
]"
:data="data2"
size="large"
ref="table2"
/>
</template>
<template #right-table>
<data-view-table <data-view-table
title="在线卡商数据" title="在线卡商数据"
:columnSizes="[25, 25, 25, 25]" :columnSizes="[25, 25, 25, 25]"
@ -63,6 +44,31 @@
:data="data3" :data="data3"
size="middle" size="middle"
ref="table3" ref="table3"
>
<template #dayMargin="{row}">
<div class="day-margin-row">
<span>{{ row.dayMargin }}/</span>
<span>{{ row.margin }}</span>
</div>
</template>
</data-view-table>
</template>
<template #right-table>
<data-view-table
title="在线卡数据"
:columnSizes="[16.5, 16.5, 16.5, 16.5, 16.5, 16.5]"
:columns="[
{label: '收款人名称', key: 'cardHolder'},
{label: '卡商名称', key: 'username'},
{label: '已收款', key: 'todayIncomeReceived'},
{label: '剩余收款额度', key: 'todayRemainingAmount'},
{label: '剩余卡余额', key: 'remainingAmount'},
{label: '通道', key: 'channel'},
]"
:data="data2"
size="large"
ref="table2"
/> />
</template> </template>
</data-view-layout> </data-view-layout>
@ -236,19 +242,21 @@ export default {
this.chart4.totalLabel = '总金额:' + chart4Total.display this.chart4.totalLabel = '总金额:' + chart4Total.display
const pushMerchant = JSON.parse(data.value.pushMerchant) const pushMerchant = JSON.parse(data.value.pushMerchant)
const f = (v) => amountFormat({ amount: v, decimal: false, decimalLength: 0 })
// //
this.data1 = pushMerchant.map(i => { this.data1 = pushMerchant.map(i => {
return { return {
username: i.username, username: i.username,
balance: amountFormat({ amount: i.balance }) || '0', balance: f(i.balance) || '0',
residueBalance: amountFormat({ amount: i.residueBalance }) || '0', residueBalance: f(i.residueBalance) || '0',
collectionSuccessPrice: amountFormat({ amount: i.collectionSuccessPrice }) || '0', collectionSuccessPrice: f(i.collectionSuccessPrice) || '0',
percentage: (i.percentage * 100).toFixed(2) + '%', percentage: (i.percentage * 100).toFixed(2) + '%',
balanceWarning: i.balanceWarning balanceWarning: i.balanceWarning
} }
}) })
this.data1 = sortBy(this.data1, 'balanceWarning') this.data1 = sortBy(this.data1, 'balanceWarning')
this.data1 = this.data1.slice(0, 10) // this.data1 = this.data1.slice(0, 10)
// 线 // 线
this.data2 = card.map(i => { this.data2 = card.map(i => {
@ -256,21 +264,24 @@ export default {
bankName: i.bankName + '/' + '**** ' + i.cardNumber.slice(-4), bankName: i.bankName + '/' + '**** ' + i.cardNumber.slice(-4),
cardHolder: i.cardHolder, cardHolder: i.cardHolder,
username: i.username, username: i.username,
todayIncomeReceived: amountFormat({ amount: i.todayIncomeReceived }) || '0', todayIncomeReceived: f(i.todayIncomeReceived) || '0',
todayRemainingAmount: amountFormat({ amount: i.todayRemainingAmount }) || '0', todayRemainingAmount: f(i.todayRemainingAmount) || '0',
todayOutNumber: i.todayOutNumber + '/' + amountFormat({ amount: i.todayOutReceived }) || '0', todayOutNumber: i.todayOutNumber + '/' + f(i.todayOutReceived) || '0',
remainingAmount: amountFormat({ amount: i.remainingAmount }) || '0', remainingAmount: f(i.remainingAmount) || '0',
balanceWarning: i.balanceWarning balanceWarning: i.balanceWarning,
channel: i.channelNames.join(',')
} }
}) })
this.data2 = sortBy(this.data2, 'balanceWarning') this.data2 = sortBy(this.data2, 'balanceWarning')
this.data2 = this.data2.slice(0, 10) this.data2 = this.data2.slice(0, 10)
// 线 // 线
this.data3 = carddealer.map(i => { this.data3 = carddealer.map(i => {
return { return {
username: i.username, username: i.username,
dayMargin: (amountFormat({ amount: i.dayMargin }) || '0') + '/' + (amountFormat({ amount: i.margin }) || '0'), dayMargin: f(i.dayMargin) || '0',
toDayTotal: amountFormat({ amount: i.toDayTotal }) || '0', margin: f(i.margin) || '0',
toDayTotal: f(i.toDayTotal) || '0',
turnoverRate: (i.turnoverRate * 100).toFixed(2) + '%', turnoverRate: (i.turnoverRate * 100).toFixed(2) + '%',
balanceWarning: i.balanceWarning balanceWarning: i.balanceWarning
} }
@ -309,7 +320,7 @@ export default {
} }
} }
</script> </script>
<style> <style lang="scss">
@font-face { @font-face {
font-family: "YouSheBiaoTiHei"; font-family: "YouSheBiaoTiHei";
src: url('../../assets/fonts/YouSheBiaoTiHei.ttf'); src: url('../../assets/fonts/YouSheBiaoTiHei.ttf');
@ -323,4 +334,14 @@ export default {
font-weight: 400; font-weight: 400;
} }
.day-margin-row {
display: flex;
flex-wrap: wrap;
justify-content: center;
span {
white-space: normal;
}
}
</style> </style>

Loading…
Cancel
Save