邓洁: 隧道接口部分对接

This commit is contained in:
邓洁
2023-12-26 09:41:44 +08:00
parent 9afb0f7f28
commit b1fde92bbd
5 changed files with 122 additions and 51 deletions

29
src/api/tunnelManage.js Normal file
View File

@@ -0,0 +1,29 @@
import request from '@/utils/request.js'
export const getTunnelList = (params) => {
return request({
url: '/tunnel/tunnel/screen/list',
method: 'get',
params
})
}
export const editTunnel = (data) => {
return request({
url: '/tunnel/tunnel',
method: 'put',
data
})
}
export const addTunnel = (data) => {
return request({
url: '/tunnel/tunnel',
method: 'post',
data
})
}
export const deleteTunnel = (tunnelIdList) => {
return request({
url: `/tunnel/tunnel/${tunnelIdList}`,
method: 'delete'
})
}

View File

@@ -1,4 +1,4 @@
import { createRouter, createWebHashHistory } from 'vue-router'; import { createRouter, createWebHistory } from 'vue-router';
import NProgress from 'nprogress'//进度条 import NProgress from 'nprogress'//进度条
import 'nprogress/nprogress.css' import 'nprogress/nprogress.css'
import { getToken } from '../utils/auth' import { getToken } from '../utils/auth'
@@ -24,7 +24,7 @@ const routes = [
}, },
}, },
{ {
path: '/edit', path: '/edit/:tunnelId(\\d+)',
name: 'tunneledit', name: 'tunneledit',
component: () => import('@/views/edit/edit.vue'), component: () => import('@/views/edit/edit.vue'),
meta: { meta: {
@@ -80,7 +80,7 @@ const routes = [
]; ];
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHistory(),
routes, routes,
}); });
router.beforeEach((to, form, next) => { router.beforeEach((to, form, next) => {

View File

@@ -170,7 +170,6 @@ const getList = () => {
}) })
siteList.value = res.data.rows; siteList.value = res.data.rows;
console.log('res',siteList.value)
}); });
} }
getList() getList()
@@ -223,14 +222,16 @@ const handleSubmit = (instance) => {
instance.validate(async (valid) => { instance.validate(async (valid) => {
if (!valid) return if (!valid) return
if (title.value === '编辑站点') { if (title.value === '编辑站点') {
editSite(form.value).then(() => { editSite(form.value).then((res) => {
isVisited.value = false isVisited.value = false
getList() getList()
ElMessage.success(res.msg)
}); });
} else { } else {
addSite(form.value).then(() => { addSite(form.value).then((res) => {
isVisited.value = false isVisited.value = false
getList() getList()
ElMessage.success(res.msg)
}); });
} }
}) })

View File

@@ -19,18 +19,17 @@
</div> </div>
</div> </div>
<div class="box-content"> <div class="box-content">
<div class="site-box" v-for="item in tunnelList" :key="item.tunnelId" <div class="site-box" v-for="item in tunnelList" :key="item.tunnelId">
@click="handleGoToEditTunnel(item.tunnelId)">
<div class="top"> <div class="top">
<span>{{ item.tunnelName }}</span> <span>{{ item.tunnelName }}</span>
<span>施工长度500米 隧道长度10公里</span> <span>施工长度{{ item.constructionLength }} 隧道长度{{ item.totalLength }}公里</span>
<el-checkbox v-model="item.checked" size="large" @change="handleClickSite(item)"/> <el-checkbox v-model="item.checked" size="large" @change="handleClickSite(item)"/>
</div> </div>
<div class="box-center"> <div class="box-center">
<div> <div>
<div class="left-img"></div> <div class="left-img"></div>
<div> <div>
<div class="edit-btn" @click.stop="handleEdit"> <div class="edit-btn" @click.stop="handleGoToEditTunnel(item.tunnelId)">
<div class="edit-icon"></div> <div class="edit-icon"></div>
<div>隧道编辑</div> <div>隧道编辑</div>
</div> </div>
@@ -46,9 +45,9 @@
<span>风机异常</span> <span>风机异常</span>
</div> </div>
<div class="icons-block"> <div class="icons-block">
<div v-for="item in iconsList" :key="item.icon" class="icon-text"> <div v-for="equItem in iconsList" :key="item.icon" class="icon-text">
<div :style="{ backgroundImage: 'url(' +getImageUrl(item.icon)+')' }" class="icon"></div> <div :style="{ backgroundImage: 'url(' +getImageUrl(equItem.icon)+')' }" class="icon"></div>
<span>{{ item.name }}{{ item.num }}</span> <span>{{ equItem.name }}{{ item.tunnelEquipmentAmountInfo[equItem.type] }}</span>
</div> </div>
</div> </div>
</div> </div>
@@ -81,14 +80,16 @@
<div class="cancel-btn" @click="isVisited=false"> <div class="cancel-btn" @click="isVisited=false">
取消 取消
</div> </div>
<div class="sure-btn"> <div class="sure-btn" @click="handleAddTunnel">
确定 确定
</div> </div>
</div> </div>
</el-dialog> </el-dialog>
<div class="pagination"> <div class="pagination">
<span>首页</span> <span>首页</span>
<el-pagination background :page-size="6" :total="50" prev-text="上一页" next-text="下一页" layout="prev, pager, next"/> <el-pagination background v-model:current-page="pageInfo.pageNum" v-model:page-size="pageInfo.pageSize"
:total="total" prev-text="上一页" next-text="下一页" layout="prev, pager, next"
@current-change="handleCurrentChange"/>
<span>尾页</span> <span>尾页</span>
</div> </div>
</div> </div>
@@ -96,6 +97,8 @@
<script setup> <script setup>
import {ElMessage, ElMessageBox} from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus";
import {getTunnelList} from "@/api/tunnelManage";
import {deleteTunnel} from "../../api/tunnelManage";
const router = useRouter() const router = useRouter()
const showAddIcon = ref(true) const showAddIcon = ref(true)
@@ -172,42 +175,50 @@ const iconsList = ref([
{ {
icon: 'sd_icon_fj.png', icon: 'sd_icon_fj.png',
name: '风机', name: '风机',
num: 2 type: 'frequency',
num: 0
}, },
{ {
icon: 'sd_icon_sd.png', icon: 'sd_icon_sd.png',
name: '湿度', name: '湿度',
num: '无' type: 'humidness',
num: 0
}, },
{ {
icon: 'sd_icon_fy.png', icon: 'sd_icon_fy.png',
name: '风压', name: '风压',
num: 10 type: 'windPressure',
num: 0
}, },
{ {
icon: 'sd_icon_yq.png', icon: 'sd_icon_yq.png',
name: '氧气', name: '氧气',
num: '无' type: 'oxygen',
num: 0
}, },
{ {
icon: 'sd_icon_fs.png', icon: 'sd_icon_fs.png',
name: '风速', name: '风速',
num: 11 type: 'windSpeed',
num: 0
}, },
{ {
icon: 'sd_icon_fc.png', icon: 'sd_icon_fc.png',
name: '粉尘', name: '粉尘',
type: 'dust',
num: 1 num: 1
}, },
{ {
icon: 'sd_icon_wd.png', icon: 'sd_icon_wd.png',
name: '温度', name: '温度',
num: 11 type: 'temperature',
num: 0
}, },
{ {
icon: 'sd_icon_qt.png', icon: 'sd_icon_qt.png',
name: '有害气体', name: '有害气体',
num: '无' type: 'harmfulGas',
num: 0
}, },
]) ])
const title = ref('新增隧道') const title = ref('新增隧道')
@@ -221,11 +232,33 @@ const form = ref({
remarks: '' remarks: ''
}); });
const isEdit = ref(false) const isEdit = ref(false)
const bgImage = computed(() => (isEdit.value ? "zdgl_bj.png" : "sdgl_bjtq.png")); const pageInfo = reactive({
pageNum: 1,
pageSize: 12
});
const total = ref(10);
const getList = () => {
getTunnelList({
...pageInfo
}).then(res => {
if (res.code === 1000) {
total.value=res.data.total
tunnelList.value = res.data.rows
}
})
}
getList()
//点击页码进行分页功能
const handleCurrentChange = (val) => {
pageInfo.pageNum = val
getList()
}
const handleAddTunnel=()=>{
}
const handleGoToEditTunnel = (tunnelId) => { const handleGoToEditTunnel = (tunnelId) => {
isEdit.value = true isEdit.value = true
router.push('/edit') router.push('/edit/' + tunnelId)
} }
const handleChooseAll = () => { const handleChooseAll = () => {
tunnelList.value.map(item => { tunnelList.value.map(item => {
@@ -234,13 +267,20 @@ const handleChooseAll = () => {
} }
const handleEdit = () => { const handleEdit = () => {
title.value = '编辑隧道' title.value = '编辑隧道'
isVisited.value = true // isVisited.value = true
} }
const handleEditDevice = () => { const handleEditDevice = () => {
router.push('/device/' + 1) router.push('/device/' + 1)
} }
const restFrom = () => {
form.value = {
address: '',
siteName: '',
describe: ''
}
}
const handleAdd = () => { const handleAdd = () => {
restFrom()
title.value = '新增隧道' title.value = '新增隧道'
isVisited.value = true isVisited.value = true
} }
@@ -249,19 +289,19 @@ const getImageUrl = (name) => {
} }
const handleClickSite = (type) => { const handleClickSite = (type) => {
if (type.checked) { if (type.checked) {
tunnelIds.value.push(type.siteId) tunnelIds.value.push(type.tunnelId)
tunnelNameList.value.push(type.siteName) tunnelNameList.value.push(type.tunnelName)
} else { } else {
// tunnelIds.value.map((item, index) => { tunnelIds.value.map((item, index) => {
// if (item === type.siteId) { if (item === type.tunnelId) {
// tunnelIds.value.splice(index, 1) tunnelIds.value.splice(index, 1)
// } }
// }) })
// tunnelNameList.value.map((item, index) => { tunnelNameList.value.map((item, index) => {
// if (item === type.siteName) { if (item === type.tunnelName) {
// tunnelNameList.value.splice(index, 1) tunnelNameList.value.splice(index, 1)
// } }
// }) })
} }
} }
const handleMoreDelete = () => { const handleMoreDelete = () => {
@@ -274,16 +314,16 @@ const handleMoreDelete = () => {
type: 'warning', type: 'warning',
customClass: 'delBox' customClass: 'delBox'
}).then(() => { }).then(() => {
// deleteSite(tunnelIds.value).then(res => { deleteTunnel(tunnelIds.value).then(res => {
// if (res.code === 1000) { if (res.code === 1000) {
// ElMessage.success(res.msg) ElMessage.success(res.msg)
// getList() getList()
// tunnelIds.value = [] tunnelIds.value = []
// tunnelNameList.value = [] tunnelNameList.value = []
// } else { } else {
// ElMessage.error(res.msg) ElMessage.error(res.msg)
// } }
// }) })
}) })
} }
} }
@@ -441,9 +481,9 @@ const handleMoreDelete = () => {
//box-sizing: border-box; //box-sizing: border-box;
position: relative; position: relative;
&:hover { //&:hover {
background-image: url('@/assets/images/tunnel/sdgl_bjtq.png'); // background-image: url('@/assets/images/tunnel/sdgl_bjtq.png');
} //}
&:nth-child(4n) { &:nth-child(4n) {
margin-right: 0; margin-right: 0;

View File

@@ -175,6 +175,7 @@ const manageSelect = (index) => {
}; };
const handleCommand = (item) => { const handleCommand = (item) => {
currentSite.value = item.label currentSite.value = item.label
currentSiteId.value = item.value
getTunnel(item.value) getTunnel(item.value)
} }
const closeLeft = () => { const closeLeft = () => {