diff --git a/src/api/dashboard/notice.js b/src/api/dashboard/notice.js index ab5350d..ca89170 100644 --- a/src/api/dashboard/notice.js +++ b/src/api/dashboard/notice.js @@ -26,10 +26,26 @@ export function readNotice(params){ }) } -export function statistic(params,noLoading = false){ +export function statisticProgress(params,noLoading = false){ return request({ method:'get', - url:'/api/ht/notice/statistic', + url:'/api/ht/notice/statistic-progress', + params, + noLoading + }) +} +export function statisticDepartment(params,noLoading = false){ + return request({ + method:'get', + url:'/api/ht/notice/statistic-department', + params, + noLoading + }) +} +export function statisticType(params,noLoading = false){ + return request({ + method:'get', + url:'/api/ht/notice/statistic-type', params, noLoading }) diff --git a/src/components/LxHeader/index.vue b/src/components/LxHeader/index.vue index e1c247c..60a702a 100644 --- a/src/components/LxHeader/index.vue +++ b/src/components/LxHeader/index.vue @@ -66,9 +66,9 @@ // padding-top: 10px; font-weight: bold; font-size: 15px; - color: #338de3; + color: var(--theme-color); white-space: nowrap; - border-bottom: 2px solid #338de3; + border-bottom: 2px solid var(--theme-color); >span { position: relative; diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index e6e83a8..19205fe 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -80,6 +80,7 @@ export default { this.$emit('change', val) Cookies.set('defaultTheme', val) document.body.style.setProperty('--theme-color', val) + this.handleIViewTheme() index++ $message?.close() } @@ -159,6 +160,87 @@ export default { } clusters.push(shadeColor(theme, 0.1)) return clusters + }, + + handleIViewTheme() { + const styleSheets = document.styleSheets; + const lightColor = this.colorUtils(this.theme, 0.2) + + for (let i = 0; i < styleSheets.length; i++) { + const styleSheet = styleSheets[i]; + try { + // 获取样式表中的所有规则 + const rules = styleSheet.cssRules || styleSheet.rules; + + // 遍历每个规则 + for (let j = 0; j < rules.length; j++) { + const rule = rules[j]; + + // 检查规则是否是 .ivu-btn-primary + if(rule.selectorText === '.ivu-btn-ghost.ivu-btn-primary') { + rule.style.color = this.theme; + } + else if (rule.selectorText === '.ivu-btn-ghost.ivu-btn-primary:hover') { + rule.style.color = lightColor; + } + else if(rule.selectorText === '.ivu-page-item-active') { + rule.style.borderColor = this.theme; + } + else if (/^.ivu-.*?-primary$|^.ivu-input-search$/.test(rule.selectorText)) { + // 修改 color 属性 + rule.style.borderColor = this.theme; // 替换为你想要的颜色 + rule.style.backgroundColor = this.theme; + } else if(/^.ivu-.*?-primary(:hover|:focus)$|^.ivu-input-search(:hover|:active)$/.test(rule.selectorText)) { + rule.style.borderColor = lightColor; // 替换为你想要的颜色 + rule.style.backgroundColor = lightColor; + } + } + } catch (e) { + // 某些样式表可能无法访问(例如跨域样式表),需要捕获异常 + console.error(e); + } + } + }, + + colorUtils(color, level) { + function hex2Rgb(str) { + var r = /^#?[0-9a-fA-F]{6}$/; + //test方法检查在字符串中是否存在一个模式,如果存在则返回true,否则返回false + if (!r.test(str)) { + console.log("输入错误的hex") + return + } + //replace替换查找的到的字符串 + str = str.replace("#", ""); + //match得到查询数组 + var hxs = str.match(/../g); + for (var i = 0; i < 3; i++) { + hxs[i] = parseInt(hxs[i], 16); + } + return hxs; + } + function rgb2Hex(a, b, c) { + var r = /^\d{1,3}$/; + if (!r.test(a) || !r.test(b) || !r.test(c)) { + console.log("输入错误的rgb颜色值") + return + } + var hexs = [a.toString(16), b.toString(16), c.toString(16)]; + for (var i = 0; i < 3; i++) { + if (hexs[i].length === 1) hexs[i] = "0" + hexs[i]; + } + return "#" + hexs.join(""); + } + var r = /^#?[0-9a-fA-F]{6}$/; + if (!r.test(color)) { + console.log("输入错误的hex颜色值") + return + } + var rgbc = hex2Rgb(color); + for (var i = 0; i < 3; i++){ + rgbc[i] = Math.floor((255 - rgbc[i]) * level + rgbc[i]); + } + return rgb2Hex(rgbc[0], rgbc[1], rgbc[2]); } } } @@ -179,4 +261,7 @@ export default { .theme-picker-dropdown .el-color-dropdown__link-btn { display: none; } +:root { + --theme-color: #409EFF; +} diff --git a/src/components/XySelectors/index.vue b/src/components/XySelectors/index.vue index c86f362..965fa0c 100644 --- a/src/components/XySelectors/index.vue +++ b/src/components/XySelectors/index.vue @@ -135,7 +135,7 @@ export default { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: none; - box-shadow: 0 2px 10px 1px $primaryColor; + box-shadow: 0 2px 10px 1px var(--theme-color); position: relative; &::after{ @@ -155,8 +155,8 @@ export default { //width: 100%; background: rgba(239,242,250,0.95); border-radius: 0 4px 4px 4px; - border: $primaryColor solid 1px; - box-shadow: 0 4px 10px 1px $primaryColor; + border: var(--theme-color) solid 1px; + box-shadow: 0 4px 10px 1px var(--theme-color); z-index: 4; position: absolute; @@ -174,7 +174,7 @@ export default { padding: 36px 0 44px 8px; &::-webkit-scrollbar-thumb{ - background: $primaryColor; + background: var(--theme-color); } } &-btn{ diff --git a/src/layout/index.vue b/src/layout/index.vue index baf0eb1..d368a01 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -2,11 +2,6 @@
-
- - - -
diff --git a/src/main.js b/src/main.js index 4a92626..90706e5 100644 --- a/src/main.js +++ b/src/main.js @@ -88,7 +88,7 @@ else if(window.top !== window.self) { store, render: h => h(App) }).$mount("#app") - router.push('/') + router.push(getQueryParam('to') || '/') // window._IN_IFRAME = true; // window.addEventListener("message",function (e) { // const { module_name, auth_token } = e.data; diff --git a/src/permission.js b/src/permission.js index ac3a513..410abf6 100644 --- a/src/permission.js +++ b/src/permission.js @@ -19,7 +19,6 @@ router.beforeEach(async(to, from, next) => { // determine whether the user has logged in const hasToken = getToken() - console.log(4444,hasToken) if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page diff --git a/src/views/dashboard/components/carryStatic.vue b/src/views/dashboard/components/carryStatic.vue index b0d198d..3c85614 100644 --- a/src/views/dashboard/components/carryStatic.vue +++ b/src/views/dashboard/components/carryStatic.vue @@ -130,7 +130,7 @@ export default { }, computed: { selectedDepartments () { - return this.departments.filter(i => this.departmentSelect.find(j => j === i.plan_department_id)) + return this.departments?.filter(i => this.departmentSelect.find(j => j === i.plan_department_id)) || [] }, totalMoneyTotal1 () { return this.selectedDepartments.reduce((pre,cur)=>(pre+Number(cur.money_total_1||0)),0) || 0 @@ -150,16 +150,16 @@ export default { }, selectedTypes () { - return this.types.filter(i => this.typeSelect.find(j => j === i.id)) + return this.types?.filter(i => this.typeSelect.find(j => j === i.id)) || [] }, totalMoneyTotal1Type () { - return this.selectedTypes.reduce((pre,cur)=>(pre+Number(cur.money_total_1||0)),0) || 0 + return this.selectedTypes?.reduce((pre,cur)=>(pre+Number(cur.money_total_1||0)),0) || 0 }, totalMoneyTotal2Type () { - return this.selectedTypes.reduce((pre,cur)=>(pre+Number(cur.money_total_2||0)),0) || 0 + return this.selectedTypes?.reduce((pre,cur)=>(pre+Number(cur.money_total_2||0)),0) || 0 }, totalUseMoneyTotalType () { - return this.selectedTypes.reduce((pre,cur)=>(pre+Number(cur.use_money_total||0)),0) || 0 + return this.selectedTypes?.reduce((pre,cur)=>(pre+Number(cur.use_money_total||0)),0) || 0 }, }, watch: { diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 64ad706..0ac12cf 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -312,7 +312,7 @@ import Pagination from "@/components/Pagination"; import PieChart from "./components/PieChart.vue"; import { adminDepartmentList } from '@/api/system/department'; import { adminUserList, getInfo } from '@/api/me'; -import { getNotice, readNotice, statistic, carry } from "@/api/dashboard/notice"; +import { getNotice, readNotice, statisticProgress, statisticDepartment, statisticType, carry } from "@/api/dashboard/notice"; import { parseTime, moneyFormatter } from '@/utils'; import { Message } from "element-ui"; import budgetStatic from '@/views/dashboard/components/budgetStatic.vue' @@ -600,7 +600,7 @@ export default { this.lineChartData = { rotate: 54, - xArr: res?.map(i => i.plan_department?.name), + xArr: res?.map(i => i.plan_department?.name || i.plan_department_id || ' '), series: [ { z: 1, @@ -783,18 +783,21 @@ export default { this.getStatistic(); }, async getStatistic() { - const res = await statistic(this.select); - console.log(res); - this.statistic = res; - let m2 = res.progress.money_total_2; - let m1 = res.progress.money_total_1; - var user_m = res.progress.use_money_total; - var m3=m1-user_m - if (m2 != 0) { - m3=m2-user_m; - } else if (m1 != 0) { - m3=m1-user_m; - } + const resTotal = await Promise.all([statisticProgress(this.select),statisticType(this.select),statisticDepartment(this.select)]); + this.statistic = { + progress: resTotal[0].progress, + departmentList: resTotal[1].departmentList, + typeList: resTotal[2].typeList + }; + let m2 = this.statistic.progress.money_total_2; + let m1 = this.statistic.progress.money_total_1; + var user_m = this.statistic.progress.use_money_total; + var m3=m1-user_m + if (m2 != 0) { + m3=m2-user_m; + } else if (m1 != 0) { + m3=m1-user_m; + } this.rptChartData = { xArr: ["预算未执行金额", "预算已执行金额"], radiusArr: "50%",