|
@@ -73,25 +73,34 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="farm-scale-form">
|
|
<div class="farm-scale-form">
|
|
|
<div class="farm-scale-item">
|
|
<div class="farm-scale-item">
|
|
|
- <label class="farm-scale-label">一般长工人数</label>
|
|
|
|
|
|
|
+ <div class="farm-scale-label">
|
|
|
|
|
+ 农场固定长工
|
|
|
|
|
+ <div class="sub-label">(会操作各种小型农机)</div>
|
|
|
|
|
+ </div>
|
|
|
<el-input v-model="farmScale.regularWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
<el-input v-model="farmScale.regularWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
|
<template #append>人</template>
|
|
<template #append>人</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="farm-scale-item">
|
|
<div class="farm-scale-item">
|
|
|
- <label class="farm-scale-label">植保技能人数</label>
|
|
|
|
|
|
|
+ <label class="farm-scale-label">无人机植保人员</label>
|
|
|
<el-input v-model="farmScale.plantProtectionWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
<el-input v-model="farmScale.plantProtectionWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
|
<template #append>人</template>
|
|
<template #append>人</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="farm-scale-item">
|
|
<div class="farm-scale-item">
|
|
|
- <label class="farm-scale-label">剪枝技能人数</label>
|
|
|
|
|
|
|
+ <label class="farm-scale-label">专业树形修剪人员</label>
|
|
|
|
|
+ <el-input v-model="farmScale.pruningWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
|
|
|
+ <template #append>人</template>
|
|
|
|
|
+ </el-input>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="farm-scale-item">
|
|
|
|
|
+ <label class="farm-scale-label">专业嫁接换种人员</label>
|
|
|
<el-input v-model="farmScale.pruningWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
<el-input v-model="farmScale.pruningWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
|
<template #append>人</template>
|
|
<template #append>人</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="farm-scale-item">
|
|
<div class="farm-scale-item">
|
|
|
- <label class="farm-scale-label">农忙时可调度人数</label>
|
|
|
|
|
|
|
+ <label class="farm-scale-label">农忙可调度人员</label>
|
|
|
<el-input v-model="farmScale.tempDispatchWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
<el-input v-model="farmScale.tempDispatchWorkerCount" placeholder="请输入人数" class="farm-scale-input">
|
|
|
<template #append>人</template>
|
|
<template #append>人</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
@@ -129,7 +138,7 @@
|
|
|
<span class="text">{{ item.name }}</span>
|
|
<span class="text">{{ item.name }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div> -->
|
|
</div> -->
|
|
|
- <el-radio-group v-model="basicForm.expertOptions">
|
|
|
|
|
|
|
+ <el-radio-group v-model="basicForm.expertCode">
|
|
|
<el-radio-button v-for="(item, index) in basicFarmFormData.expertOptions" :key="index"
|
|
<el-radio-button v-for="(item, index) in basicFarmFormData.expertOptions" :key="index"
|
|
|
:label="item.name" :value="item.code" />
|
|
:label="item.name" :value="item.code" />
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
@@ -161,24 +170,79 @@
|
|
|
<span class="ml-2">数量</span>
|
|
<span class="ml-2">数量</span>
|
|
|
</div>
|
|
</div>
|
|
|
<el-input class="popup-input" v-model="popupInputNum" :placeholder="'请输入' + formNameObj[addTypeKey]+'数量'" size="large">
|
|
<el-input class="popup-input" v-model="popupInputNum" :placeholder="'请输入' + formNameObj[addTypeKey]+'数量'" size="large">
|
|
|
- <template #append>{{ machineryUnit || '辆/架' }}</template>
|
|
|
|
|
|
|
+ <template #append>{{ machineryUnit || '辆' }}</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="popup-button">
|
|
<div class="popup-button">
|
|
|
- <div class="delete" v-if="isEditPopup" @click="handleDelete">删除</div>
|
|
|
|
|
|
|
+ <div class="delete" v-if="isEditPopup && isMachineSelf" @click="handleDelete">删除</div>
|
|
|
|
|
+ <div class="delete" v-else-if="isEditPopup && !isMachineSelf" @click="handleCancelSelect">取消选中</div>
|
|
|
<div class="cancel" v-else @click="showAddPopup = false">取消</div>
|
|
<div class="cancel" v-else @click="showAddPopup = false">取消</div>
|
|
|
<div @click="handleConfirm">确认</div>
|
|
<div @click="handleConfirm">确认</div>
|
|
|
</div>
|
|
</div>
|
|
|
</popup>
|
|
</popup>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 物候期信息 -->
|
|
|
|
|
+ <popup class="period-popup" round v-model:show="showPeriodPopup">
|
|
|
|
|
+ <div class="period-header">为了{{ basicForm?.expertInfo?.name }}专家的处方体系适用于您的果园管理,请完善基本物候信息</div>
|
|
|
|
|
+ <div class="period-content">
|
|
|
|
|
+ <div class="period-item" v-for="(item, i) in phenologyList" :key="i">
|
|
|
|
|
+ <div class="period-item-name">{{ item.typeName }}</div>
|
|
|
|
|
+ <div class="period-item-label">
|
|
|
|
|
+ <div class="label-item-group">
|
|
|
|
|
+ <div class="label-item">当下物候期</div>
|
|
|
|
|
+ <div class="label-item-value period-display">{{ item.phenologyName }}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="label-item-group">
|
|
|
|
|
+ <div class="label-item">{{ item.startDateLabel || '起始时间' }}</div>
|
|
|
|
|
+ <div class="label-item-value">
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ v-model="item.phenologyStartDate"
|
|
|
|
|
+ type="date"
|
|
|
|
|
+ :default-value="new Date(2026, 1, 1)"
|
|
|
|
|
+ placeholder="选择时间"
|
|
|
|
|
+ :disabled-date="disabledDate"
|
|
|
|
|
+ :clearable="false"
|
|
|
|
|
+ format="YYYY-MM-DD"
|
|
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="period-footer">
|
|
|
|
|
+ <div class="period-footer-btn" @click="handlePeriodConfirm">确认信息</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </popup>
|
|
|
|
|
+
|
|
|
|
|
+ <tip-popup
|
|
|
|
|
+ v-model:show="showSuccessPopup"
|
|
|
|
|
+ type="success"
|
|
|
|
|
+ text="专属处方已经生成"
|
|
|
|
|
+ buttonText="点击查看"
|
|
|
|
|
+ @closedPopup="handleSuccessConfirm"
|
|
|
|
|
+ @confirm="handleSuccessConfirm"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #default>
|
|
|
|
|
+ <div class="expert-info">
|
|
|
|
|
+ <img class="expert-img" src="@/assets/img/home/zj-1.png" alt="">
|
|
|
|
|
+ {{ basicForm?.expertInfo?.name }} 专家的
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </tip-popup>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onActivated } from "vue";
|
|
|
|
|
|
|
+import { ref, onActivated, onBeforeUnmount, onDeactivated, onMounted } from "vue";
|
|
|
import { ElMessage } from "element-plus";
|
|
import { ElMessage } from "element-plus";
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
|
|
+import tipPopup from "@/components/popup/tipPopup.vue";
|
|
|
import { Popup } from "vant";
|
|
import { Popup } from "vant";
|
|
|
|
|
+import { useStore } from "vuex";
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
|
|
+const store = useStore();
|
|
|
|
|
|
|
|
const outputList = ref([
|
|
const outputList = ref([
|
|
|
{ name: "低温冻害" },
|
|
{ name: "低温冻害" },
|
|
@@ -203,20 +267,79 @@ onActivated(() => {
|
|
|
// 为 productList 的每个 group 设置默认选中第一项
|
|
// 为 productList 的每个 group 设置默认选中第一项
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ getCurrentAndNextPhenology();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const basicForm = ref({
|
|
const basicForm = ref({
|
|
|
soilTypes: "",
|
|
soilTypes: "",
|
|
|
irrigationMethods: [],
|
|
irrigationMethods: [],
|
|
|
machineryWithQuantity: [],
|
|
machineryWithQuantity: [],
|
|
|
improvementAreas: [],
|
|
improvementAreas: [],
|
|
|
|
|
+ expertCode: "",
|
|
|
|
|
+ expertInfo: {},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const basicFarmFormData = ref({});
|
|
const basicFarmFormData = ref({});
|
|
|
const getBasicFarmFormData = () => {
|
|
const getBasicFarmFormData = () => {
|
|
|
- VE_API.basic_farm.fetchBasicFarmFormData({ farmId: 766 }).then(({ data }) => {
|
|
|
|
|
|
|
+ VE_API.basic_farm.fetchBasicFarmFormData().then(({ data }) => {
|
|
|
basicFarmFormData.value = data;
|
|
basicFarmFormData.value = data;
|
|
|
|
|
+
|
|
|
|
|
+ // 根据返回的数据进行默认赋值
|
|
|
|
|
+ // 1. 土壤类型 - 找到 selected: true 的项
|
|
|
|
|
+ if (data.soilTypes && Array.isArray(data.soilTypes)) {
|
|
|
|
|
+ const selectedSoilType = data.soilTypes.find(item => item.selected);
|
|
|
|
|
+ if (selectedSoilType) {
|
|
|
|
|
+ basicForm.value.soilTypes = selectedSoilType.code;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 专家选项 - 找到 selected: true 的项
|
|
|
|
|
+ if (data.expertOptions && Array.isArray(data.expertOptions)) {
|
|
|
|
|
+ const selectedExpert = data.expertOptions.find(item => item.selected);
|
|
|
|
|
+ if (selectedExpert) {
|
|
|
|
|
+ basicForm.value.expertCode = selectedExpert.code;
|
|
|
|
|
+ basicForm.value.expertInfo = selectedExpert;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 农场规模数据
|
|
|
|
|
+ if (data.farmScale) {
|
|
|
|
|
+ farmScale.value = {
|
|
|
|
|
+ regularWorkerCount: data.farmScale.regularWorkerCount || "",
|
|
|
|
|
+ plantProtectionWorkerCount: data.farmScale.plantProtectionWorkerCount || "",
|
|
|
|
|
+ pruningWorkerCount: data.farmScale.pruningWorkerCount || "",
|
|
|
|
|
+ tempDispatchWorkerCount: data.farmScale.tempDispatchWorkerCount || "",
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 4. irrigationMethods, improvementAreas, machinery 的 selected 状态已经在 data 中设置好了
|
|
|
|
|
+ // 这些数据会直接显示在页面上,因为页面是通过 basicFarmFormData 来渲染的
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 收集表单数据并保存草稿
|
|
|
|
|
+const saveDraft = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const draftData = handleSubmit();
|
|
|
|
|
+
|
|
|
|
|
+ // 调用保存草稿接口
|
|
|
|
|
+ await VE_API.basic_farm.saveDraft(draftData);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("保存草稿失败:", error);
|
|
|
|
|
+ // 静默失败,不显示错误提示
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 离开页面时保存草稿
|
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
|
|
+ // saveDraft();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+onDeactivated(() => {
|
|
|
|
|
+ saveDraft();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const formNameObj = ref({
|
|
const formNameObj = ref({
|
|
|
irrigationMethods: '灌溉方式',
|
|
irrigationMethods: '灌溉方式',
|
|
|
crops: '作物',
|
|
crops: '作物',
|
|
@@ -246,6 +369,7 @@ function handleMachineryAdd(type) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function handleSelect(type, index, custom) {
|
|
function handleSelect(type, index, custom) {
|
|
|
|
|
+ isMachineSelf.value = custom;
|
|
|
if (custom === true) {
|
|
if (custom === true) {
|
|
|
showAddPopup.value = true;
|
|
showAddPopup.value = true;
|
|
|
isEditPopup.value = true;
|
|
isEditPopup.value = true;
|
|
@@ -278,12 +402,16 @@ function handleConfirm() {
|
|
|
|
|
|
|
|
saveCustomOption(popupInputVal.value);
|
|
saveCustomOption(popupInputVal.value);
|
|
|
} else {
|
|
} else {
|
|
|
- basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].name = popupInputVal.value;
|
|
|
|
|
- basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].quantity = popupInputNum.value;
|
|
|
|
|
- basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].selected = true;
|
|
|
|
|
|
|
+ const option = basicFarmFormData.value[addTypeKey.value][currentEditIndex.value]
|
|
|
|
|
+ option.name = popupInputVal.value;
|
|
|
|
|
+ option.quantity = popupInputNum.value;
|
|
|
|
|
+ option.selected = true;
|
|
|
// 更新名称
|
|
// 更新名称
|
|
|
console.log('更新名称', basicFarmFormData.value[addTypeKey.value][currentEditIndex.value]);
|
|
console.log('更新名称', basicFarmFormData.value[addTypeKey.value][currentEditIndex.value]);
|
|
|
- updateCustomOption(popupInputVal.value, basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].id);
|
|
|
|
|
|
|
+ if (option.custom) {
|
|
|
|
|
+ // updateCustomOption(popupInputVal.value, option.id || option.code);
|
|
|
|
|
+ updateCustomOption(popupInputVal.value, basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].id);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
currentEditIndex.value = -1;
|
|
currentEditIndex.value = -1;
|
|
|
isEditPopup.value = false;
|
|
isEditPopup.value = false;
|
|
@@ -294,14 +422,15 @@ function handleConfirm() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (isEditPopup.value) {
|
|
if (isEditPopup.value) {
|
|
|
- basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].name = popupInputVal.value;
|
|
|
|
|
|
|
+ const option = basicFarmFormData.value[addTypeKey.value][currentEditIndex.value]
|
|
|
|
|
+ option.name = popupInputVal.value;
|
|
|
currentEditIndex.value = -1;
|
|
currentEditIndex.value = -1;
|
|
|
isEditPopup.value = false;
|
|
isEditPopup.value = false;
|
|
|
showAddPopup.value = false;
|
|
showAddPopup.value = false;
|
|
|
- updateCustomOption(popupInputVal.value, basicFarmFormData.value[addTypeKey.value][currentEditIndex.value].id);
|
|
|
|
|
|
|
+ updateCustomOption(popupInputVal.value, option.id || option.code);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- basicFarmFormData.value[addTypeKey.value].push({ name: popupInputVal.value, code: popupInputVal.value, selected: true, custom: true });
|
|
|
|
|
|
|
+ // basicFarmFormData.value[addTypeKey.value].push({ name: popupInputVal.value, code: popupInputVal.value, selected: true, custom: true });
|
|
|
saveCustomOption(popupInputVal.value);
|
|
saveCustomOption(popupInputVal.value);
|
|
|
|
|
|
|
|
showAddPopup.value = false;
|
|
showAddPopup.value = false;
|
|
@@ -336,39 +465,276 @@ function handleDelete() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function handleCancelSelect() {
|
|
|
|
|
+ const option = basicFarmFormData.value[addTypeKey.value][currentEditIndex.value]
|
|
|
|
|
+ option.selected = false;
|
|
|
|
|
+ option.quantity = null;
|
|
|
|
|
+ currentEditIndex.value = -1;
|
|
|
|
|
+ showAddPopup.value = false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const goBack = () => {
|
|
const goBack = () => {
|
|
|
|
|
+ // saveDraft();
|
|
|
// router.go(-1);
|
|
// router.go(-1);
|
|
|
router.replace(`/create_farm?from=${route.query.from}&type=${route.query.type}`)
|
|
router.replace(`/create_farm?from=${route.query.from}&type=${route.query.type}`)
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const handlePage = () => {
|
|
|
|
|
|
|
+function handleSubmit() {
|
|
|
|
|
+ // 收集土壤类型(转换为数组)
|
|
|
|
|
+ const soilTypes = basicForm.value.soilTypes
|
|
|
|
|
+ ? (Array.isArray(basicForm.value.soilTypes) ? basicForm.value.soilTypes : [basicForm.value.soilTypes])
|
|
|
|
|
+ : [];
|
|
|
|
|
+
|
|
|
|
|
+ // 收集灌溉方式(获取选中的 code)
|
|
|
|
|
+ const irrigationMethods = (basicFarmFormData.value.irrigationMethods || [])
|
|
|
|
|
+ .filter(item => item.selected)
|
|
|
|
|
+ .map(item => item.code || item.id);
|
|
|
|
|
+
|
|
|
|
|
+ // 收集农机设备(包含 code 和 quantity)
|
|
|
|
|
+ const machineryWithQuantity = (basicFarmFormData.value.machinery || [])
|
|
|
|
|
+ .filter(item => item.selected && item.quantity)
|
|
|
|
|
+ .map(item => ({
|
|
|
|
|
+ code: item.code || item.id,
|
|
|
|
|
+ quantity: Number(item.quantity) || 0
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ // 收集希望专家帮助解决的种植难题(获取选中的 code)
|
|
|
|
|
+ const improvementAreas = (basicFarmFormData.value.improvementAreas || [])
|
|
|
|
|
+ .filter(item => item.selected)
|
|
|
|
|
+ .map(item => item.code || item.id);
|
|
|
|
|
+
|
|
|
|
|
+ // 收集农场规模数据
|
|
|
|
|
+ const draftData = {
|
|
|
|
|
+ soilTypes: soilTypes.map(code => Number(code)),
|
|
|
|
|
+ irrigationMethods: irrigationMethods.map(code => Number(code)),
|
|
|
|
|
+ machineryWithQuantity: machineryWithQuantity.map(item => ({
|
|
|
|
|
+ code: Number(item.code),
|
|
|
|
|
+ quantity: item.quantity
|
|
|
|
|
+ })),
|
|
|
|
|
+ regularWorkerCount: Number(farmScale.value.regularWorkerCount) || 0,
|
|
|
|
|
+ plantProtectionWorkerCount: Number(farmScale.value.plantProtectionWorkerCount) || 0,
|
|
|
|
|
+ pruningWorkerCount: Number(farmScale.value.pruningWorkerCount) || 0,
|
|
|
|
|
+ tempDispatchWorkerCount: Number(farmScale.value.tempDispatchWorkerCount) || 0,
|
|
|
|
|
+ improvementAreas: improvementAreas.map(code => Number(code)),
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- if (route.query.type === 'farmer') {
|
|
|
|
|
- router.push('/agri_record')
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ // 如果有选择的专家,添加 preferredExpertCode
|
|
|
|
|
+ if (basicForm.value.expertCode) {
|
|
|
|
|
+ draftData.preferredExpertCode = Number(basicForm.value.expertCode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 获取所有需要传递的参数,包括 from 参数
|
|
|
|
|
- const queryParams = {
|
|
|
|
|
- containerId: route.query.containerId,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ return draftData;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 校验必填项
|
|
|
|
|
+function validateForm() {
|
|
|
|
|
+ // 校验土壤类型
|
|
|
|
|
+ if (!basicForm.value.soilTypes) {
|
|
|
|
|
+ ElMessage.warning('请选择您的果园土壤类型');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验灌溉方式
|
|
|
|
|
+ const irrigationMethods = (basicFarmFormData.value.irrigationMethods || [])
|
|
|
|
|
+ .filter(item => item.selected);
|
|
|
|
|
+ if (irrigationMethods.length === 0) {
|
|
|
|
|
+ ElMessage.warning('请选择您的灌溉方式');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 如果存在 from 参数,继续传递
|
|
|
|
|
- if (route.query.from) {
|
|
|
|
|
- queryParams.from = route.query.from;
|
|
|
|
|
|
|
+ // 校验农机设备
|
|
|
|
|
+ const machineryWithQuantity = (basicFarmFormData.value.machinery || [])
|
|
|
|
|
+ .filter(item => item.selected && item.quantity);
|
|
|
|
|
+ if (machineryWithQuantity.length === 0) {
|
|
|
|
|
+ ElMessage.warning('请选择您的农机设备并填写数量');
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 传递所有农场相关的参数,以便在 agricultural_plan 页面创建农场
|
|
|
|
|
- const farmParams = ['wkt', 'speciesId', 'containerId', 'agriculturalCreate', 'geom', 'address', 'mu', 'name', 'fzr', 'tel', 'defaultFarm', 'typeId', 'speciesName', 'userType'];
|
|
|
|
|
- farmParams.forEach(key => {
|
|
|
|
|
- if (route.query[key] !== undefined) {
|
|
|
|
|
- queryParams[key] = route.query[key];
|
|
|
|
|
|
|
+ // 校验希望专家帮助解决的种植难题
|
|
|
|
|
+ const improvementAreas = (basicFarmFormData.value.improvementAreas || [])
|
|
|
|
|
+ .filter(item => item.selected);
|
|
|
|
|
+ if (improvementAreas.length === 0) {
|
|
|
|
|
+ ElMessage.warning('请选择希望专家帮助解决的种植难题');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验专家选项
|
|
|
|
|
+ if (!basicForm.value.expertCode) {
|
|
|
|
|
+ ElMessage.warning('请选择您最希望得到哪位荔枝专家的农事处方');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+const showSuccessPopup = ref(false);
|
|
|
|
|
+const handleSuccessConfirm = () => {
|
|
|
|
|
+ router.push('/agri_record');
|
|
|
|
|
+}
|
|
|
|
|
+async function submit() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 正式提交
|
|
|
|
|
+ const draftData = handleSubmit();
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ ...route.query,
|
|
|
|
|
+ phenologyId: phenologyList.value[0].phenologyId,
|
|
|
|
|
+ phenologyStartDate: phenologyList.value[0].phenologyStartDate,
|
|
|
|
|
+ basicInfo: draftData,
|
|
|
|
|
+ expertMiniUserId: '81881',
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- router.push({
|
|
|
|
|
- path: '/agricultural_plan',
|
|
|
|
|
- query: queryParams
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const res = await VE_API.basic_farm.saveBasicFarmInfoByExpert(params);
|
|
|
|
|
+
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ showSuccessPopup.value = true;
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ElMessage.error(res.msg || '提交失败,请重试');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('提交失败:', error);
|
|
|
|
|
+ ElMessage.error('提交失败,请重试');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const showPeriodPopup = ref(false);
|
|
|
|
|
+const phenologyList = ref([]);
|
|
|
|
|
+const disabledDate = (time) => {
|
|
|
|
|
+ // 获取今天的开始时间(00:00:00)
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ today.setHours(0, 0, 0, 0);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取明天的开始时间(00:00:00)
|
|
|
|
|
+ const tomorrow = new Date(today);
|
|
|
|
|
+ tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
|
|
+
|
|
|
|
|
+ // 设置最小日期为 2025-01-01
|
|
|
|
|
+ const minDate = new Date(2025, 0, 1); // 月份从0开始,0表示1月
|
|
|
|
|
+ minDate.setHours(0, 0, 0, 0);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果时间 < 2025-01-01 或 >= 明天的开始时间,则禁用
|
|
|
|
|
+ // 只能选择 2025-01-01 到今天的日期范围
|
|
|
|
|
+ return time.getTime() < minDate.getTime() || time.getTime() >= tomorrow.getTime();
|
|
|
|
|
+}
|
|
|
|
|
+const handlePage = async () => {
|
|
|
|
|
+ // 先进行校验
|
|
|
|
|
+ if (!validateForm()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const typeNames = JSON.parse(route.query.typeNames);
|
|
|
|
|
+ phenologyList.value = typeNames.map(item => ({
|
|
|
|
|
+ typeName: item,
|
|
|
|
|
+ phenologyId: firstPhenology.value.phenologyId,
|
|
|
|
|
+ startDateLabel: firstPhenology.value.startDateLabel,
|
|
|
|
|
+ phenologyName: firstPhenology.value.phenologyName,
|
|
|
|
|
+ phenologyStartDate: '2026-01-01',
|
|
|
|
|
+ }));
|
|
|
|
|
+ // 如果有选择的专家,添加 preferredExpertCode
|
|
|
|
|
+ if (basicForm.value.expertCode) {
|
|
|
|
|
+ const selectedExpert = basicFarmFormData.value.expertOptions.find(item => item.code === basicForm.value.expertCode);
|
|
|
|
|
+ if (selectedExpert) {
|
|
|
|
|
+ basicForm.value.expertInfo = selectedExpert;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('basicForm.value', basicForm.value)
|
|
|
|
|
+ showPeriodPopup.value = true;
|
|
|
|
|
+ // // 获取所有需要传递的参数,包括 from 参数
|
|
|
|
|
+ // const queryParams = {
|
|
|
|
|
+ // containerId: route.query.containerId,
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // // 如果存在 from 参数,继续传递
|
|
|
|
|
+ // if (route.query.from) {
|
|
|
|
|
+ // queryParams.from = route.query.from;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // // 传递所有农场相关的参数,以便在 agricultural_plan 页面创建农场
|
|
|
|
|
+ // const farmParams = ['wkt', 'speciesId', 'containerId', 'agriculturalCreate', 'geom', 'address', 'mu', 'name', 'fzr', 'tel', 'defaultFarm', 'typeId', 'speciesName', 'userType'];
|
|
|
|
|
+ // farmParams.forEach(key => {
|
|
|
|
|
+ // if (route.query[key] !== undefined) {
|
|
|
|
|
+ // queryParams[key] = route.query[key];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ // router.push({
|
|
|
|
|
+ // path: '/agricultural_plan',
|
|
|
|
|
+ // query: queryParams
|
|
|
|
|
+ // });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// 获取当前日期(YYYY-MM-DD格式)
|
|
|
|
|
+const getTodayDate = () => {
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ const year = today.getFullYear();
|
|
|
|
|
+ const month = String(today.getMonth() + 1).padStart(2, "0");
|
|
|
|
|
+ const day = String(today.getDate()).padStart(2, "0");
|
|
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const firstPhenology = ref({});
|
|
|
|
|
+const phenologyData = ref({});
|
|
|
|
|
+// 获取当前和下一个物候期
|
|
|
|
|
+const getCurrentAndNextPhenology = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const { data } = await VE_API.home.getCurrentAndNextPhenology({
|
|
|
|
|
+ expertMiniUserId: '81881',
|
|
|
|
|
+ containerId: route.query.containerId,
|
|
|
|
|
+ });
|
|
|
|
|
+ if (data && Array.isArray(data)) {
|
|
|
|
|
+ // 初始化物候期表单数据,日期使用第一个物候期的 startDate
|
|
|
|
|
+ firstPhenology.value = data[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("获取物候期数据失败", error);
|
|
|
|
|
+ ElMessage.error("获取物候期数据失败");
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 确认物候期信息
|
|
|
|
|
+const handlePeriodConfirm = async () => {
|
|
|
|
|
+ // 校验所有物候期信息是否填写完整
|
|
|
|
|
+ const hasEmptyDate = phenologyList.value.some(item => !item.phenologyStartDate);
|
|
|
|
|
+ if (hasEmptyDate) {
|
|
|
|
|
+ ElMessage.warning('请选择时间');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 关闭弹窗并提交表单
|
|
|
|
|
+ showPeriodPopup.value = false;
|
|
|
|
|
+
|
|
|
|
|
+ // 正式提交
|
|
|
|
|
+ const success = await submit();
|
|
|
|
|
+ if (!success) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 提交成功后跳转
|
|
|
|
|
+ // if (route.query.type === 'farmer') {
|
|
|
|
|
+ // router.push('/agri_record')
|
|
|
|
|
+ // return
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // // 获取所有需要传递的参数,包括 from 参数
|
|
|
|
|
+ // const queryParams = {
|
|
|
|
|
+ // containerId: route.query.containerId,
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // // 如果存在 from 参数,继续传递
|
|
|
|
|
+ // if (route.query.from) {
|
|
|
|
|
+ // queryParams.from = route.query.from;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // // 传递所有农场相关的参数,以便在 agricultural_plan 页面创建农场
|
|
|
|
|
+ // const farmParams = ['wkt', 'speciesId', 'containerId', 'agriculturalCreate', 'geom', 'address', 'mu', 'name', 'fzr', 'tel', 'defaultFarm', 'typeId', 'speciesName', 'userType'];
|
|
|
|
|
+ // farmParams.forEach(key => {
|
|
|
|
|
+ // if (route.query[key] !== undefined) {
|
|
|
|
|
+ // queryParams[key] = route.query[key];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ // router.push({
|
|
|
|
|
+ // path: '/agricultural_plan',
|
|
|
|
|
+ // query: queryParams
|
|
|
|
|
+ // });
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
@@ -695,8 +1061,13 @@ const handlePage = () => {
|
|
|
width: 116px;
|
|
width: 116px;
|
|
|
font-size: 14px;
|
|
font-size: 14px;
|
|
|
color: rgba(0, 0, 0, 0.9);
|
|
color: rgba(0, 0, 0, 0.9);
|
|
|
- text-align: right;
|
|
|
|
|
|
|
+ // text-align: right;
|
|
|
margin-right: 10px;
|
|
margin-right: 10px;
|
|
|
|
|
+ .sub-label {
|
|
|
|
|
+ font-size: 10px;
|
|
|
|
|
+ color: rgba(0, 0, 0, 0.4);
|
|
|
|
|
+ line-height: 15px;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.farm-scale-input {
|
|
.farm-scale-input {
|
|
@@ -785,4 +1156,121 @@ const handlePage = () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+.period-popup {
|
|
|
|
|
+ width: 90%;
|
|
|
|
|
+ padding: 24px 16px 20px 16px;
|
|
|
|
|
+ background: linear-gradient(360deg, #FFFFFF 74.2%, #D1EBFF 100%);
|
|
|
|
|
+
|
|
|
|
|
+ .period-header {
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ font-weight: 400;
|
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
|
+ color: #121212;
|
|
|
|
|
+ line-height: 22px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .period-content {
|
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
|
+
|
|
|
|
|
+ .period-item {
|
|
|
|
|
+ background: rgba(33, 153, 248, 0.05);
|
|
|
|
|
+ border: 1px solid rgba(33, 153, 248, 0.2);
|
|
|
|
|
+ border-radius: 5px;
|
|
|
|
|
+ padding: 10px;
|
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+
|
|
|
|
|
+ &:last-child {
|
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .period-item-name {
|
|
|
|
|
+ background: rgba(33, 153, 248, 0.1);
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ color: #2199F8;
|
|
|
|
|
+ padding: 2px 10px;
|
|
|
|
|
+ border-radius: 2px;
|
|
|
|
|
+ font-weight: 400;
|
|
|
|
|
+ width: fit-content;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .period-item-label {
|
|
|
|
|
+ margin-top: 10px;
|
|
|
|
|
+
|
|
|
|
|
+ .label-item-group {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ margin-bottom: 12px;
|
|
|
|
|
+
|
|
|
|
|
+ &:last-child {
|
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .label-item {
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ color: #1D2129;
|
|
|
|
|
+ min-width: 100px;
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ padding-right: 10px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .label-item-value {
|
|
|
|
|
+ border-radius: 2px;
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ color: #1D2129;
|
|
|
|
|
+ min-height: 31px;
|
|
|
|
|
+ line-height: 31px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ &.period-display {
|
|
|
|
|
+ background: #FFFFFF;
|
|
|
|
|
+ border: 0.5px solid rgba(0, 0, 0, 0.2);
|
|
|
|
|
+ padding: 0 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .period-footer {
|
|
|
|
|
+ .period-footer-btn {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ background: #2199F8;
|
|
|
|
|
+ color: #ffffff;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ height: 40px;
|
|
|
|
|
+ line-height: 40px;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ font-weight: 500;
|
|
|
|
|
+
|
|
|
|
|
+ &:active {
|
|
|
|
|
+ opacity: 0.8;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+.expert-info {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ font-size: 20px;
|
|
|
|
|
+ line-height: 36px;
|
|
|
|
|
+ .expert-img {
|
|
|
|
|
+ width: 26px;
|
|
|
|
|
+ height: 26px;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ object-fit: cover;
|
|
|
|
|
+ margin-right: 5px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss">
|
|
|
|
|
+.el-message--warning .el-message__content {
|
|
|
|
|
+ line-height: 20px;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|