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

226 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'">三通阀
2025-01-22 15:38:07 +08:00
<span>{{valveKey[wo.deviceTypeKey][wo.valveNo]}}</span>
2025-01-21 18:40:11 +08:00
<span v-if="wo.angle">
2025-01-22 15:38:07 +08:00
({{`${valveKey[wo.deviceTypeKey][wo.angle.valveNo]}-${wo.angle.anglePercent}`}})
2025-01-21 18:40:11 +08:00
</span>
</view>
<view v-if="wo.deviceTypeKey == 'fiveValve'">五通阀
2025-01-22 15:38:07 +08:00
<span>{{valveKey[wo.deviceTypeKey][wo.valveNo]}}</span>
<span v-if="wo.angle">
({{`${wo.angle.angleKey == 'open' ? '开':'关'}-${wo.angle.anglePercent}`}})
</span>
2025-01-21 18:40:11 +08:00
</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-02-19 18:28:55 +08:00
import plugins from "@/plugins";
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": {
2025-01-22 15:38:07 +08:00
"1": "①开",
"2": "②开",
"3": "全开 ",
"4": "全关",
2025-01-21 18:40:11 +08:00
},
"fiveValve": {
2025-01-22 15:38:07 +08:00
"1": "①",
"2": "②",
"3": "③",
"4": "④",
2025-01-21 18:40:11 +08:00
}
},
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
});
},
2025-01-24 11:16:04 +08:00
// 分享
share() {
uni.navigateTo({
url: `/pages/batch-control/share?landId=${this.landId}`
});
},
2025-01-21 18:40:11 +08:00
// 删除
removeItem(item) {
this.$showConfirm(`删除"${item.groupName}"?`).then(res => {
2025-01-23 11:02:58 +08:00
isApi.removeBatchControl(item.id).then(res => {
this.queryList();
2025-02-19 18:28:55 +08:00
plugins.modal.msg("删除成功")
2025-01-23 11:02:58 +08:00
});
}).catch(() => {});
2025-01-21 18:40:11 +08:00
},
// 开阀
batchControlExec(isMemory, item) {
this.$showConfirm("执行批量开阀?").then(res => {
2025-01-23 11:02:58 +08:00
this.disabled = true;
isApi.batchControlExec(isMemory, item.id).then(res => {
this.disabled = false;
if (res.data && res.data.length) {
2025-02-19 18:28:55 +08:00
plugins.modal.msg(`"${res.data.toString()}"以上阀门执行异常`)
2025-01-23 11:02:58 +08:00
}
uni.showModal({
title: '开阀完成',
content: "仅表示命令发送成功,不代表阀门执行成功,请留意阀门状态,以阀门上报状态为准。",
showCancel: false,
success: (res) => {
uni.navigateBack();
2025-01-21 18:40:11 +08:00
}
});
2025-01-23 11:02:58 +08:00
});
}).catch(() => {});
2025-01-21 18:40:11 +08:00
},
// 关阀
batchControlClose(item) {
this.$showConfirm("执行批量关阀?").then(res => {
2025-01-23 11:02:58 +08:00
this.disabled = true;
isApi.batchControlClose(item.id).then(res => {
this.disabled = false;
if (res.data && res.data.length) {
2025-02-19 18:28:55 +08:00
plugins.modal.msg(`"${res.data.toString()}"以上阀门执行异常`)
2025-01-23 11:02:58 +08:00
}
uni.showModal({
title: '关阀完成',
content: "仅表示命令发送成功,不代表阀门执行成功,请留意阀门状态,以阀门上报状态为准。",
showCancel: false,
success: (res) => {
uni.navigateBack();
2025-01-21 18:40:11 +08:00
}
});
2025-01-23 11:02:58 +08:00
});
}).catch(() => {});
2025-01-21 18:40:11 +08:00
},
// 角度记忆
saveBatchControlAngle(item) {
this.$showConfirm("执行角度记忆?").then(res => {
2025-01-23 11:02:58 +08:00
this.disabled = true;
isApi.saveBatchControlAngle(item.id).then(res => {
this.disabled = false;
2025-02-19 18:28:55 +08:00
plugins.modal.msg("记忆成功")
2025-01-23 11:02:58 +08:00
this.queryList();
});
}).catch(() => {});
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>