Explorar el Código

feat:对接复制方案接口

wangsisi hace 1 día
padre
commit
5f8b82fe37

+ 5 - 0
src/api/modules/monitor.js

@@ -58,4 +58,9 @@ module.exports = {
         url: config.base_dev_url + "z_farm_work_lib/save",
         url: config.base_dev_url + "z_farm_work_lib/save",
         type: "post",
         type: "post",
     },
     },
+    //农资用户复制自己的方案
+    copyScheme: {
+        url: config.base_dev_url + "container_farm_work_scheme/copyMyScheme",
+        type: "get",
+    },
 }
 }

+ 5 - 0
src/components/pageComponents/FarmWorkPlanTimeline.vue

@@ -109,6 +109,8 @@ const props = defineProps({
 
 
 const emits = defineEmits(["row-click", "edit"]);
 const emits = defineEmits(["row-click", "edit"]);
 
 
+
+
 const solarTerms = ref([]);
 const solarTerms = ref([]);
 const phenologyList = ref([]);
 const phenologyList = ref([]);
 const timelineContainerRef = ref(null);
 const timelineContainerRef = ref(null);
@@ -308,6 +310,8 @@ const handleEdit = (item) => {
     emits("edit", item);
     emits("edit", item);
 };
 };
 
 
+const containerIdData = ref(null);
+
 // 获取农事规划数据
 // 获取农事规划数据
 const getFarmWorkPlan = () => {
 const getFarmWorkPlan = () => {
     if (!props.farmId && !props.containerId) return;
     if (!props.farmId && !props.containerId) return;
@@ -320,6 +324,7 @@ const getFarmWorkPlan = () => {
         .farmWorkPlan({ farmId: props.farmId, containerId: props.containerId })
         .farmWorkPlan({ farmId: props.farmId, containerId: props.containerId })
         .then(({ data, code }) => {
         .then(({ data, code }) => {
             if (code === 0) {
             if (code === 0) {
+                containerIdData.value = data.phenologyList[0].containerSpaceTimeId;
                 const list = Array.isArray(data?.solarTermsList) ? data.solarTermsList : [];
                 const list = Array.isArray(data?.solarTermsList) ? data.solarTermsList : [];
                 const filtered = list
                 const filtered = list
                     .filter((t) => t && t.type === 1)
                     .filter((t) => t && t.type === 1)

+ 7 - 0
src/views/old_mini/home/components/AgriculturalDynamics.vue

@@ -49,6 +49,8 @@
                             <div class="timeline-right">
                             <div class="timeline-right">
                                 <div class="date">
                                 <div class="date">
                                     <span class="work-name">{{ timelineItem.farmWorkName }}</span>
                                     <span class="work-name">{{ timelineItem.farmWorkName }}</span>
+                                    <span v-show="timelineItem.expectedRisk">({{timelineItem.expectedRisk}})</span>
+                                    <span class="ignore-btn" @click="handleIgnore(timelineItem)">忽略</span>
                                 </div>
                                 </div>
                                 <div class="text">
                                 <div class="text">
                                     预计报价<span class="price">{{ timelineItem.estimatedCost }}元</span>
                                     预计报价<span class="price">{{ timelineItem.estimatedCost }}元</span>
@@ -389,6 +391,11 @@ const getFutureFarmWorkWarning = async (item) => {
                         .work-name {
                         .work-name {
                             padding-left: 4px;
                             padding-left: 4px;
                         }
                         }
+                        .ignore-btn{
+                            margin-left: 6px;
+                            color: rgba(29, 33, 41, 0.4);
+                            font-size: 13px;
+                        }
                     }
                     }
                     .timeline-action {
                     .timeline-action {
                         align-self: center;
                         align-self: center;

+ 1 - 1
src/views/old_mini/mine/index.vue

@@ -259,7 +259,7 @@ const cellItems = computed(() => {
         },
         },
         {
         {
             title: "种植方案",
             title: "种植方案",
-            path: "/plan?farmId=101532&pageType=plant",
+            path: "/plan?pageType=plant",
         },
         },
         {
         {
             title: "服务记录",
             title: "服务记录",

+ 73 - 60
src/views/old_mini/monitor/subPages/plan.vue

@@ -3,8 +3,13 @@
         <custom-header :name="pageType === 'plant' ? '种植方案' : '农事规划'"></custom-header>
         <custom-header :name="pageType === 'plant' ? '种植方案' : '农事规划'"></custom-header>
         <div class="plan-content">
         <div class="plan-content">
             <div class="plan-content-header" v-if="pageType === 'plant'">
             <div class="plan-content-header" v-if="pageType === 'plant'">
-                <el-select class="select-item" v-model="value" placeholder="选择品类">
-                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
+                <el-select class="select-item" v-model="specieValue" placeholder="选择品类" @change="getListMySchemes">
+                    <el-option
+                        v-for="item in options"
+                        :key="item.id"
+                        :label="item.name"
+                        :value="item.defaultContainerId"
+                    />
                 </el-select>
                 </el-select>
                 <tab-list type="light" v-model="active" :tabs="tabs" @change="handleTabChange" />
                 <tab-list type="light" v-model="active" :tabs="tabs" @change="handleTabChange" />
             </div>
             </div>
@@ -12,10 +17,10 @@
                 class="timeline-container"
                 class="timeline-container"
                 :class="{
                 :class="{
                     'timeline-container-plant': pageType == 'plant',
                     'timeline-container-plant': pageType == 'plant',
-                    'timeline-container-no-permission': !hasPlanPermission
+                    'timeline-container-no-permission': !hasPlanPermission,
                 }"
                 }"
                 :pageType="pageType"
                 :pageType="pageType"
-                :farmId="route.query.farmId"
+                :containerId="specieValue"
                 @row-click="handleRowClick"
                 @row-click="handleRowClick"
                 @edit="handleEdit"
                 @edit="handleEdit"
                 :disableClick="!hasPlanPermission"
                 :disableClick="!hasPlanPermission"
@@ -25,7 +30,7 @@
             <div class="bottom-btn-group">
             <div class="bottom-btn-group">
                 <div class="bottom-btn secondary-btn" @click="handlePhenologySetting">物候期设置</div>
                 <div class="bottom-btn secondary-btn" @click="handlePhenologySetting">物候期设置</div>
                 <div class="bottom-btn secondary-btn" v-if="pageType === 'plant'" @click="openCopyPlanPopup">
                 <div class="bottom-btn secondary-btn" v-if="pageType === 'plant'" @click="openCopyPlanPopup">
-                    {{ active === 1 ? "复制方案" : "方案设置" }}
+                    {{ defaultContainerId === specieValue ? "复制方案" : "方案设置" }}
                 </div>
                 </div>
             </div>
             </div>
             <div class="bottom-btn primary-btn" @click="addNewTask">新增农事</div>
             <div class="bottom-btn primary-btn" @click="addNewTask">新增农事</div>
@@ -39,19 +44,21 @@
         @handleSaveSuccess="getFarmWorkPlanForPhenology"
         @handleSaveSuccess="getFarmWorkPlanForPhenology"
         @handleDeleteInteract="handleDeleteInteract"
         @handleDeleteInteract="handleDeleteInteract"
     ></interact-popup>
     ></interact-popup>
+
     <!-- 复制方案弹窗 -->
     <!-- 复制方案弹窗 -->
     <Popup v-model:show="showCopyPlan" class="copy-plan-popup" round closeable :close-on-click-overlay="false">
     <Popup v-model:show="showCopyPlan" class="copy-plan-popup" round closeable :close-on-click-overlay="false">
         <div class="copy-plan-content">
         <div class="copy-plan-content">
-            <div class="label">{{ active === 1 ? "复制为" : "方案名称" }}</div>
+            <div class="label">{{ defaultContainerId === specieValue ? "复制为" : "方案名称" }}</div>
             <el-input v-model="copyPlanName" size="large" placeholder="请输入方案名称" class="copy-plan-input" />
             <el-input v-model="copyPlanName" size="large" placeholder="请输入方案名称" class="copy-plan-input" />
         </div>
         </div>
         <div class="copy-plan-footer">
         <div class="copy-plan-footer">
-            <div class="btn btn-cancel" @click="handleCancelCopyPlan">{{ active === 1 ? "取消复制" : "删除方案" }}</div>
+            <div class="btn btn-cancel" @click="handleCancelCopyPlan">{{ defaultContainerId === specieValue ? "取消复制" : "删除方案" }}</div>
             <div class="btn btn-confirm" @click="handleConfirmCopyPlan">
             <div class="btn btn-confirm" @click="handleConfirmCopyPlan">
                 {{ active === 1 ? "确定复制" : "确定设置" }}
                 {{ active === 1 ? "确定复制" : "确定设置" }}
             </div>
             </div>
         </div>
         </div>
     </Popup>
     </Popup>
+
     <!-- 物候期设置弹窗 -->
     <!-- 物候期设置弹窗 -->
     <Popup
     <Popup
         v-model:show="showPhenologySetting"
         v-model:show="showPhenologySetting"
@@ -62,11 +69,7 @@
     >
     >
         <div class="phenology-header">物候期时间设置</div>
         <div class="phenology-header">物候期时间设置</div>
         <div class="phenology-list">
         <div class="phenology-list">
-            <div
-                class="phenology-item"
-                v-for="(item, index) in mergedReproductiveList"
-                :key="item.id || index"
-            >
+            <div class="phenology-item" v-for="(item, index) in mergedReproductiveList" :key="item.id || index">
                 <div class="item-label">
                 <div class="item-label">
                     <span class="label-text">{{ item.name }}</span>
                     <span class="label-text">{{ item.name }}</span>
                     <span>起始时间</span>
                     <span>起始时间</span>
@@ -115,52 +118,52 @@ const hasPlanPermission = computed(() => {
     }
     }
 });
 });
 
 
-const active = ref(1);
-const tabs = ref([
-    {
-        id: 1,
-        name: "标准化方案",
-    },
-    {
-        id: 2,
-        name: "全托管方案",
-    },
-    {
-        id: 3,
-        name: "半托管方案",
-    },
-]);
-const handleTabChange = (id, item) => {
-    active.value = id;
-    console.log(id, item);
-};
-
-const value = ref("1");
-const options = ref([
-    {
-        value: "1",
-        label: "荔枝",
-    },
-    {
-        value: "2",
-        label: "全托管方案",
-    },
-]);
-
 const pageType = ref("");
 const pageType = ref("");
+
 onMounted(() => {
 onMounted(() => {
     pageType.value = route.query.pageType || "";
     pageType.value = route.query.pageType || "";
-    getFarmWorkPlanForPhenology();
+    if (pageType.value === "plant") {
+        getSpecieList();
+    }
 });
 });
 
 
+// 获取品类列表
+const specieValue = ref(null);
+const defaultContainerId = ref(null);
+const options = ref([]);
+const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
+const getSpecieList = () => {
+    VE_API.farm.fetchSpecieList({ agriculturalId: userInfo.agriculturalId }).then(({ data }) => {
+        options.value = data || [];
+        specieValue.value = data[0].defaultContainerId;
+        defaultContainerId.value = data[0].defaultContainerId;
+        getListMySchemes();
+    });
+};
+
+// 获取方案列表
+const active = ref(null);
+const tabs = ref([]);
+const getListMySchemes = () => {
+    VE_API.home.listMySchemes({ containerId: specieValue.value }).then(({ data }) => {
+        tabs.value = data || [];
+        active.value = data[0].id;
+        defaultContainerId.value = data[0].containerId;
+        getFarmWorkPlanForPhenology();
+    });
+};
+
+const handleTabChange = (id, item) => {
+    active.value = id;
+    console.log(id, item);
+};
+
 const mergedReproductiveList = ref([]);
 const mergedReproductiveList = ref([]);
 const containerSpaceTimeId = ref(null);
 const containerSpaceTimeId = ref(null);
 
 
-const getPhenologyList = async (containerSpaceTimeIdVal) => {
-    if (!containerSpaceTimeIdVal) return;
+const getPhenologyList = async () => {
     const res = await VE_API.monitor.listPhenology({
     const res = await VE_API.monitor.listPhenology({
-        containerSpaceTimeId: containerSpaceTimeIdVal,
-        farmId: route.query.farmId,
+        containerSpaceTimeId: containerSpaceTimeId.value,
     });
     });
     if (res.code === 0) {
     if (res.code === 0) {
         mergedReproductiveList.value = res.data || [];
         mergedReproductiveList.value = res.data || [];
@@ -171,7 +174,7 @@ const getPhenologyList = async (containerSpaceTimeIdVal) => {
 const getFarmWorkPlanForPhenology = async () => {
 const getFarmWorkPlanForPhenology = async () => {
     try {
     try {
         const { data, code } = await VE_API.monitor.farmWorkPlan({
         const { data, code } = await VE_API.monitor.farmWorkPlan({
-            farmId: route.query.farmId,
+            containerId: specieValue.value,
         });
         });
         if (code === 0 && data?.phenologyList?.[0]?.containerSpaceTimeId) {
         if (code === 0 && data?.phenologyList?.[0]?.containerSpaceTimeId) {
             containerSpaceTimeId.value = data.phenologyList[0].containerSpaceTimeId;
             containerSpaceTimeId.value = data.phenologyList[0].containerSpaceTimeId;
@@ -200,7 +203,6 @@ const handlePhenologySetting = () => {
  * 确认物候期设置
  * 确认物候期设置
  */
  */
 const handleConfirmPhenologySetting = async () => {
 const handleConfirmPhenologySetting = async () => {
-    console.log(mergedReproductiveList.value);
     const params = {
     const params = {
         farmId: route.query.farmId,
         farmId: route.query.farmId,
         items: mergedReproductiveList.value.map((item) => ({
         items: mergedReproductiveList.value.map((item) => ({
@@ -226,12 +228,20 @@ const handleConfirmCopyPlan = () => {
         ElMessage.warning("请输入方案名称");
         ElMessage.warning("请输入方案名称");
         return;
         return;
     }
     }
-    // TODO: 在此处调用复制方案的接口
-    ElMessage.success("复制成功");
-    showCopyPlan.value = false;
+    if (defaultContainerId.value === specieValue.value) {
+        VE_API.monitor.copyScheme({
+            containerId: specieValue.value,
+            sourceSchemeId: active.value,
+        }).then(({ code }) => {
+            if (code === 0) {
+                showCopyPlan.value = false;
+                ElMessage.success("复制成功");
+                getListMySchemes();
+            }
+        });
+    }
 };
 };
 
 
-
 // 新增农事
 // 新增农事
 const addNewTask = () => {
 const addNewTask = () => {
     ElMessage.warning("该功能正在升级中,敬请期待");
     ElMessage.warning("该功能正在升级中,敬请期待");
@@ -251,7 +261,13 @@ const handleRowClick = (item) => {
     curFarmObj.value = item;
     curFarmObj.value = item;
     router.push({
     router.push({
         path: "/modify",
         path: "/modify",
-        query: { id: item.id, farmId: route.query.farmId, farmWorkId: item.farmWorkId, containerSpaceTimeId: item.containerSpaceTimeId, agriculturalStoreId: route.query.agriculturalStoreId },
+        query: {
+            id: item.id,
+            farmId: route.query.farmId,
+            farmWorkId: item.farmWorkId,
+            containerSpaceTimeId: item.containerSpaceTimeId,
+            agriculturalStoreId: route.query.agriculturalStoreId,
+        },
     });
     });
 };
 };
 
 
@@ -300,9 +316,6 @@ const handleDeleteInteract = (params) => {
             &.timeline-container-plant {
             &.timeline-container-plant {
                 height: calc(100vh - 40px - 73px - 38px);
                 height: calc(100vh - 40px - 73px - 38px);
             }
             }
-            &.timeline-container-plant {
-                height: calc(100vh - 40px - 38px);
-            }
             // 没有权限时,底部按钮不显示,高度增加 73px
             // 没有权限时,底部按钮不显示,高度增加 73px
             &.timeline-container-no-permission {
             &.timeline-container-no-permission {
                 height: calc(100vh - 40px - 58px);
                 height: calc(100vh - 40px - 58px);
@@ -397,7 +410,7 @@ const handleDeleteInteract = (params) => {
             margin-top: 10px;
             margin-top: 10px;
         }
         }
     }
     }
-    .phenology-footer{
+    .phenology-footer {
         width: 100%;
         width: 100%;
         text-align: center;
         text-align: center;
         font-size: 16px;
         font-size: 16px;

+ 1 - 0
src/views/old_mini/plan/index.vue

@@ -128,6 +128,7 @@ const handleConfirmPlan = () => {
         .then((res) => {
         .then((res) => {
             if (res.code === 0) {
             if (res.code === 0) {
                 shareData.value = res.data;
                 shareData.value = res.data;
+                ElMessage.success("创建成功");
                 handleClickOverlay();
                 handleClickOverlay();
             } else {
             } else {
                 ElMessage.error(res.msg || "创建失败");
                 ElMessage.error(res.msg || "创建失败");