From 2a7203b9a506314e86ee02e91af88f4eff8d59d9 Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Thu, 20 Mar 2025 15:42:07 +0800 Subject: [PATCH] init --- src/api/user/user.js | 9 + src/components/XyTinymce/index.vue | 7 +- src/views/Recommend/Recommend.vue | 83 +++++++-- .../Recommend/components/AddRecommend.vue | 107 ++++++++--- .../Recommend/components/ShowRecommend.vue | 36 +++- src/views/RecommendForm/RecommendForm.vue | 28 ++- .../components/AddRecommendForm.vue | 28 ++- src/views/School/School.vue | 48 ++--- src/views/School/components/AddSchool.vue | 24 +-- src/views/dashboard/components/BarChart.vue | 176 +++++++++--------- src/views/dashboard/components/Card1.vue | 99 +++++++++- src/views/dashboard/components/Card2.vue | 99 +++++++++- src/views/dashboard/components/VisitPanel.vue | 117 ++++++++++++ src/views/dashboard/index.scss | 7 + src/views/dashboard/index.vue | 47 ++++- 15 files changed, 718 insertions(+), 197 deletions(-) create mode 100644 src/views/dashboard/components/VisitPanel.vue create mode 100644 src/views/dashboard/index.scss diff --git a/src/api/user/user.js b/src/api/user/user.js index 65e9664..08c9643 100644 --- a/src/api/user/user.js +++ b/src/api/user/user.js @@ -44,3 +44,12 @@ export function chart(params, isLoading = true) { isLoading: true }) } + +export function home(params,isLoading = true) { + return request({ + method: 'get', + url: '/api/admin/user/home', + params, + isLoading: true + }) +} diff --git a/src/components/XyTinymce/index.vue b/src/components/XyTinymce/index.vue index 72b8196..bff6169 100644 --- a/src/components/XyTinymce/index.vue +++ b/src/components/XyTinymce/index.vue @@ -113,8 +113,11 @@ tinymce.init({}); }, watch: { - value(newValue) { - this.myValue = newValue; + value: { + handler: function (newValue) { + this.myValue = newValue; + }, + immediate: true }, myValue(newValue) { this.$emit("input", newValue); diff --git a/src/views/Recommend/Recommend.vue b/src/views/Recommend/Recommend.vue index 2f0aeea..0f1b6fe 100644 --- a/src/views/Recommend/Recommend.vue +++ b/src/views/Recommend/Recommend.vue @@ -28,7 +28,7 @@ type="primary" plain size="small" - @click="getList(true)" + @click="getList" >搜索 @@ -121,19 +121,57 @@ /> + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + - - + > @@ -114,7 +159,17 @@ export default { school_way: "", - user_way: "", + chong_max: "", + + chong_min: "", + + bao_max: "", + + bao_min: "", + + wen_max: "", + + wen_min: "", }, rules: { school_way: [ @@ -194,7 +249,17 @@ export default { school_way: "", - user_way: "", + chong_max: "", + + chong_min: "", + + bao_max: "", + + bao_min: "", + + wen_max: "", + + wen_min: "", }; this.$refs["elForm"].resetFields(); }, diff --git a/src/views/Recommend/components/ShowRecommend.vue b/src/views/Recommend/components/ShowRecommend.vue index 34253ae..36d5326 100644 --- a/src/views/Recommend/components/ShowRecommend.vue +++ b/src/views/Recommend/components/ShowRecommend.vue @@ -23,8 +23,28 @@ {{ typeof form['school_way'] === 'number' ? form['school_way'].toFixed(2) : form['school_way'] }} - - {{ [{'value':1,'label':'裸分'},{'value':2,'label':'总分'}].find(i => i['value'] === form['user_way']) ? [{'value':1,'label':'裸分'},{'value':2,'label':'总分'}].find(i => i['value'] === form['user_way'])['label'] : '' }} + + {{ typeof form['chong_max'] === 'number' ? form['chong_max'].toFixed(2) : form['chong_max'] }} + + + + {{ typeof form['chong_min'] === 'number' ? form['chong_min'].toFixed(2) : form['chong_min'] }} + + + + {{ typeof form['bao_max'] === 'number' ? form['bao_max'].toFixed(2) : form['bao_max'] }} + + + + {{ typeof form['bao_min'] === 'number' ? form['bao_min'].toFixed(2) : form['bao_min'] }} + + + + {{ typeof form['wen_max'] === 'number' ? form['wen_max'].toFixed(2) : form['wen_max'] }} + + + + {{ typeof form['wen_min'] === 'number' ? form['wen_min'].toFixed(2) : form['wen_min'] }} @@ -58,7 +78,17 @@ school_way: '', - user_way: '', + chong_max: '', + + chong_min: '', + + bao_max: '', + + bao_min: '', + + wen_max: '', + + wen_min: '', }, } diff --git a/src/views/RecommendForm/RecommendForm.vue b/src/views/RecommendForm/RecommendForm.vue index 004efa8..edd0cd0 100644 --- a/src/views/RecommendForm/RecommendForm.vue +++ b/src/views/RecommendForm/RecommendForm.vue @@ -179,6 +179,24 @@ :edit-render="{ name: 'input', attrs: { type: 'number' } }" /> + + + + + + + + + + + + @@ -370,6 +362,7 @@ import axios from "axios"; import { getToken } from "@/utils/auth"; import { download } from "@/utils/downloadRequest" import { index as areaIndex } from "@/api/area/area"; +import { getparameter } from "@/api/system/dictionary" export default { name: "School", @@ -403,32 +396,26 @@ export default { 'filter[2][key]': 'star', 'filter[2][op]': 'like', 'filter[2][value]': '', + 'filter[3][key]': 'from', + 'filter[3][op]': 'eq', + 'filter[3][value]': '', }, total: 0, allAlign: null, tableData: [], form: { id: "", - name: "", - area_id: "", - code: "", - star: "", - address: "", - nature: "", - type: "", - build_year: "", - introduce: "", - teacher: "", + from: 1 }, validRules: { name: [ @@ -447,6 +434,7 @@ export default { }, area: [], + schoolType: [], }; }, computed: { @@ -464,8 +452,10 @@ export default { }, }, created() { + console.log(this.$route) + this.select['filter[3][value]'] = this.$route.meta?.params?.from this.getArea(); - + this.getSchoolType(); this.getList(); }, mounted() { @@ -551,6 +541,22 @@ export default { console.error(err); } }, + async getSchoolType() { + try { + const { detail } = await getparameter( + { + number: 'school_type' + }, + false + ); + this.schoolType = detail?.map(i => ({ + value: i.value, + label: i.value + })); + } catch (err) { + console.error(err); + } + }, uploadMethod(file) { const formData = new FormData(); diff --git a/src/views/School/components/AddSchool.vue b/src/views/School/components/AddSchool.vue index 1f4c318..f500fbe 100644 --- a/src/views/School/components/AddSchool.vue +++ b/src/views/School/components/AddSchool.vue @@ -100,16 +100,7 @@ style="width: 100%" > - + - + [], }, + schoolType: { + type: Array, + default: () => [], + } }, data() { return { + key: 0, uploadSize, action: process.env.VUE_APP_UPLOAD_API, loading: false, @@ -224,6 +222,7 @@ export default { }, watch: { isShow(newVal) { + ++this.key; this.visible = newVal; }, visible(newVal) { @@ -305,6 +304,7 @@ export default { if (valid) { this.loading = true; try { + this.form.from = this.$route.meta?.params?.from; await save(this.form); this.$message.success("新增成功"); this.$emit("refresh"); diff --git a/src/views/dashboard/components/BarChart.vue b/src/views/dashboard/components/BarChart.vue index 6eab820..c0cf067 100644 --- a/src/views/dashboard/components/BarChart.vue +++ b/src/views/dashboard/components/BarChart.vue @@ -9,9 +9,9 @@ import resize from './mixins/resize' const animationDuration = 6000 - export default { mixins: [resize], + inject: ['statictis'], props: { className: { type: String, @@ -24,9 +24,6 @@ height: { type: String, default: '500px' - }, - chartData: { - type: Object } }, data() { @@ -34,19 +31,16 @@ chart: null } }, + computed: { + myData() { + return this.statictis().list ?? [] + } + }, mounted() { this.$nextTick(() => { this.initChart() }) }, - watch: { - chartData: { - deep: true, - handler(val) { - this.setOptions(val) - } - } - }, beforeDestroy() { if (!this.chart) { return @@ -54,92 +48,104 @@ this.chart.dispose() this.chart = null }, + watch: { + myData: { + handler(newVal) { + if (newVal && this.chart) { + this.$nextTick(_ => { + this.setOptions() + }) + } + }, + immediate: true + } + }, methods: { initChart() { this.chart = echarts.init(this.$el, 'macarons'); - this.setOptions(this.chartData); + this.setOptions(); }, - setOptions(chartdata) { - console.log(chartdata.xArr) + setOptions() { + const containerWidth = this.chart.getWidth(); + const gridLeft = containerWidth * 0.04; // 对应grid的left: '3%' + const gridRight = containerWidth * 0.01; // 对应grid的right: '4%' + const rectWidth = containerWidth - gridLeft - gridRight; this.chart.setOption({ - dataZoom: [ - //给x轴设置滚动条 - { - startValue: 0, - endValue: 6, // 显示条数 - type: 'slider', - show: true, - xAxisIndex: [0], - handleSize: 0, //滑动条的 左右2个滑动条的大小 - height: 8, //组件高度 - left: 50, //左边的距离 - right: 40, //右边的距离 - bottom: 26, //右边的距离 - handleColor: '#EFEFEF', //h滑动图标的颜色 - handleStyle: { - borderColor: '#409EFF', - borderWidth: '1', - shadowBlur: 2, - background: '#EFEFEF', - shadowColor: '#EFEFEF' - }, - fillerColor: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ - //给颜色设置渐变色 前面4个参数,给第一个设置1,第四个设置0 ,就是水平渐变 - //给第一个设置0,第四个设置1,就是垂直渐变 - offset: 0, - color: '#409EFF' - }, - { - offset: 1, - color: '#409EFF' - } - ]), - backgroundColor: '#EFEFEF', //两边未选中的滑动条区域的颜色 - showDataShadow: false, //是否显示数据阴影 默认auto - showDetail: false, //即拖拽时候是否显示详细数值信息 默认true - handleIcon: 'M-292,322.2c-3.2,0-6.4-0.6-9.3-1.9c-2.9-1.2-5.4-2.9-7.6-5.1s-3.9-4.8-5.1-7.6c-1.3-3-1.9-6.1-1.9-9.3c0-3.2,0.6-6.4,1.9-9.3c1.2-2.9,2.9-5.4,5.1-7.6s4.8-3.9,7.6-5.1c3-1.3,6.1-1.9,9.3-1.9c3.2,0,6.4,0.6,9.3,1.9c2.9,1.2,5.4,2.9,7.6,5.1s3.9,4.8,5.1,7.6c1.3,3,1.9,6.1,1.9,9.3c0,3.2-0.6,6.4-1.9,9.3c-1.2,2.9-2.9,5.4-5.1,7.6s-4.8,3.9-7.6,5.1C-285.6,321.5-288.8,322.2-292,322.2z', - filterMode: 'filter' + title: { + text: '趋势', + left: 'left', + textStyle: { + color: "#000", } - //下面这个属性是里面拖到 - // { - // type: 'inside', - // show: true, - // xAxisIndex: [0], - // start: 0, //默认为1 - // end: 50, - // }, - ], + }, grid: { - top: 10, - left: '2%', - right: '2%', - bottom: '3%', - containLabel: true + left: '4%', + right: '1%', }, - xAxis: [{ - type: 'category', - data: chartdata.xArr, - axisTick: { - alignWithLabel: true - } - }], - yAxis: [{ - type: 'value', - minInterval: 1, + tooltip: { + show: true + }, + legend: { + show: true + }, + xAxis: { + axisLabel: { + color: '#000', + fontSize: '16', + margin: 18 + }, + axisLine: { + show: false + }, axisTick: { show: false + }, + data: this.myData?.map(i => i.month ? this.$moment(i.month).format('MM月') : i.month) + }, + yAxis: { + type: 'value', + axisLabel: { + color: '#1c1a1d' + }, + axisLine: { //轴线 + show: true, + lineStyle: { + color: "transparent" + } + }, + splitLine: { //网格线 + show: true + } + }, + series: [ + { + barWidth: 30, + type: 'bar', + name: '填报数量', + itemStyle: { + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 1, color: '#155ce0' }, + { offset: 0.2, color: '#155ce0' }, + { offset: 0, color: '#0093dd' } + ]), + barBorderRadius: [8, 8, 0, 0] + }, + data: this.myData?.map(i => i.total) } - }], - series: [{ - name: '数据', - type: 'bar', - stack: 'vistors', - barWidth: '60%', - data: chartdata.yArr, - animationDuration + ], + graphic: [ { + type: "rect", + bottom: '3%', + left: '4%', + shape: { + width: rectWidth, + height: 50 + }, + style: { + fill: "#eaeff3" + }, }] }) - } } } diff --git a/src/views/dashboard/components/Card1.vue b/src/views/dashboard/components/Card1.vue index ca33803..f1a619d 100644 --- a/src/views/dashboard/components/Card1.vue +++ b/src/views/dashboard/components/Card1.vue @@ -2,22 +2,22 @@ - + 访客量 - 描述文字 + 访客量 - 2000 - 今日访客 + {{ myData.todayVisitCount | resolveData }} + 今日访客 - 100000 - 总计访客 + {{ myData.totalVisitCount | resolveData }} + 总计访客 @@ -25,19 +25,102 @@ diff --git a/src/views/dashboard/components/Card2.vue b/src/views/dashboard/components/Card2.vue index f099e36..65b5a72 100644 --- a/src/views/dashboard/components/Card2.vue +++ b/src/views/dashboard/components/Card2.vue @@ -2,22 +2,22 @@ - + 填报量 - 描述文字 + 填报量 - 2000 - 今日填报 + {{ myData.todayFillCount | resolveData }} + 今日填报 - 100000 - 总计填报 + {{ myData.totalFillCount | resolveData }} + 总计填报 @@ -25,19 +25,102 @@ diff --git a/src/views/dashboard/components/VisitPanel.vue b/src/views/dashboard/components/VisitPanel.vue new file mode 100644 index 0000000..51b6874 --- /dev/null +++ b/src/views/dashboard/components/VisitPanel.vue @@ -0,0 +1,117 @@ + + + + + + + + + + 访问量 + + + + + + + + + + + + diff --git a/src/views/dashboard/index.scss b/src/views/dashboard/index.scss new file mode 100644 index 0000000..eb05398 --- /dev/null +++ b/src/views/dashboard/index.scss @@ -0,0 +1,7 @@ +// 将px转换为vw的混入函数 +@function px2vw($px) { + @return ($px / 1668) * 100vw; +} +@function px2vh($px) { + @return ($px / 1066) * 100vh; +} diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 06f2001..b364c9f 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,8 +1,9 @@ - + + @@ -10,17 +11,45 @@