|
|
@@ -36,7 +36,8 @@
|
|
|
:class="{
|
|
|
'timeline-container-plant-wrap': pageType == 'plant',
|
|
|
'timeline-container-no-permission-wrap': !hasPlanPermission,
|
|
|
- 'no-default-plan-wrap': active !== tabs[0]?.id && pageType == 'plant' && currentTab?.enabled == 0,
|
|
|
+ 'no-default-plan-wrap':
|
|
|
+ active !== tabs[0]?.id && pageType == 'plant' && tabs[currentTabIndex]?.enabled == 0,
|
|
|
}"
|
|
|
>
|
|
|
<farm-work-plan-timeline
|
|
|
@@ -50,9 +51,16 @@
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="custom-bottom-fixed-btns" :class="{ center: (active === tabs[0]?.id && pageType == 'plant') }" v-has-permission="'农事规划'">
|
|
|
+ <div
|
|
|
+ class="custom-bottom-fixed-btns"
|
|
|
+ :class="{ center: active === tabs[0]?.id && pageType == 'plant' }"
|
|
|
+ v-has-permission="'农事规划'"
|
|
|
+ >
|
|
|
<div class="bottom-btn-group-wrap">
|
|
|
- <div class="bottom-btn-group" :class="{ 'justify-center': active === tabs[0]?.id && pageType == 'plant' }">
|
|
|
+ <div
|
|
|
+ class="bottom-btn-group"
|
|
|
+ :class="{ 'justify-center': active === tabs[0]?.id && pageType == 'plant' }"
|
|
|
+ >
|
|
|
<div
|
|
|
class="bottom-btn secondary-btn"
|
|
|
@click="handlePhenologySetting"
|
|
|
@@ -66,7 +74,7 @@
|
|
|
</div>
|
|
|
<div class="bottom-btn primary-btn" @click="addNewTask" v-show="active !== tabs[0]?.id">新增农事</div>
|
|
|
</div>
|
|
|
- <template v-if="active !== tabs[0]?.id && pageType == 'plant' && currentTab?.enabled == 0">
|
|
|
+ <template v-if="active !== tabs[0]?.id && pageType == 'plant' && tabs[currentTabIndex]?.enabled == 0">
|
|
|
<div class="bottom-btn-divider"></div>
|
|
|
<div class="bottom-btn primary-btn submit-btn" @click="handleSubmitPlan">提交方案</div>
|
|
|
</template>
|
|
|
@@ -182,9 +190,9 @@ const getSpecieList = () => {
|
|
|
VE_API.farm.fetchSpecieList({ agriculturalId: userInfo?.agriculturalId }).then(({ data }) => {
|
|
|
if (data && data.length) {
|
|
|
options.value = data || [];
|
|
|
- if(sessionStorage.getItem('specieValue')) {
|
|
|
- specieValue.value = sessionStorage.getItem('specieValue');
|
|
|
- sessionStorage.removeItem('specieValue');
|
|
|
+ if (sessionStorage.getItem("specieValue")) {
|
|
|
+ specieValue.value = sessionStorage.getItem("specieValue");
|
|
|
+ sessionStorage.removeItem("specieValue");
|
|
|
} else {
|
|
|
specieValue.value = data[0]?.defaultContainerId;
|
|
|
}
|
|
|
@@ -203,9 +211,9 @@ const getListMySchemes = (type = "auto") => {
|
|
|
VE_API.home.listMySchemes({ containerId: specieValue.value }).then(({ data }) => {
|
|
|
tabs.value = data || [];
|
|
|
containerIdData.value = tabs.value[0]?.containerId;
|
|
|
- if(sessionStorage.getItem('active')) {
|
|
|
- active.value = sessionStorage.getItem('active');
|
|
|
- sessionStorage.removeItem('active');
|
|
|
+ if (sessionStorage.getItem("active")) {
|
|
|
+ active.value = sessionStorage.getItem("active");
|
|
|
+ sessionStorage.removeItem("active");
|
|
|
} else {
|
|
|
if (type === "right") {
|
|
|
active.value = data[data.length - 1].id;
|
|
|
@@ -222,9 +230,11 @@ const getListMySchemes = (type = "auto") => {
|
|
|
};
|
|
|
|
|
|
const currentTab = ref(null);
|
|
|
-const handleTabChange = (id, item) => {
|
|
|
+const currentTabIndex = ref(0);
|
|
|
+const handleTabChange = (id, item, index) => {
|
|
|
active.value = id;
|
|
|
currentTab.value = item;
|
|
|
+ currentTabIndex.value = index;
|
|
|
getFarmWorkPlanForPhenology();
|
|
|
};
|
|
|
|
|
|
@@ -244,6 +254,7 @@ const getPhenologyList = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const farmWorkIds = ref([]);
|
|
|
// 获取农事规划数据以获取 containerSpaceTimeId
|
|
|
const getFarmWorkPlanForPhenology = async () => {
|
|
|
try {
|
|
|
@@ -255,6 +266,23 @@ const getFarmWorkPlanForPhenology = async () => {
|
|
|
if (code === 0 && data?.phenologyList?.[0]?.containerSpaceTimeId) {
|
|
|
containerSpaceTimeId.value = data.phenologyList[0].containerSpaceTimeId;
|
|
|
schemeId.value = data.phenologyList[0].reproductiveList[0].farmWorkArrangeList[0].schemeId;
|
|
|
+
|
|
|
+ // 收集所有farmWorkId
|
|
|
+ farmWorkIds.value = [];
|
|
|
+ data.phenologyList.forEach((phenology) => {
|
|
|
+ if (Array.isArray(phenology.reproductiveList)) {
|
|
|
+ phenology.reproductiveList.forEach((reproductive) => {
|
|
|
+ if (Array.isArray(reproductive.farmWorkArrangeList)) {
|
|
|
+ reproductive.farmWorkArrangeList.forEach((farmWork) => {
|
|
|
+ if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
|
|
|
+ farmWorkIds.value.push(farmWork.farmWorkId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
await getPhenologyList(containerSpaceTimeId.value);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -360,14 +388,38 @@ const handleConfirmCopyPlan = () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const handleSubmitPlan = () => {
|
|
|
- // showTipPopup.value = true;
|
|
|
- console.log('ti')
|
|
|
+// 提交方案
|
|
|
+const handleSubmitPlan = async () => {
|
|
|
+ // 调用验证方法,传入所有ids
|
|
|
+ if (farmWorkIds.value.length > 0) {
|
|
|
+ const { data, code } = await VE_API.monitor.batchValidatePesticideFertilizerQuotes({
|
|
|
+ ids: farmWorkIds.value,
|
|
|
+ schemeId: active.value,
|
|
|
+ });
|
|
|
+ if (code === 0) {
|
|
|
+ // 判断data对象中所有的值是否都为true
|
|
|
+ const allTrue = Object.values(data).every((value) => value === true);
|
|
|
+ if (allTrue) {
|
|
|
+ VE_API.monitor
|
|
|
+ .enableScheme({
|
|
|
+ schemeId: active.value,
|
|
|
+ })
|
|
|
+ .then(({ code }) => {
|
|
|
+ if (code === 0) {
|
|
|
+ ElMessage.success("提交成功");
|
|
|
+ getListMySchemes("auto");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ showTipPopup.value = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const savePlanPageInfo = () => {
|
|
|
- sessionStorage.setItem('specieValue', specieValue.value);
|
|
|
- sessionStorage.setItem('active', active.value);
|
|
|
+ sessionStorage.setItem("specieValue", specieValue.value);
|
|
|
+ sessionStorage.setItem("active", active.value);
|
|
|
};
|
|
|
|
|
|
// 新增农事
|
|
|
@@ -399,11 +451,13 @@ const handleRowClick = (item) => {
|
|
|
path: "/modify",
|
|
|
query: {
|
|
|
id: item.id,
|
|
|
- noPrice: pageType.value === 'plant' ? true : false,
|
|
|
+ noPrice: pageType.value === "plant" ? true : false,
|
|
|
farmId: route.query.farmId,
|
|
|
farmWorkId: item.farmWorkId,
|
|
|
containerSpaceTimeId: item.containerSpaceTimeId,
|
|
|
isDefault: active.value === tabs.value[0]?.id,
|
|
|
+ farmWorkIds: farmWorkIds.value,
|
|
|
+ enabled: tabs.value[currentTabIndex.value]?.enabled,
|
|
|
},
|
|
|
});
|
|
|
};
|