|
@@ -191,62 +191,20 @@ function restoreSelection() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function getSelectedFieldNames() {
|
|
|
|
|
- return new Set(
|
|
|
|
|
- fieldTaskList.value
|
|
|
|
|
- .filter((item) => selectedIds.has(String(item.id)))
|
|
|
|
|
- .map((item) => item.name)
|
|
|
|
|
- .filter(Boolean)
|
|
|
|
|
- );
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/** 大田已选、果树侧同名项默认勾上(id 不同,按 name 对齐) */
|
|
|
|
|
-function applyFieldOverlapToFruit() {
|
|
|
|
|
- if (!hasFruit.value) return;
|
|
|
|
|
- const fieldNames = getSelectedFieldNames();
|
|
|
|
|
- if (!fieldNames.size) return;
|
|
|
|
|
- let changed = false;
|
|
|
|
|
- allFruitTasks.value.forEach((item) => {
|
|
|
|
|
- if (!item?.name || !fieldNames.has(item.name)) return;
|
|
|
|
|
- const id = String(item.id);
|
|
|
|
|
- if (selectedIds.has(id)) return;
|
|
|
|
|
- selectedIds.add(id);
|
|
|
|
|
- changed = true;
|
|
|
|
|
- });
|
|
|
|
|
- if (changed) saveSelection();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-function syncFruitByFieldName(name, selected) {
|
|
|
|
|
- if (!name) return;
|
|
|
|
|
- allFruitTasks.value.forEach((item) => {
|
|
|
|
|
- if (item?.name !== name) return;
|
|
|
|
|
- const id = String(item.id);
|
|
|
|
|
- if (selected) selectedIds.add(id);
|
|
|
|
|
- else selectedIds.delete(id);
|
|
|
|
|
- });
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const handleTabChange = (key) => {
|
|
const handleTabChange = (key) => {
|
|
|
if (key === activeTab.value) return;
|
|
if (key === activeTab.value) return;
|
|
|
activeTab.value = key;
|
|
activeTab.value = key;
|
|
|
- if (key === "fruit") applyFieldOverlapToFruit();
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/** 大田 / 果树按各自 id 独立勾选,同名也不互通 */
|
|
|
const toggleSelect = (item) => {
|
|
const toggleSelect = (item) => {
|
|
|
const id = String(item.id);
|
|
const id = String(item.id);
|
|
|
- const nextSelected = !selectedIds.has(id);
|
|
|
|
|
- if (nextSelected) selectedIds.add(id);
|
|
|
|
|
- else selectedIds.delete(id);
|
|
|
|
|
-
|
|
|
|
|
- // 大田勾选/取消时,同步果树同名项
|
|
|
|
|
- if (item?.scope === "field" || activeTab.value === "field") {
|
|
|
|
|
- syncFruitByFieldName(item.name, nextSelected);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (selectedIds.has(id)) selectedIds.delete(id);
|
|
|
|
|
+ else selectedIds.add(id);
|
|
|
saveSelection();
|
|
saveSelection();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleConfirm = () => {
|
|
const handleConfirm = () => {
|
|
|
- applyFieldOverlapToFruit();
|
|
|
|
|
saveSelection();
|
|
saveSelection();
|
|
|
emit("complete");
|
|
emit("complete");
|
|
|
};
|
|
};
|
|
@@ -254,7 +212,6 @@ const handleConfirm = () => {
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
refreshCropFlags();
|
|
refreshCropFlags();
|
|
|
restoreSelection();
|
|
restoreSelection();
|
|
|
- applyFieldOverlapToFruit();
|
|
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|