|
@@ -124,11 +124,17 @@
|
|
|
size="large"
|
|
size="large"
|
|
|
value-format="YYYY-MM-DD"
|
|
value-format="YYYY-MM-DD"
|
|
|
v-model="item.startDate"
|
|
v-model="item.startDate"
|
|
|
|
|
+ :clearable="false"
|
|
|
type="date"
|
|
type="date"
|
|
|
placeholder="选择日期"
|
|
placeholder="选择日期"
|
|
|
|
|
+ @change="(date) => handleStartDateChange(date, index)"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <div class="phenology-footer-tip">
|
|
|
|
|
+ <span>注:</span>
|
|
|
|
|
+ <span class="text">请从上往下按照时间顺序填写日期</span>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="phenology-footer" @click="handleConfirmPhenologySetting">确认设置</div>
|
|
<div class="phenology-footer" @click="handleConfirmPhenologySetting">确认设置</div>
|
|
|
</Popup>
|
|
</Popup>
|
|
@@ -144,7 +150,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onMounted, computed} from "vue";
|
|
|
|
|
|
|
+import { ref, onMounted, computed, watch } from "vue";
|
|
|
import { Popup, Highlight } from "vant";
|
|
import { Popup, Highlight } from "vant";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
import customHeader from "@/components/customHeader.vue";
|
|
|
import tabList from "@/components/pageComponents/TabList.vue";
|
|
import tabList from "@/components/pageComponents/TabList.vue";
|
|
@@ -286,11 +292,20 @@ const getPhenologyList = async () => {
|
|
|
};
|
|
};
|
|
|
const res = await VE_API.monitor.listPhenology(params);
|
|
const res = await VE_API.monitor.listPhenology(params);
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- mergedReproductiveList.value = res.data || [];
|
|
|
|
|
|
|
+ // 将intervalDaysArr合并到mergedReproductiveList中
|
|
|
|
|
+ if (intervalDaysArr.value.length > 0 && res.data.length > 0) {
|
|
|
|
|
+ mergedReproductiveList.value = res.data.map((item, index) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ intervalDays: intervalDaysArr.value[index],
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const farmWorkIds = ref([]);
|
|
const farmWorkIds = ref([]);
|
|
|
|
|
+const intervalDaysArr = ref([]);
|
|
|
// 获取农事规划数据以获取 containerSpaceTimeId
|
|
// 获取农事规划数据以获取 containerSpaceTimeId
|
|
|
const getFarmWorkPlanForPhenology = async () => {
|
|
const getFarmWorkPlanForPhenology = async () => {
|
|
|
try {
|
|
try {
|
|
@@ -305,7 +320,9 @@ const getFarmWorkPlanForPhenology = async () => {
|
|
|
|
|
|
|
|
// 收集所有farmWorkId
|
|
// 收集所有farmWorkId
|
|
|
farmWorkIds.value = [];
|
|
farmWorkIds.value = [];
|
|
|
|
|
+ intervalDaysArr.value = [];
|
|
|
data.phenologyList.forEach((phenology) => {
|
|
data.phenologyList.forEach((phenology) => {
|
|
|
|
|
+ intervalDaysArr.value.push(phenology.intervalDays);
|
|
|
if (Array.isArray(phenology.reproductiveList)) {
|
|
if (Array.isArray(phenology.reproductiveList)) {
|
|
|
phenology.reproductiveList.forEach((reproductive) => {
|
|
phenology.reproductiveList.forEach((reproductive) => {
|
|
|
if (Array.isArray(reproductive.farmWorkArrangeList)) {
|
|
if (Array.isArray(reproductive.farmWorkArrangeList)) {
|
|
@@ -344,6 +361,43 @@ const handlePhenologySetting = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 处理物候期开始时间变化
|
|
|
|
|
+ * 当修改某个物候期的开始时间时,自动更新后续所有物候期的开始时间
|
|
|
|
|
+ */
|
|
|
|
|
+const handleStartDateChange = (date, currentIndex) => {
|
|
|
|
|
+ if (!date || !mergedReproductiveList.value || mergedReproductiveList.value.length === 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 从当前修改的物候期开始,更新后续所有物候期的开始时间
|
|
|
|
|
+ for (let i = currentIndex; i < mergedReproductiveList.value.length - 1; i++) {
|
|
|
|
|
+ const currentItem = mergedReproductiveList.value[i];
|
|
|
|
|
+ const nextItem = mergedReproductiveList.value[i + 1];
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前物候期的间隔天数
|
|
|
|
|
+ const intervalDays = currentItem.intervalDays || 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (intervalDays > 0 && currentItem.startDate) {
|
|
|
|
|
+ // 将日期字符串转换为时间戳(毫秒)
|
|
|
|
|
+ const currentStartDateTimestamp = new Date(currentItem.startDate).getTime();
|
|
|
|
|
+
|
|
|
|
|
+ // 在时间戳基础上加上间隔天数(转换为毫秒:天数 * 24小时 * 60分钟 * 60秒 * 1000毫秒)
|
|
|
|
|
+ const nextStartDateTimestamp = currentStartDateTimestamp + (intervalDays * 24 * 60 * 60 * 1000);
|
|
|
|
|
+
|
|
|
|
|
+ // 将时间戳转换回日期对象,然后格式化为 YYYY-MM-DD 格式
|
|
|
|
|
+ const nextStartDate = new Date(nextStartDateTimestamp);
|
|
|
|
|
+ const year = nextStartDate.getFullYear();
|
|
|
|
|
+ const month = String(nextStartDate.getMonth() + 1).padStart(2, '0');
|
|
|
|
|
+ const day = String(nextStartDate.getDate()).padStart(2, '0');
|
|
|
|
|
+ const nextStartDateStr = `${year}-${month}-${day}`;
|
|
|
|
|
+
|
|
|
|
|
+ // 更新下一个物候期的开始时间
|
|
|
|
|
+ nextItem.startDate = nextStartDateStr;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
* 确认物候期设置
|
|
* 确认物候期设置
|
|
|
*/
|
|
*/
|
|
|
const handleConfirmPhenologySetting = async () => {
|
|
const handleConfirmPhenologySetting = async () => {
|
|
@@ -689,11 +743,18 @@ const handleRowClick = (item) => {
|
|
|
margin-top: 10px;
|
|
margin-top: 10px;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ .phenology-footer-tip {
|
|
|
|
|
+ margin-top: 20px;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ .text{
|
|
|
|
|
+ color: rgba(0, 0, 0, 0.4);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
.phenology-footer {
|
|
.phenology-footer {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
text-align: center;
|
|
text-align: center;
|
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
|
- margin-top: 20px;
|
|
|
|
|
|
|
+ margin-top: 10px;
|
|
|
color: #fff;
|
|
color: #fff;
|
|
|
background: #2199f8;
|
|
background: #2199f8;
|
|
|
border-radius: 25px;
|
|
border-radius: 25px;
|