This commit is contained in:
李想 2025-03-14 17:33:56 +08:00
commit 903b520d1c
13 changed files with 1300 additions and 114 deletions

115
README.md
View File

@ -1,93 +1,48 @@
# daimp-front
## daimp-front
### 介绍
基于 qiankun + vue2&vue3 + Vite + vite-plugin-qiankun 技术栈实现的前端微应用架构,实现了主子应用切换。
1、主应用介绍
技术栈 Vite+Vue3 + Element-plus + qiankun + Pinia
2、sub-government-affairs-service 政务服务子应用介绍
技术栈 Vite + Vue3 + Element-plus + vite-plugin-qiankun + Pinia
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
### 启动应用
```
cd existing_repo
git remote add origin http://192.168.18.88:8077/sznyb/daimp-front.git
git branch -M main
git push -uf origin main
# 项目依赖安装
npm install || yarn install
```
## Integrate with your tools
```
# 本地运行
npm run dev || yarn dev
```
- [ ] [Set up project integrations](http://192.168.18.88:8077/sznyb/daimp-front/-/settings/integrations)
```
# 构建
npm run build || yarn build
```
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
1、运行子应用
## Test and Deploy
```
cd sub-government-affairs-service/
yarn dev
```
Use the built-in continuous integration in GitLab.
2、运行主应用
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
```
cd main/
yarn dev
```
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
3、打开http://localhost:9000/ 访问主应用

View File

@ -0,0 +1,17 @@
import request from '@/utils/axios';
// 作物种植结构
export function GetCropData(params = {}) {
return request('/land-resource/TotalAnalysis/cropPlan', {
method: 'GET',
params,
});
}
// 土地用途分析
export function GetLandData(params = {}) {
return request('/land-resource/TotalAnalysis/landAnalysis', {
method: 'GET',
params,
});
}

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang
* @Date: 2023-06-20 11:48:41
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-03-11 16:51:49
* @LastEditTime: 2025-03-12 11:10:12
*/
import { createRouter, createWebHistory } from 'vue-router';
import Layout from '@/layouts/index.vue';
@ -43,10 +43,10 @@ export const constantRoutes = [
],
},
...resourceRouter,
...traceRouter,
...productOperateMainRoutes,
...inputSuppliesRoutes,
...plantingAndBreedingRouter,
...traceRouter,
];
/**

View File

@ -5,7 +5,7 @@ export default [
path: '/sub-government-affairs-service/plantingAndBreeding',
name: 'plantingAndBreeding',
component: Layout,
redirect: '/sub-government-affairs-service/breeding-base-information',
redirect: '/sub-government-affairs-service/environment-monitor',
meta: { title: '种养植综合管理', icon: 'Document' },
children: [
{
@ -14,11 +14,24 @@ export default [
component: () => import('@/views/plantingAndBreeding/environment/index.vue'),
meta: { title: '环境监测信息', icon: 'Document' },
},
{
path: '/sub-government-affairs-service/threshold-value-setting',
name: 'threshold-value-setting',
component: () => import('@/views/plantingAndBreeding/threshold/index.vue'),
hidden: true,
meta: { title: '阀值设置', icon: 'Document' },
},
{
path: '/sub-government-affairs-service/pest-monitor',
name: 'pest-monitor',
component: () => import('@/views/plantingAndBreeding/pest/index.vue'),
meta: { title: '病虫害监测信息', icon: 'Document' },
},
// {
// path: '/sub-government-affairs-service/breeding-base-information',
// name: 'breeding-base-information',
// component: () => import('@/views/plantingAndBreeding/base/index.vue'),
// meta: { title: '种养殖基地信息', icon: 'Document' },
// meta: { title: '种养殖基地', icon: 'Document' },
// },
],
},

View File

@ -0,0 +1,6 @@
<template>
<div class="custom-page">种养殖基地信息</div>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
</script>

View File

@ -23,11 +23,9 @@
@row-save="rowSave"
@row-update="rowUpdate"
>
<!-- <template #menu-left>
<el-button type="primary" icon="Plus" @click="onAdd">新增</el-button>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template> -->
<template #menu-left>
<el-button type="primary" icon="plus" @click="onThreshold">阀值设置</el-button>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
@ -35,17 +33,22 @@
</el-col>
</el-row>
</div>
<custom-info ref="customInfoRef" :row="state.currentRow" />
</template>
<script setup>
import { ref, reactive } from 'vue';
import { useRouter } from 'vue-router';
import { useApp } from '@/hooks';
import { useUserStore } from '@/store/modules/user';
import { CRUD_OPTIONS } from '@/config';
import { mockData, sleep } from '@/utils';
import CustomInfo from './info.vue';
const { VITE_APP_BASE_API } = import.meta.env;
const { VITE_APP_BASE_API, VITE_APP_NAME } = import.meta.env;
const app = useApp();
const UserStore = useUserStore();
const router = useRouter();
const crudRef = ref(null);
const landTypeData = ref([
{
@ -78,6 +81,7 @@ const state = reactive({
options: {
...CRUD_OPTIONS,
addBtnText: '阀值设置',
addBtn: false,
selection: false,
column: [
{
@ -230,16 +234,16 @@ const state = reactive({
icon: 'edit',
event: ({ row }) => rowEdit(row),
},
{
type: 'success',
name: ({ row }) => {
return row.status === 1 ? '禁用' : '启用';
},
icon: ({ row }) => {
return row.status === 1 ? 'turnOff' : 'open';
},
event: ({ row }) => rowStatus(row),
},
// {
// type: 'success',
// name: ({ row }) => {
// return row.status === 1 ? '' : '';
// },
// icon: ({ row }) => {
// return row.status === 1 ? 'turnOff' : 'open';
// },
// event: ({ row }) => rowStatus(row),
// },
{
type: 'danger',
name: '删除',
@ -301,7 +305,7 @@ const loadData = async () => {
p16: '正常',
p17: '偏低',
p18: '正常',
status: 1,
// status: 1,
createTime: '2025-01-01',
updateTime: '2025-01-15',
},
@ -348,8 +352,10 @@ const selectionChange = (rows) => {
};
//
const customInfoRef = ref(null);
const rowView = (row) => {
crudRef.value && crudRef.value.rowView(row);
state.currentRow = row;
customInfoRef.value && customInfoRef.value.show();
};
//
@ -403,4 +409,9 @@ const rowUpdate = (row, index, done, loading) => {
//
const rowDel = (row) => {};
//
const onThreshold = () => {
router.push({ path: `/${VITE_APP_NAME}/threshold-value-setting` });
};
</script>

View File

@ -0,0 +1,292 @@
<template>
<el-dialog
v-model="state.visible"
draggable
title="查看"
width="70%"
:close-on-click-modal="false"
:close-on-press-escape="false"
@close="state.visible = false"
>
<div class="monitor">
<div class="monitor-tabs">
<el-radio-group v-model="state.currentTab">
<el-radio-button :value="1">环境检测报告</el-radio-button>
<el-radio-button :value="2">环境监测数据</el-radio-button>
</el-radio-group>
</div>
<div v-if="state.currentTab === 1" class="monitor-panel">
<div class="monitor-panel-item">
<h3>土壤环境报告</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="酸碱度PH值">正常</el-descriptions-item>
<el-descriptions-item label="土壤质地">砂土含量大通气性良好含水性较差</el-descriptions-item>
<el-descriptions-item label="养分含量">氮元素含量不足</el-descriptions-item>
<el-descriptions-item label="重金属含量">重金属含量超标</el-descriptions-item>
</el-descriptions>
<div class="suggestion">
<el-tag type="primary">处理建议</el-tag>
<p>根据大气情况及时浇灌适宜施加配肥清理田中污染物</p>
</div>
</div>
<div class="monitor-panel-item">
<h3>水环境报告</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="水温">偏高</el-descriptions-item>
<el-descriptions-item label="浑浊度">正常</el-descriptions-item>
<el-descriptions-item label="酸碱度">正常</el-descriptions-item>
<el-descriptions-item label="盐分含量">正常</el-descriptions-item>
<el-descriptions-item label="重金属和有毒物">铜金属含量接近预警值</el-descriptions-item>
</el-descriptions>
<div class="suggestion">
<el-tag type="primary">处理建议</el-tag>
<p>温度偏高不宜在此处取水灌溉建议观察水源</p>
</div>
</div>
<div class="monitor-panel-item">
<h3>大气环境报告</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="温度">正常</el-descriptions-item>
<el-descriptions-item label="湿度">偏低</el-descriptions-item>
<el-descriptions-item label="风速">微风</el-descriptions-item>
</el-descriptions>
<div class="suggestion">
<el-tag type="primary">处理建议</el-tag>
<p>可进行适量浇灌如需进行浇灌农药喷洒请注意风向同时注解</p>
</div>
</div>
</div>
<div v-if="state.currentTab === 2" class="monitor-panel">
<div class="monitor-panel-item">
<h3>土壤环境检测</h3>
<div class="data-row">
<span class="label">酸碱度PH值</span>
<span class="value">6.3</span>
</div>
<div class="data-row">
<span class="label">土壤质地</span>
<div class="value">
<el-descriptions :column="3" border>
<el-descriptions-item label="砂土含量">75%</el-descriptions-item>
<el-descriptions-item label="土壤含量">50%</el-descriptions-item>
<el-descriptions-item label="黏土含量">30%</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div class="data-row nutrient-table">
<span class="label">养分含量</span>
<div class="value">
<el-descriptions :column="3" border>
<el-descriptions-item v-for="(item, index) in nutrientData" :key="index" :label="item.name">{{ item.value }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div class="data-row">
<span class="label">重金属含量</span>
<div class="value">
<el-descriptions :column="2" border>
<el-descriptions-item v-for="(item, index) in waterMetalData" :key="index" :label="item.name">{{ item.value }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
</div>
<div class="monitor-panel-item">
<h3>水环境检测</h3>
<div class="data-row">
<span class="label"></span>
<div class="value">
<el-descriptions :column="2" border>
<el-descriptions-item label="水温">15%</el-descriptions-item>
<el-descriptions-item label="浑浊度">8NTU</el-descriptions-item>
<el-descriptions-item label="酸碱度">5.8</el-descriptions-item>
<el-descriptions-item label="盐分含量">1500us/cm</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div class="data-row">
<span class="label">重金属和有毒物</span>
<div class="value">
<el-descriptions :column="2" border>
<el-descriptions-item v-for="(item, index) in waterMetalData" :key="index" :label="item.name">{{ item.value }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
</div>
<div class="monitor-panel-item">
<h3>大气环境检测</h3>
<div class="data-row">
<span class="label"></span>
<div class="value">
<el-descriptions :column="2" border>
<el-descriptions-item label="温度">15</el-descriptions-item>
<el-descriptions-item label="湿度">50%</el-descriptions-item>
<el-descriptions-item label="风速">1.5m/s</el-descriptions-item>
<el-descriptions-item label="风向">东南风</el-descriptions-item>
<el-descriptions-item label="光照强度">10000lx</el-descriptions-item>
<el-descriptions-item label="降雨量">500mm</el-descriptions-item>
</el-descriptions>
</div>
</div>
</div>
<div class="monitor-panel-item">
<h3>传感器工作情况</h3>
<div class="data-row">
<span class="label"></span>
<div class="value sensor-status">
<div class="status-item">
<span>土壤传感器</span>
<el-tag type="success">正常</el-tag>
</div>
<div class="status-item">
<span>水传感器</span>
<el-tag type="success">正常</el-tag>
</div>
<div class="status-item">
<span>大气传感器</span>
<el-tag type="danger">异常</el-tag>
</div>
<div class="status-item">
<span>雨量剂</span>
<el-tag type="success">正常</el-tag>
</div>
</div>
</div>
</div>
</div>
</div>
</el-dialog>
</template>
<script setup>
import { ref, reactive } from 'vue';
const props = defineProps({
row: {
type: Object,
default: () => {},
},
});
const state = reactive({
visible: false,
currentTab: 1,
});
const nutrientData = ref([
{ name: '全氮', value: '0.2%' },
{ name: '有效磷', value: '20mg/kg' },
{ name: '速效钾', value: '150mg/kg' },
{ name: '硼元素', value: '300mg/kg' },
{ name: '锌元素', value: '40mg/kg' },
{ name: '铁元素', value: '10mg/kg' },
{ name: '锰元素', value: '5mg/kg' },
{ name: '铜元素', value: '3mg/kg' },
]);
const metalData = ref([
{ name: '铅', value: '0.2mg/kg' },
{ name: '铬', value: '45mg/kg' },
{ name: '汞', value: '1.3mg/kg' },
{ name: '镉', value: '0.3mg/kg' },
]);
const waterMetalData = ref([
{ name: '铜', value: '0.5mg/L' },
{ name: '锌', value: '1.5mg/L' },
{ name: '铅', value: '0.08mg/L' },
{ name: '镉', value: '0.005mg/L' },
]);
defineExpose({
show: () => {
state.visible = true;
},
hide: () => {
state.visible = false;
},
});
</script>
<style lang="scss" scoped>
.monitor {
padding: 20px;
margin: 0 auto;
&-tabs {
margin-bottom: 20px;
text-align: center;
}
&-panel {
&-item {
margin-bottom: 20px;
h3 {
margin-bottom: 16px;
font-size: 14px;
color: var(--el-text-color-primary);
}
.suggestion {
display: flex;
flex-direction: row;
align-items: center;
margin-top: 16px;
padding: 10px;
background-color: var(--el-color-info-light-9);
border-radius: 4px;
color: var(--el-text-color-secondary);
p {
padding-left: 20px;
}
}
:deep(.el-descriptions__label) {
width: 150px;
}
:deep(.el-descriptions__content) {
padding: 12px;
}
.data-row {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 16px;
}
.label {
min-width: 120px;
color: var(--el-text-color-secondary);
text-align: right;
margin-right: 16px;
}
.value {
flex: 1;
}
.sensor-status {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.status-item {
display: flex;
flex-direction: column;
justify-content: center;
gap: 10px;
}
}
}
}
</style>

View File

@ -0,0 +1,6 @@
<template>
<div class="custom-page">病虫害监测</div>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
</script>

View File

@ -0,0 +1,400 @@
<template>
<div class="custom-page">
<avue-crud
ref="crudRef"
v-model="state.form"
v-model:search="state.query"
v-model:page="state.pageData"
:table-loading="state.loading"
:data="state.data"
:option="state.options"
@refresh-change="refreshChange"
@search-reset="searchChange"
@search-change="searchChange"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@row-save="rowSave"
@row-update="rowUpdate"
@row-del="rowDel"
>
<template #menu-left>
<el-button type="danger" icon="delete" @click="onDel(state.selection)">批量删除</el-button>
</template>
<template #condition="{ row }">
<div v-for="item in row.condition" :key="item.thresholdName">
<span>
{{ item.condition1 }} {{ item.value1 }}
<template v-if="item.condition2"> & {{ item.condition2 }} {{ item.value2 }}</template>
</span>
<span>{{ item.tip }}</span>
</div>
</template>
<template #condition-form="{ column, value }">
<el-table :data="value" style="width: 100%" border>
<el-table-column prop="thresholdName" label="阈值设置" align="center"></el-table-column>
<el-table-column label="条件" width="120" align="center">
<template #default="scope">
{{ scope.row.condition1 }}
<span v-if="scope.row.condition2"> & {{ scope.row.condition2 }}</span>
</template>
</el-table-column>
<el-table-column label="数值" width="120" align="center">
<template #default="scope">
{{ scope.row.value1 }}
<span v-if="scope.row.value2"> & {{ scope.row.value2 }}</span>
</template>
</el-table-column>
<el-table-column prop="warning" label="告警" align="center"></el-table-column>
<el-table-column prop="tip" label="提示" align="center"></el-table-column>
<el-table-column label="操作" width="130" align="center">
<template #default="scope">
<el-button type="primary" icon="edit" text></el-button>
<el-button type="danger" icon="delete" text></el-button>
</template>
</el-table-column>
</el-table>
</template>
<template #status="{ row }">
<el-tag v-if="row.status == 1" type="success" size="small">启用</el-tag>
<el-tag v-if="row.status == 0" type="danger" size="small">禁用</el-tag>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
</div>
</template>
<script setup>
import { reactive, ref } from 'vue';
import { useApp } from '@/hooks';
import { CRUD_OPTIONS } from '@/config';
import { mockData, sleep } from '@/utils';
const app = useApp();
const crudRef = ref(null);
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
selection: [],
options: {
...CRUD_OPTIONS,
addBtnText: '告警阀值',
column: [
{
label: '名称',
prop: 'name',
search: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '数据来源',
prop: 'from',
hide: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '条件',
prop: 'condition',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
span: 24,
},
{
label: '状态',
prop: 'status',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
addDisplay: false,
editDisplay: false,
},
{
label: '排序',
prop: 'sort',
type: 'number',
},
// {
// label: '',
// prop: 'tips',
// type: 'textarea',
// span: 24,
// rows: 4,
// overHidden: true,
// width: 300,
// },
],
actions: [
{
name: '查看',
icon: 'view',
event: ({ row }) => rowView(row),
},
{
name: '编辑',
icon: 'edit',
event: ({ row }) => rowEdit(row),
},
{
type: 'success',
name: ({ row }) => {
return row.status === 1 ? '禁用' : '启用';
},
icon: ({ row }) => {
return row.status === 1 ? 'turnOff' : 'open';
},
event: ({ row }) => rowStatus(row),
},
{
type: 'danger',
name: '删除',
icon: 'delete',
event: ({ row }) => rowDel(row),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
//
const loadData = async () => {
// state.loading = true;
// GetEntityList(state.query)
// .then((res) => {
// if (res.code === 200) {
// const { current, size, total, records } = res.data;
// state.data = records;
// state.pageData = {
// currentPage: current || 1,
// pageSize: size || 10,
// total: total,
// };
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// state.data = [];
// })
// .finally(() => {
// state.loading = false;
// });
state.loading = true;
await sleep(500);
state.data = [
{
name: 'PH值',
condition: [
{
thresholdName: '阈值一',
condition1: '大于',
value1: 7,
condition2: '',
value2: '',
warning: '正常',
tip: '土壤为碱性',
},
{
thresholdName: '阈值二',
condition1: '小于',
value1: 7,
condition2: '',
value2: '',
warning: '正常',
tip: '土壤为酸性',
},
],
sort: 1,
status: 1,
},
{
name: '气温',
condition: [
{
thresholdName: '阈值一',
condition1: '大于',
value1: 25,
condition2: '',
value2: '',
warning: '炎热',
tip: '不建议进行劳作',
},
{
thresholdName: '阈值二',
condition1: '大于',
value1: 20,
condition2: '小于',
value2: 25,
warning: '干燥',
tip: '可适量进行劳作',
},
{
thresholdName: '阈值三',
condition1: '大于',
value1: 15,
condition2: '小于',
value2: 20,
warning: '正常',
tip: '可正常进行劳作',
},
{
thresholdName: '阈值四',
condition1: '大于',
value1: 10,
condition2: '小于',
value2: 15,
warning: '凉爽',
tip: '可适量进行劳作',
},
{
thresholdName: '阈值五',
condition1: '',
value1: '',
condition2: '小于',
value2: 10,
warning: '寒冷',
tip: '尽量避免劳作',
},
],
sort: 2,
status: 1,
},
];
state.loading = false;
};
loadData();
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
//
const rowView = (row) => {
// state.currentRow = row;
crudRef.value.rowView(row);
};
//
const rowStatus = (row) => {
console.info('操作状态');
};
//
const rowSave = (row, done, loading) => {
// AddEntity(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
};
//
const rowEdit = (row) => {
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
// UpdateEntity(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
};
//
const rowDel = (row, index, done) => {
// if (isEmpty(row)) return;
// app
// .$confirm(``, '', {
// confirmButtonText: '',
// cancelButtonText: '',
// type: 'warning',
// })
// .then(() => {
// DeleteEntity({ id: row.id })
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// });
// })
// .catch(() => {});
};
</script>

View File

@ -0,0 +1,444 @@
<template>
<div class="custom-page">
<avue-crud
ref="crudRef"
v-model="state.form"
v-model:search="state.query"
v-model:page="state.pageData"
:table-loading="state.loading"
:data="state.data"
:option="state.options"
@refresh-change="refreshChange"
@search-reset="searchChange"
@search-change="searchChange"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@row-save="rowSave"
@row-update="rowUpdate"
@row-del="rowDel"
>
<template #menu-left>
<el-button type="primary" icon="plus" @click="rowAdd">告警阀值</el-button>
<el-button type="danger" icon="delete" @click="onDel(state.selection)">批量删除</el-button>
</template>
<template #condition="{ row }">
<div v-for="item in row.condition" :key="item.thresholdName" style="margin-bottom: 5px; text-align: left">
{{ item.min }} ~ {{ item.max }}<el-tag type="primary">{{ item.warning }}</el-tag> {{ item.tip }}
</div>
</template>
<template #condition-form="{ column, value }">
<el-button type="primary" style="margin-bottom: 16px" @click="addThreshold(value)">新增</el-button>
<el-table :data="value" style="width: 100%" border>
<el-table-column prop="thresholdName" label="阈值设置" align="center">
<template #default="scope">
<el-input v-model="scope.row.thresholdName" :disabled="scope.row.disabled" />
</template>
</el-table-column>
<el-table-column label="最小值" width="120" align="center">
<template #default="scope">
<el-input v-model="scope.row.min" :disabled="scope.row.disabled" />
</template>
</el-table-column>
<el-table-column label="最大值" width="120" align="center">
<template #default="scope">
<el-input v-model="scope.row.max" :disabled="scope.row.disabled" />
</template>
</el-table-column>
<el-table-column prop="warning" label="告警" align="center">
<template #default="scope">
<el-input v-model="scope.row.warning" :disabled="scope.row.disabled" />
</template>
</el-table-column>
<el-table-column prop="tip" label="提示语" align="center">
<template #default="scope">
<el-input v-model="scope.row.tip" type="textarea" rows="2" :disabled="scope.row.disabled" />
</template>
</el-table-column>
<el-table-column label="操作" width="130" align="center">
<template #default="scope">
<el-button type="primary" icon="edit" text @click="editThreshold(scope.row)"></el-button>
<el-button type="danger" icon="delete" text @click="delThreshold(value, scope.row, scope.$index)"></el-button>
</template>
</el-table-column>
</el-table>
</template>
<template #status="{ row }">
<el-tag v-if="row.status == 1" type="success" size="small">启用</el-tag>
<el-tag v-if="row.status == 0" type="danger" size="small">禁用</el-tag>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
</div>
</template>
<script setup>
import { reactive, ref } from 'vue';
import { useApp } from '@/hooks';
import { CRUD_OPTIONS } from '@/config';
import { isEmpty, sleep } from '@/utils';
const app = useApp();
const crudRef = ref(null);
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
selection: [],
options: {
...CRUD_OPTIONS,
addBtnText: '告警阀值',
addBtn: false,
column: [
{
label: '名称',
prop: 'name',
search: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '数据来源',
prop: 'from',
type: 'select',
hide: true,
dicData: [
{
label: '土壤传感器',
value: '土壤传感器',
},
{
label: '水传感器',
value: '水传感器',
},
{
label: '大气传感器',
value: '大气传感器',
},
],
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '条件',
prop: 'condition',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
span: 24,
},
{
label: '状态',
prop: 'status',
type: 'select',
search: true,
dicData: [
{
label: '启用',
value: 1,
},
{
label: '禁用',
value: 0,
},
],
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '排序',
prop: 'sort',
type: 'number',
},
// {
// label: '',
// prop: 'tips',
// type: 'textarea',
// span: 24,
// rows: 4,
// overHidden: true,
// width: 300,
// },
],
actions: [
{
type: 'success',
name: ({ row }) => {
return row.status === 1 ? '禁用' : '启用';
},
icon: ({ row }) => {
return row.status === 1 ? 'turnOff' : 'open';
},
event: ({ row }) => rowStatus(row),
},
{
name: '编辑',
icon: 'edit',
event: ({ row }) => rowEdit(row),
},
{
type: 'danger',
name: '删除',
icon: 'delete',
event: ({ row }) => rowDel(row),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
//
const loadData = async () => {
// state.loading = true;
// GetEntityList(state.query)
// .then((res) => {
// if (res.code === 200) {
// const { current, size, total, records } = res.data;
// state.data = records;
// state.pageData = {
// currentPage: current || 1,
// pageSize: size || 10,
// total: total,
// };
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// state.data = [];
// })
// .finally(() => {
// state.loading = false;
// });
state.loading = true;
await sleep(500);
state.data = [
{
name: 'PH值',
condition: [
{
thresholdName: '阈值一',
min: 7,
max: 14,
warning: '正常',
tip: '土壤为碱性',
},
{
thresholdName: '阈值二',
min: 0,
max: 7,
warning: '正常',
tip: '土壤为酸性',
},
],
sort: 1,
status: 1,
},
{
name: '气温',
condition: [
{
thresholdName: '阈值一',
min: 25,
max: null,
warning: '炎热',
tip: '不建议进行劳作',
},
{
thresholdName: '阈值二',
min: 20,
max: 25,
warning: '干燥',
tip: '可适量进行劳作',
},
{
thresholdName: '阈值三',
min: 15,
max: 20,
warning: '正常',
tip: '可正常进行劳作',
},
{
thresholdName: '阈值四',
min: 10,
max: 15,
warning: '凉爽',
tip: '可适量进行劳作',
},
{
thresholdName: '阈值五',
min: null,
max: 10,
warning: '寒冷',
tip: '尽量避免劳作',
},
],
sort: 2,
status: 1,
},
];
state.loading = false;
};
loadData();
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
//
const rowStatus = (row) => {
console.info('操作状态');
};
//
const rowAdd = () => {
state.form = {
condition: [],
};
crudRef.value.rowAdd(state.form);
};
const rowSave = (row, done, loading) => {
// AddEntity(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
};
//
const rowEdit = (row) => {
if (!isEmpty(row.condition)) {
row.condition.forEach((item) => {
item.disabled = true;
});
}
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
// UpdateEntity(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
};
//
const onDel = (rows = []) => {
if (isEmpty(rows)) return;
const ids = rows.map((item) => item.id);
app
.$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
// DeleteEntity({ ids: ids.join(',') })
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// });
})
.catch(() => {});
};
const rowDel = (row, index, done) => {
onDel([row]);
};
//
const addThreshold = (list) => {
list.push({
thresholdName: '',
min: '',
max: '',
warning: '',
tip: '',
disabled: false,
});
};
const editThreshold = (row) => {
row.disabled = false;
};
const delThreshold = (list, row, index) => {
list.splice(index, 1);
};
</script>

View File

@ -25,7 +25,10 @@
<script setup>
import { reactive } from 'vue';
import { useApp } from '@/hooks';
import { GetCropData, GetLandData } from '@/apis/statisticAnalysis';
const app = useApp();
const state = reactive({
landOption: {
color: ['#3685fe', '#41b879', '#ffd500'],
@ -36,7 +39,7 @@ const state = reactive({
},
},
legend: {
data: ['耕地', '林地', '建设用地'],
// data: ['', '', ''],
},
label: {
color: '#333',
@ -53,9 +56,9 @@ const state = reactive({
],
},
landData: [
{ value: 100, name: '耕地' },
{ value: 105, name: '林地' },
{ value: 217, name: '建设用地' },
// { value: 100, name: '' },
// { value: 105, name: '' },
// { value: 217, name: '' },
],
cropOption: {
title: {
@ -66,7 +69,7 @@ const state = reactive({
},
xAxis: {
type: 'category',
data: ['土豆', '西红柿', '玉米', '花生', '水稻'],
// data: ['', '西', '', '', ''],
},
yAxis: {
type: 'value',
@ -84,11 +87,11 @@ const state = reactive({
},
},
cropData: [
{ value: 230, name: '土豆' },
{ value: 165, name: '西红柿' },
{ value: 217, name: '玉米' },
{ value: 200, name: '花生' },
{ value: 305, name: '水稻' },
// { value: 230, name: '' },
// { value: 165, name: '西' },
// { value: 217, name: '' },
// { value: 200, name: '' },
// { value: 305, name: '' },
],
landTrendOption: {
color: ['#3685fe', '#41b879', '#ffd500'],
@ -173,6 +176,43 @@ const state = reactive({
},
],
});
//
const loadData = () => {
state.loading = true;
GetCropData()
.then((res) => {
if (res.code === 200) {
state.cropData = res.data.map((item) => {
return {
name: item.crop,
value: item.area,
};
});
}
})
.catch((err) => {
app.$message.error(err.msg);
});
GetLandData()
.then((res) => {
console.log(res);
if (res.code === 200) {
state.landData = res.data.map((item) => {
return {
name: item.landType,
value: item.area,
};
});
}
})
.catch((err) => {
app.$message.error(err.msg);
});
};
loadData();
</script>
<style lang="scss" scoped>
.analysis {

View File

@ -35,6 +35,7 @@ import { useRouter } from 'vue-router';
import { useApp } from '@/hooks';
import { isEmpty, getAssetsFile } from '@/utils';
const { VITE_APP_NAME } = import.meta.env;
const router = useRouter();
const app = useApp();
const code = ref('');
@ -44,7 +45,7 @@ const onSearch = () => {
app.$message.error('请输入溯源码进行查询!');
return;
}
router.push({ path: '/trace-info', query: { code: code.value } });
router.push({ path: `/${VITE_APP_NAME}/trace-info`, query: { code: code.value } });
};
</script>
<style lang="scss" scoped>

View File

@ -105,6 +105,7 @@ import { CRUD_VIEW_OPTIONS } from '@/config';
import { isEmpty } from '@/utils';
import { GetTraceDetail } from '@/apis/coding';
const { VITE_APP_NAME } = import.meta.env;
const router = useRouter();
const route = useRoute();
const app = useApp();
@ -209,7 +210,7 @@ const onSelect = (index) => {
};
const onBack = () => {
router.push({ path: '/trace-search' });
router.push({ path: `/${VITE_APP_NAME}/trace-search` });
};
</script>
<style lang="scss" scoped>