fix: 首页日历、净资产、统计页面,统一优化样式。

This commit is contained in:
tianyongbao
2025-11-03 02:53:14 +08:00
parent 831bf9e773
commit fceb61533c
24 changed files with 4281 additions and 1360 deletions

View File

@@ -3,9 +3,9 @@
<div class="search-con">
<div class="title">查询条件</div>
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="名称" prop="name">
<!-- <el-form-item label="名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-form-item> -->
<el-form-item label="记录时间" prop="time">
<el-date-picker v-model="queryParams.time" type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
</el-form-item>
@@ -17,24 +17,19 @@
</div>
<div class="main-con">
<div class="title-con">
<div class="title">基本信息</div>
<div class="title">净资产趋势分析</div>
<div class="operate-btn-con">
<!-- <el-button
@click="handleAdd"
icon="Plus"
v-hasPermi="['invest:dailyLiabilities:add']"
>新增</el-button>
<el-button
:disabled="multiple"
icon="Delete"
@click="handleDelete"
v-hasPermi="['invest:dailyLiabilities:remove']"
>删除</el-button> -->
<el-button @click="handleExport" icon="Download" v-hasPermi="['invest:dailyLiabilities:export']">导出</el-button>
<el-radio-group v-model="radioVal" @change="handleRadioChange">
<el-radio-button label="柱状图" />
<el-radio-button label="折线图" />
<el-radio-button label="表格" />
</el-radio-group>
</div>
</div>
<div class="content-con" v-loading="loading">
<el-table v-loading="loading" :data="dailyLiabilitiesList" @selection-change="handleSelectionChange">
<div class="content-con">
<div v-show="radioVal === '柱状图'" class="chart" id="chartBar"></div>
<div v-show="radioVal === '折线图'" class="chart" id="chartLine"></div>
<el-table v-show="radioVal === '表格'" v-loading="loading" :data="dailyLiabilitiesList" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="名称" align="center" width="260" prop="name" />
<el-table-column label="净资产" align="center" prop="totalBalance" />
@@ -53,7 +48,6 @@
</template>
</el-table-column> -->
</el-table>
<el-pagination small background layout="total, prev, pager, next" :total="total" @current-change="handleCurrentChange" />
</div>
</div>
<!-- 添加或修改每日负债统计对话框 -->
@@ -83,6 +77,7 @@
import { listDailyLiabilities, getDailyLiabilities, delDailyLiabilities, addDailyLiabilities, updateDailyLiabilities } from '@/api/invest/dailyLiabilities'
// eslint-disable-next-line no-unused-vars
import dayjs from 'dayjs'
import * as echarts from 'echarts'
import { require } from '@/utils/require'
const { proxy } = getCurrentInstance()
@@ -95,17 +90,27 @@ const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref('')
const radioVal = ref('柱状图')
const chartData = ref({
name: [],
value1: []
})
const operateList = ref([
{ id: 'view', icon: 'View', title: '查看', hasPermi: ['invest:dailyLiabilities:query'] },
{ id: 'edit', icon: 'Edit', title: '修改', hasPermi: ['invest:dailyLiabilities:edit'] },
{ id: 'delete', icon: 'Delete', title: '删除', hasPermi: ['invest:dailyLiabilities:remove'] }
])
// 初始化默认查询最近10天
const today = new Date()
const tenDaysAgo = new Date()
tenDaysAgo.setDate(today.getDate() - 9) // 包含今天共10天
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
time: '',
pageSize: 100, // 增加pageSize以确保能获取到足够的数据
time: [tenDaysAgo, today],
name: null,
recordDate: null
},
@@ -146,6 +151,16 @@ function getList() {
dailyLiabilitiesList.value = response.rows
total.value = response.total
loading.value = false
// 准备图表数据 - 使用查询结果的所有数据
chartData.value = { name: [], value1: [] }
const chartDataList = response.rows.slice().reverse() // 倒序显示,时间从旧到新
chartDataList.forEach((item) => {
chartData.value.name.push(item.recordDate)
chartData.value.value1.push(parseFloat(item.totalBalance) || 0)
})
handleRadioChange(currentType.value)
})
}
@@ -178,22 +193,20 @@ function reset() {
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm('queryRef')
// 重置为默认的最近10天
const today = new Date()
const tenDaysAgo = new Date()
tenDaysAgo.setDate(today.getDate() - 9)
queryParams.value.time = [tenDaysAgo, today]
queryParams.value.name = null
handleQuery()
}
// 分页
const handleCurrentChange = (val) => {
queryParams.value.pageNum = val
getList()
}
// 多选框选中数据
function handleSelectionChange(selection) {
ids.value = selection.map((item) => item.id)
@@ -273,5 +286,234 @@ function handleExport() {
)
}
/** 绘制柱状图 */
const drawBar = (data) => {
if (document.getElementById('chartBar') === null) {
return
}
echarts.dispose(document.getElementById('chartBar'))
const myChart = echarts.init(document.getElementById('chartBar'))
const option = {
legend: {
show: true,
top: 50,
right: 50,
itemGap: 20
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
return params[0].name + '<br>' + '净资产:' + params[0].value + '元'
}
},
grid: {
left: '5%',
right: '5%',
bottom: '5%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: data.name,
axisTick: {
alignWithLabel: true
},
axisLine: {
lineStyle: {
width: 1,
color: '#999'
}
}
}
],
yAxis: [
{
type: 'value',
axisTick: {
show: false
},
axisLine: {
show: true,
lineStyle: {
width: 1,
color: '#999'
}
}
}
],
series: [
{
data: data.value1,
type: 'bar',
barWidth: 20,
itemStyle: {
color: '#2283cf'
}
}
],
emphasis: {
itemStyle: {
color: '#2283cf',
barWidth: 20
},
barWidth: 24
}
}
myChart.setOption(option)
setTimeout(() => {
myChart.resize()
}, 100)
}
/** 绘制折线图 */
const drawLine = (data) => {
if (document.getElementById('chartLine') === null) {
return
}
echarts.dispose(document.getElementById('chartLine'))
const myChart = echarts.init(document.getElementById('chartLine'))
const option = {
grid: {
left: '5%',
right: '5%',
bottom: '5%',
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
return params[0].name + '<br>' + '净资产:' + params[0].value + '元'
}
},
xAxis: {
type: 'category',
data: data.name,
axisTick: {
alignWithLabel: true
},
axisLine: {
lineStyle: {
width: 1,
color: '#999'
}
}
},
yAxis: {
type: 'value',
axisTick: {
show: false
},
axisLine: {
show: true,
lineStyle: {
width: 1,
color: '#999'
}
}
},
series: [
{
data: data.value1,
type: 'line',
lineStyle: {
color: '#4181c9'
},
itemStyle: {
color: '#4181c9'
},
smooth: true,
symbol: 'emptyCircle',
areaStyle: {
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: 'rgba(65,129,201, 0.70)'
},
{
offset: 1,
color: 'rgba(65,129,201, 0.10)'
}
],
false
),
shadowColor: 'rgba(65,129,201, 0.10)',
shadowBlur: 10
}
}
]
}
myChart.setOption(option)
setTimeout(() => {
myChart.resize()
}, 100)
}
/** 单选按钮切换处理 */
const currentType = ref('柱状图')
const handleRadioChange = (type) => {
currentType.value = type
nextTick(() => {
switch (type) {
case '柱状图':
drawBar(chartData.value)
break
case '折线图':
drawLine(chartData.value)
break
default:
break
}
})
}
getList()
</script>
<style lang="scss" scoped>
.main-con {
height: calc(100vh - 200px);
display: flex;
flex-direction: column;
overflow: hidden;
}
.title-con {
margin-top: 0 !important;
padding-top: 0.08rem !important;
flex-shrink: 0;
}
.content-con {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
min-height: 0;
.chart {
flex: 1;
min-height: 0;
width: 100%;
}
.el-table {
flex: 1;
}
}
</style>