jsy-app/pages/irrigation/index.vue

290 lines
8.9 KiB
Vue
Raw Normal View History

2024-09-30 15:52:11 +08:00
<template>
2025-01-09 18:29:36 +08:00
<!-- 顶部导航栏 -->
<custom-nav-bar :left="false" leftText="" @leftClick="" title="轮灌">
<template v-slot:right>
<view class="fixed">
2025-02-11 16:23:48 +08:00
<view align="right" class="iconfont icon-jia1 icon" @click="addTask()" v-show="tab.current === 0"
v-hasPermi="['system:irrigateTask:add']" />
2025-01-23 11:02:58 +08:00
<view align="right" class="iconfont icon-jia1 icon" @click="editScenario()" v-show="tab.current === 1"
v-hasPermi="['irrigate:irrigateScenario:saveIrrigateScenario']" />
2025-01-09 18:29:36 +08:00
</view>
</template>
</custom-nav-bar>
<!-- 选项卡 -->
2025-01-22 23:45:15 +08:00
<uni-segmented-control :current="tab.current" :values="tab.items" @clickItem="onClickItem" styleType="text"
2025-01-09 18:29:36 +08:00
activeColor="#39ac4f"></uni-segmented-control>
2025-01-22 23:45:15 +08:00
2025-01-09 18:29:36 +08:00
<view class="content">
2025-01-22 23:45:15 +08:00
<view v-show="tab.current === 0">
<z-paging ref="pagingTask" @query="queryTask" v-model="task" :auto-show-system-loading="true"
:default-page-size="pageSize" empty-view-text="抱歉,暂时还没有相关数据!" class="custom-z-paging">
2025-01-24 10:51:49 +08:00
<view class="card" v-for="item in task">
<view class="cards-title">
<view>
<view class="text">任务名称{{item.taskName}}</view>
</view>
<view class="title-r">
<!-- default灰色primary蓝色success绿色warning(黄色)error(红色)royal(紫色) -->
<uni-tag type="default" :circle="true" text="未轮灌" v-if="item.status == 0" />
<uni-tag type="primary" :circle="true" text="轮灌中" v-else-if="item.status == 1" />
<uni-tag type="success" :circle="true" text="已完成" v-else-if="item.status == 2" />
<uni-tag type="warning" :circle="true" text="已终止" v-else-if="item.status == 3" />
<uni-tag type="royal" :circle="true" text="暂停" v-else-if="item.status == 4" />
<uni-tag type="error" :circle="true" text="未知" v-else />
</view>
</view>
<view class="content">
<view class="cards-content">
<view class="txt-list">
<view class="list1">
<view><text>轮灌方案</text>{{item.scenarioName}}</view>
<view><text>轮灌组数</text>{{item.groupNum}}</view>
<!-- <view><text>起始组</text>{{item.startGroup}}</view> -->
<!-- <view><text>总时长</text>{{item.irrigateTotalDuration}}</view> -->
<!-- <view><text>是否调压</text>{{item.isAutoAdjust == 0 ? '否':'是'}}</view> -->
<!-- <view><text>压力</text>{{`${item.pressureMin} - ${item.pressureMax}`}}</view> -->
<view><text>开始时间</text>{{item.startTime}}</view>
<view><text>结束时间</text>{{item.endTime}}</view>
2025-01-09 18:29:36 +08:00
</view>
2025-01-24 10:51:49 +08:00
<view class="right" @click="taskDetail(item)"
v-hasPermi="['system:irrigateTask:query']">
<view class="iconfont icon-you" />
2025-01-09 18:29:36 +08:00
</view>
</view>
2025-01-24 10:51:49 +08:00
<view class="card-font">
<u-button v-hasPermi="['system:irrigateTask:remove']" size="mini" type="error" text="删除"
@click="delTask(item)" v-if="item.status == 0" />
</view>
</view>
</view>
2025-01-22 23:45:15 +08:00
</view>
</z-paging>
2025-01-24 10:51:49 +08:00
</view>
2025-01-22 23:45:15 +08:00
<view v-show="tab.current === 1">
<z-paging ref="pagingScenario" @query="queryScenario" v-model="scenario" :auto-show-system-loading="true"
:default-page-size="pageSize" empty-view-text="抱歉,暂时还没有相关数据!" class="custom-z-paging">
2025-01-24 10:51:49 +08:00
<view class="card" v-for="item in scenario">
<view class="cards-title">
<view>
<view class="text">方案名称{{item.scenarioName}}</view>
</view>
<view class="title-r">
<uni-tag class="bg-green" :circle="true" text="启用" v-if="item.delFlag == '0'" />
<uni-tag class="bg-red" :circle="true" text="禁用" v-else />
</view>
</view>
<view class="content">
<view class="cards-content">
<view class="txt-list">
<view class="list2">
<view><text>轮灌组数量</text>{{item.groupNum}}</view>
<view><text>总时长</text>{{item.irrigateTotalDuration}}</view>
<view><text>自动调压</text>{{item.isAutoAdjust == 0 ? '否':'是'}}</view>
<view><text>压力</text>{{`${item.pressureMin} - ${item.pressureMax}`}}</view>
2025-01-22 23:45:15 +08:00
</view>
2025-01-24 10:51:49 +08:00
<view class="right" @click="irrigationgroup(item)">
<view class="iconfont icon-you" />
2025-01-09 18:29:36 +08:00
</view>
</view>
2025-01-24 10:51:49 +08:00
<view class="card-font">
<u-button v-hasPermi="['irrigate:irrigateScenario:saveIrrigateScenario']" type="success"
size="mini" text="编辑" @click="editScenario(item)" />
<u-button v-hasPermi="['irrigate:irrigateScenario:delFlag']" size="mini" type="error"
text="禁用" @click="updateScenario(item,true)" v-if="item.delFlag == '0'" />
<u-button v-hasPermi="['irrigate:irrigateScenario:delFlag']" size="mini" type="success"
text="启用" @click="updateScenario(item,false)" v-else />
</view>
</view>
</view>
2025-01-22 23:45:15 +08:00
</view>
</z-paging>
2025-01-09 18:29:36 +08:00
</view>
</view>
2024-09-30 15:52:11 +08:00
</template>
<script>
2025-02-08 17:40:19 +08:00
import useUserStore from '@/store/modules/user'
const permissions = useUserStore.state.permissions
2025-01-23 22:48:11 +08:00
import * as taskApi from '@/api/irrigate/task.js'
2025-01-22 09:34:51 +08:00
import * as isApi from '@/api/irrigate/irrigateScenario.js'
2025-01-09 18:29:36 +08:00
export default {
data() {
return {
2025-01-22 23:45:15 +08:00
tab: {
items: ['轮灌详情', '轮灌方案'],
current: 0,
},
2025-01-23 15:17:08 +08:00
landId: null,
2025-01-22 23:45:15 +08:00
pageSize: 20,
2025-01-23 15:17:08 +08:00
landId: null,
2025-01-22 23:45:15 +08:00
task: [],
scenario: [],
2025-02-08 17:40:19 +08:00
permission: {
task: false,
scenario: false,
}
2025-01-09 18:29:36 +08:00
};
},
2025-01-23 15:17:08 +08:00
onShow() {
2025-01-23 22:48:11 +08:00
if (this.landId) {
this.reload();
}
2025-01-23 15:17:08 +08:00
if (getApp().ijs.land) {
this.landId = getApp().ijs.land.id;
}
},
2025-02-08 17:40:19 +08:00
mounted() {
this.permission.task = this.hasPermissions("system:irrigateTask:list");
this.permission.scenario = this.hasPermissions("irrigate:irrigateScenario:list");
},
2025-01-09 18:29:36 +08:00
methods: {
2025-02-08 17:40:19 +08:00
hasPermissions(key) {
if (permissions.includes("*:*:*") || permissions.includes(key)) {
return true;
} else {
return false;
}
},
2025-01-23 22:48:11 +08:00
reload() {
if (this.tab.current == 0) {
this.$refs.pagingTask.reload();
}
if (this.tab.current == 1) {
this.$refs.pagingScenario.reload();
}
},
2025-01-22 23:45:15 +08:00
onClickItem(e) {
if (this.tab.current != e.currentIndex) {
this.tab.current = e.currentIndex;
2025-01-22 09:34:51 +08:00
}
2025-01-23 22:48:11 +08:00
this.reload();
2025-01-22 09:34:51 +08:00
},
2025-01-22 23:45:15 +08:00
async queryTask() {
2025-02-08 17:40:19 +08:00
if (!this.permission.task) {
this.$refs.pagingTask.completeByTotal([], 0);
return;
}
2025-01-23 22:48:11 +08:00
taskApi.listTask({
2025-02-11 16:23:48 +08:00
landId: this.landId || -1
2025-01-23 22:48:11 +08:00
}).then(res => {
this.$refs.pagingTask.completeByTotal(res.rows, res.total);
});
2025-01-22 23:45:15 +08:00
},
async queryScenario() {
2025-02-08 17:40:19 +08:00
if (!this.permission.scenario) {
this.$refs.pagingScenario.completeByTotal([], 0);
return;
}
2025-01-22 23:45:15 +08:00
isApi.list({
2025-02-11 16:23:48 +08:00
landId: this.landId || -1,
2025-01-22 23:45:15 +08:00
scenarioType: 2,
status: "0",
2025-01-23 11:02:58 +08:00
// delFlag: "0",
2025-01-22 23:45:15 +08:00
}).then(res => {
this.$refs.pagingScenario.completeByTotal(res.rows, res.total);
})
},
2025-01-23 11:02:58 +08:00
/********************************* 任务 *********************************/
2025-01-23 22:48:11 +08:00
//新增任务
addTask(item = null) {
let url = `/pages/irrigation/task/task?landId=${this.landId}`
2025-01-23 15:17:08 +08:00
uni.navigateTo({
url: url
});
2025-01-09 18:29:36 +08:00
},
2025-01-23 22:48:11 +08:00
//删除任务
delTask(item) {
this.$showConfirm(`删除"${item.taskName}"?`).then(() => {
taskApi.delTask(item.id).then(res => {
this.$toast("删除成功");
this.reload();
}).catch(err => {
this.$showConfirm(err, false).then(() => {
this.reload();
})
})
}).catch(() => {});
},
//任务详情
taskDetail(item) {
2025-01-09 18:29:36 +08:00
uni.navigateTo({
2025-01-23 22:48:11 +08:00
url: `/pages/irrigation/task/detail?id=${item.id}`
2025-01-09 18:29:36 +08:00
});
2025-01-13 12:18:59 +08:00
},
2025-01-22 23:45:15 +08:00
/********************************* 方案 *********************************/
2025-01-23 11:02:58 +08:00
//方案编辑
editScenario(item = null) {
let url = `/pages/irrigation/scenario/scenario`
if (item) {
url = `${url}?id=${item.id}`
2025-01-23 15:17:08 +08:00
} else {
url = `${url}?landId=${this.landId}`
2025-01-23 11:02:58 +08:00
}
2025-01-13 12:18:59 +08:00
uni.navigateTo({
2025-01-23 11:02:58 +08:00
url: url
2025-01-22 23:45:15 +08:00
});
},
2025-01-23 11:02:58 +08:00
//方案详情
irrigationgroup(item) {
2025-01-22 23:45:15 +08:00
uni.navigateTo({
2025-01-23 11:02:58 +08:00
url: `/pages/irrigation/scenario/detail?id=${item.id}`
2025-01-13 12:18:59 +08:00
});
},
2025-01-23 11:02:58 +08:00
//方案删除
updateScenario(item, disabled) {
if (disabled) {
this.$showConfirm(`禁用"${item.scenarioName}"?`).then(() => {
isApi.disabled(item.id).then(res => {
this.$toast("禁用成功");
2025-01-23 22:48:11 +08:00
this.reload();
2025-01-23 11:02:58 +08:00
})
}).catch(() => {});
} else {
this.$showConfirm(`启用"${item.scenarioName}"?`).then(() => {
2025-01-23 11:32:16 +08:00
isApi.enable(item.id).then(res => {
2025-01-23 11:02:58 +08:00
this.$toast("启用成功");
2025-01-23 22:48:11 +08:00
this.reload();
2025-01-23 11:02:58 +08:00
})
}).catch(() => {});
}
}
2025-01-22 09:34:51 +08:00
2025-01-22 23:45:15 +08:00
// // 页面跳转
// config() {
// uni.navigateTo({
// url: '/pages/irrigation/config'
// });
// }
2025-01-09 18:29:36 +08:00
},
};
2024-09-30 15:52:11 +08:00
</script>
2025-01-09 18:29:36 +08:00
<style lang="scss" scoped>
// 选项卡
.segmented-control {
background-color: #fff;
}
.segmented-control__item--text {
font-weight: bold;
}
::v-deep .segmented-control__text {
font-size: 16px;
}
2025-01-22 23:45:15 +08:00
.custom-z-paging {
2025-01-24 10:51:49 +08:00
/* #ifdef H5 */
2025-01-22 23:45:15 +08:00
margin-top: 80px;
2025-01-24 10:51:49 +08:00
/* #endif */
/* #ifdef APP-PLUS */
margin-top: 105px;
/* #endif */
2025-01-22 23:45:15 +08:00
}
2024-09-30 15:52:11 +08:00
</style>