|
@@ -62,21 +62,21 @@
|
|
|
<el-form-item label="存放点位" prop="location" required>
|
|
<el-form-item label="存放点位" prop="location" required>
|
|
|
<div class="field-block">
|
|
<div class="field-block">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-if="isEdit"
|
|
|
|
|
|
|
+ v-if="isEdit || form.location"
|
|
|
v-model="form.location"
|
|
v-model="form.location"
|
|
|
placeholder="请选择存放点位"
|
|
placeholder="请选择存放点位"
|
|
|
readonly
|
|
readonly
|
|
|
/>
|
|
/>
|
|
|
<el-button class="btn-outline" @click="handleSelectLocation">
|
|
<el-button class="btn-outline" @click="handleSelectLocation">
|
|
|
- {{ isEdit ? "修改点位" : "选择点位" }}
|
|
|
|
|
|
|
+ {{ isEdit || form.location ? "修改点位" : "选择点位" }}
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
- <el-form-item label="执行区域" prop="areaThumb" required>
|
|
|
|
|
|
|
+ <el-form-item label="执行区域" prop="areaLabel" required>
|
|
|
<div class="field-block">
|
|
<div class="field-block">
|
|
|
- <div v-if="isEdit" class="area-preview">
|
|
|
|
|
- 执行区域区域地图地图地图地图
|
|
|
|
|
|
|
+ <div v-if="isEdit && form.areaLabel" class="area-preview">
|
|
|
|
|
+ {{ form.areaLabel }}
|
|
|
</div>
|
|
</div>
|
|
|
<el-button class="btn-outline" @click="handleSelectArea">
|
|
<el-button class="btn-outline" @click="handleSelectArea">
|
|
|
{{ isEdit ? "修改区域" : "选择区域" }}
|
|
{{ isEdit ? "修改区域" : "选择区域" }}
|
|
@@ -110,11 +110,27 @@
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
+
|
|
|
|
|
+ <SelectAreaDialog
|
|
|
|
|
+ v-model="areaDialogVisible"
|
|
|
|
|
+ :farm-id="101532"
|
|
|
|
|
+ :selected-ids="form.selectedAreaIds"
|
|
|
|
|
+ @confirm="handleAreaConfirm"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <SelectLocationDialog
|
|
|
|
|
+ v-model="locationDialogVisible"
|
|
|
|
|
+ :farm-id="101532"
|
|
|
|
|
+ :location-wkt="form.locationWkt"
|
|
|
|
|
+ @confirm="handleLocationConfirm"
|
|
|
|
|
+ />
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { computed, reactive, ref, watch } from "vue";
|
|
import { computed, reactive, ref, watch } from "vue";
|
|
|
import { ElMessage } from "element-plus";
|
|
import { ElMessage } from "element-plus";
|
|
|
|
|
+import SelectAreaDialog from "./SelectAreaDialog.vue";
|
|
|
|
|
+import SelectLocationDialog from "./SelectLocationDialog.vue";
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
modelValue: {
|
|
modelValue: {
|
|
@@ -136,6 +152,8 @@ const emit = defineEmits(["update:modelValue", "submit"]);
|
|
|
const isEdit = computed(() => props.mode === "edit");
|
|
const isEdit = computed(() => props.mode === "edit");
|
|
|
const formRef = ref();
|
|
const formRef = ref();
|
|
|
const submitting = ref(false);
|
|
const submitting = ref(false);
|
|
|
|
|
+const areaDialogVisible = ref(false);
|
|
|
|
|
+const locationDialogVisible = ref(false);
|
|
|
|
|
|
|
|
const typeOptions = ["肥水一体", "水肥一体", "植保无人机", "收割机", "播种机"];
|
|
const typeOptions = ["肥水一体", "水肥一体", "植保无人机", "收割机", "播种机"];
|
|
|
const categoryOptions = ["类别一", "类别二", "类别三", "类别四", "类别五", "类别六", "类别七"];
|
|
const categoryOptions = ["类别一", "类别二", "类别三", "类别四", "类别五", "类别六", "类别七"];
|
|
@@ -146,7 +164,10 @@ const createEmptyForm = () => ({
|
|
|
type: "",
|
|
type: "",
|
|
|
categories: [],
|
|
categories: [],
|
|
|
location: "",
|
|
location: "",
|
|
|
- areaThumb: "",
|
|
|
|
|
|
|
+ locationWkt: "",
|
|
|
|
|
+ areaLabel: "",
|
|
|
|
|
+ selectedAreaIds: [],
|
|
|
|
|
+ selectedAreas: [],
|
|
|
ownerName: "",
|
|
ownerName: "",
|
|
|
ownerPhone: "",
|
|
ownerPhone: "",
|
|
|
});
|
|
});
|
|
@@ -174,10 +195,10 @@ const rules = {
|
|
|
trigger: "change",
|
|
trigger: "change",
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
- areaThumb: [
|
|
|
|
|
|
|
+ areaLabel: [
|
|
|
{
|
|
{
|
|
|
validator: (_rule, _value, callback) => {
|
|
validator: (_rule, _value, callback) => {
|
|
|
- if (!form.areaThumb) callback(new Error("请选择执行区域"));
|
|
|
|
|
|
|
+ if (!form.selectedAreaIds?.length) callback(new Error("请选择执行区域"));
|
|
|
else callback();
|
|
else callback();
|
|
|
},
|
|
},
|
|
|
trigger: "change",
|
|
trigger: "change",
|
|
@@ -201,7 +222,10 @@ const fillForm = (data) => {
|
|
|
type: data?.type || "",
|
|
type: data?.type || "",
|
|
|
categories: [...(data?.categories || [])],
|
|
categories: [...(data?.categories || [])],
|
|
|
location: data?.location || "",
|
|
location: data?.location || "",
|
|
|
- areaThumb: data?.areaThumb,
|
|
|
|
|
|
|
+ locationWkt: data?.locationWkt || "",
|
|
|
|
|
+ areaLabel: data?.areaLabel || "",
|
|
|
|
|
+ selectedAreaIds: [...(data?.selectedAreaIds || [])],
|
|
|
|
|
+ selectedAreas: [...(data?.selectedAreas || [])],
|
|
|
ownerName: data?.ownerName || "",
|
|
ownerName: data?.ownerName || "",
|
|
|
ownerPhone: data?.ownerPhone || "",
|
|
ownerPhone: data?.ownerPhone || "",
|
|
|
});
|
|
});
|
|
@@ -223,19 +247,31 @@ const close = () => emit("update:modelValue", false);
|
|
|
|
|
|
|
|
const handleClosed = () => {
|
|
const handleClosed = () => {
|
|
|
submitting.value = false;
|
|
submitting.value = false;
|
|
|
|
|
+ areaDialogVisible.value = false;
|
|
|
|
|
+ locationDialogVisible.value = false;
|
|
|
formRef.value?.resetFields?.();
|
|
formRef.value?.resetFields?.();
|
|
|
Object.assign(form, createEmptyForm());
|
|
Object.assign(form, createEmptyForm());
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleSelectLocation = () => {
|
|
const handleSelectLocation = () => {
|
|
|
- form.location = form.location || "位置位置位置位置位置";
|
|
|
|
|
- ElMessage.success(isEdit.value ? "已修改点位(占位)" : "已选择点位(占位)");
|
|
|
|
|
|
|
+ locationDialogVisible.value = true;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const handleLocationConfirm = (point) => {
|
|
|
|
|
+ form.locationWkt = point.wkt;
|
|
|
|
|
+ form.location = point.label;
|
|
|
formRef.value?.validateField?.("location");
|
|
formRef.value?.validateField?.("location");
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleSelectArea = () => {
|
|
const handleSelectArea = () => {
|
|
|
- ElMessage.success(isEdit.value ? "已修改区域(占位)" : "已选择区域(占位)");
|
|
|
|
|
- formRef.value?.validateField?.("areaThumb");
|
|
|
|
|
|
|
+ areaDialogVisible.value = true;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const handleAreaConfirm = ({ areas, ids, label }) => {
|
|
|
|
|
+ form.selectedAreas = areas;
|
|
|
|
|
+ form.selectedAreaIds = ids;
|
|
|
|
|
+ form.areaLabel = label;
|
|
|
|
|
+ formRef.value?.validateField?.("areaLabel");
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleSubmit = async () => {
|
|
const handleSubmit = async () => {
|
|
@@ -249,7 +285,10 @@ const handleSubmit = async () => {
|
|
|
type: form.type,
|
|
type: form.type,
|
|
|
categories: [...form.categories],
|
|
categories: [...form.categories],
|
|
|
location: form.location,
|
|
location: form.location,
|
|
|
- areaThumb: form.areaThumb,
|
|
|
|
|
|
|
+ locationWkt: form.locationWkt,
|
|
|
|
|
+ areaLabel: form.areaLabel,
|
|
|
|
|
+ selectedAreaIds: [...form.selectedAreaIds],
|
|
|
|
|
+ selectedAreas: [...form.selectedAreas],
|
|
|
ownerName: form.ownerName,
|
|
ownerName: form.ownerName,
|
|
|
ownerPhone: form.ownerPhone,
|
|
ownerPhone: form.ownerPhone,
|
|
|
};
|
|
};
|
|
@@ -265,7 +304,8 @@ const handleSubmit = async () => {
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
.device-form {
|
|
.device-form {
|
|
|
- padding: 8px 24px 0 8px;
|
|
|
|
|
|
|
+ padding: 20px 24px 0 8px;
|
|
|
|
|
+ border-top: 1px solid #E5E6EB;
|
|
|
|
|
|
|
|
:deep(.el-form-item) {
|
|
:deep(.el-form-item) {
|
|
|
margin-bottom: 24px;
|
|
margin-bottom: 24px;
|
|
@@ -296,6 +336,18 @@ const handleSubmit = async () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.area-preview {
|
|
|
|
|
+ min-width: 148px;
|
|
|
|
|
+ max-width: 100%;
|
|
|
|
|
+ padding: 10px 12px;
|
|
|
|
|
+ border: 1px solid #e5e5e5;
|
|
|
|
|
+ border-radius: 2px;
|
|
|
|
|
+ background: #f7f7f7;
|
|
|
|
|
+ color: #666;
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+ line-height: 1.5;
|
|
|
|
|
+ word-break: break-all;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
.dialog-footer {
|
|
.dialog-footer {
|
|
|
display: flex;
|
|
display: flex;
|