修改大屏
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 生产环境配置
|
||||
VITE_API_BASE_URL=https://ad.ningmuyun.com/api/government
|
||||
VITE_API_BASE_URL=https://ad.liaoniuyun.com/api/government
|
||||
VITE_APP_TITLE=政府管理系统
|
||||
VITE_APP_ENV=production
|
||||
@@ -8,17 +8,21 @@
|
||||
@openChange="handleOpenChange"
|
||||
class="sidebar-menu"
|
||||
>
|
||||
<!-- 数据览仓 -->
|
||||
<!-- 数据览仓(已注释) -->
|
||||
<!--
|
||||
<a-menu-item key="/index/data_center">
|
||||
<template #icon><BarChartOutlined /></template>
|
||||
<span>数据览仓</span>
|
||||
</a-menu-item>
|
||||
-->
|
||||
|
||||
<!-- 市场行情 -->
|
||||
<!-- 市场行情(已注释) -->
|
||||
<!--
|
||||
<a-menu-item key="/price/price_list">
|
||||
<template #icon><LineChartOutlined /></template>
|
||||
<span>市场行情</span>
|
||||
</a-menu-item>
|
||||
-->
|
||||
|
||||
<!-- 人员管理 -->
|
||||
<a-sub-menu key="personnel">
|
||||
|
||||
@@ -6,7 +6,7 @@ import axios from 'axios'
|
||||
|
||||
// 创建axios实例
|
||||
const instance = axios.create({
|
||||
baseURL: '/api',
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import axios from 'axios'
|
||||
import api from '@/utils/api-redesigned'
|
||||
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
@@ -155,8 +155,8 @@ const editPositionRules = {
|
||||
// 从API获取部门数据
|
||||
const fetchDepartments = async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/government/departments')
|
||||
departments.value = response.data
|
||||
const response = await api.government.departments.getList()
|
||||
departments.value = response?.data || response
|
||||
} catch (error) {
|
||||
message.error('获取部门数据失败:' + error.message)
|
||||
console.error('获取部门数据失败:', error)
|
||||
@@ -209,7 +209,7 @@ const showSetPermissionModal = (record) => {
|
||||
// 新增部门
|
||||
const handleAddDepartment = async () => {
|
||||
try {
|
||||
await axios.post('/api/government/departments', {
|
||||
await api.government.departments.create({
|
||||
name: addDepartmentFormData.name,
|
||||
description: addDepartmentFormData.description
|
||||
})
|
||||
@@ -226,7 +226,7 @@ const handleAddDepartment = async () => {
|
||||
// 新增岗位
|
||||
const handleAddPosition = async () => {
|
||||
try {
|
||||
await axios.post(`/api/government/departments/${addPositionFormData.department_id}/positions`, {
|
||||
await api.government.positions.create({
|
||||
department_id: addPositionFormData.department_id,
|
||||
name: addPositionFormData.name
|
||||
})
|
||||
@@ -243,7 +243,7 @@ const handleAddPosition = async () => {
|
||||
// 编辑岗位
|
||||
const handleEditPosition = async () => {
|
||||
try {
|
||||
await axios.put(`/api/government/positions/${editPositionFormData.id}`, {
|
||||
await api.government.positions.update(editPositionFormData.id, {
|
||||
name: editPositionFormData.name
|
||||
})
|
||||
message.success('岗位编辑成功')
|
||||
@@ -259,7 +259,7 @@ const handleEditPosition = async () => {
|
||||
// 删除岗位
|
||||
const handleDeletePosition = async (positionId) => {
|
||||
try {
|
||||
await axios.delete(`/api/government/positions/${positionId}`)
|
||||
await api.government.positions.delete(positionId)
|
||||
message.success('岗位删除成功')
|
||||
// 重新获取数据
|
||||
await fetchDepartments()
|
||||
@@ -272,7 +272,7 @@ const handleDeletePosition = async (positionId) => {
|
||||
// 删除部门
|
||||
const handleDeleteDepartment = async (departmentId) => {
|
||||
try {
|
||||
await axios.delete(`/api/government/departments/${departmentId}`)
|
||||
await api.government.departments.delete(departmentId)
|
||||
message.success('部门删除成功')
|
||||
// 重新获取数据
|
||||
await fetchDepartments()
|
||||
@@ -285,7 +285,7 @@ const handleDeleteDepartment = async (departmentId) => {
|
||||
// 设置权限
|
||||
const handleSetPermission = async () => {
|
||||
try {
|
||||
await axios.post(`/api/government/positions/${currentPosition.value.id}/permission`, {
|
||||
await api.government.positions.setPermission(currentPosition.value.id, {
|
||||
permission_details: { basic: ['view', 'edit', 'add'], advanced: ['delete'] }
|
||||
})
|
||||
message.success('权限设置成功')
|
||||
|
||||
@@ -111,23 +111,25 @@ const formatTime = (time) => {
|
||||
return dayjs(time).format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
|
||||
// 获取统计数据
|
||||
import api from '@/utils/api-redesigned'
|
||||
|
||||
// 获取统计数据(统一封装)
|
||||
const fetchStats = async () => {
|
||||
try {
|
||||
// 获取监管统计数据
|
||||
const supervisionResponse = await axios.get('/api/supervision/stats')
|
||||
if (supervisionResponse.data.code === 200) {
|
||||
const supervisionData = supervisionResponse.data.data
|
||||
stats.value.totalEntities = supervisionData.entityCount || 0
|
||||
stats.value.inspectionCount = supervisionData.inspectionCount || 0
|
||||
const supervisionResp = await api.supervision.getStats()
|
||||
if (supervisionResp?.code === 200) {
|
||||
const supervisionData = supervisionResp.data
|
||||
stats.value.totalEntities = supervisionData?.entityCount || 0
|
||||
stats.value.inspectionCount = supervisionData?.inspectionCount || 0
|
||||
}
|
||||
|
||||
// 获取疫情统计数据
|
||||
const epidemicResponse = await axios.get('/api/epidemic/stats')
|
||||
if (epidemicResponse.data.code === 200) {
|
||||
const epidemicData = epidemicResponse.data.data
|
||||
stats.value.vaccinated = epidemicData.vaccinated || 0
|
||||
stats.value.tested = epidemicData.tested || 0
|
||||
const epidemicResp = await api.epidemic.getStats()
|
||||
if (epidemicResp?.code === 200) {
|
||||
const epidemicData = epidemicResp.data
|
||||
stats.value.vaccinated = epidemicData?.vaccinated || 0
|
||||
stats.value.tested = epidemicData?.tested || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取统计数据失败:', error)
|
||||
|
||||
@@ -365,11 +365,12 @@ const initScaleChart = () => {
|
||||
})
|
||||
}
|
||||
|
||||
// 从API获取数据
|
||||
// 从API获取数据(统一封装)
|
||||
import api from '@/utils/api-redesigned'
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/government/data-center');
|
||||
const data = response.data;
|
||||
const data = await api.dashboard.getDataCenter();
|
||||
|
||||
// 更新统计数据
|
||||
养殖户总数.value = data.totalFarmers.toLocaleString();
|
||||
|
||||
@@ -88,14 +88,12 @@ const productTypeText = computed(() => {
|
||||
return map[activeProductTab.value] || '育肥牛'
|
||||
})
|
||||
|
||||
// 从后端获取市场行情数据
|
||||
// 从后端获取市场行情数据(统一封装)
|
||||
import api from '@/utils/api-redesigned'
|
||||
|
||||
const fetchMarketPriceData = async (type = 'beef') => {
|
||||
try {
|
||||
const response = await axios.get('/api/government/market-price', {
|
||||
params: { type }
|
||||
})
|
||||
|
||||
const data = response.data
|
||||
const data = await api.dashboard.getMarketPrice({ type })
|
||||
|
||||
// 更新数据
|
||||
currentPrice.value = data.currentPrice
|
||||
|
||||
@@ -132,4 +132,32 @@ pm2 status government-backend
|
||||
|
||||
# 测试API连通性
|
||||
curl -k https://ad.ningmuyun.com/api/government/departments
|
||||
```
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 附:历史路由刷新 404 修复
|
||||
|
||||
若在访问如 `https://ad.liaoniuyun.com/government/farmer` 并刷新后出现 404,这是前端使用 `history` 路由模式时,服务器未对深链接进行回退到 `index.html` 导致。请在 Nginx 中为 `/government/` 增加路由回退:
|
||||
|
||||
```nginx
|
||||
# 优先匹配政府端前端路径,并做历史路由回退
|
||||
location ^~ /government/ {
|
||||
# 推荐使用 root 方式,目录中应包含 government/index.html 与打包的 assets/
|
||||
root /var/www/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /government/index.html;
|
||||
}
|
||||
|
||||
# 若使用 alias,也请注意路径以 / 结尾,并保留回退
|
||||
# location ^~ /government/ {
|
||||
# alias /var/www/html/government/;
|
||||
# index index.html;
|
||||
# try_files $uri $uri/ /government/index.html;
|
||||
# }
|
||||
```
|
||||
|
||||
验证步骤:
|
||||
- 访问并刷新:`https://ad.liaoniuyun.com/government/farmer` 应正常显示页面,不再 404。
|
||||
- 如仍异常,检查是否有其它 `location` 块(例如 `/` 或正则)优先生效覆盖了 `/government/` 的回退配置;可通过 `^~` 提升优先级。
|
||||
- 确认 `vite.config.js` 已设置 `base: '/government/'`,且路由为 `createWebHistory('/government/')`(本项目已配置)。
|
||||
Reference in New Issue
Block a user