<!-- d:\wordpack\WholeProcessPlatform\frontend\src\views\system\map\components\LegendData\index.vue -->
<template>
  <div class="content">
    <LegendDataSearch
      ref="legendDataSearch"
      :handle-add="handleAdd"
      @reset="handleReset"
      @search-finish="onSearchFinish"
    />
    <BasicTable
      :columns="columns"
      :data="dataSource"
      :list-url="fetchLegendData"
      :search-params="searchParams"
    >
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'action'">
          <a-space>
            <a-button type="link" size="small" @click="handleEdit(record)">编辑</a-button>
            <a-button type="link" size="small" danger @click="handleDelete(record)"
              >删除</a-button
            >
          </a-space>
        </template>

        <template v-if="column.key === 'enable'">
          <a-switch
            :checked="record.enable === 1"
            @change="(checked: boolean) => handleEnableChange(record, checked)"
          />
        </template>
        <template v-if="column.key === 'internal'">
          <a-switch
            :checked="record.internal === 1"
            @change="(checked: boolean) => handleInternalChange(record, checked)"
          />
        </template>
        <template v-if="column.key === 'ifShow'">
          <a-switch
            :checked="record.ifShow === 1"
            @change="(checked: boolean) => handleIfShowChange(record, checked)"
          />
        </template>
      </template>
    </BasicTable>
    <LegendDataForm
      ref="legendDataForm"
      v-model:visible="editModalVisible"
      :initial-values="currentRecord"
      @cancel="editModalCancel"
      @ok="handleEditSubmit"
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import BasicTable from "@/components/BasicTable/index.vue";
import LegendDataSearch from "./LegendDataSearch.vue";
import LegendDataForm from "./LegendDataForm.vue";
import { message } from "ant-design-vue";
import { C } from "vue-router/dist/router-CWoNjPRp.mjs";

// 表格列配置
const columns = [
  {
    title: "序号",
    dataIndex: "index",
    key: "index",
    width: 50,
    customRender: ({ _, index }) => index + 1,
  },
  {
    title: "图例名称",
    dataIndex: "name",
    key: "name",
    width: 150,
  },
  {
    title: "图例编码",
    key: "nameEn",
    dataIndex: "nameEn",
    width: 120,
  },
  {
    title: "icon编码",
    key: "icon",
    dataIndex: "icon",
    width: 150,
  },
  {
    title: "图例类型",
    dataIndex: "codeName",
    key: "codeName",
    width: 80,
  },
  {
    title: "二维最小缩放",
    dataIndex: "minZoom",
    key: "minZoom",
    width: 100,
  },
  {
    title: "二维最大缩放",
    dataIndex: "maxZoom",
    key: "maxZoom",
    width: 100,
  },
  {
    title: "三维最小高程",
    dataIndex: "minHeightThd",
    key: "minHeightThd",
    width: 100,
  },
  {
    title: "三维最大高程",
    dataIndex: "maxHeightThd",
    key: "maxHeightThd",
    width: 100,
  },
  {
    title: "区间表达式",
    dataIndex: "expression",
    key: "expression",
    width: 100,
  },
  {
    title: "父级图例名称",
    dataIndex: "parentName",
    key: "parentName",
    width: 170,
  },
  {
    title: "父级图例编码",
    dataIndex: "parentCode",
    key: "parentCode",
    width: 150,
  },
  {
    title: "图层名称",
    dataIndex: "layerCodeName",
    key: "layerCodeName",
    width: 180,
  },
  {
    title: "图层编码",
    dataIndex: "layerCode",
    key: "layerCode",
    width: 180,
  },
  {
    title: "是否启用",
    dataIndex: "enable",
    key: "enable",
    width: 80,
  },
  {
    title: "系统内置项",
    dataIndex: "internal",
    key: "internal",
    width: 100,
  },
  {
    title: "是否显示",
    dataIndex: "ifShow",
    key: "ifShow",
    width: 80,
  },
  {
    title: "备注",
    dataIndex: "description",
    key: "description",
    width: 160,
  },
  {
    title: "创建人",
    key: "recordUser",
    dataIndex: "recordUser",
    width: 150,
  },
  {
    title: "创建时间",
    key: "recordTime",
    dataIndex: "recordTime",
    width: 150,
  },
  {
    title: "更新时间",
    key: "modifyTime",
    dataIndex: "modifyTime",
    width: 150,
  },
  {
    title: "操作",
    key: "action",
    width: 150,
    fixed: "right",
  },
];

// 搜索参数
const searchParams = ref({});
// 编辑弹窗数据
const currentRecord = ref<any | null>(null);
const editModalVisible = ref(false);

// 数据源
const dataSource = ref([
  {
    _tls: {},
    id: "86c233f69a934b729ec2be075c1bef9e",
    recordUser: "2a84192b-68e0-43e1-9f9c-3d8dd38badbb",
    recordTime: "2025-09-26 15:31:16",
    modifyTime: "2025-10-11 11:15:53",
    displayRecordUser: "2a84192b-68e0-43e1-9f9c-3d8dd38badbb",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "鱼类调查装置",
    parentName: "鱼类调查装置",
    parentCode: "FPRD",
    layerCode: "fprd_point",
    layerCodeName: "鱼类调查装置",
    dataType: 2,
    name: "鱼类调查装置",
    nameEn: "fprd",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-aishipinzhan",
    orderIndex: 1,
    enable: 1,
    systemId: "10EC2E0B-AEA9-4757-83A2-201BA1BC54E9",
    treeLevel: 2,
    fullPath: "20aeca4aed5c4afebbffe211baaa6210,86c233f69a934b729ec2be075c1bef9e,",
    hasChildren: 0,
    parentId: "20aeca4aed5c4afebbffe211baaa6210",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 0,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: "鱼类调查装置",
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "CA9229DFDDE94586A6EB965A884BFC50",
    recordUser: "wanglh",
    recordTime: "2024-06-07 17:18:00",
    modifyTime: "2025-09-29 18:16:18",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "测站站点",
    parentName: "测站站点",
    parentCode: "ST2",
    layerCode: "stinfo_ai_video_point",
    layerCodeName: "AI视频监控站",
    dataType: 2,
    name: "AI视频监控站",
    nameEn: "aispjk",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-aishipinzhan",
    orderIndex: 3,
    enable: 1,
    systemId: "qgc",
    treeLevel: 2,
    fullPath: "98664FEDD5E1436A808181B680F2AE85,CA9229DFDDE94586A6EB965A884BFC50,",
    hasChildren: null,
    parentId: "98664FEDD5E1436A808181B680F2AE85",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 0,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "c9902f2ef89a4a2898a7a2eb13da2c5b",
    recordUser: "ca57a4aa-8c95-4e43-8c45-a7002e741f3e",
    recordTime: "2024-05-30 09:47:53",
    modifyTime: "2024-05-30 09:48:18",
    displayRecordUser: "ca57a4aa-8c95-4e43-8c45-a7002e741f3e",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施",
    parentName: "生态流量泄放设施",
    parentCode: "EQST",
    layerCode: "eq_point",
    layerCodeName: "生态流量泄放设施",
    dataType: 2,
    name: "泄洪设施",
    nameEn: "EQ_7",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssShengtaijizu",
    orderIndex: 7,
    enable: 1,
    systemId: "qgc",
    treeLevel: 2,
    fullPath: "C3CF7A3673F94EC5A96F3D271C244834,c9902f2ef89a4a2898a7a2eb13da2c5b,",
    hasChildren: 0,
    parentId: "C3CF7A3673F94EC5A96F3D271C244834",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "bb414d40e851414eb2fd05726a54e15c",
    recordUser: "061bd3e1-5264-42fa-9d24-87a09c6ce132",
    recordTime: "2024-04-26 15:25:08",
    modifyTime: "2024-04-26 15:25:43",
    displayRecordUser: "061bd3e1-5264-42fa-9d24-87a09c6ce132",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "自然保护区",
    parentName: "自然保护区",
    parentCode: "nature_reserve",
    layerCode: "lcj_bhq",
    layerCodeName: "自然保护区",
    dataType: 2,
    name: "自然保护区",
    nameEn: "nature_reserve_area",
    code: "baseLayer",
    codeName: "地图GIS",
    icon: "map-ziranbaohuqu",
    orderIndex: 1,
    enable: 1,
    systemId: "10EC2E0B-AEA9-4757-83A2-201BA1BC54E9",
    treeLevel: 2,
    fullPath: "cfc8313399d64f0fb18b3a93113940f1,bb414d40e851414eb2fd05726a54e15c,",
    hasChildren: 0,
    parentId: "cfc8313399d64f0fb18b3a93113940f1",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 0,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "19E136D4C242614951547A3E39386DB4",
    recordUser: "wanglh",
    recordTime: "2024-03-28 10:48:41",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "栖息地",
    parentName: "栖息地",
    parentCode: "FHST",
    layerCode: "fh_wq_point",
    layerCodeName: "水质监测站",
    dataType: 2,
    name: "水质监测站",
    nameEn: "FH_WQ",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-zjszzDabiao",
    orderIndex: 6,
    enable: 1,
    systemId: "qgc",
    treeLevel: 2,
    fullPath: "13357665B04A42E2A504BAC3E113752B,19E136D4C242614951547A3E39386DB4,",
    hasChildren: 0,
    parentId: "13357665B04A42E2A504BAC3E113752B",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "3F51A402EF6C3AB6E9485DFEF24B6460",
    recordUser: "wanglh",
    recordTime: "2024-03-28 10:48:41",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "栖息地",
    parentName: "栖息地",
    parentCode: "FHST",
    layerCode: "fh_vd_point",
    layerCodeName: "视频监控",
    dataType: 2,
    name: "视频监控",
    nameEn: "FH_VD",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-shipinzhan",
    orderIndex: 9,
    enable: 1,
    systemId: "qgc",
    treeLevel: 2,
    fullPath: "13357665B04A42E2A504BAC3E113752B,3F51A402EF6C3AB6E9485DFEF24B6460,",
    hasChildren: 0,
    parentId: "13357665B04A42E2A504BAC3E113752B",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "6A863CD380AD7C032404FBB81B4E10F6",
    recordUser: "wanglh",
    recordTime: "2024-03-28 10:48:41",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "栖息地",
    parentName: "栖息地",
    parentCode: "FHST",
    layerCode: "fh_zq_point",
    layerCodeName: "流量监测站",
    dataType: 2,
    name: "流量监测站",
    nameEn: "FH_ZQ",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-liuliangzhan",
    orderIndex: 8,
    enable: 1,
    systemId: "qgc",
    treeLevel: 2,
    fullPath: "13357665B04A42E2A504BAC3E113752B,6A863CD380AD7C032404FBB81B4E10F6,",
    hasChildren: 0,
    parentId: "13357665B04A42E2A504BAC3E113752B",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "34F27ABC31CEC60D6EC9A0CC366DB6DE",
    recordUser: "wanglh",
    recordTime: "2024-03-28 10:48:41",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "栖息地",
    parentName: "栖息地",
    parentCode: "FHST",
    layerCode: "fh_wtrv_point",
    layerCodeName: "水温监测站",
    dataType: 2,
    name: "水温监测站",
    nameEn: "FH_WTRV",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-zidongshuiwenjiance",
    orderIndex: 7,
    enable: 1,
    systemId: "qgc",
    treeLevel: 2,
    fullPath: "13357665B04A42E2A504BAC3E113752B,34F27ABC31CEC60D6EC9A0CC366DB6DE,",
    hasChildren: 0,
    parentId: "13357665B04A42E2A504BAC3E113752B",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "4ff1a39872c847dfba35f51912befad3",
    recordUser: "20210408-1122-2456-4a46-281b742d0372",
    recordTime: "2024-03-11 12:21:59",
    modifyTime: "2024-03-11 12:22:11",
    displayRecordUser: "20210408-1122-2456-4a46-281b742d0372",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "野生动物监测",
    parentName: "野生动物监测",
    parentCode: "WA_LEGEND",
    layerCode: "wa_point",
    layerCodeName: "野生动物监测",
    dataType: 2,
    name: "野生动物监测",
    nameEn: "wild_animal_legend",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-yeshengdongwu",
    orderIndex: 1,
    enable: 1,
    systemId: "10EC2E0B-AEA9-4757-83A2-201BA1BC54E9",
    treeLevel: 2,
    fullPath: "607cf6bbd5e749b98b58f7b1188cdfb0,4ff1a39872c847dfba35f51912befad3,",
    hasChildren: 0,
    parentId: "607cf6bbd5e749b98b58f7b1188cdfb0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 0,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "0FA144C8AB218AD7B8406C8B923A78EC",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "过鱼设施-在建",
    parentName: "过鱼设施-在建",
    parentCode: "FPST_BUILT",
    layerCode: "fp_built_point",
    layerCodeName: "过鱼设施-在建",
    dataType: 2,
    name: "鱼道-在建",
    nameEn: "gy_1_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-gyssYudao",
    orderIndex: 11,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "e53e2a300031446ca168244fb30cc818,0FA144C8AB218AD7B8406C8B923A78EC,",
    hasChildren: 0,
    parentId: "e53e2a300031446ca168244fb30cc818",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "85E821AF9482B72F5E73A769D3B2C129",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-01-31 09:32:10",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施-在建",
    parentName: "生态流量泄放设施-在建",
    parentCode: "OTHERST_BUILT",
    layerCode: "eq_built_point",
    layerCodeName: "生态流量泄放设施-在建",
    dataType: 2,
    name: "放流孔-在建",
    nameEn: "EQ_1_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssFangliukong",
    orderIndex: 18,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "42b6bdfb27e04a2689ece4309a8a21e0,85E821AF9482B72F5E73A769D3B2C129,",
    hasChildren: 0,
    parentId: "42b6bdfb27e04a2689ece4309a8a21e0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "84971EB164CB6EC8D06ABAFF615F06C3",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-01-31 09:31:51",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施-在建",
    parentName: "生态流量泄放设施-在建",
    parentCode: "OTHERST_BUILT",
    layerCode: "eq_built_point",
    layerCodeName: "生态流量泄放设施-在建",
    dataType: 2,
    name: "基荷发电-在建",
    nameEn: "EQ_5_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssFangliuguan",
    orderIndex: 17,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "42b6bdfb27e04a2689ece4309a8a21e0,84971EB164CB6EC8D06ABAFF615F06C3,",
    hasChildren: 0,
    parentId: "42b6bdfb27e04a2689ece4309a8a21e0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "2CEFF8BA05A9D956B6B4EF9C44E870E1",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-01-31 09:31:37",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施-在建",
    parentName: "生态流量泄放设施-在建",
    parentCode: "OTHERST_BUILT",
    layerCode: "eq_built_point",
    layerCodeName: "生态流量泄放设施-在建",
    dataType: 2,
    name: "放流管-在建",
    nameEn: "EQ_4_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssFangliudong",
    orderIndex: 16,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "42b6bdfb27e04a2689ece4309a8a21e0,2CEFF8BA05A9D956B6B4EF9C44E870E1,",
    hasChildren: 0,
    parentId: "42b6bdfb27e04a2689ece4309a8a21e0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "2D098C3BB49CEF469B065B535DAC02B2",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-01-31 09:31:21",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施-在建",
    parentName: "生态流量泄放设施-在建",
    parentCode: "OTHERST_BUILT",
    layerCode: "eq_built_point",
    layerCodeName: "生态流量泄放设施-在建",
    dataType: 2,
    name: "放流洞-在建",
    nameEn: "EQ_3_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssJihefadian",
    orderIndex: 15,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "42b6bdfb27e04a2689ece4309a8a21e0,2D098C3BB49CEF469B065B535DAC02B2,",
    hasChildren: 0,
    parentId: "42b6bdfb27e04a2689ece4309a8a21e0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "ADDC294D3C0C40B4B10B3CD63586DC78",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-01-31 09:30:53",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施-在建",
    parentName: "生态流量泄放设施-在建",
    parentCode: "OTHERST_BUILT",
    layerCode: "eq_built_point",
    layerCodeName: "生态流量泄放设施-在建",
    dataType: 2,
    name: "放流闸-在建",
    nameEn: "EQ_2_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssXiehongzha",
    orderIndex: 14,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "42b6bdfb27e04a2689ece4309a8a21e0,ADDC294D3C0C40B4B10B3CD63586DC78,",
    hasChildren: 0,
    parentId: "42b6bdfb27e04a2689ece4309a8a21e0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "EC8D47F0668FC804AA68CAAB349A0C0B",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-01-31 17:06:10",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "生态流量泄放设施-在建",
    parentName: "生态流量泄放设施-在建",
    parentCode: "OTHERST_BUILT",
    layerCode: "eq_built_point",
    layerCodeName: "生态流量泄放设施-在建",
    dataType: 2,
    name: "生态机组-在建",
    nameEn: "EQ_6_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-stllxfssShengtaijizu",
    orderIndex: 13,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "42b6bdfb27e04a2689ece4309a8a21e0,EC8D47F0668FC804AA68CAAB349A0C0B,",
    hasChildren: 0,
    parentId: "42b6bdfb27e04a2689ece4309a8a21e0",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "13F0A48F380F2DA55ED2868530FAFADC",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "过鱼设施-在建",
    parentName: "过鱼设施-在建",
    parentCode: "FPST_BUILT",
    layerCode: "fp_built_point",
    layerCodeName: "过鱼设施-在建",
    dataType: 2,
    name: "其他过鱼设施-在建",
    nameEn: "gy_5_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-gyssQita",
    orderIndex: 15,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "e53e2a300031446ca168244fb30cc818,13F0A48F380F2DA55ED2868530FAFADC,",
    hasChildren: 0,
    parentId: "e53e2a300031446ca168244fb30cc818",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "3022999EB8536731B94B75FEEF1DDEC7",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "过鱼设施-在建",
    parentName: "过鱼设施-在建",
    parentCode: "FPST_BUILT",
    layerCode: "fp_built_point",
    layerCodeName: "过鱼设施-在建",
    dataType: 2,
    name: "升鱼机-在建",
    nameEn: "gy_4_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-gyssShengyuji",
    orderIndex: 14,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "e53e2a300031446ca168244fb30cc818,3022999EB8536731B94B75FEEF1DDEC7,",
    hasChildren: 0,
    parentId: "e53e2a300031446ca168244fb30cc818",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "3EEA1525F02D2482983A5D8F9C8D44FE",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: "2024-02-23 17:20:02",
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "过鱼设施-在建",
    parentName: "过鱼设施-在建",
    parentCode: "FPST_BUILT",
    layerCode: "fp_built_point",
    layerCodeName: "过鱼设施-在建",
    dataType: 2,
    name: "集运鱼系统-在建",
    nameEn: "gy_3_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-gyssJiyunyuxitong",
    orderIndex: 13,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "e53e2a300031446ca168244fb30cc818,3EEA1525F02D2482983A5D8F9C8D44FE,",
    hasChildren: 0,
    parentId: "e53e2a300031446ca168244fb30cc818",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
  {
    _tls: {},
    id: "033B91284D67586C2C56D25674FA8A2E",
    recordUser: "wanglh",
    recordTime: "2024-01-30 15:30:00",
    modifyTime: null,
    displayRecordUser: "wanglh",
    childrenList: [],
    multiSelect: null,
    checked: null,
    canBeChecked: null,
    psort: null,
    departmentId: null,
    displayDepartment: null,
    groupName: "过鱼设施-在建",
    parentName: "过鱼设施-在建",
    parentCode: "FPST_BUILT",
    layerCode: "fp_built_point",
    layerCodeName: "过鱼设施-在建",
    dataType: 2,
    name: "仿自然通道-在建",
    nameEn: "gy_2_built",
    code: "pointLayer",
    codeName: "锚点",
    icon: "map-gyssFangzirantongdao",
    orderIndex: 12,
    enable: 1,
    systemId: null,
    treeLevel: 2,
    fullPath: "e53e2a300031446ca168244fb30cc818,033B91284D67586C2C56D25674FA8A2E,",
    hasChildren: 0,
    parentId: "e53e2a300031446ca168244fb30cc818",
    minZoom: null,
    maxZoom: null,
    minHeightThd: null,
    maxHeightThd: null,
    internal: 1,
    ifShow: 1,
    isFilter: null,
    expression: null,
    ext: null,
    description: null,
    color: null,
    shape: null,
    minVal: null,
    maxVal: null,
  },
]);

// 模拟数据获取函数
const fetchLegendData = (params: any) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        data: {
          records: [
            {
              id: 1,
              dataName: "长江流域水系",
              dataType: "矢量",
              relatedLegend: "水系分布",
              dataSource: "国家地理信息中心",
              updateTime: "2023-05-15 10:30:00",
            },
            {
              id: 2,
              dataName: "三峡库区影像",
              dataType: "栅格",
              relatedLegend: "遥感影像",
              dataSource: "卫星遥感中心",
              updateTime: "2023-06-20 14:45:00",
            },
            {
              id: 3,
              dataName: "鱼类分布数据",
              dataType: "属性",
              relatedLegend: "鱼类栖息地",
              dataSource: "生态监测站",
              updateTime: "2023-07-10 09:15:00",
            },
          ],
          total: 3,
        },
      });
    }, 500);
  });
};

const handleAdd = () => {
  currentRecord.value = null;
  editModalVisible.value = true;
};

// 编辑处理
const handleEdit = (record: any) => {
  currentRecord.value = { ...record };
  editModalVisible.value = true;
};

// 删除处理
const handleDelete = (record: any) => {
  message.warning(`删除数据: ${record.dataName}`);
};

// 搜索完成处理
const onSearchFinish = (values: any) => {
  console.log(values);
};

// 重置
const handleReset = (params: any) => {};
// 是否启用切换处理
const handleEnableChange = (record: any, checked: boolean) => {
  console.log("启用状态变更:", record.title, checked);
  // TODO: 调用 API 更新启用状态
  message.success(`${checked ? "启用" : "禁用"}图层: ${record.title}`);
};
// 是否内部切换处理
const handleInternalChange = (record: any, checked: boolean) => {
  console.log("内部状态变更:", record.title, checked);
  // TODO: 调用 API 更新内部状态
  message.success(`${checked ? "启用" : "禁用"}图层: ${record.title}`);
};
// 是否显示处理
const handleIfShowChange = (record: any, checked: boolean) => {
  console.log("显示状态变更:", record.name, checked);
  // TODO: 调用 API 显示状态
  message.success(`${checked ? "显示" : "隐藏"}图层: ${record.name}`);
};
// 表单取消
const editModalCancel = () => {
  editModalVisible.value = false;
};

// 表单提交
const handleEditSubmit = (values: any) => {
  console.log(values);
};
</script>

<style scoped lang="scss"></style>
