editCrimical.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <el-form ref="form" label-width="84px">
  3. <!-- {{ bindExample }} -->
  4. <el-form-item label="案件名称">
  5. <el-input v-model="bindExample.caseTitle" maxlength="50" placeholder="请输入案件名称" />
  6. </el-form-item>
  7. <el-form-item label="详细地址">
  8. <el-input v-model="bindExample.mapUrl" placeholder="输入名称搜索" clearable disabled>
  9. <template #append>
  10. <el-button :icon="Search" @click="searchAMapAddress" />
  11. </template>
  12. </el-input>
  13. </el-form-item>
  14. <el-form-item label="首页显示">
  15. <el-switch v-model="bindExample.mapShow" :disabled="!bindExample.latAndLong" />
  16. </el-form-item>
  17. </el-form>
  18. <!-- 地图弹窗(使用与 basicInfo.vue 相同的 creatMap 组件) -->
  19. <creatMap v-model="showMapDialog" :caseId="bindExample.caseId" @confirm="handleMapConfirm" />
  20. </template>
  21. <script setup lang="ts">
  22. import { ref } from "vue";
  23. import { Example, setExample, addExample } from "@/app/criminal/store/example";
  24. import { ElMessage } from "element-plus";
  25. import { QuiskExpose } from "@/helper/mount";
  26. import { Search } from "@element-plus/icons-vue";
  27. import creatMap from "../newFireDetails/components/creatMap.vue";
  28. const props = defineProps<{ example?: Example }>();
  29. const bindExample = ref<Example>(props.example ? { ...props.example } : ({} as Example));
  30. const showMapDialog = ref(false);
  31. defineExpose<QuiskExpose>({
  32. async submit() {
  33. if (!bindExample.value.caseTitle || !bindExample.value.caseTitle.trim()) {
  34. ElMessage.error("案件名称不能为空");
  35. throw "案件名称不能为空";
  36. } else if (!bindExample.value.latAndLong || !bindExample.value.latAndLong.trim()) {
  37. ElMessage.error("详细地址不能为空");
  38. throw "详细地址不能为空!";
  39. }
  40. await (bindExample.value.caseId
  41. ? setExample(bindExample.value)
  42. : addExample(bindExample.value));
  43. },
  44. });
  45. // 打开地图弹窗(与 basicInfo.vue 保持一致)
  46. const searchAMapAddress = () => {
  47. showMapDialog.value = true;
  48. };
  49. // 处理地图选择确认,更新地址与经纬度
  50. const handleMapConfirm = (locationInfo: any) => {
  51. const { cityname, adname, address, name, location } = locationInfo || {};
  52. // 更新展示地址
  53. bindExample.value.mapUrl = `${cityname || ''}${adname || ''}${address || ''}${name || ''}`;
  54. // 更新经纬度
  55. if (location && typeof location.lat === 'number' && typeof location.lng === 'number') {
  56. bindExample.value.latlng = bindExample.value.latAndLong = `${location.lat},${location.lng}`;
  57. }
  58. showMapDialog.value = false;
  59. };
  60. </script>