|
|
@@ -6,83 +6,65 @@
|
|
|
<div class="map-wrap">
|
|
|
<div class="map-container" ref="mapContainer"></div>
|
|
|
<div class="add-farm-btn" @click="handleAddFarm">
|
|
|
- <el-icon size="12"><Plus /></el-icon>
|
|
|
+ <el-icon size="12">
|
|
|
+ <Plus />
|
|
|
+ </el-icon>
|
|
|
<span>{{ t("garden.addFarm") }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="farm-filter">
|
|
|
- <el-input
|
|
|
- v-model="searchFarm"
|
|
|
- class="filter-search"
|
|
|
- :placeholder="t('weather.searchFarm')"
|
|
|
- :prefix-icon="Search"
|
|
|
- clearable
|
|
|
- />
|
|
|
+ <el-input v-model="searchFarm" class="filter-search" :placeholder="t('weather.searchFarm')"
|
|
|
+ :prefix-icon="Search" clearable />
|
|
|
<div class="filter-select-wrap">
|
|
|
- <el-select
|
|
|
- v-model="regionVal"
|
|
|
- class="filter-select"
|
|
|
- :placeholder="t('weather.selectRegion')"
|
|
|
- clearable
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in regionOptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
+ <el-select v-model="regionVal" class="filter-select" :placeholder="t('weather.selectRegion')"
|
|
|
+ popper-class="garden-dark-select-popper" clearable>
|
|
|
+ <el-option v-for="item in regionOptions" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value" />
|
|
|
</el-select>
|
|
|
- <el-select
|
|
|
- v-model="typeVal"
|
|
|
- class="filter-select"
|
|
|
- :placeholder="t('weather.selectCategory')"
|
|
|
- clearable
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in typeOptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
+ <el-select v-model="typeVal" class="filter-select" :placeholder="t('weather.selectCategory')"
|
|
|
+ popper-class="garden-dark-select-popper" clearable>
|
|
|
+ <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value" />
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="farm-list">
|
|
|
- <div
|
|
|
- v-for="item in filteredFarmList"
|
|
|
- :key="item.id"
|
|
|
- class="farm-card"
|
|
|
- @click.stop="handleEnterFarm(item)"
|
|
|
- :class="{ 'is-current': item.isCurrent }"
|
|
|
- >
|
|
|
+ <div v-for="item in filteredFarmList" :key="item.id" class="farm-card"
|
|
|
+ @click.stop="handleEnterFarm(item)" :class="{ 'is-current': item.isCurrent }">
|
|
|
<div class="farm-card__header">
|
|
|
<div class="farm-card__main">
|
|
|
<div class="farm-card__title-row">
|
|
|
<span class="farm-name van-ellipsis">{{ item.name }}</span>
|
|
|
<span v-if="item.categoryLabel" class="category-tag">{{ item.categoryLabel }}</span>
|
|
|
</div>
|
|
|
- <div class="farm-address van-ellipsis">
|
|
|
- <el-icon><Location /></el-icon>
|
|
|
- {{ item.rawAddress || t("common.noAddress") }}
|
|
|
- </div>
|
|
|
</div>
|
|
|
- <div
|
|
|
- v-if="item.isCurrent"
|
|
|
- class="action-btn action-btn-current"
|
|
|
- >
|
|
|
+ <div v-if="item.isCurrent" class="action-btn action-btn-current">
|
|
|
{{ t("garden.currentFarm") }}
|
|
|
</div>
|
|
|
- <div
|
|
|
- v-else
|
|
|
- class="action-btn action-btn-enter"
|
|
|
- @click.stop="handleEnterFarm(item)"
|
|
|
- >
|
|
|
+ <div v-else class="action-btn action-btn-enter" @click.stop="handleEnterFarm(item)">
|
|
|
{{ t("garden.enterFarm") }}
|
|
|
- <el-icon color="rgba(255, 255, 255, 0.6)"><ArrowRightBold /></el-icon>
|
|
|
+ <el-icon color="rgba(255, 255, 255, 0.6)">
|
|
|
+ <ArrowRightBold />
|
|
|
+ </el-icon>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="farm-address">
|
|
|
+ <el-icon class="address-icon">
|
|
|
+ <Location />
|
|
|
+ </el-icon>
|
|
|
+ {{ item.rawAddress || t("common.noAddress") }}
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- <div
|
|
|
+ v-if="canDeleteFarm(item) && !item.isCurrent"
|
|
|
+ class="del-icon"
|
|
|
+ @click.stop="handleDeleteFarm(item)"
|
|
|
+ >
|
|
|
+ <el-button type="danger" link :icon="Delete" circle />
|
|
|
+ </div> -->
|
|
|
|
|
|
<div class="phenology-box">
|
|
|
{{ t("garden.currentPhenology") }}
|
|
|
@@ -95,7 +77,8 @@
|
|
|
<div class="task-bar" v-if="item.taskName">
|
|
|
<div class="task-bar__left">
|
|
|
<img class="task-icon" src="@/assets/img/home/task.png" alt="" />
|
|
|
- <span class="task-name van-ellipsis">{{ item.taskName || t("garden.taskNamePlaceholder") }}</span>
|
|
|
+ <span class="task-name van-ellipsis">{{ item.taskName || t("garden.taskNamePlaceholder")
|
|
|
+ }}</span>
|
|
|
<span class="task-status">{{ item.taskStatus || t("garden.pendingExecute") }}</span>
|
|
|
</div>
|
|
|
<div class="task-bar__forward" @click.stop="handleForward(item)">
|
|
|
@@ -128,8 +111,8 @@
|
|
|
import { computed, nextTick, onActivated, onMounted, ref, watch } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
|
import { useStore } from "vuex";
|
|
|
-import { ElMessage } from "element-plus";
|
|
|
-import { Plus, Search, Share, User, UserFilled } from "@element-plus/icons-vue";
|
|
|
+import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
+import { Plus, Search, Share, User, UserFilled, Delete } from "@element-plus/icons-vue";
|
|
|
import { useI18n } from "@/i18n";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
|
import IndexMap from "@/views/old_mini/work_execute/index.js";
|
|
|
@@ -204,10 +187,17 @@ function getSelectedFarmId() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/** find_farm_information:农事详情在 fw_tasks[],取第一项展示 / 转发 */
|
|
|
+function pickFarmFwTask(item = {}) {
|
|
|
+ const tasks = Array.isArray(item.fw_tasks) ? item.fw_tasks : [];
|
|
|
+ return tasks[0] || null;
|
|
|
+}
|
|
|
+
|
|
|
function normalizeFarmList(data) {
|
|
|
const selectedId = getSelectedFarmId();
|
|
|
return (data || []).map((farm) => {
|
|
|
const id = farm.farm_id;
|
|
|
+ const task = pickFarmFwTask(farm);
|
|
|
return {
|
|
|
...farm,
|
|
|
id,
|
|
|
@@ -217,8 +207,8 @@ function normalizeFarmList(data) {
|
|
|
rawAddress: farm.farm_address || "",
|
|
|
categoryLabel: farm.variety_name || "",
|
|
|
phenologyText: farm.period_name || "",
|
|
|
- taskName: farm.fw_name || "",
|
|
|
- taskStatus: farm.work_status_name || farm.work_status || "",
|
|
|
+ taskName: task?.fw_name || "",
|
|
|
+ taskStatus: task?.fw_status || "",
|
|
|
isCurrent: selectedId != null && Number(id) === selectedId,
|
|
|
};
|
|
|
});
|
|
|
@@ -258,6 +248,61 @@ function getMiniUserId() {
|
|
|
return store.state.home.miniUserId || localStorage.getItem("MINI_USER_ID");
|
|
|
}
|
|
|
|
|
|
+/** 仅农场创建者(user_id === 当前 MINI_USER_ID)可删 */
|
|
|
+function canDeleteFarm(item) {
|
|
|
+ const uid = getMiniUserId();
|
|
|
+ if (uid == null || uid === "" || item?.user_id == null || item?.user_id === "") {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return String(item.user_id) === String(uid);
|
|
|
+}
|
|
|
+
|
|
|
+function clearSelectedFarmIfMatch(farmId) {
|
|
|
+ const selectedId = getSelectedFarmId();
|
|
|
+ if (selectedId == null || Number(farmId) !== selectedId) return;
|
|
|
+ localStorage.removeItem("selectedFarmId");
|
|
|
+ localStorage.removeItem("selectedFarmName");
|
|
|
+ localStorage.removeItem("selectedFarmPoint");
|
|
|
+ localStorage.removeItem("selectedFarmData");
|
|
|
+}
|
|
|
+
|
|
|
+async function handleDeleteFarm(item) {
|
|
|
+ const farmId = item?.farm_id ?? item?.id;
|
|
|
+ if (farmId == null || farmId === "") return;
|
|
|
+ if (!canDeleteFarm(item)) return;
|
|
|
+
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm(
|
|
|
+ t("garden.deleteFarmConfirm"),
|
|
|
+ t("garden.deleteFarmTitle"),
|
|
|
+ {
|
|
|
+ confirmButtonText: t("garden.deleteFarmOk"),
|
|
|
+ cancelButtonText: t("garden.deleteFarmCancel"),
|
|
|
+ type: "warning",
|
|
|
+ customClass: "garden-delete-confirm",
|
|
|
+ modalClass: "garden-delete-confirm-modal",
|
|
|
+ lockScroll: false,
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } catch {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await VE_API.pheno.deleteFarm({ farm_id: farmId });
|
|
|
+ if (res?.code === 200) {
|
|
|
+ ElMessage.success(res?.msg || t("garden.deleteFarmSuccess"));
|
|
|
+ clearSelectedFarmIfMatch(farmId);
|
|
|
+ getFarmList();
|
|
|
+ getFilterOptions();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ElMessage.error(res?.msg || t("garden.deleteFarmFail"));
|
|
|
+ } catch {
|
|
|
+ ElMessage.error(t("garden.deleteFarmFail"));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function getFarmList() {
|
|
|
const id = getMiniUserId();
|
|
|
if (!id) {
|
|
|
@@ -299,8 +344,35 @@ function handleAddFarm() {
|
|
|
router.push("/entry_information");
|
|
|
}
|
|
|
|
|
|
-function handleForward() {
|
|
|
- ElMessage.info(t("garden.forwardTip"));
|
|
|
+/** 与 work_execute「派发工人」一致:分享农事详情 */
|
|
|
+function handleForward(item) {
|
|
|
+ const task = pickFarmFwTask(item);
|
|
|
+ const fwCode = task?.fw_code || item?.fw_code || item?.fwCode || "";
|
|
|
+ if (!fwCode) {
|
|
|
+ ElMessage.warning("暂无可转发的农事任务");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const statusText = String(item?.taskStatus || task?.fw_status || "");
|
|
|
+ const doneStatus = /已完成|已执行|已认证|本人完成/.test(statusText);
|
|
|
+ const workName = item?.taskName || task?.fw_name || item?.farmName || "农事详情";
|
|
|
+ const query = {
|
|
|
+ askInfo: { title: "转发农事", content: "是否分享给好友" },
|
|
|
+ shareText: doneStatus
|
|
|
+ ? `${workName} 已完成,请点击查看吧!`
|
|
|
+ : `${workName} 已触发,请在最佳农时内及时执行`,
|
|
|
+ targetUrl: "work_detail",
|
|
|
+ paramsPage: JSON.stringify({
|
|
|
+ farm_id: item?.farm_id ?? item?.id ?? "",
|
|
|
+ zone_id: item?.zone_id ?? item?.zoneId ?? "",
|
|
|
+ fw_code: fwCode,
|
|
|
+ fromShare: 1,
|
|
|
+ }),
|
|
|
+ imageUrl: "https://birdseye-img.sysuimars.com/farm-h5/work_cover.png",
|
|
|
+ };
|
|
|
+ wx.miniProgram.navigateTo({
|
|
|
+ url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/** 与 growth_report 一致:跳转小程序分享页邀请完善信息 */
|
|
|
@@ -458,12 +530,10 @@ onActivated(() => {
|
|
|
|
|
|
:deep(.el-input__wrapper),
|
|
|
:deep(.el-select__wrapper) {
|
|
|
- min-height: 36px;
|
|
|
- line-height: 36px;
|
|
|
- height: 36px;
|
|
|
- padding: 0 10px;
|
|
|
- box-sizing: border-box;
|
|
|
- border-radius: 6px;
|
|
|
+ // min-height: 36px;
|
|
|
+ // line-height: 36px;
|
|
|
+ // height: 34px;
|
|
|
+ border-radius: 8px;
|
|
|
background: rgba(255, 255, 255, 0.05);
|
|
|
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset !important;
|
|
|
|
|
|
@@ -519,6 +589,7 @@ onActivated(() => {
|
|
|
.phenology-box .phenology-text {
|
|
|
color: #ffd489;
|
|
|
}
|
|
|
+
|
|
|
.farm-name {
|
|
|
color: #ffd489;
|
|
|
}
|
|
|
@@ -566,10 +637,26 @@ onActivated(() => {
|
|
|
.farm-address {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
+ text-wrap: auto;
|
|
|
gap: 5px;
|
|
|
margin-top: 4px;
|
|
|
font-size: 12px;
|
|
|
color: rgba(255, 255, 255, 0.4);
|
|
|
+
|
|
|
+ .address-icon {
|
|
|
+ // padding-top: 4px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.del-icon {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-top: 4px;
|
|
|
+
|
|
|
+ :deep(.el-button) {
|
|
|
+ padding: 4px;
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.action-btn {
|
|
|
@@ -603,9 +690,11 @@ onActivated(() => {
|
|
|
font-size: 12px;
|
|
|
color: rgba(255, 255, 255, 0.7);
|
|
|
line-height: 18px;
|
|
|
+
|
|
|
.phenology-desc {
|
|
|
color: rgba(255, 255, 255, 0.7);
|
|
|
}
|
|
|
+
|
|
|
.phenology-text {
|
|
|
padding-left: 2px;
|
|
|
color: #FFFFFF;
|
|
|
@@ -654,7 +743,6 @@ onActivated(() => {
|
|
|
color: #FFD489;
|
|
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
|
|
font-size: 12px;
|
|
|
- line-height: 18px;
|
|
|
}
|
|
|
|
|
|
.task-bar__forward {
|
|
|
@@ -706,3 +794,136 @@ onActivated(() => {
|
|
|
}
|
|
|
}
|
|
|
</style>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+/* 下拉面板挂到 body,需非 scoped 才能吃到黑金样式 */
|
|
|
+.garden-dark-select-popper {
|
|
|
+ background: #1a191d !important;
|
|
|
+ border-color: rgba(255, 212, 137, 0.28) !important;
|
|
|
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45) !important;
|
|
|
+
|
|
|
+ .el-select-dropdown__item {
|
|
|
+ color: rgba(255, 255, 255, 0.85);
|
|
|
+ font-size: 13px;
|
|
|
+
|
|
|
+ &.is-hovering,
|
|
|
+ &:hover {
|
|
|
+ background: rgba(255, 212, 137, 0.12);
|
|
|
+ color: #FFD489;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.is-selected {
|
|
|
+ color: #FFD489;
|
|
|
+ font-weight: 500;
|
|
|
+ background: rgba(255, 212, 137, 0.08);
|
|
|
+ }
|
|
|
+
|
|
|
+ &.is-disabled {
|
|
|
+ color: rgba(255, 255, 255, 0.35) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-select-dropdown__empty {
|
|
|
+ color: rgba(255, 255, 255, 0.4);
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-popper__arrow::before {
|
|
|
+ background: #1a191d !important;
|
|
|
+ border-color: rgba(255, 212, 137, 0.28) !important;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/* 删除确认框:黑金配色,禁止遮罩出现滚动条 */
|
|
|
+.garden-delete-confirm-modal {
|
|
|
+ overflow: hidden !important;
|
|
|
+}
|
|
|
+
|
|
|
+.el-message-box.garden-delete-confirm {
|
|
|
+ // width: 300px;
|
|
|
+ max-width: calc(100vw - 48px);
|
|
|
+ padding: 20px 18px 16px;
|
|
|
+ background: #1a191d;
|
|
|
+ border: 1px solid rgba(201, 53, 50, 0.41);
|
|
|
+ border-radius: 12px;
|
|
|
+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .el-message-box__header {
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__title {
|
|
|
+ color: #FF7D7B;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 500;
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__headerbtn {
|
|
|
+ top: 4px;
|
|
|
+ right: 2px;
|
|
|
+
|
|
|
+ .el-message-box__close {
|
|
|
+ color: #B5B5B5;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__content {
|
|
|
+ padding: 14px 0 6px;
|
|
|
+ color: rgba(255, 255, 255, 0.75);
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__container {
|
|
|
+ align-items: flex-start;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__status {
|
|
|
+ color: #FF7D7B !important;
|
|
|
+ font-size: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__message {
|
|
|
+ color: rgba(255, 255, 255, 0.75);
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 1.5;
|
|
|
+ padding-right: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-message-box__btns {
|
|
|
+ padding-top: 14px;
|
|
|
+
|
|
|
+ .el-button {
|
|
|
+ min-width: 94px;
|
|
|
+ // height: 34px;
|
|
|
+ border-radius: 18px;
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-button--default {
|
|
|
+ background: rgba(255, 255, 255, 0.05);
|
|
|
+ border: 1px solid rgba(255, 255, 255, 0.12);
|
|
|
+ color: rgba(255, 255, 255, 0.85);
|
|
|
+
|
|
|
+ // &:hover,
|
|
|
+ // &:focus {
|
|
|
+ // background: rgba(255, 212, 137, 0.08);
|
|
|
+ // border-color: rgba(255, 212, 137, 0.65);
|
|
|
+ // color: #FFD489;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-button--primary {
|
|
|
+ // background: linear-gradient(135deg, #FFEBC9 0%, #FFCA6D 100%);
|
|
|
+ background: rgba(126, 35, 33, 0.26);
|
|
|
+ border: none;
|
|
|
+ color: #FF7D7B;
|
|
|
+
|
|
|
+ // &:hover,
|
|
|
+ // &:focus {
|
|
|
+ // background: linear-gradient(90deg, #FFF0D4 0%, #FFD489 100%);
|
|
|
+ // color: #1A1408;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|