Commit f3503c7b by 潘际乾

完善首页小组件

parent 43043f23
<template> <template>
<CellWrapper title="大客户分析"> <CellWrapper title="大客户分析" :cellContentHeight="cellContentHeight">
<template v-slot:header> <template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span> <span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span> <span class="el-icon-more" title="操作"></span>
</template> </template>
<div class="content"> <div class="chart-container">
<div class="chart-operate"> <div class="chart-operate">
<i class="el-icon-arrow-up"></i> <i class="el-icon-arrow-up"></i>
<i class="el-icon-arrow-down"></i> <i class="el-icon-arrow-down"></i>
...@@ -23,6 +23,7 @@ import * as echarts from "echarts"; ...@@ -23,6 +23,7 @@ import * as echarts from "echarts";
export default { export default {
name: "CustomerAnalyse", name: "CustomerAnalyse",
props: ["cellContentHeight"],
components: { CellWrapper }, components: { CellWrapper },
data() { data() {
return { return {
...@@ -30,14 +31,20 @@ export default { ...@@ -30,14 +31,20 @@ export default {
}; };
}, },
mounted() { mounted() {
this.echartInstance = echarts.init(this.$el.querySelector('.content .chartWrapper .chart')); this.$nextTick(() => {
this.loadCharts(); this.loadCharts();
this.loadChartsBind = this.loadCharts.bind(this); this.loadChartsBind = this.loadCharts.bind(this);
window.addEventListener("resize", this.loadChartsBind); window.addEventListener("resize", this.loadChartsBind);
});
}, },
methods: { methods: {
loadCharts() { loadCharts() {
this.echartInstance.clear(); if (this.echartInstance) {
this.echartInstance.dispose();
}
this.echartInstance = echarts.init(
this.$el.querySelector(".chart-container .chartWrapper .chart")
);
const option = { const option = {
title: { title: {
// text: "Test Demo", // text: "Test Demo",
...@@ -100,7 +107,8 @@ export default { ...@@ -100,7 +107,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
.content { .chart-container {
height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0 5px; padding: 0 5px;
......
<template> <template>
<CellWrapper title="电子大厅"> <CellWrapper title="电子大厅" :cellContentHeight="cellContentHeight">
<template v-slot:header> <template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span> <span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span> <span class="el-icon-more" title="操作"></span>
</template> </template>
<div class="content"> <div class="card-wrapper">
<div class="card-item" v-for="(item, idx) in itemList" :key="idx"> <div class="card-item" v-for="(item, idx) in itemList" :key="idx">
<div class="dept-name"> <div class="dept-name">
<div <div
...@@ -34,6 +34,7 @@ import CellWrapper from "../common/CellWrapper.vue"; ...@@ -34,6 +34,7 @@ import CellWrapper from "../common/CellWrapper.vue";
export default { export default {
name: "Hall", name: "Hall",
props: ['cellContentHeight'],
components: { CellWrapper }, components: { CellWrapper },
data() { data() {
return { return {
...@@ -65,7 +66,8 @@ export default { ...@@ -65,7 +66,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
.content { .card-wrapper {
height: 100%;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-around; justify-content: space-around;
......
<template> <template>
<CellWrapper title="通知公告"> <CellWrapper title="通知公告" :cellContentHeight="cellContentHeight">
<template v-slot:header> <template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span> <span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span> <span class="el-icon-more" title="操作"></span>
</template> </template>
<div class="content"> <div class="notice-container">
<el-scrollbar :style="{ height: cellScrollHeight + 'px' }"> <el-scrollbar style="height: 100%;">
<div class="notice-item" v-for="(item, idx) in noticeList" :key="idx"> <div class="notice-item" v-for="(item, idx) in noticeList" :key="idx">
<div class="notice-title" :class="{ active: idx === 0 }"> <div class="notice-title" :class="{ active: idx === 0 }">
<a :href="item.url" target="_blank" rel="noopener noreferrer"> <a :href="item.url" target="_blank" rel="noopener noreferrer">
...@@ -27,13 +27,8 @@ import CellWrapper from "../common/CellWrapper.vue"; ...@@ -27,13 +27,8 @@ import CellWrapper from "../common/CellWrapper.vue";
export default { export default {
name: "NoticeAnnouncement", name: "NoticeAnnouncement",
props: ['cellContentHeight'],
components: { CellWrapper }, components: { CellWrapper },
props: {
cellScrollHeight: {
type: Number,
required: true,
},
},
data() { data() {
return { return {
noticeList: [], noticeList: [],
...@@ -103,6 +98,21 @@ export default { ...@@ -103,6 +98,21 @@ export default {
url: "https://www.safe.gov.cn/safe/2021/0720/19437.html", url: "https://www.safe.gov.cn/safe/2021/0720/19437.html",
date: "2021-07-20", date: "2021-07-20",
}, },
{
title: "现行有效外汇管理主要法规目录(截至2021年6月30日)...",
url: "https://www.safe.gov.cn/safe/2021/0720/19437.html",
date: "2021-07-20",
},
{
title: "现行有效外汇管理主要法规目录(截至2021年6月30日)...",
url: "https://www.safe.gov.cn/safe/2021/0720/19437.html",
date: "2021-07-20",
},
{
title: "现行有效外汇管理主要法规目录(截至2021年6月30日)...",
url: "https://www.safe.gov.cn/safe/2021/0720/19437.html",
date: "2021-07-20",
},
], ],
}; };
}, },
...@@ -121,7 +131,8 @@ export default { ...@@ -121,7 +131,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
.content { .notice-container {
height: 100%;
margin: 0 20px; margin: 0 20px;
box-sizing: border-box; box-sizing: border-box;
} }
......
<template> <template>
<CellWrapper title="快速查询"> <CellWrapper title="快速查询" :cellContentHeight="cellContentHeight">
<template v-slot:header> <template v-slot:header>
<span class="el-icon-setting" title="设置" @click="openSetting"></span> <span class="el-icon-setting" title="设置" @click="openSetting"></span>
</template> </template>
<div class="content"> <quick
<quick ref="quick"
ref="quick" quickType="search"
:cellScrollHeight="cellScrollHeight" :cellContentHeight="cellContentHeight"
quickType="search" ></quick>
></quick>
</div>
</CellWrapper> </CellWrapper>
</template> </template>
...@@ -24,7 +22,7 @@ export default { ...@@ -24,7 +22,7 @@ export default {
name: "QuickSearch", name: "QuickSearch",
components: { CellWrapper, quick }, components: { CellWrapper, quick },
props: { props: {
cellScrollHeight: { cellContentHeight: {
type: Number, type: Number,
required: true, required: true,
}, },
......
<template> <template>
<CellWrapper title="快速访问"> <CellWrapper title="快速访问" :cellContentHeight="cellContentHeight">
<template v-slot:header> <template v-slot:header>
<span class="el-icon-setting" title="设置" @click="openSetting"></span> <span class="el-icon-setting" title="设置" @click="openSetting"></span>
</template> </template>
<div class="content"> <quick
<quick ref="quick"
ref="quick" quickType="visit"
:cellScrollHeight="cellScrollHeight" :cellContentHeight="cellContentHeight"
quickType="visit" ></quick>
></quick>
</div>
</CellWrapper> </CellWrapper>
</template> </template>
...@@ -24,7 +22,7 @@ export default { ...@@ -24,7 +22,7 @@ export default {
name: "QuickVisit", name: "QuickVisit",
components: { CellWrapper, quick }, components: { CellWrapper, quick },
props: { props: {
cellScrollHeight: { cellContentHeight: {
type: Number, type: Number,
required: true, required: true,
}, },
......
<template> <template>
<CellWrapper title="任务统计"> <CellWrapper title="任务统计" :cellContentHeight="cellContentHeight">
<template v-slot:header> <template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span> <span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span> <span class="el-icon-more" title="操作"></span>
</template> </template>
<div class="content"> <div class="statistics-container">
<div class="task-stat-display total"> <div class="task-stat-display total">
<div class="display-wrapper"> <div class="display-wrapper">
<div <div
...@@ -53,6 +53,7 @@ import { all } from "~/service/report"; ...@@ -53,6 +53,7 @@ import { all } from "~/service/report";
export default { export default {
name: "TaskStatistics", name: "TaskStatistics",
props: ["cellContentHeight"],
components: { CellWrapper }, components: { CellWrapper },
data() { data() {
return { return {
...@@ -93,7 +94,8 @@ export default { ...@@ -93,7 +94,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
.content { .statistics-container {
height: 100%;
padding: 0px 8px; padding: 0px 8px;
} }
.task-stat-display { .task-stat-display {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<CellHeader :title="title"> <CellHeader :title="title">
<slot name="header"></slot> <slot name="header"></slot>
</CellHeader> </CellHeader>
<div class="cell-content"> <div class="cell-content" :style="{ height: cellContentHeight + 'px' }">
<slot></slot> <slot></slot>
</div> </div>
</div> </div>
...@@ -13,13 +13,17 @@ ...@@ -13,13 +13,17 @@
import CellHeader from "./CellHeader.vue"; import CellHeader from "./CellHeader.vue";
export default { export default {
name: 'CellWrapper', name: "CellWrapper",
components: { CellHeader }, components: { CellHeader },
props: { props: {
title: { title: {
type: String, type: String,
required: true, required: true,
}, },
cellContentHeight: {
type: Number,
required: true,
},
}, },
data() { data() {
return {}; return {};
...@@ -29,21 +33,14 @@ export default { ...@@ -29,21 +33,14 @@ export default {
<style scoped> <style scoped>
.home-cell { .home-cell {
height: 100%;
background-color: #ffffff; background-color: #ffffff;
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%); box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
border-radius: 8px; border-radius: 8px;
padding-bottom: 10px;
} }
.home-cell::before { .home-cell::before {
display: table; display: table;
content: ''; content: "";
}
.home-cell .cell-content {
height: calc(100% - 52px);
}
.home-cell .cell-content >>> .content {
padding-bottom: 10px;
height: calc(100% - 10px);
} }
.home-cell >>> .el-scrollbar__wrap { .home-cell >>> .el-scrollbar__wrap {
overflow-y: scroll; overflow-y: scroll;
......
<template> <template>
<el-scrollbar :style="{ height: cellScrollHeight + 'px' }"> <el-scrollbar style="height: 100%">
<router-link <router-link
v-for="(item, index) in quickVisitItem" v-for="(item, index) in quickVisitItem"
:key="index" :key="index"
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
> >
<div <div
class="content-wrapper" class="content-wrapper"
:style="{ height: Math.floor(cellScrollHeight * 0.3) + 'px' }" :style="{ height: Math.floor(cellContentHeight * 0.33) + 'px' }"
> >
<div class="visit-item-wrapper"> <div class="visit-item-wrapper">
<div class="visit-item"> <div class="visit-item">
...@@ -18,7 +18,12 @@ ...@@ -18,7 +18,12 @@
</div> </div>
</router-link> </router-link>
<el-dialog :visible="visible" title="设置" width="60%" :before-close="handleClose"> <el-dialog
:visible="visible"
title="设置"
width="60%"
:before-close="handleClose"
>
<div style="text-align: center"> <div style="text-align: center">
<el-transfer <el-transfer
style="text-align: left; display: inline-block" style="text-align: left; display: inline-block"
...@@ -47,14 +52,14 @@ import icons from "./icons.js"; ...@@ -47,14 +52,14 @@ import icons from "./icons.js";
export default { export default {
props: { props: {
cellScrollHeight: {
type: Number,
required: true,
},
quickType: { quickType: {
type: String, type: String,
required: true, required: true,
}, },
cellContentHeight: {
type: Number,
required: true,
},
}, },
data() { data() {
return { return {
......
export const cellDataDefinition = [
{
title: "快速访问",
name: "QuickVisit",
description: "交易快速访问入口",
},
{
title: "任务统计",
name: "TaskStatistics",
description: "任务的数量统计",
},
{
title: "通知公告",
name: "NoticeAnnouncement",
description: "最新的通知公告",
},
{ title: "电子大厅", name: "Hall", description: "电子大厅" },
{
title: "大客户分析",
name: "CustomerAnalyse",
description: "客户数据分析",
},
{
title: "快速查询",
name: "QuickSearch",
description: "交易快速查询入口",
},
];
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
<div class="eContainer-home"> <div class="eContainer-home">
<c-row <c-row
:gutter="10" :gutter="10"
:style="{ height: getRowHeightPercent() * 100 + '%' }"
v-for="cRow in cellRows" v-for="cRow in cellRows"
:key="cRow" :key="cRow"
> >
<c-col <c-col
class="home-cell-col"
:span="24 / cellCols" :span="24 / cellCols"
v-for="cCol in cellCols" v-for="cCol in cellCols"
:key="cCol" :key="cCol"
...@@ -15,7 +13,7 @@ ...@@ -15,7 +13,7 @@
<component <component
v-if="getComponentName([cRow - 1], [cCol - 1])" v-if="getComponentName([cRow - 1], [cCol - 1])"
v-bind:is="getComponentName([cRow - 1], [cCol - 1])" v-bind:is="getComponentName([cRow - 1], [cCol - 1])"
:cellScrollHeight="cellScrollHeight" :cellContentHeight="cellContentHeight"
></component> ></component>
</c-col> </c-col>
</c-row> </c-row>
...@@ -33,6 +31,8 @@ import Hall from "./cells/Hall.vue"; ...@@ -33,6 +31,8 @@ import Hall from "./cells/Hall.vue";
import CustomerAnalyse from "./cells/CustomerAnalyse.vue"; import CustomerAnalyse from "./cells/CustomerAnalyse.vue";
import QuickSearch from "./cells/QuickSearch.vue"; import QuickSearch from "./cells/QuickSearch.vue";
import { cellDataDefinition } from "./config";
export default { export default {
name: "Home", name: "Home",
components: { components: {
...@@ -45,44 +45,16 @@ export default { ...@@ -45,44 +45,16 @@ export default {
}, },
data() { data() {
return { return {
cellScrollHeight: 0, cellContentHeight: 0,
cellDataDefinition: [
{
title: "快速访问",
name: "QuickVisit",
description: "交易快速访问入口",
},
{
title: "任务统计",
name: "TaskStatistics",
description: "任务的数量统计",
},
{
title: "通知公告",
name: "NoticeAnnouncement",
description: "最新的通知公告",
},
{ title: "电子大厅", name: "Hall", description: "电子大厅" },
{
title: "大客户分析",
name: "CustomerAnalyse",
description: "客户数据分析",
},
{
title: "快速查询",
name: "QuickSearch",
description: "交易快速查询入口",
},
],
}; };
}, },
created() { created() {
this.loadCellData(); this.loadCellData();
}, },
mounted() { mounted() {
this.calcCellScrollHeight(); this.calcCellContentHeight();
this.calcCellScrollHeightBind = this.calcCellScrollHeight.bind(this); this.calcCellContentHeightBind = this.calcCellContentHeight.bind(this);
window.addEventListener("resize", this.calcCellScrollHeightBind); window.addEventListener("resize", this.calcCellContentHeightBind);
}, },
computed: { computed: {
...mapState({ ...mapState({
...@@ -93,14 +65,14 @@ export default { ...@@ -93,14 +65,14 @@ export default {
}, },
watch: { watch: {
cellRows(newVal, oldVal) { cellRows(newVal, oldVal) {
this.calcCellScrollHeight() this.calcCellContentHeight()
}, },
}, },
methods: { methods: {
loadCellData() { loadCellData() {
this.$store.commit( this.$store.commit(
"UserContext/setHomeDefaultCells", "UserContext/setHomeDefaultCells",
this.cellDataDefinition cellDataDefinition
); );
let cellsSettingDefault = localStorage.getItem("cells-setting-default"); let cellsSettingDefault = localStorage.getItem("cells-setting-default");
if (!cellsSettingDefault) { if (!cellsSettingDefault) {
...@@ -114,7 +86,7 @@ export default { ...@@ -114,7 +86,7 @@ export default {
cellNames: this.generateRowColNames( cellNames: this.generateRowColNames(
rows, rows,
cols, cols,
this.cellDataDefinition.map((definition) => definition.name) cellDataDefinition.map((definition) => definition.name)
), ),
}) })
); );
...@@ -144,20 +116,16 @@ export default { ...@@ -144,20 +116,16 @@ export default {
getComponentName(rowIdx, colIdx) { getComponentName(rowIdx, colIdx) {
return this.cellNames[rowIdx] ? this.cellNames[rowIdx][colIdx] : null; return this.cellNames[rowIdx] ? this.cellNames[rowIdx][colIdx] : null;
}, },
calcCellScrollHeight() { calcCellContentHeight() {
this.cellScrollHeight = Math.floor(this.$el.clientHeight * this.getRowHeightPercent() - 52 - 10) this.cellContentHeight = this.$el.clientHeight * this.getRowHeightPercent() - 52 - 10
}, },
getRowHeightPercent() { getRowHeightPercent() {
// 每行预留 0.4% 的间距 // 每行预留 0.4% 的间距
return 1 / this.cellRows - 0.004 * this.cellRows; return 1 / this.cellRows - 0.004 * this.cellRows;
}, },
getRowWidthPercent() {
// 每列预留 0.4% 的间距
return 1 / this.cellCols - 0.004 * this.cellCols;
},
}, },
destroyed() { destroyed() {
window.removeEventListener("resize", this.calcCellScrollHeightBind); window.removeEventListener("resize", this.calcCellContentHeightBind);
}, },
}; };
</script> </script>
...@@ -169,7 +137,4 @@ export default { ...@@ -169,7 +137,4 @@ export default {
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
} }
.home-cell-col {
height: 100%;
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment