fix : 修复确认按钮防抖

This commit is contained in:
2024-03-25 16:31:37 +08:00
parent ef3bd6a125
commit 1cde879d78
7 changed files with 62 additions and 35 deletions

View File

@@ -29,6 +29,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.1",
"lodash": "^4.17.21",
"unplugin-auto-import": "^0.15.3",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.3.4"

View File

@@ -310,7 +310,7 @@
import {ElLoading, ElMessage} from "element-plus";
import {getEquipmentList, editEquipment, getTunnelDetail} from "@/api/tunnelManage";
import TunnelTitle from "@/components/tunnelTitle/index.vue";
import { debounce } from 'lodash'
const router = useRouter()
const tunnelId = reactive(router.currentRoute.value.params.tunnelId)
const userId = reactive(router.currentRoute.value.params.userId)
@@ -373,7 +373,7 @@ const changeData = (item) => {
state: item.state,
}
}
const editEquip = () => {
const editEquip = debounce(() => {
let newFrequency = [{
acquisitionPeriod: fanFrequency.value * 1000,
tunnelId: parseInt(tunnelId),
@@ -393,7 +393,7 @@ const editEquip = () => {
fanData.value.forEach(item => {
let obj = {
equipmentId: item.equipmentId,
ratedPower:parseInt(item.ratedPower),
ratedPower: parseInt(item.ratedPower),
acurrentValue: parseInt(item.acurrentValue),
bcurrentValue: parseInt(item.bcurrentValue),
ccurrentValue: parseInt(item.ccurrentValue),
@@ -423,7 +423,7 @@ const editEquip = () => {
ElMessage.error(res.msg)
}
})
}
}, 1000)
const handleChangeMenu = (e) => {
changeIndex.value = e

View File

@@ -78,7 +78,7 @@ import {editTunnel, getTunnelDetail} from "@/api/tunnelManage";
import {ElLoading, ElMessage} from "element-plus";
import {initSceneData} from "@/api/tunnelScene";
import TunnelTitle from "@/components/tunnelTitle/index.vue";
import { debounce } from 'lodash'
const router = useRouter();
const tunnelId = reactive(router.currentRoute.value.params.tunnelId);
const userId = reactive(router.currentRoute.value.params.userId);
@@ -144,9 +144,9 @@ const getTunnelInfo = () => {
});
})
}
const handleSave = () => {
const handleSave =debounce(() => {
getTunnelInfo()
};
},1000)
</script>
<style lang="scss" scoped>
:deep(.el-form-item__content) {

View File

@@ -146,7 +146,7 @@ import {ElMessage, ElMessageBox} from "element-plus";
import TunnelTitle from "@/components/tunnelTitle/index.vue";
import {getToken} from '@/utils/auth'
import {ElLoading} from 'element-plus'
import { debounce } from 'lodash'
const router = useRouter()
const userId = reactive(router.currentRoute.value.params.userId)
const siteId = reactive(router.currentRoute.value.params.siteId)
@@ -294,7 +294,7 @@ const handleAdd = () => {
formInstance.value.clearValidate()
})
}
const handleSubmit = (instance) => {
const handleSubmit =debounce((instance) => {
if (!instance) return
instance.validate(valid => {
if (!valid) return
@@ -320,8 +320,8 @@ const handleSubmit = (instance) => {
});
}
})
}
const handleChooseAll = () => {
},1000)
const handleChooseAll = debounce(() => {
siteList.value.map(item => {
item.checked = !item.checked
if (item.checked && !item.isDefault) {
@@ -334,8 +334,8 @@ const handleChooseAll = () => {
})
}
})
}
const handleMoreDelete = () => {
},1000)
const handleMoreDelete =debounce(() => {
if (siteIds.value.length === 0) {
ElMessage.warning('请先选择站点进行删除')
} else {
@@ -372,7 +372,7 @@ const handleMoreDelete = () => {
})
}
}
}
},1000)
const firstPage = () => {
pageInfo.pageNum = 1
getList()

View File

@@ -9,11 +9,11 @@
{{ siteName }}
</div>
<div class="model-change">
<div class="model" @click="clickModel=1">
<div class="model" @click="clickModel=1;showNull=false">
<div class="card-bg"></div>
<span>卡片模式</span>
</div>
<div class="model" @click="clickModel=2">
<div class="model" @click="clickModel=2;getSiteImg()">
<div class="img-bg"></div>
<span>图纸导航</span>
</div>
@@ -73,7 +73,10 @@
</div>
</div>
<div v-else>
<div class="img-box">
<div v-if="showNull" class="showNull">
暂无图纸~ 请前往站点管理上传图纸~
</div>
<div class="img-box" v-else>
<!-- @/assets/images/tunnel/img.png-->
<img :src="'data:image/png;base64,'+siteImage" style="width:3500px;height:1789px" id="imgModel" usemap="#image"
alt="" @click="clickHandler">
@@ -165,6 +168,7 @@ import {getTunnelList, addTunnel, deleteTunnel} from "@/api/tunnelManage";
import {getSiteDrawing, getSiteDetail} from "@/api/site";
import TunnelTitle from "@/components/tunnelTitle/index.vue";
import {getTunnelBySiteId} from "@/api/largeScreen";
import { debounce } from 'lodash'
const validateNumber = (rule, value) => {
const reg = /^[A-Za-z0-9]+$/;
@@ -260,6 +264,7 @@ const iconsList = ref([
},
])
const title = ref('新增隧道')
const showNull = ref(false);
const isVisited = ref(false);
const tunnelIds = ref([])
const tunnelNameList = ref([])
@@ -287,13 +292,26 @@ onMounted(() => {
showOperation.value = localStorage.getItem('roleKey') !== 'tunnel_admin';
})
const getSiteImg = () => {
showNull.value=false
getSiteDrawing(siteId).then((res) => {
if (res.code === 1000) {
siteImage.value = res.data.drawingData
if(res.data.drawingData===null){
// ElMessageBox.confirm('暂无图纸, 是否前往站点管理上传图纸?', '系统提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// router.push('/site/' + userId + '/' + localStorage.getItem('currentSiteId'))
// }).catch(()=>{
showNull.value=true
// })
}else{
showNull.value=false
siteImage.value = res.data.drawingData
}
}
});
}
getSiteImg()
const clickHot = (id) => {
console.log('点击热区===============')
router.push('/' + id + '/' + siteId)
@@ -358,8 +376,7 @@ const handleCurrentChange = (val) => {
pageInfo.pageNum = val
getList()
}
const handleSubmit = (instance) => {
console.log('form.value', form.value)
const handleSubmit = debounce((instance) => {
if (!instance) return
instance.validate(async (valid) => {
if (!valid) return
@@ -377,7 +394,7 @@ const handleSubmit = (instance) => {
}
})
})
}
},1000)
//预览隧道
const handlePreview = (id) => {
console.log('预览')
@@ -401,7 +418,7 @@ const handleGoToEditTunnel = (tunnelId) => {
router.push('/edit/' + tunnelId + '/byHome/' + userId)
}
}
const handleChooseAll = () => {
const handleChooseAll = debounce(() => {
tunnelList.value.map(item => {
item.checked = !item.checked
if (item.checked && !item.isDefault) {
@@ -414,7 +431,7 @@ const handleChooseAll = () => {
})
}
})
}
},1000)
const handleEditDevice = (tunnelId) => {
if (type === 'bySite') {
router.push('/device/' + tunnelId + '/bySite/' + userId)
@@ -466,7 +483,7 @@ const handleClickSite = (type) => {
})
}
}
const handleMoreDelete = () => {
const handleMoreDelete = debounce(() => {
if (tunnelIds.value.length === 0) {
ElMessage.warning('请先选择隧道进行删除')
} else {
@@ -488,11 +505,16 @@ const handleMoreDelete = () => {
})
})
}
}
},1000)
</script>
<style scoped lang="scss">
.showNull{
margin-top: 150px;
font-size: 60px;
color: #05FEFF;
}
:deep(.el-form-item__error) {
font-size: 35px;
}

View File

@@ -165,7 +165,7 @@ import { ElMessage, ElMessageBox } from "element-plus";
import { getUserInfo } from "@/api/login";
import { initSceneData } from "@/api/tunnelScene";
import { getTunnelList } from "@/api/tunnelManage";
import { debounce, throttle } from 'lodash'
import { debounce } from 'lodash'
const authStore = useAuthStore();
const router = useRouter();
const previewId = reactive(router.currentRoute.value.params.tunnelId)
@@ -503,7 +503,7 @@ const changeTunnel = (e) => {
}
const manageSelect = (index) => {
socket.close()
if (index === '站点管理') {
if (currentUserId.value) {
router.push("/site/" + currentUserId.value + '/' + currentSiteId.value);
@@ -517,6 +517,7 @@ const manageSelect = (index) => {
router.push("/user/" + localStorage.getItem('currentSiteId'));
}
}
socket.close()
};
const handleChangeSite = debounce((item) => {
socket.close()

View File

@@ -146,6 +146,7 @@ import {addUser, editUser, getUser, getRoleOption, deleteUser, getUserDetail} fr
import {ElLoading, ElMessage, ElMessageBox} from "element-plus";
import {getTunnelOption} from "@/api/tunnel";
import TunnelTitle from "@/components/tunnelTitle/index.vue";
import {debounce} from 'lodash'
const router = useRouter()
const title = ref('添加用户')
@@ -218,7 +219,7 @@ const handleEditUser = (row) => {
lock: true,
text: '正在加载系统资源...',
background: 'rgba(0, 0, 0, 0.7)',
customClass:'allLoading'
customClass: 'allLoading'
})
getUserDetail(row.userId).then(res => {
if (res.code === 1000) {
@@ -234,7 +235,7 @@ const handleEditUser = (row) => {
}
const handleDelete = () => {
const handleDelete = debounce(() => {
if (userIds.value === undefined) {
ElMessage.warning('请先选择用户进行删除')
} else {
@@ -251,7 +252,7 @@ const handleDelete = () => {
})
})
}
}
}, 1000)
const reset = () => {
form.value = {
password: '',
@@ -276,7 +277,7 @@ const getInfo = () => {
lock: true,
text: '正在加载系统资源...',
background: 'rgba(0, 0, 0, 0.7)',
customClass:'allLoading'
customClass: 'allLoading'
})
getUser({
siteId: siteId,
@@ -305,7 +306,7 @@ const handleCurrentChange = (val) => {
pageInfo.pageNum = val
getInfo()
}
const handleSubmit = (formInstance) => {
const handleSubmit = debounce((formInstance) => {
if (!formInstance) return;
formInstance.validate((valid) => {
if (!valid) return;
@@ -345,7 +346,7 @@ const handleSubmit = (formInstance) => {
})
}
})
}
}, 1000)
const handleSelect = async (selection, row) => {
if (selection.length !== 0) {
// disabled.value = false
@@ -368,6 +369,7 @@ const handleSelect = async (selection, row) => {
}
}
}
.el-select__wrapper {
min-height: 75px;
height: auto !important;
@@ -775,8 +777,9 @@ const handleSelect = async (selection, row) => {
color: #60DDDE;
font-size: 38px;
font-weight: bold;
:deep(.el-pagination.is-background ) {
.btn-next,.btn-prev {
.btn-next, .btn-prev {
background-color: transparent;
}