|
|
@@ -17,16 +17,24 @@
|
|
|
|
|
|
<div v-for="(region, regionIndex) in crop.regions" :key="regionIndex" class="variety-card">
|
|
|
<div class="field-row">
|
|
|
- <div class="field-value" v-if="farmData.status === 'INIT' || isAddVariety">
|
|
|
+ <div class="field-value variety-select-wrap" v-if="farmData.status === 'INIT' || isAddVariety">
|
|
|
<el-select v-model="region.regionId" class="variety-input" placeholder="选择品种">
|
|
|
<el-option v-for="(item, index) in crop.typeIdItems" :key="index" :label="item.name"
|
|
|
- :value="item.id" />
|
|
|
+ :value="item.id"
|
|
|
+ :disabled="isVarietyOptionDisabled(crop, region, item.id) || item.selected === 1" />
|
|
|
<template #footer>
|
|
|
<el-button text bg @click="onAddOption(region)">
|
|
|
+ 增加品种
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-select>
|
|
|
+ <div
|
|
|
+ v-if="regionIndex > 0"
|
|
|
+ class="delete-variety-btn"
|
|
|
+ @click="removeVariety(crop, regionIndex)"
|
|
|
+ >
|
|
|
+ <el-icon><Delete /></el-icon>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="tag-val" v-else>
|
|
|
{{ region.regionName }}
|
|
|
@@ -168,6 +176,22 @@ const addVariety = (crop) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+// 同一作物下,已被其它行选择的品种不可重复选择
|
|
|
+const isVarietyOptionDisabled = (crop, currentRegion, optionId) => {
|
|
|
+ const optionKey = String(optionId);
|
|
|
+ return (crop?.regions || []).some((region) => {
|
|
|
+ if (region === currentRegion) return false;
|
|
|
+ if (!region?.regionId) return false;
|
|
|
+ return String(region.regionId) === optionKey;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+// 第一项保留不可删,其余项可删
|
|
|
+const removeVariety = (crop, regionIndex) => {
|
|
|
+ if (!crop?.regions || regionIndex <= 0) return;
|
|
|
+ crop.regions.splice(regionIndex, 1);
|
|
|
+};
|
|
|
+
|
|
|
// 获取物候期对应的时间标签
|
|
|
const getPhenologyLabel = (farm, phenologyId) => {
|
|
|
if (!farm?.phenologyOptions) return "选择时间";
|
|
|
@@ -506,6 +530,20 @@ onBeforeUnmount(() => {
|
|
|
flex: 1;
|
|
|
}
|
|
|
|
|
|
+.variety-select-wrap {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.delete-variety-btn {
|
|
|
+ color: #ff4d4f;
|
|
|
+ font-size: 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ user-select: none;
|
|
|
+}
|
|
|
+
|
|
|
.tag-val {
|
|
|
background: rgba(33, 153, 248, 0.1);
|
|
|
color: #2199F8;
|