Commit 7ac6aebb by liuxin
parents ddd01c73 149c8c0f
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,4 +2,12 @@ import Api from "~/service/Api"
export function all(data) {
return Api.post("/report/task/all", data)
}
export function my(data) {
return Api.post("/report/task/my",data)
}
export function ins(data) {
return Api.post("/report/task/ins", data)
}
\ No newline at end of file
......@@ -7,6 +7,12 @@ const UserContext={
menu:[],
state:"LOGOUT",
token:"",
homeCellsSetting: {
defaultCells: [],
cellRows: 0,
cellCols: 0,
cellNames: []
}
},
mutations:{
setLoginInfo(state,info){
......@@ -30,6 +36,15 @@ const UserContext={
},
setMenu(state, menu) {
state.menu = menu;
},
setHomeCellsSetting(state, setting) {
state.homeCellsSetting.cellRows = setting.cellRows
state.homeCellsSetting.cellCols = setting.cellCols
state.homeCellsSetting.cellNames = setting.cellNames
localStorage.setItem(`cells-setting-${state.userId}`, JSON.stringify(setting));
},
setHomeDefaultCells(state, cells) {
state.homeCellsSetting.defaultCells = cells;
}
}
}
......
<template>
<div class="home-cell" id="customerAnalyse">
<CellHeaderVue title="大客户分析">
<CellWrapper title="大客户分析" :cellContentHeight="cellContentHeight">
<template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span>
</CellHeaderVue>
<div class="cell-content">
</template>
<div class="chart-container">
<div class="chart-operate">
<i class="el-icon-arrow-up"></i>
<i class="el-icon-arrow-down"></i>
</div>
<div id="chartWrapper">
<div id="chart"></div>
<div class="chartWrapper">
<div class="chart"></div>
</div>
</div>
</div>
</CellWrapper>
</template>
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import CellWrapper from "../common/CellWrapper.vue";
import * as echarts from "echarts";
export default {
name: "CustomerAnalyse",
components: { CellHeaderVue },
props: ["cellContentHeight"],
components: { CellWrapper },
data() {
return {
echartInstance: null,
};
},
mounted() {
this.echartInstance = echarts.init(document.getElementById("chart"));
this.loadCharts()
this.loadChartsBind = this.loadCharts.bind(this)
window.addEventListener('resize', this.loadChartsBind)
this.$nextTick(() => {
this.loadCharts();
this.loadChartsBind = this.loadCharts.bind(this);
window.addEventListener("resize", this.loadChartsBind);
});
},
methods: {
loadCharts() {
this.echartInstance.clear()
if (this.echartInstance) {
this.echartInstance.dispose();
}
this.echartInstance = echarts.init(
this.$el.querySelector(".chart-container .chartWrapper .chart")
);
const option = {
title: {
// text: "Test Demo",
......@@ -93,32 +101,29 @@ export default {
},
},
destroyed() {
window.removeEventListener('resize', this.loadChartsBind)
}
window.removeEventListener("resize", this.loadChartsBind);
},
};
</script>
<style scoped>
#customerAnalyse .cell-content {
.chart-container {
height: 100%;
display: flex;
flex-direction: column;
padding: 0 5px;
}
#customerAnalyse .cell-content .chart-operate {
.chart-operate {
margin-left: 20px;
height: 20px;
}
#customerAnalyse .cell-content .chart-operate i {
.chart-operate i {
cursor: pointer;
}
#customerAnalyse .cell-content #chartWrapper {
/* width: 98%; */
/* height: calc(100% - 50px); */
/* height: 200px; */
/* margin: 0 auto; */
.chartWrapper {
flex: 1;
}
#customerAnalyse .cell-content #chartWrapper #chart {
.chartWrapper .chart {
width: 100%;
height: 100%;
}
......
<template>
<div class="home-cell" id="hall">
<CellHeaderVue title="电子大厅">
<CellWrapper title="电子大厅" :cellContentHeight="cellContentHeight">
<template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span>
</CellHeaderVue>
<div class="cell-content">
</template>
<div class="card-wrapper">
<div class="card-item" v-for="(item, idx) in itemList" :key="idx">
<div class="dept-name">
<div
......@@ -25,15 +26,16 @@
</div>
</div>
</div>
</div>
</CellWrapper>
</template>
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import CellWrapper from "../common/CellWrapper.vue";
export default {
name: "Hall",
components: { CellHeaderVue },
props: ['cellContentHeight'],
components: { CellWrapper },
data() {
return {
itemList: [
......@@ -64,15 +66,14 @@ export default {
</script>
<style scoped>
#hall .cell-content {
.card-wrapper {
height: 100%;
display: flex;
flex-wrap: wrap;
}
#hall .cell-content {
justify-content: space-around;
align-items: center;
}
#hall .cell-content .card-item {
.card-item {
width: 45%;
height: 45%;
background-color: #e6e8ef;
......
<template>
<div class="home-cell" id="noticeAnnouncement">
<CellHeaderVue title="通知公告">
<CellWrapper title="通知公告" :cellContentHeight="cellContentHeight">
<template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span>
</CellHeaderVue>
</template>
<el-scrollbar :style="{ height: cellScrollHeight + 'px' }">
<div class="cell-content">
<div class="notice-container">
<el-scrollbar style="height: 100%;">
<div class="notice-item" v-for="(item, idx) in noticeList" :key="idx">
<div class="notice-title" :class="{ active: idx === 0 }">
<a :href="item.url" target="_blank" rel="noopener noreferrer">
......@@ -17,26 +17,22 @@
{{ item.date }}
</div>
</div>
</div>
</el-scrollbar>
</div>
</el-scrollbar>
</div>
</CellWrapper>
</template>
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import CellWrapper from "../common/CellWrapper.vue";
export default {
name: "NoticeAnnouncement",
components: { CellHeaderVue },
props: {
cellScrollHeight: {
type: Number,
required: true,
},
},
props: ['cellContentHeight'],
components: { CellWrapper },
data() {
return {
noticeList: [
noticeList: [],
testData: [
{
title: "中国国际货物和服务贸易数据(BPM6,2015年以后)",
url: "https://www.safe.gov.cn/safe/2018/0427/8886.html",
......@@ -102,40 +98,67 @@ export default {
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",
},
{
title: "现行有效外汇管理主要法规目录(截至2021年6月30日)...",
url: "https://www.safe.gov.cn/safe/2021/0720/19437.html",
date: "2021-07-20",
},
],
};
},
mounted() {
this.$nextTick(() => {
this.loadNoticeData();
});
},
methods: {
loadNoticeData() {
// 查询加载数据
this.noticeList = this.testData;
},
},
};
</script>
<style scoped>
/* 通知公告 */
#noticeAnnouncement .cell-content {
.notice-container {
height: 100%;
margin: 0 20px;
box-sizing: border-box;
}
#noticeAnnouncement .cell-content .notice-item {
.notice-item {
width: 100%;
display: flex;
justify-content: space-between;
margin-bottom: 5px;
font-size: 15px;
}
#noticeAnnouncement .cell-content .notice-item .notice-title {
.notice-item .notice-title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 75%;
}
#noticeAnnouncement .cell-content .notice-item .notice-title a {
.notice-item .notice-title a {
color: #4e4e4e;
text-decoration: none;
}
#noticeAnnouncement .cell-content .notice-item .notice-title::before {
.notice-item .notice-title::before {
content: "";
display: inline-block;
width: 8px;
}
#noticeAnnouncement .cell-content .notice-item .notice-title.active::before {
.notice-item .notice-title.active::before {
content: "";
background: rgb(255, 0, 0);
display: inline-block;
......@@ -146,7 +169,7 @@ export default {
margin-right: 2px;
margin-bottom: 2px;
}
#noticeAnnouncement .cell-content .notice-item .notice-date {
.notice-item .notice-date {
/* width: 20%; */
margin-right: 6px;
}
......
<template>
<div class="home-cell" id="quickSearch">
<CellHeaderVue title="快速查询">
<CellWrapper title="快速查询" :cellContentHeight="cellContentHeight">
<template v-slot:header>
<span class="el-icon-setting" title="设置" @click="openSetting"></span>
</CellHeaderVue>
</template>
<quick
ref="quick"
:cellScrollHeight="cellScrollHeight"
quickType="search"
:cellContentHeight="cellContentHeight"
></quick>
</div>
</CellWrapper>
</template>
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import quick from "./common/quick.vue";
import CellWrapper from "../common/CellWrapper.vue";
import quick from "../common/quick.vue";
import defaultQuickSearchItems from "./common/defaultQuickSearchItems.js";
import defaultQuickSearchItems from "../common/defaultQuickSearchItems.js";
export default {
name: "QuickSearch",
components: { CellHeaderVue, quick },
components: { CellWrapper, quick },
props: {
cellScrollHeight: {
cellContentHeight: {
type: Number,
required: true,
},
......
<template>
<div class="home-cell" id="quickVisit">
<CellHeaderVue title="快速访问">
<CellWrapper title="快速访问" :cellContentHeight="cellContentHeight">
<template v-slot:header>
<span class="el-icon-setting" title="设置" @click="openSetting"></span>
</CellHeaderVue>
</template>
<quick
ref="quick"
:cellScrollHeight="cellScrollHeight"
quickType="visit"
:cellContentHeight="cellContentHeight"
></quick>
</div>
</CellWrapper>
</template>
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import quick from "./common/quick.vue";
import CellWrapper from "../common/CellWrapper.vue";
import quick from "../common/quick.vue";
import defaultVisitItems from "./common/defaultQuickVisitItems.js";
import defaultVisitItems from "../common/defaultQuickVisitItems.js";
export default {
name: "QuickVisit",
components: { CellHeaderVue, quick },
components: { CellWrapper, quick },
props: {
cellScrollHeight: {
cellContentHeight: {
type: Number,
required: true,
},
......
<template>
<div class="home-cell">
<CellHeaderVue title="任务统计">
<CellWrapper title="任务统计" :cellContentHeight="cellContentHeight">
<template v-slot:header>
<span class="el-icon-refresh" title="刷新"></span>
<span class="el-icon-more" title="操作"></span>
</CellHeaderVue>
<div class="cell-content">
<!-- <span class="el-icon-more" title="操作"></span> -->
</template>
<div class="statistics-container">
<div class="task-stat-display total">
<div class="display-wrapper">
<div
......@@ -13,7 +14,7 @@
:key="idx"
:style="{ width: item.name === '来报待处理' ? '20%' : 'unset' }"
>
<div class="stat-name">{{ item.name }}</div>
<div class="stat-name" @click="goToTaskPage(item.name)">{{ item.name }}</div>
<div class="stat-count">{{ item.count }}</div>
</div>
</div>
......@@ -25,7 +26,7 @@
<div class="task-stat-display mime">
<div class="display-wrapper">
<div class="stat-item" v-for="(item, idx) in mime" :key="idx">
<div class="stat-name">{{ item.name }}</div>
<div class="stat-name" @click="goToTaskPage(item.name)">{{ item.name }}</div>
<div class="stat-count">{{ item.count }}</div>
</div>
</div>
......@@ -37,67 +38,93 @@
<div class="task-stat-display pty">
<div class="display-wrapper">
<div class="stat-item" v-for="(item, idx) in pty" :key="idx">
<div class="stat-name">{{ item.name }}</div>
<div class="stat-name" @click="goToTaskPage(item.name)">{{ item.name }}</div>
<div class="stat-count">{{ item.count }}</div>
</div>
</div>
</div>
</div>
</div>
</CellWrapper>
</template>
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import { all } from "~/service/report";
import CellHeader from "../common/CellHeader.vue";
import CellWrapper from "../common/CellWrapper.vue";
import { all,my,ins } from "~/service/report";
export default {
name: "TaskStatistics",
components: { CellHeaderVue },
props: ["cellContentHeight"],
components: { CellWrapper },
data() {
return {
total: [
{ name: "待经办", count: "5454" },
{ name: "来报待处理", count: "4231" },
{ name: "待复核", count: "652" },
{ name: "待授权", count: "2" },
{ name: "待匹配", count: "5" },
{ name: "待打印", count: "1235" },
// { name: "待经办", count: "5454" },
// { name: "来报待处理", count: "4231" },
// { name: "待复核", count: "652" },
// { name: "待授权", count: "2" },
// { name: "待匹配", count: "5" },
// { name: "待打印", count: "1235" },
],
mime: [
{ name: "待经办", count: "154" },
{ name: "待修改", count: "1254" },
{ name: "待复核", count: "5" },
{ name: "待授权", count: "0" },
{ name: "待回复", count: "0" },
{ name: "待打印", count: "4564" },
{ name: "已完结", count: "3212" },
// { name: "待经办", count: "154" },
// { name: "待修改", count: "1254" },
// { name: "待复核", count: "5" },
// { name: "待授权", count: "0" },
// { name: "待回复", count: "0" },
// { name: "待打印", count: "4564" },
// { name: "已完结", count: "3212" },
],
pty: [
{ name: "待经办", count: "1164" },
{ name: "待修改", count: "2341" },
{ name: "待复核", count: "168" },
{ name: "待授权", count: "423" },
{ name: "待打印", count: "6547" },
{ name: "待匹配", count: "23" },
{ name: "已完结", count: "3212" },
],
mapping: {
'待经办': 'sptsel',
'来报待处理': 'sptsel',
'待复核': 'trnrel',
'待授权': 'trnrel',
'待匹配': 'sptsel',
'待打印': 'trnfnd',
'待修改': 'sptsel',
'待回复': '',
'已完结': 'trnfnd',
}
};
},
created() {
all().then(res => {
console.log(res);
this.total=res;
}),
my().then(res =>{
this.mime = res;
}),
ins().then(res =>{
this.pty = res;
})
},
//点击对应的文字 跳转
methods: {
goToTaskPage(name) {
if(!this.mapping[name]) {
return;
}
this.$router.push('/taskList').then(() => {
this.$store.commit('setTaskListTabVal', this.mapping[name])
})
}
}
};
</script>
<style scoped>
.cell-content {
.statistics-container {
height: 100%;
padding: 0px 8px;
}
.task-stat-display {
height: 25%;
max-height: 90px;
/* max-height: 90px; */
display: flex;
justify-content: space-around;
color: #f3f3f3;
......@@ -156,6 +183,7 @@ export default {
justify-content: center;
align-items: center;
border-right: 1px solid;
cursor: pointer;
}
.task-stat-display.total .display-wrapper .stat-item:last-child .stat-count {
border-right: 0;
......@@ -176,7 +204,7 @@ export default {
border-right: 0;
}
.task-sign {
height: 12%;
height: 12.5%;
display: flex;
align-items: center;
padding-left: 15px;
......
......@@ -9,12 +9,7 @@
<script>
export default {
props: {
title: {
type: String,
required: true,
},
},
props: ['title'],
};
</script>
......
<template>
<div class="home-cell">
<CellHeader :title="title">
<slot name="header"></slot>
</CellHeader>
<div class="cell-content" :style="{ height: cellContentHeight + 'px' }">
<slot></slot>
</div>
</div>
</template>
<script>
import CellHeader from "./CellHeader.vue";
export default {
name: "CellWrapper",
components: { CellHeader },
props: {
title: {
type: String,
required: true,
},
cellContentHeight: {
type: Number,
required: true,
},
},
data() {
return {};
},
};
</script>
<style scoped>
.home-cell {
background-color: #ffffff;
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
border-radius: 8px;
padding-bottom: 10px;
}
.home-cell::before {
display: table;
content: "";
}
.home-cell >>> .el-scrollbar__wrap {
overflow-y: scroll;
overflow-x: auto;
}
</style>
\ No newline at end of file
<template>
<el-scrollbar :style="{ height: cellScrollHeight + 'px' }">
<div class="cell-content">
<router-link
v-for="(item, index) in quickVisitItem"
:key="index"
:to="item.path"
>
<div
class="content-wrapper"
:style="{ height: Math.floor(cellScrollHeight * 0.3) + 'px' }"
>
<div class="visit-item-wrapper">
<div class="visit-item">
<img :src="item.icon" alt="" />
<span>{{ item.name }}</span>
</div>
</div>
<el-scrollbar style="height: 100%">
<router-link
v-for="(item, index) in quickVisitItem"
:key="index"
:to="item.path"
>
<div
class="content-wrapper"
:style="{ height: Math.floor(cellContentHeight * 0.33) + 'px' }"
>
<div class="visit-item-wrapper">
<div class="visit-item">
<img :src="item.icon" alt="" />
<span>{{ item.name }}</span>
</div>
</router-link>
</div>
</div>
</router-link>
<el-dialog :visible="visible" title="设置" :before-close="handleClose">
<div style="text-align: center">
<el-transfer
style="text-align: left; display: inline-block"
v-model="selectedVals"
filterable
:titles="['未添加', '已添加']"
:button-texts="['移除', '添加']"
:format="{
noChecked: '${total}',
hasChecked: '${checked}/${total}',
}"
:data="transferData"
>
</el-transfer>
</div>
<span slot="footer" class="dialog-footer">
<c-button @click="cancel">取消</c-button>
<c-button type="primary" @click="save">保存</c-button>
</span>
</el-dialog>
</el-scrollbar>
<el-dialog
:visible="visible"
title="设置"
width="60%"
:before-close="handleClose"
>
<div style="text-align: center">
<el-transfer
style="text-align: left; display: inline-block"
v-model="selectedVals"
filterable
:titles="['未添加', '已添加']"
:button-texts="['移除', '添加']"
:format="{
noChecked: '${total}',
hasChecked: '${checked}/${total}',
}"
:data="transferData"
>
</el-transfer>
</div>
<span slot="footer" class="dialog-footer">
<c-button @click="cancel">取消</c-button>
<c-button type="primary" @click="save">保存</c-button>
</span>
</el-dialog>
</el-scrollbar>
</template>
<script>
......@@ -49,16 +52,16 @@ import icons from "./icons.js";
export default {
props: {
cellScrollHeight: {
type: Number,
quickType: {
type: String,
required: true,
},
quickType: {
type: String,
cellContentHeight: {
type: Number,
required: true,
}
},
},
data() {
data() {
return {
allAvailableItems: [],
quickVisitItem: [],
......@@ -67,11 +70,11 @@ export default {
transferData: [],
};
},
mounted() {
mounted() {
this.$nextTick(() => {
this.init();
this.generateVisitItems(this.getCachedVisitItems());
})
});
},
methods: {
init() {
......@@ -79,27 +82,29 @@ export default {
this.getAllAvailableItems(this.$store.state.UserContext.menu, arr);
this.allAvailableItems = arr;
this.transferData = arr.map((item) => {
const ps = item.path.split("/")
const ps = item.path.split("/");
return {
key: item.path,
label: `${ps[ps.length - 1]} - ${item.name}` ,
label: `${ps[ps.length - 1]} - ${item.name}`,
};
});
},
getCachedVisitItems() {
const userId = this.$store.state.UserContext.userId;
const data = localStorage.getItem(
`quick-${this.quickType}-${userId.toLowerCase() === "zl" ? "admin" : "normal"}`
`quick-${this.quickType}-${this.getUserRole()}`
);
return JSON.parse(data);
},
setCachedVisitItems(data) {
const userId = this.$store.state.UserContext.userId;
localStorage.setItem(
`quick-${this.quickType}-${userId.toLowerCase() === "zl" ? "admin" : "normal"}`,
`quick-${this.quickType}-${this.getUserRole()}`,
JSON.stringify(data)
);
},
getUserRole() {
const userId = this.$store.state.UserContext.userId;
return userId.toLowerCase() === "zl" ? "admin" : "normal";
},
generateVisitItems(keys) {
const res = [];
for (let i = 0; i < keys.length; i++) {
......@@ -144,50 +149,43 @@ export default {
}
},
},
}
};
</script>
<style scoped>
.cell-content {
/* display: flex;
flex-wrap: wrap; */
}
.content-wrapper {
display: inline-block;
width: 33%;
width: 33.33%;
/* height: 30%; */
}
.cell-content .visit-item-wrapper {
.visit-item-wrapper {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
}
.cell-content .visit-item {
.visit-item {
/* padding-bottom: 16px; */
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
}
.cell-content .visit-item i {
.visit-item i {
color: #0088ff;
font-size: 36px;
}
.cell-content .visit-item span {
.visit-item span {
color: #303133;
font-size: 14px;
margin-top: 10px;
}
/* .cell-content .visit-item:hover i {
color: var(--themecolor);
} */
.cell-content .visit-item:hover span {
.visit-item:hover span {
color: var(--themecolor);
}
.el-scrollbar >>> .el-transfer-panel {
width: 300px;
height: 600px;
height: 400px;
}
.el-scrollbar >>> .el-checkbox-group.el-transfer-panel__list {
height: 500px;
......
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: "交易快速查询入口",
},
];
<template>
<div class="eContainer-home">
<QuickVisitVue :cellScrollHeight="cellScrollHeight"></QuickVisitVue>
<TaskStatisticsVue></TaskStatisticsVue>
<NoticeAnnouncementVue :cellScrollHeight="cellScrollHeight" ></NoticeAnnouncementVue>
<HallVue></HallVue>
<CustomerAnalyseVue></CustomerAnalyseVue>
<QuickSearchVue :cellScrollHeight="cellScrollHeight"></QuickSearchVue>
<c-row
:gutter="10"
v-for="cRow in cellRows"
:key="cRow"
>
<c-col
:span="24 / cellCols"
v-for="cCol in cellCols"
:key="cCol"
>
<component
v-if="getComponentName([cRow - 1], [cCol - 1])"
v-bind:is="getComponentName([cRow - 1], [cCol - 1])"
:cellContentHeight="cellContentHeight"
></component>
</c-col>
</c-row>
</div>
</template>
<script>
import QuickVisitVue from "./cells/QuickVisit.vue";
import TaskStatisticsVue from "./cells/TaskStatistics.vue";
import NoticeAnnouncementVue from "./cells/NoticeAnnouncement.vue";
import HallVue from "./cells/Hall.vue";
import CustomerAnalyseVue from "./cells/CustomerAnalyse.vue";
import QuickSearchVue from "./cells/QuickSearch.vue";
import { createNamespacedHelpers } from "vuex";
const { mapState } = createNamespacedHelpers("UserContext");
import QuickVisit from "./cells/QuickVisit.vue";
import TaskStatistics from "./cells/TaskStatistics.vue";
import NoticeAnnouncement from "./cells/NoticeAnnouncement.vue";
import Hall from "./cells/Hall.vue";
import CustomerAnalyse from "./cells/CustomerAnalyse.vue";
import QuickSearch from "./cells/QuickSearch.vue";
import { cellDataDefinition } from "./config";
export default {
name: "Home",
components: {
QuickVisitVue,
TaskStatisticsVue,
NoticeAnnouncementVue,
HallVue,
CustomerAnalyseVue,
QuickSearchVue,
},
mounted() {
this.calcCellScrollHeight();
this.calcCellScrollHeightBind = this.calcCellScrollHeight.bind(this);
window.addEventListener("resize", this.calcCellScrollHeightBind);
QuickVisit,
TaskStatistics,
NoticeAnnouncement,
Hall,
CustomerAnalyse,
QuickSearch,
},
data() {
return {
cellScrollHeight: 0,
cellContentHeight: 0,
};
},
created() {
this.loadCellData();
},
mounted() {
this.calcCellContentHeight();
this.calcCellContentHeightBind = this.calcCellContentHeight.bind(this);
window.addEventListener("resize", this.calcCellContentHeightBind);
},
computed: {
...mapState({
cellRows: (state) => state.homeCellsSetting.cellRows,
cellCols: (state) => state.homeCellsSetting.cellCols,
cellNames: (state) => state.homeCellsSetting.cellNames,
}),
},
watch: {
cellRows(newVal, oldVal) {
this.calcCellContentHeight()
},
},
methods: {
calcCellScrollHeight() {
this.cellScrollHeight = this.$el.clientHeight * 0.49 - 52;
loadCellData() {
this.$store.commit(
"UserContext/setHomeDefaultCells",
cellDataDefinition
);
let cellsSettingDefault = localStorage.getItem("cells-setting-default");
if (!cellsSettingDefault) {
const rows = 2;
const cols = 3;
localStorage.setItem(
"cells-setting-default",
JSON.stringify({
cellRows: rows,
cellCols: cols,
cellNames: this.generateRowColNames(
rows,
cols,
cellDataDefinition.map((definition) => definition.name)
),
})
);
}
let userCellsSetting = localStorage.getItem(
`cells-setting-${this.$store.state.UserContext.userId}`
);
if (!userCellsSetting) {
userCellsSetting = localStorage.getItem("cells-setting-default");
}
this.$store.commit(
"UserContext/setHomeCellsSetting",
JSON.parse(userCellsSetting)
);
},
generateRowColNames(rows, cols, cells) {
const rArr = [];
for (let i = 0; i < rows; i++) {
const cArr = [];
for (let j = 0; j < cols; j++) {
cArr.push(cells[i * cols + j]);
}
rArr.push(cArr);
}
return rArr;
},
getComponentName(rowIdx, colIdx) {
return this.cellNames[rowIdx] ? this.cellNames[rowIdx][colIdx] : null;
},
calcCellContentHeight() {
this.cellContentHeight = this.$el.clientHeight * this.getRowHeightPercent() - 52 - 10
},
getRowHeightPercent() {
// 每行预留 0.4% 的间距
return 1 / this.cellRows - 0.004 * this.cellRows;
},
},
destroyed() {
window.removeEventListener("resize", this.calcCellScrollHeightBind);
window.removeEventListener("resize", this.calcCellContentHeightBind);
},
};
</script>
......@@ -52,26 +134,7 @@ export default {
.eContainer-home {
height: 100%;
display: flex;
flex-wrap: wrap;
/* justify-content: space-around; */
align-items: center;
}
.home-cell {
width: 33%;
height: 49%;
margin-left: 0.166%;
margin-right: 0.166%;
background-color: #ffffff;
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
border-radius: 8px;
}
.home-cell >>> .cell-content {
/* max-height: calc(100% - 52px); */
height: calc(100% - 52px);
overflow: auto;
}
.home-cell >>> .el-scrollbar__wrap {
overflow-y: scroll;
overflow-x: auto;
flex-direction: column;
justify-content: space-around;
}
</style>
......@@ -42,6 +42,12 @@
>修改密码</el-button
>
<el-button
@click="showHomeCellSettingDialog"
size="small"
style="width:100%;margin-left:0px;margin-top:5px"
>首页组件</el-button
>
<el-button
@click="showLogoutDialog(false)"
size="small"
style="width:100%;margin-left:0px;margin-top:5px"
......@@ -117,6 +123,65 @@
</el-popover>
<span class="header-tool-item-text">会计日期: {{ accDate }}</span>
</div>
<el-dialog custom-class="homeSetting"
:visible="homeSettingDialog"
title="首页小组件设置"
width="60%"
:before-close="handleCloseHomeSettingDialog"
>
<div style="padding: 0 20px;">
<div class="clear">
<c-col :span="24" style="margin-bottom: 10px;">
选择行数:
<c-select v-model="homeSetting.rows" :clearable="false" @change="updateDisplayArr">
<el-option label="1" :value="1"></el-option>
<el-option label="2" :value="2"></el-option>
<el-option label="3" :value="3"></el-option>
</c-select>
</c-col>
<c-col :span="24" style="margin-bottom: 10px;">
选择列数:
<c-select v-model="homeSetting.cols" :clearable="false" @change="updateDisplayArr">
<el-option label="1" :value="1"></el-option>
<el-option label="2" :value="2"></el-option>
<el-option label="3" :value="3"></el-option>
<el-option label="4" :value="4"></el-option>
</c-select>
</c-col>
</div>
<div>
<div class="setting-grid-row" v-for="row in getCellRows()" :key="row">
<div class="setting-grid-col" v-for="col in getCellCols()" :key="col" :style="{ width: 100 / getCellCols() + '%', height: '50px'}">
<div class="cell-item">
<div>{{ homeSetting.displayArray[row - 1][col - 1].title ? '标题:' + homeSetting.displayArray[row - 1][col - 1].title : '' }}</div>
<div>{{ homeSetting.displayArray[row - 1][col - 1].description ? '描述:' + homeSetting.displayArray[row - 1][col - 1].description : '' }}</div>
</div>
<div class="cell-operate">
<el-dropdown trigger="click">
<span class="el-dropdown-link">
设置&nbsp;&nbsp;<i class="el-icon-edit"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="(item,idx) in $store.state.UserContext.homeCellsSetting.defaultCells"
:key="idx"
@click.native="setCell(row, col, item)"
>
{{ item.title }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</div>
</div>
</div>
<span slot="footer" class="dialog-footer">
<c-button @click="cancelHomeSetting">取消</c-button>
<c-button type="primary" @click="saveHomeSetting">保存</c-button>
</span>
</el-dialog>
</div>
</template>
......@@ -152,6 +217,12 @@ export default {
{ lang: "th", shortName: "ไทย", fullName: "ภาษาไทย" },
{ lang: "vi", shortName: "Tiếng Việt", fullName: "Tiếng Việt" },
],
homeSettingDialog: false,
homeSetting: {
rows: null,
cols: null,
displayArray: []
}
};
},
computed: {
......@@ -198,6 +269,68 @@ export default {
showChgPwdDialog() {
this.$refs["chgPwdForm"].dialogOpen = true;
},
showHomeCellSettingDialog() {
this.homeSettingDialog = true;
this.homeSetting.rows = this.$store.state.UserContext.homeCellsSetting.cellRows
this.homeSetting.cols = this.$store.state.UserContext.homeCellsSetting.cellCols
this.homeSetting.displayArray = this.$store.state.UserContext.homeCellsSetting.cellNames.map(cellNameRows => {
return cellNameRows.map(cellName => {
return Object.assign({}, this.$store.state.UserContext.homeCellsSetting.defaultCells.find(cell => cell.name === cellName))
})
})
},
saveHomeSetting() {
if (!this.homeSetting.rows || !this.homeSetting.cols) {
this.$message.warning('请选择正确的行列数!')
return
}
const cellNames = this.homeSetting.displayArray.map(row => {
return row.map(col => col.name)
})
if (cellNames.some(row => row.some(cellName => !cellName))) {
this.$message.warning('请配置全部的格子组件!')
return
}
this.$store.commit('UserContext/setHomeCellsSetting', {
cellRows: this.homeSetting.rows,
cellCols: this.homeSetting.cols,
cellNames: cellNames
})
this.homeSettingDialog = false;
},
cancelHomeSetting() {
this.homeSettingDialog = false;
},
handleCloseHomeSettingDialog(done) {
this.homeSettingDialog = false;
done();
},
getCellRows() {
return this.homeSetting.rows ? this.homeSetting.rows : this.homeSetting.cols ? 1 : 0
},
getCellCols() {
return this.homeSetting.cols ? this.homeSetting.cols : this.homeSetting.rows ? 1 : 0
},
updateDisplayArr() {
const rArr = []
for (let i = 0; i < this.getCellRows(); i++) {
const cArr = []
for (let j = 0; j < this.getCellCols(); j++) {
cArr.push({
title: null,
name: null,
description: null
})
}
rArr.push(cArr)
}
this.homeSetting.displayArray = rArr
},
setCell(row, col, item) {
this.homeSetting.displayArray[row - 1][col - 1].title = item.title
this.homeSetting.displayArray[row - 1][col - 1].name = item.name
this.homeSetting.displayArray[row - 1][col - 1].description = item.description
}
},
};
</script>
......@@ -334,4 +467,38 @@ export default {
.long-text:hover {
background-color: #e8f0fe;
}
/* 首页设置框 */
.homeSetting .setting-grid-row {
width: 100%;
display: flex;
border-bottom: 1px solid #ebebeb;
}
.homeSetting .setting-grid-row:nth-of-type(1) {
border-top: 1px solid #ebebeb;
}
.homeSetting .setting-grid-col {
display: flex;
border-right: 1px solid #ebebeb;
}
.homeSetting .setting-grid-row .setting-grid-col:nth-of-type(1) {
border-left: 1px solid #ebebeb;
}
.homeSetting .setting-grid-col .cell-item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
margin-left: 15px;
}
.homeSetting .setting-grid-col .cell-operate {
font-size: 24px;
margin: 0 10px;
display: flex;
justify-content: center;
align-items: center;
}
.homeSetting .setting-grid-col .cell-operate .el-dropdown-link {
cursor: pointer;
color: #409EFF;
}
</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