jsy-app/pages/batch-control/index.vue

230 lines
6.2 KiB
Vue
Raw Normal View History

2025-01-16 15:36:52 +08:00
<template>
<z-paging ref="paging" @query="queryList" v-model="dataList" :auto-show-system-loading="true"
2025-01-21 18:40:11 +08:00
empty-view-text="抱歉,暂时还没有相关数据!" :pull-refresh="false">
2025-01-16 15:36:52 +08:00
<template #top>
<!-- 顶部导航栏 -->
<custom-nav-bar :left="true" @leftClick="" title="批量控制">
2025-01-21 09:37:40 +08:00
<template v-slot:right>
2025-01-16 15:36:52 +08:00
<view class="fixed">
2025-01-22 11:53:59 +08:00
<view align="right" class="icon iconfont icon-fenxiang" @click="share"></view>
2025-01-21 09:37:40 +08:00
<view align="right" class="icon iconfont icon-jia" @click="editItem()"></view>
2025-01-16 15:36:52 +08:00
</view>
2025-01-21 09:37:40 +08:00
</template>
2025-01-16 15:36:52 +08:00
</custom-nav-bar>
</template>
2025-01-21 18:40:11 +08:00
<view class="card">
<uni-collapse>
<uni-collapse-item title-border="none" :border="false" :show-arrow="false" :open="true"
v-for="item in dataList">
<template v-slot:title>
<view class="cards-title">
<view>
<view class="text">{{ item.groupName }}</view>
<view></view>
<view>已选{{item.wos.length}}</view>
</view>
<view class="title-r">
<view @click.stop="editItem(item)">
<u-button type="success" size="mini" text="编辑" />
</view>
<view @click.stop="removeItem(item)">
<u-button class="bg-red" type="success" size="mini" text="删除" />
</view>
</view>
2025-01-16 15:36:52 +08:00
</view>
2025-01-21 18:40:11 +08:00
</template>
<view class="content">
<view class="cards-content">
<view class="greybar" v-for="wo in item.wos">
<view>出水口<span>{{ wo.woName }}</span></view>
<view v-if="wo.deviceTypeKey == 'valve'">三通阀
<span>{{valveKey[wo.deviceTypeKey][wo.angleKey]}}</span>
<span v-if="wo.angle">
({{`${valveKey[wo.deviceTypeKey][wo.angle.angleKey]}-${wo.angle.angle}`}})
</span>
</view>
<view v-if="wo.deviceTypeKey == 'fiveValve'">五通阀
<span>{{valveKey[wo.deviceTypeKey][wo.angleKey]}}</span>
<span>{{valveKey[wo.deviceTypeKey][wo.angleKey]}}</span>
</view>
</view>
<view class="card-font">
<u-button type="primary" size="mini" text="角度记忆" @click="saveBatchControlAngle(item)"
:disabled="disabled" />
<u-button type="success" size="mini" text="关阀" @click="batchControlClose(item)"
:disabled="disabled" />
<u-button type="success" size="mini" text="记忆开阀" @click="batchControlExec(1,item)"
:disabled="disabled" />
<u-button type="success" size="mini" text="直接开阀" @click="batchControlExec(0,item)"
:disabled="disabled" />
2025-01-16 15:36:52 +08:00
</view>
</view>
</view>
2025-01-21 18:40:11 +08:00
</uni-collapse-item>
</uni-collapse>
2025-01-16 15:36:52 +08:00
</view>
</z-paging>
</template>
<script>
2025-01-21 09:37:40 +08:00
import * as isApi from '@/api/irrigate/irrigateScenario.js'
2025-01-16 15:36:52 +08:00
export default {
data() {
return {
2025-01-21 09:37:40 +08:00
landId: null,
2025-01-16 15:36:52 +08:00
dataList: [],
2025-01-21 18:40:11 +08:00
valveKey: {
"valve": {
"close": "全关",
"open1": "①开",
"open2": "②开",
"open": "全开 ",
},
"fiveValve": {
"open1": "①开",
"open2": "②开",
"open3": "③开",
"open4": "④开",
}
},
disabled: false
2025-01-16 15:36:52 +08:00
}
},
2025-01-21 09:37:40 +08:00
onLoad(par) {
2025-01-16 15:36:52 +08:00
if (getApp().ijs.land) {
2025-01-21 09:37:40 +08:00
this.landId = getApp().ijs.land.id;
2025-01-16 15:36:52 +08:00
}
},
2025-01-21 18:40:11 +08:00
onShow() {
this.queryList();
},
2025-01-16 15:36:52 +08:00
mounted() {},
methods: {
queryList() {
2025-01-21 09:37:40 +08:00
isApi.getBatchControlList(this.landId).then(res => {
2025-01-21 18:40:11 +08:00
if (res.data) {
this.$refs.paging.completeByTotal(res.data.groups || []);
} else {
this.$refs.paging.completeByTotal([]);
}
2025-01-21 09:37:40 +08:00
2025-01-21 18:40:11 +08:00
});
2025-01-16 15:36:52 +08:00
},
// 新增
2025-01-21 18:40:11 +08:00
async editItem(item = null) {
let url = `/pages/batch-control/edit?landId=${this.landId}`
if (item) {
url = `${url}&id=${item.id}`
2025-01-21 09:37:40 +08:00
}
2025-01-21 18:40:11 +08:00
uni.navigateTo({
url: url
});
},
// 删除
removeItem(item) {
this.$showConfirm(`删除"${item.groupName}"?`).then(res => {
if (res.confirm) {
isApi.removeBatchControl(item.id).then(res => {
this.queryList();
this.$toast("删除成功")
});
}
})
},
// 开阀
batchControlExec(isMemory, item) {
this.$showConfirm("执行批量开阀?").then(res => {
if (res.confirm) {
this.disabled = true;
isApi.batchControlExec(isMemory, item.id).then(res => {
this.disabled = false;
if (res.data && res.data.length) {
this.$toast(`"${res.data.toString()}"以上阀门执行异常`)
}
uni.showModal({
title: '开阀完成',
content: "仅表示命令发送成功,不代表阀门执行成功,请留意阀门状态,以阀门上报状态为准。",
showCancel: false,
success: (res) => {
uni.navigateBack();
}
});
});
}
});
},
// 关阀
batchControlClose(item) {
this.$showConfirm("执行批量关阀?").then(res => {
if (res.confirm) {
this.disabled = true;
isApi.batchControlClose(item.id).then(res => {
this.disabled = false;
if (res.data && res.data.length) {
this.$toast(`"${res.data.toString()}"以上阀门执行异常`)
}
uni.showModal({
title: '关阀完成',
content: "仅表示命令发送成功,不代表阀门执行成功,请留意阀门状态,以阀门上报状态为准。",
showCancel: false,
success: (res) => {
uni.navigateBack();
}
});
});
}
});
},
// 角度记忆
saveBatchControlAngle(item) {
this.$showConfirm("执行角度记忆?").then(res => {
if (res.confirm) {
this.disabled = true;
isApi.saveBatchControlAngle(item.id).then(res => {
this.disabled = false;
this.$toast("记忆成功");
this.queryList();
});
}
});
2025-01-21 09:37:40 +08:00
2025-01-16 15:36:52 +08:00
},
2025-01-21 20:33:50 +08:00
// 分享
share() {
this.$toast("开发中")
},
2025-01-16 15:36:52 +08:00
}
}
</script>
<style lang="scss" scoped>
2025-01-21 18:40:11 +08:00
uni-app,
uni-page,
uni-page-wrapper,
uni-page-body {
padding-bottom: 38px !important;
}
::v-deep .uni-forms {
margin-right: 10px;
padding: 0 !important;
}
::v-deep .uni-forms-item {
margin-bottom: 0 !important;
}
::v-deep .uni-forms-item__label {
min-width: 0 !important;
width: auto !important;
font-size: 0.8rem;
height: inherit;
padding: 0;
2025-01-16 15:36:52 +08:00
}
2025-01-21 18:40:11 +08:00
::v-deep .uni-easyinput__content-input {
height: 20px;
width: 50px;
padding-left: 5px !important;
2025-01-16 15:36:52 +08:00
}
</style>