From be7220a6797855edf37c93358e3ef7579ed92b87 Mon Sep 17 00:00:00 2001
From: Iruka <1017819588@qq.com>
Date: Thu, 23 Jan 2025 11:02:58 +0800
Subject: [PATCH] .
---
api/irrigate/irrigateScenario.js | 23 +--
pages/batch-control/index.vue | 89 ++++++------
pages/dev-ops/device.vue | 63 ++++-----
pages/dev-ops/station.vue | 52 +++----
pages/dev-ops/valve.vue | 41 +++---
pages/index-map.vue | 148 +++++++++-----------
pages/irrigation/index.vue | 104 +++++++-------
pages/irrigation/scenario/scenarioGroup.vue | 95 ++++++-------
utils/common.js | 6 +-
9 files changed, 294 insertions(+), 327 deletions(-)
diff --git a/api/irrigate/irrigateScenario.js b/api/irrigate/irrigateScenario.js
index 6f745ad..938f1f8 100644
--- a/api/irrigate/irrigateScenario.js
+++ b/api/irrigate/irrigateScenario.js
@@ -85,6 +85,21 @@ export function getIrrigateScenario(id) {
})
}
+// 禁用轮灌-轮灌方案(逻辑)
+export function disabled(id) {
+ return request({
+ url: `/system/irrigateScenario/disabled/${id}`,
+ method: 'delete'
+ })
+}
+
+// 启用轮灌-轮灌方案(逻辑)
+export function undisabled(id) {
+ return request({
+ url: `/system/irrigateScenario/undisabled/${id}`,
+ method: 'delete'
+ })
+}
@@ -100,12 +115,4 @@ export function updateIrrigateScenario(data) {
method: 'put',
data: data
})
-}
-
-// 删除轮灌-轮灌方案
-export function delIrrigateScenario(id) {
- return request({
- url: '/irrigate/irrigateScenario/' + id,
- method: 'delete'
- })
}
\ No newline at end of file
diff --git a/pages/batch-control/index.vue b/pages/batch-control/index.vue
index bf66b3f..fc24796 100644
--- a/pages/batch-control/index.vue
+++ b/pages/batch-control/index.vue
@@ -125,71 +125,62 @@
// 删除
removeItem(item) {
this.$showConfirm(`删除"${item.groupName}"?`).then(res => {
- if (res.confirm) {
- isApi.removeBatchControl(item.id).then(res => {
- this.queryList();
- this.$toast("删除成功")
- });
- }
- })
+ isApi.removeBatchControl(item.id).then(res => {
+ this.queryList();
+ this.$toast("删除成功")
+ });
+ }).catch(() => {});
},
// 开阀
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()}"以上阀门执行异常`)
+ 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();
}
- uni.showModal({
- title: '开阀完成',
- content: "仅表示命令发送成功,不代表阀门执行成功,请留意阀门状态,以阀门上报状态为准。",
- showCancel: false,
- success: (res) => {
- uni.navigateBack();
- }
- });
});
- }
- });
+ });
+ }).catch(() => {});
},
// 关阀
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()}"以上阀门执行异常`)
+ 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();
}
- uni.showModal({
- title: '关阀完成',
- content: "仅表示命令发送成功,不代表阀门执行成功,请留意阀门状态,以阀门上报状态为准。",
- showCancel: false,
- success: (res) => {
- uni.navigateBack();
- }
- });
});
- }
- });
+ });
+ }).catch(() => {});
},
// 角度记忆
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();
- });
- }
- });
-
+ this.disabled = true;
+ isApi.saveBatchControlAngle(item.id).then(res => {
+ this.disabled = false;
+ this.$toast("记忆成功");
+ this.queryList();
+ });
+ }).catch(() => {});
},
// 分享
share() {
diff --git a/pages/dev-ops/device.vue b/pages/dev-ops/device.vue
index 9b52a09..f2aec79 100644
--- a/pages/dev-ops/device.vue
+++ b/pages/dev-ops/device.vue
@@ -284,12 +284,10 @@
// 下发列表
sendTopoList(item) {
this.$showConfirm("下发列表").then(res => {
- if (res.confirm) {
- DevOpsApi.gvl(item.deviceCode).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.gvl(item.deviceCode).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 修改频段
SLF(item) {
@@ -301,12 +299,10 @@
// 获取配置
getStationConfig(item) {
this.$showConfirm("获取配置").then(res => {
- if (res.confirm) {
- DevOpsApi.gsc(item.deviceCode).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.gsc(item.deviceCode).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 压力校准
pressureCalibrationTopo(item) {
@@ -325,12 +321,10 @@
// 升级
upgradeStation(item) {
this.$showConfirm(`升级"${item.deviceCode}"到"${item.newVersionName}"版本?`).then(res => {
- if (res.confirm) {
- DevOpsApi.upgradeStation(item.deviceCode, item.newDeviceVersionId).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.upgradeStation(item.deviceCode, item.newDeviceVersionId).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 设备升级
upgradeTopoValve(item) {
@@ -349,18 +343,16 @@
// }
let msg = `您确定要修改【${this.rolaFrequency.item.deviceCode }】的频段为【${this.rolaFrequency.new}】?`;
this.$showConfirm(msg).then(res => {
- if (res.confirm) {
- DevOpsApi.slf({
- deviceCode: this.rolaFrequency.item.deviceCode,
- oldFrequency: this.rolaFrequency.old,
- newFrequency: this.rolaFrequency.new
- }).then(res => {
- this.$toast(res.msg)
- })
- } else {
- this.pop.rolaFrequency = true;
- }
- })
+ DevOpsApi.slf({
+ deviceCode: this.rolaFrequency.item.deviceCode,
+ oldFrequency: this.rolaFrequency.old,
+ newFrequency: this.rolaFrequency.new
+ }).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {
+ this.pop.rolaFrequency = true;
+ });
},
/************************************************** 4G阀门 **************************************************/
@@ -374,14 +366,11 @@
},
// 设备升级
upgradeValve4(item) {
- console.error("设备升级:", item);
this.$showConfirm(`升级"${item.deviceCode}"到"${item.newVersionName}"版本?`).then(res => {
- if (res.confirm) {
- DevOpsApi.upgradeValve4G(item.deviceCode, item.newDeviceVersionId).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.upgradeValve4G(item.deviceCode, item.newDeviceVersionId).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 压力校准
pressureCalibrationValve4(item) {
diff --git a/pages/dev-ops/station.vue b/pages/dev-ops/station.vue
index f7e286f..0b86f92 100644
--- a/pages/dev-ops/station.vue
+++ b/pages/dev-ops/station.vue
@@ -189,12 +189,10 @@
// 下发列表
sendList(item) {
this.$showConfirm("下发列表").then(res => {
- if (res.confirm) {
- DevOpsApi.gvl(item.deviceCode).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.gvl(item.deviceCode).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 修改频段
editRolaFrequency(item) {
@@ -206,12 +204,10 @@
// 获取配置
getConfig(item) {
this.$showConfirm("获取配置").then(res => {
- if (res.confirm) {
- DevOpsApi.gsc(item.deviceCode).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.gsc(item.deviceCode).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 压力校准
pressureCalibration(item) {
@@ -230,12 +226,10 @@
// 升级
upgrade(item) {
this.$showConfirm("基站升级").then(res => {
- if (res.confirm) {
- DevOpsApi.stationUpgrade(item.deviceCode, item.newDeviceVersionId).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.stationUpgrade(item.deviceCode, item.newDeviceVersionId).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 设备升级
valveUpgrade(item) {
@@ -257,18 +251,16 @@
// }
let msg = `您确定要修改【${this.rolaFrequency.item.deviceCode }】的频段为【${this.rolaFrequency.new}】?`;
this.$showConfirm(msg).then(res => {
- if (res.confirm) {
- DevOpsApi.slf({
- deviceCode: this.rolaFrequency.item.deviceCode,
- oldFrequency: this.rolaFrequency.old,
- newFrequency: this.rolaFrequency.new
- }).then(res => {
- this.$toast(res.msg)
- })
- } else {
- this.pop.rolaFrequency = true;
- }
- })
+ DevOpsApi.slf({
+ deviceCode: this.rolaFrequency.item.deviceCode,
+ oldFrequency: this.rolaFrequency.old,
+ newFrequency: this.rolaFrequency.new
+ }).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {
+ this.pop.rolaFrequency = true;
+ });
},
}
}
diff --git a/pages/dev-ops/valve.vue b/pages/dev-ops/valve.vue
index e5d4bec..117458e 100644
--- a/pages/dev-ops/valve.vue
+++ b/pages/dev-ops/valve.vue
@@ -143,7 +143,7 @@
// that.mqttConnected = e.connected;
} else if (e.type == "msg") {
if (e.topic.includes("jsy/iot/deviceConfig/2/") || e.topic.includes(
- "jsy/iot/deviceConfig/13/")) {
+ "jsy/iot/deviceConfig/13/")) {
const arr = e.topic.split("/");
const deviceCode = arr[4];
let obj = that.dataObj[deviceCode] || {};
@@ -159,7 +159,7 @@
lf: e.data.data,
})
}
-
+
that.dataObj[deviceCode] = obj;
}
}
@@ -182,7 +182,8 @@
if (rows && rows.length) {
let topic = [];
rows.forEach(item => {
- topic.push(`jsy/iot/deviceConfig/${item.device.deviceTypeId}/${item.device.deviceCode}`);//获取配置
+ topic.push(
+ `jsy/iot/deviceConfig/${item.device.deviceTypeId}/${item.device.deviceCode}`); //获取配置
});
this.topics = topic;
getApp().mqttSubscribes(this.topics);
@@ -202,12 +203,10 @@
// 获取配置
getConfig(item) {
this.$showConfirm("获取配置").then(res => {
- if (res.confirm) {
- DevOpsApi.gvc(item.device.deviceCode).then(res => {
- this.$toast(res.msg)
- })
- }
- })
+ DevOpsApi.gvc(item.device.deviceCode).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {});
},
// 关闭弹出层
close() {
@@ -226,19 +225,17 @@
// }
let msg = `您确定要修改【${this.rolaFrequency.item.deviceCode}】的频段为【${this.rolaFrequency.new}】?`;
this.$showConfirm(msg).then(res => {
- if (res.confirm) {
- DevOpsApi.vlf({
- stationCode: this.station.deviceCode,
- deviceCode: this.rolaFrequency.item.deviceCode,
- oldFrequency: this.rolaFrequency.old,
- newFrequency: this.rolaFrequency.new
- }).then(res => {
- this.$toast(res.msg)
- })
- } else {
- this.pop.rolaFrequency = true;
- }
- })
+ DevOpsApi.vlf({
+ stationCode: this.station.deviceCode,
+ deviceCode: this.rolaFrequency.item.deviceCode,
+ oldFrequency: this.rolaFrequency.old,
+ newFrequency: this.rolaFrequency.new
+ }).then(res => {
+ this.$toast(res.msg)
+ })
+ }).catch(() => {
+ this.pop.rolaFrequency = true;
+ });
},
}
diff --git a/pages/index-map.vue b/pages/index-map.vue
index a7846bc..5f00fe3 100644
--- a/pages/index-map.vue
+++ b/pages/index-map.vue
@@ -692,32 +692,30 @@
//导航
mapNavigation() {
this.$showConfirm(`导航至"${this.title}"?`).then(res => {
- if (res.confirm) {
- const centerPoint = JSON.parse(this.mapObj.landMap.centerPoint);
- const lat = centerPoint[1]
- const lng = centerPoint[0]
- let url = '';
- const appName = appInfo.name; // 替换为你的应用名
- const name = this.title; // 名称
- // 高德地图
- if (uni.getSystemInfoSync().platform === 'android') { // Android 平台
- url =
- `androidamap://route/plan/?sourceApplication=${appName}&sid=BGVIS1&did=BGVIS2&dlat=${lat}&dlon=${lng}&dname=${encodeURIComponent(name)}&mode=driving`;
- } else if (uni.getSystemInfoSync().platform === 'ios') { // iOS 平台
- url = `iosamap://path?sourceApplication=${appName}&mldl=${lat},${lng}`;
- }
-
- // // 百度地图 mode:driving:驾车模式。walking:步行模式。transit:公交模式。
- // url = `baidumap://map/direction?destination=latlng:${lat},${lng}|name:${encodeURIComponent(name)}&mode=driving`;
- // 尝试打开地图
- plus.runtime.openURL(url, function(err) {
- uni.showToast({
- title: '未安装应用',
- icon: 'none'
- });
- });
+ const centerPoint = JSON.parse(this.mapObj.landMap.centerPoint);
+ const lat = centerPoint[1]
+ const lng = centerPoint[0]
+ let url = '';
+ const appName = appInfo.name; // 替换为你的应用名
+ const name = this.title; // 名称
+ // 高德地图
+ if (uni.getSystemInfoSync().platform === 'android') { // Android 平台
+ url =
+ `androidamap://route/plan/?sourceApplication=${appName}&sid=BGVIS1&did=BGVIS2&dlat=${lat}&dlon=${lng}&dname=${encodeURIComponent(name)}&mode=driving`;
+ } else if (uni.getSystemInfoSync().platform === 'ios') { // iOS 平台
+ url = `iosamap://path?sourceApplication=${appName}&mldl=${lat},${lng}`;
}
- });
+
+ // // 百度地图 mode:driving:驾车模式。walking:步行模式。transit:公交模式。
+ // url = `baidumap://map/direction?destination=latlng:${lat},${lng}|name:${encodeURIComponent(name)}&mode=driving`;
+ // 尝试打开地图
+ plus.runtime.openURL(url, function(err) {
+ uni.showToast({
+ title: '未安装应用',
+ icon: 'none'
+ });
+ });
+ }).catch(() => {});
},
// 测距
mapRanging() {
@@ -727,10 +725,8 @@
return;
}
this.$showConfirm(`开启测距,开启后再次点击关闭。`).then(res => {
- if (res.confirm) {
- this.mapObj.ranging = true;
- }
- });
+ this.mapObj.ranging = true;
+ }).catch(() => {});
},
//设备状态更新
mapUpdateMarker(e) {
@@ -769,28 +765,26 @@
case 'sfj':
case 'sb':
this.$showConfirm("确定打开首部设备?").then(res => {
- if (res.confirm) {
- uni.showLoading()
- getHeadDevice(e.device.deviceId).then((res) => {
- uni.hideLoading()
- if (res.data.deviceTypeId === 4) {
- if (res.data.controlMode == 1) {
- uni.navigateTo({
- url: `/pages/head/fertilizerapplicator/detail?item=${JSON.stringify(res.data)}`,
- });
- } else if (item.controlMode == 2) {
- uni.navigateTo({
- url: `/pages/head/fertilizerapplicator/detailkl?item=${JSON.stringify(res.data)}`,
- });
- } else {}
- } else if (res.data.deviceTypeId === 5) {
+ uni.showLoading()
+ getHeadDevice(e.device.deviceId).then((res) => {
+ uni.hideLoading()
+ if (res.data.deviceTypeId === 4) {
+ if (res.data.controlMode == 1) {
uni.navigateTo({
- url: `/pages/head/headdevice/detail?item=${JSON.stringify(res.data)}`,
+ url: `/pages/head/fertilizerapplicator/detail?item=${JSON.stringify(res.data)}`,
});
- }
- });
- }
- })
+ } else if (item.controlMode == 2) {
+ uni.navigateTo({
+ url: `/pages/head/fertilizerapplicator/detailkl?item=${JSON.stringify(res.data)}`,
+ });
+ } else {}
+ } else if (res.data.deviceTypeId === 5) {
+ uni.navigateTo({
+ url: `/pages/head/headdevice/detail?item=${JSON.stringify(res.data)}`,
+ });
+ }
+ });
+ }).catch(() => {});
break;
case 'qxz':
@@ -799,36 +793,34 @@
case 'sxt':
case 'scd':
this.$showConfirm("确定打开农情设备?").then(res => {
- if (res.confirm) {
- uni.showLoading()
- getOtherDevice(e.device.deviceId).then((res) => {
- uni.hideLoading()
- let url = null;
- if (res.data.deviceTypeId === 6) {
- url =
- `/pages/fourmonitor/weatherstation?item=${encodeURIComponent(JSON.stringify(res.data))}`;
- } else if (res.data.deviceTypeId === 7) {
- url =
- `/pages/fourmonitor/pest?item=${encodeURIComponent(JSON.stringify(res.data))}`;
- } else if (res.data.deviceTypeId === 8) {
- url =
- `/pages/fourmonitor/spore?item=${encodeURIComponent(JSON.stringify(res.data))}`;
- } else if (res.data.deviceTypeId === 9) {
- if (!res.data.ezopenUrl1 || !res.data.ezopenUrl2) {
- this.$toast("获取播放地址失败!")
- return;
- }
- url =
- `/pages/fourmonitor/camera?item=${encodeURIComponent(JSON.stringify(res.data))}`;
- } else if (res.data.deviceTypeId === 10) {}
- if (url) {
- uni.navigateTo({
- url: url,
- });
+ uni.showLoading()
+ getOtherDevice(e.device.deviceId).then((res) => {
+ uni.hideLoading()
+ let url = null;
+ if (res.data.deviceTypeId === 6) {
+ url =
+ `/pages/fourmonitor/weatherstation?item=${encodeURIComponent(JSON.stringify(res.data))}`;
+ } else if (res.data.deviceTypeId === 7) {
+ url =
+ `/pages/fourmonitor/pest?item=${encodeURIComponent(JSON.stringify(res.data))}`;
+ } else if (res.data.deviceTypeId === 8) {
+ url =
+ `/pages/fourmonitor/spore?item=${encodeURIComponent(JSON.stringify(res.data))}`;
+ } else if (res.data.deviceTypeId === 9) {
+ if (!res.data.ezopenUrl1 || !res.data.ezopenUrl2) {
+ this.$toast("获取播放地址失败!")
+ return;
}
- });
- }
- });
+ url =
+ `/pages/fourmonitor/camera?item=${encodeURIComponent(JSON.stringify(res.data))}`;
+ } else if (res.data.deviceTypeId === 10) {}
+ if (url) {
+ uni.navigateTo({
+ url: url,
+ });
+ }
+ });
+ }).catch(() => {});
break;
case 'sq':
this.$refs.mpRef.show(this.ijs.land, e.device.id);
diff --git a/pages/irrigation/index.vue b/pages/irrigation/index.vue
index 6141544..436dde7 100644
--- a/pages/irrigation/index.vue
+++ b/pages/irrigation/index.vue
@@ -3,7 +3,9 @@
-
+
+
@@ -128,6 +130,10 @@
方案名称:{{item.scenarioName}}
+
+
+
+
@@ -135,56 +141,28 @@
轮灌组数量:{{item.groupNum}}
- 压力:{{item.pressureMin}}-{{item.pressureMax}}
总时长:{{item.irrigateTotalDuration}}
+ 自动调压:{{item.isAutoAdjust == 0 ? '否':'是'}}
+ 压力:{{`${item.pressureMin} - ${item.pressureMax}`}}
-
-
+
-
-
-
+
+
+
-
@@ -221,23 +199,16 @@
isApi.list({
scenarioType: 2,
status: "0",
- delFlag: "0",
+ // delFlag: "0",
}).then(res => {
this.scenario = res.rows;
this.$refs.pagingScenario.completeByTotal(res.rows, res.total);
})
},
- add() {
- if (this.tab.current === 0) { //新增任务
-
- }
- if (this.tab.current === 1) { //新增轮灌
- uni.navigateTo({
- url: '/pages/irrigation/scenario/scenario'
- });
- }
- },
/********************************* 任务 *********************************/
+ editTask(item = null) {
+
+ },
//页面跳转
taskdetails() {
uni.navigateTo({
@@ -246,17 +217,40 @@
},
/********************************* 方案 *********************************/
+ //方案编辑
+ editScenario(item = null) {
+ let url = `/pages/irrigation/scenario/scenario`
+ if (item) {
+ url = `${url}?id=${item.id}`
+ }
+ uni.navigateTo({
+ url: url
+ });
+ },
//方案详情
irrigationgroup(item) {
uni.navigateTo({
url: `/pages/irrigation/scenario/detail?id=${item.id}`
});
},
- editScenario(item) {
- uni.navigateTo({
- url: `/pages/irrigation/scenario/scenario?id=${item.id}`
- });
- },
+ //方案删除
+ updateScenario(item, disabled) {
+ if (disabled) {
+ this.$showConfirm(`禁用"${item.scenarioName}"?`).then(() => {
+ isApi.disabled(item.id).then(res => {
+ this.$toast("禁用成功");
+ this.queryScenario();
+ })
+ }).catch(() => {});
+ } else {
+ this.$showConfirm(`启用"${item.scenarioName}"?`).then(() => {
+ isApi.undisabled(item.id).then(res => {
+ this.$toast("启用成功");
+ this.queryScenario();
+ })
+ }).catch(() => {});
+ }
+ }
diff --git a/pages/irrigation/scenario/scenarioGroup.vue b/pages/irrigation/scenario/scenarioGroup.vue
index 9b31f92..8640bdd 100644
--- a/pages/irrigation/scenario/scenarioGroup.vue
+++ b/pages/irrigation/scenario/scenarioGroup.vue
@@ -342,15 +342,13 @@
itemChange(wo, vItem) {
if (this.selected[`${wo.id}_${vItem.valveNo}`]) {
this.$showConfirm("更换到当前轮灌组?").then(res => {
- if (res.confirm) {
- //删除之前存储的组中的数据
- this.removeWo(this.selected[`${wo.id}_${vItem.valveNo}`].gIndex, wo.id, vItem.valveNo);
- delete this.selected[`${wo.id}_${vItem.valveNo}`];
+ //删除之前存储的组中的数据
+ this.removeWo(this.selected[`${wo.id}_${vItem.valveNo}`].gIndex, wo.id, vItem.valveNo);
+ delete this.selected[`${wo.id}_${vItem.valveNo}`];
- //添加新选中的
- this.setSelect(wo, vItem);
- }
- })
+ //添加新选中的
+ this.setSelect(wo, vItem);
+ }).catch(() => {});
return;
}
//添加新选中的
@@ -490,40 +488,39 @@
this.groupPop = false;
const groupName = this.formData.groups[index].groupName;
this.$showConfirm(`删除"${groupName}"?`).then(res => {
- this.groupPop = true;
- if (res.confirm) {
- //删除轮灌组
- this.formData.groups[index]._isHide = true;
- let i = 0;
- this.formData.groups.forEach(item => {
- if (item._isHide) {
- return;
- }
- i++;
- item.groupName = `轮灌组${i}`;
- item.sort = i;
- });
- this.formData.groupNum = i;
- this.calcAVGDuration();
+ //删除轮灌组
+ this.formData.groups[index]._isHide = true;
+ let i = 0;
+ this.formData.groups.forEach(item => {
+ if (item._isHide) {
+ return;
+ }
+ i++;
+ item.groupName = `轮灌组${i}`;
+ item.sort = i;
+ });
+ this.formData.groupNum = i;
+ this.calcAVGDuration();
- //删除存储的数据
- if (this.gIndex == index) { //删除的是当前的组
- this.select = {};
- } else { //不是当前组
- for (var key in this.selected) {
- let item = this.selected[key];
- if (item.gIndex == index) {
- delete this.selected[key];
- } else {
- this.selected[key].text = this.formData.groups[item.gIndex].groupName;
- }
+ //删除存储的数据
+ if (this.gIndex == index) { //删除的是当前的组
+ this.select = {};
+ } else { //不是当前组
+ for (var key in this.selected) {
+ let item = this.selected[key];
+ if (item.gIndex == index) {
+ delete this.selected[key];
+ } else {
+ this.selected[key].text = this.formData.groups[item.gIndex].groupName;
}
}
-
- //新的编辑组索引
- this.selectIndex = true;
- this.$toast("删除成功,轮灌组重新排序")
}
+
+ //新的编辑组索引
+ this.selectIndex = true;
+ this.$toast("删除成功,轮灌组重新排序")
+ }).catch(() => {
+ this.groupPop = true;
});
},
//新增轮灌组
@@ -554,17 +551,21 @@
this.$toast(`"${title}"未选择出水口`)
return;
}
+ formData.groups.forEach((item, index) => {
+ item.wos = item.wos.slice().sort((v1, v2) => woSort(v1, v2, "woName"));
+ item.wos.forEach((_item, _index) => {
+ _item.sort = (_index + 1)
+ })
+ })
this.$showConfirm("保存轮灌方案?").then(res => {
- if (res.confirm) {
- uni.showLoading();
- isApi.saveIrrigateScenario(formData).then(res => {
- uni.hideLoading();
- uni.switchTab({
- url: '/pages/irrigation/index'
- });
+ uni.showLoading();
+ isApi.saveIrrigateScenario(formData).then(res => {
+ uni.hideLoading();
+ uni.switchTab({
+ url: '/pages/irrigation/index'
});
- }
- });
+ });
+ }).catch(() => {});
},
}
}
diff --git a/utils/common.js b/utils/common.js
index 5f0fc89..6aa4892 100644
--- a/utils/common.js
+++ b/utils/common.js
@@ -21,7 +21,11 @@ export function showConfirm(content) {
cancelText: '取消',
confirmText: '确定',
success: function(res) {
- resolve(res)
+ if (res.confirm) {
+ resolve(res)
+ } else {
+ reject(res);
+ }
}
})
})