|
|
@@ -3,8 +3,13 @@
|
|
|
<custom-header :name="pageType === 'plant' ? '种植方案' : '农事规划'"></custom-header>
|
|
|
<div class="plan-content">
|
|
|
<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>
|
|
|
<tab-list type="light" v-model="active" :tabs="tabs" @change="handleTabChange" />
|
|
|
</div>
|
|
|
@@ -12,10 +17,10 @@
|
|
|
class="timeline-container"
|
|
|
:class="{
|
|
|
'timeline-container-plant': pageType == 'plant',
|
|
|
- 'timeline-container-no-permission': !hasPlanPermission
|
|
|
+ 'timeline-container-no-permission': !hasPlanPermission,
|
|
|
}"
|
|
|
:pageType="pageType"
|
|
|
- :farmId="route.query.farmId"
|
|
|
+ :containerId="specieValue"
|
|
|
@row-click="handleRowClick"
|
|
|
@edit="handleEdit"
|
|
|
:disableClick="!hasPlanPermission"
|
|
|
@@ -25,7 +30,7 @@
|
|
|
<div class="bottom-btn-group">
|
|
|
<div class="bottom-btn secondary-btn" @click="handlePhenologySetting">物候期设置</div>
|
|
|
<div class="bottom-btn secondary-btn" v-if="pageType === 'plant'" @click="openCopyPlanPopup">
|
|
|
- {{ active === 1 ? "复制方案" : "方案设置" }}
|
|
|
+ {{ defaultContainerId === specieValue ? "复制方案" : "方案设置" }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="bottom-btn primary-btn" @click="addNewTask">新增农事</div>
|
|
|
@@ -39,19 +44,21 @@
|
|
|
@handleSaveSuccess="getFarmWorkPlanForPhenology"
|
|
|
@handleDeleteInteract="handleDeleteInteract"
|
|
|
></interact-popup>
|
|
|
+
|
|
|
<!-- 复制方案弹窗 -->
|
|
|
<Popup v-model:show="showCopyPlan" class="copy-plan-popup" round closeable :close-on-click-overlay="false">
|
|
|
<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" />
|
|
|
</div>
|
|
|
<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">
|
|
|
{{ active === 1 ? "确定复制" : "确定设置" }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</Popup>
|
|
|
+
|
|
|
<!-- 物候期设置弹窗 -->
|
|
|
<Popup
|
|
|
v-model:show="showPhenologySetting"
|
|
|
@@ -62,11 +69,7 @@
|
|
|
>
|
|
|
<div class="phenology-header">物候期时间设置</div>
|
|
|
<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">
|
|
|
<span class="label-text">{{ item.name }}</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("");
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
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 containerSpaceTimeId = ref(null);
|
|
|
|
|
|
-const getPhenologyList = async (containerSpaceTimeIdVal) => {
|
|
|
- if (!containerSpaceTimeIdVal) return;
|
|
|
+const getPhenologyList = async () => {
|
|
|
const res = await VE_API.monitor.listPhenology({
|
|
|
- containerSpaceTimeId: containerSpaceTimeIdVal,
|
|
|
- farmId: route.query.farmId,
|
|
|
+ containerSpaceTimeId: containerSpaceTimeId.value,
|
|
|
});
|
|
|
if (res.code === 0) {
|
|
|
mergedReproductiveList.value = res.data || [];
|
|
|
@@ -171,7 +174,7 @@ const getPhenologyList = async (containerSpaceTimeIdVal) => {
|
|
|
const getFarmWorkPlanForPhenology = async () => {
|
|
|
try {
|
|
|
const { data, code } = await VE_API.monitor.farmWorkPlan({
|
|
|
- farmId: route.query.farmId,
|
|
|
+ containerId: specieValue.value,
|
|
|
});
|
|
|
if (code === 0 && data?.phenologyList?.[0]?.containerSpaceTimeId) {
|
|
|
containerSpaceTimeId.value = data.phenologyList[0].containerSpaceTimeId;
|
|
|
@@ -200,7 +203,6 @@ const handlePhenologySetting = () => {
|
|
|
* 确认物候期设置
|
|
|
*/
|
|
|
const handleConfirmPhenologySetting = async () => {
|
|
|
- console.log(mergedReproductiveList.value);
|
|
|
const params = {
|
|
|
farmId: route.query.farmId,
|
|
|
items: mergedReproductiveList.value.map((item) => ({
|
|
|
@@ -226,12 +228,20 @@ const handleConfirmCopyPlan = () => {
|
|
|
ElMessage.warning("请输入方案名称");
|
|
|
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 = () => {
|
|
|
ElMessage.warning("该功能正在升级中,敬请期待");
|
|
|
@@ -251,7 +261,13 @@ const handleRowClick = (item) => {
|
|
|
curFarmObj.value = item;
|
|
|
router.push({
|
|
|
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 {
|
|
|
height: calc(100vh - 40px - 73px - 38px);
|
|
|
}
|
|
|
- &.timeline-container-plant {
|
|
|
- height: calc(100vh - 40px - 38px);
|
|
|
- }
|
|
|
// 没有权限时,底部按钮不显示,高度增加 73px
|
|
|
&.timeline-container-no-permission {
|
|
|
height: calc(100vh - 40px - 58px);
|
|
|
@@ -397,7 +410,7 @@ const handleDeleteInteract = (params) => {
|
|
|
margin-top: 10px;
|
|
|
}
|
|
|
}
|
|
|
- .phenology-footer{
|
|
|
+ .phenology-footer {
|
|
|
width: 100%;
|
|
|
text-align: center;
|
|
|
font-size: 16px;
|