|
|
@@ -398,7 +398,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onActivated, ref, reactive, onDeactivated, computed, onMounted } from "vue";
|
|
|
+import { onActivated, ref, reactive, onDeactivated, onBeforeUnmount, computed, onMounted } from "vue";
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
import { ElMessage ,ElMessageBox} from "element-plus";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
|
@@ -425,7 +425,7 @@ const taskPopupType = ref('warning');
|
|
|
const isEdit = ref(false)
|
|
|
isAdd.value = route.query.isAdd ? true : false
|
|
|
isEdit.value = route.query.isEdit ? true : false
|
|
|
-onMounted(() => {
|
|
|
+onActivated(() => {
|
|
|
const id = route.query.id;
|
|
|
if (id) {
|
|
|
getDetail(id);
|
|
|
@@ -465,11 +465,6 @@ onMounted(() => {
|
|
|
getWarningMsg();
|
|
|
});
|
|
|
|
|
|
-onDeactivated(() => {
|
|
|
- // areaRef.value && newFarmMap.destroyMap();
|
|
|
- resetForm(formRef.value);
|
|
|
-});
|
|
|
-
|
|
|
const detailData = ref({});
|
|
|
const getDetail = (id) => {
|
|
|
VE_API.z_farm_work_record.getDetail({ id }).then(({ data }) => {
|
|
|
@@ -514,6 +509,56 @@ const resetForm = (formEl) => {
|
|
|
regionId.value = null;
|
|
|
};
|
|
|
|
|
|
+// 清空所有数据
|
|
|
+const clearData = () => {
|
|
|
+ // 清空表单
|
|
|
+ resetForm(formRef.value);
|
|
|
+
|
|
|
+ // 清空详情数据
|
|
|
+ detailData.value = {};
|
|
|
+
|
|
|
+ // 清空表单数据
|
|
|
+ dynamicValidateForm.farmWorkName = "";
|
|
|
+ dynamicValidateForm.conditionRate = "";
|
|
|
+ dynamicValidateForm.purpose = "";
|
|
|
+ dynamicValidateForm.executeDate = dayjs().format("YYYY-MM-DD");
|
|
|
+ dynamicValidateForm.checkDay = "";
|
|
|
+ dynamicValidateForm.usageMode = "";
|
|
|
+ dynamicValidateForm.prescriptionList = [{
|
|
|
+ name: "",
|
|
|
+ pesticideFertilizerList: [{
|
|
|
+ key: 1,
|
|
|
+ typeName: "",
|
|
|
+ muUsage: "",
|
|
|
+ muUsage2: "",
|
|
|
+ ratio: "",
|
|
|
+ ratio2: "",
|
|
|
+ remark: "",
|
|
|
+ }],
|
|
|
+ }];
|
|
|
+
|
|
|
+ // 清空其他数据
|
|
|
+ serveArea.value = null;
|
|
|
+ regionId.value = null;
|
|
|
+ areaList.value = [];
|
|
|
+ farmProgress.value = 0;
|
|
|
+ situationDescription.value = '';
|
|
|
+ checkedArea.value = false;
|
|
|
+ actionType.value = [];
|
|
|
+ gardenId.value = null;
|
|
|
+ showTaskPopup.value = false;
|
|
|
+ taskPopupType.value = 'warning';
|
|
|
+};
|
|
|
+
|
|
|
+onDeactivated(() => {
|
|
|
+ // areaRef.value && newFarmMap.destroyMap();
|
|
|
+ clearData();
|
|
|
+});
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ clearData();
|
|
|
+});
|
|
|
+
|
|
|
const cancelEdit = () => {
|
|
|
ElMessageBox.confirm("确认要取消编辑吗?", "提示", {
|
|
|
confirmButtonText: "确认",
|