<template>
  <div class="">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="维保" prop="maintenanceId">
        <el-tree-select v-model="queryParams.maintenanceId" :data="maintenanceOptions" :props="{ value: 'maintenanceId', label: 'maintenanceName', children: 'children' }" value-key="maintenanceId" placeholder="请选择维保" check-strictly filterable clearable @change="handleQuery" @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="维保项目" prop="maintenanceProjectName">
        <el-input maxlength="100" v-model="queryParams.maintenanceProjectName" placeholder="请输入维保项目" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="维保项目标准" prop="maintenanceProjectStandard">
        <el-input maxlength="100" v-model="queryParams.maintenanceProjectStandard" placeholder="请输入维保项目标准" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="维保项目责任人" prop="maintenanceProjectPersonLiable">
        <el-select v-model="queryParams.maintenanceProjectPersonLiable" filterable placeholder="请选择维保项目责任人" @change="handleQuery" clearable>
          <el-option v-for="item in roleList" :key="item.roleId" :label="item.roleName" :value="item.roleId" />
        </el-select>
      </el-form-item>
      <el-form-item label="维保项目周期" prop="maintenanceProjectCycle">
        <el-select v-model="queryParams.maintenanceProjectCycle" filterable placeholder="请选择维保项目周期" @change="handleQuery" clearable>
          <el-option v-for="item in maintenance_project_cycle" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8" style="min-height:32px">
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:add']">
        <el-button type="primary" plain icon="Plus" @click="handleAddMaintenanceProjectForm">新增
        </el-button>
      </el-col>
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:edit']">
        <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdateMaintenanceProject">
          修改
        </el-button>
      </el-col>
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:remove']">
        <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDeleteMaintenanceProject">删除
        </el-button>
      </el-col>
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:import']">
        <!-- <el-button type="info" plain icon="Upload" @click="handleImport">导入</el-button> -->
        <ImportData url="maintenanceProject/maintenanceProject" title="维保清单" @success="getList" />
      </el-col>
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:export']">
        <el-button type="warning" plain icon="Download" @click="handleExportMaintenanceProjectForm">导出
        </el-button>
      </el-col>
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:apply', 'maintenanceApply:maintenanceApply:add']">
        <el-button type="warning" plain icon="ShoppingBag" :disabled="multiple" @click="handleAddMaintenanceRecordDetails">申请
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain :icon="showSidebar ? 'DArrowLeft' : 'DArrowRight'" @click="handleToggleShowSidebar">
          {{ showSidebar ? "隐藏" : "显示" }}侧边栏
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="MostlyCloudy" @click="handleSwitchSidebarSpan" v-show="showSidebar">
          侧边栏比例 {{ sidebarSpan }}:{{ 24 - sidebarSpan }}
        </el-button>
      </el-col>
      <el-col :span="1.5" v-hasPermi="['maintenanceProject:maintenanceProject:apply', 'maintenanceApply:maintenanceApply:add']">
        <el-badge :value="maintenanceApplyDetailsTotal" :hidden="maintenanceApplyDetailsTotal == 0">
          <el-button type="warning" plain icon="ShoppingBag" @click="showApplyDrawer">维保申请列表
          </el-button>
        </el-badge>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loadingMaintenanceProject" :data="maintenanceProjectList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="40" align="center" v-hasPermi="['maintenanceProject:maintenanceProject:edit', 'maintenanceProject:maintenanceProject:remove', 'maintenanceProject:maintenanceProject:apply', 'maintenanceApply:maintenanceApply:add']" />
      <el-table-column type="expand" width="30">
        <template #default="scope">
          <div class="padding">
            <el-descriptions :column="1">
              <el-descriptions-item label="维保">
                <TextTag :options="maintenanceList" column="maintenanceId" label="maintenanceName" :value="scope.row.maintenanceId" style="display:inline-block" />
              </el-descriptions-item>
              <el-descriptions-item label="维保项目">
                {{ scope.row.maintenanceProjectName }}
              </el-descriptions-item>
              <el-descriptions-item label="维保项目标准">
                {{ scope.row.maintenanceProjectStandard }}
              </el-descriptions-item>
              <el-descriptions-item label="维保项目责任人">
                <TextTag :options="roleList" column="roleId" label="roleName" :value="scope.row.maintenanceProjectPersonLiable" style="display:inline-block" />
              </el-descriptions-item>
              <el-descriptions-item label="维保项目周期">
                <dict-tag :options="maintenance_project_cycle" :value="scope.row.maintenanceProjectCycle" style="display:inline-block" />
              </el-descriptions-item>
            </el-descriptions>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="序号" align="center" type="index" width="50" />
      <el-table-column label="维保" align="center" prop="maintenanceId">
        <template #default="scope">
          <TextTag :options="maintenanceList" column="maintenanceId" label="maintenanceName" :value="scope.row.maintenanceId" />
        </template>
      </el-table-column>
      <el-table-column label="维保项目" align="center" prop="maintenanceProjectName" :show-overflow-tooltip="true" />
      <el-table-column label="维保项目标准" align="center" prop="maintenanceProjectStandard" :show-overflow-tooltip="true" />
      <el-table-column label="维保项目责任人" align="center" prop="maintenanceProjectPersonLiable">
        <template #default="scope">
          <TextTag :options="roleList" column="roleId" label="roleName" :value="scope.row.maintenanceProjectPersonLiable" text />
        </template>
      </el-table-column>
      <el-table-column label="维保项目周期" align="center" prop="maintenanceProjectCycle">
        <template #default="scope">
          <dict-tag :options="maintenance_project_cycle" :value="scope.row.maintenanceProjectCycle" />
        </template>
      </el-table-column>
      <el-table-column label="自定义维保项目周期" align="center" prop="maintenanceProjectCycleCustom">
        <template #default="scope">
          <span v-if="scope.row.maintenanceProjectCycle != 50"></span>
          <span v-else>{{ scope.row.maintenanceProjectCycleCustom }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160" fixed="right" v-hasPermi="['maintenanceProject:maintenanceProject:edit', 'maintenanceProject:maintenanceProject:remove', 'maintenanceProject:maintenanceProject:apply', 'maintenanceApply:maintenanceApply:add']">
        <template #default="scope">
          <!-- <el-button link type="primary" icon="View" @click="handleView(scope.row)"
                        v-hasPermi="['maintenanceProject:maintenanceProject:query']">详细
                    </el-button> -->
          <el-button link type="success" icon="Edit" @click="handleUpdateMaintenanceProject(scope.row)" v-hasPermi="['maintenanceProject:maintenanceProject:edit']">修改
          </el-button>
          <el-button link type="danger" icon="Delete" @click="handleDeleteMaintenanceProject(scope.row)" v-hasPermi="['maintenanceProject:maintenanceProject:remove']">删除
          </el-button>
          <el-button link type="warning" icon="ShoppingBag" @click="addMaintenanceApplyDetails(scope.row)" v-hasPermi="['maintenanceProject:maintenanceProject:apply', 'maintenanceApply:maintenanceApply:add']">申请
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改维保管理-维保项目对话框 -->
    <el-dialog :title="title" v-model="openMaintenanceProjectDialog" width="800px" append-to-body>
      <el-form ref="maintenanceProjectRef" :model="maintenanceProjectForm" :rules="rules" label-width="150px">
        <el-form-item label="维保" prop="maintenanceId">
          <el-tree-select filterable v-model="maintenanceProjectForm.maintenanceId" :data="maintenanceOptions" :props="{ value: 'maintenanceId', label: 'maintenanceName', children: 'children' }" value-key="maintenanceId" placeholder="请选择维保" check-strictly style="width:100%" @change="handleMaintenanceProjectFormMaintenanceIdChange" />
        </el-form-item>
        <el-form-item label="维保项目" prop="maintenanceProjectName">
          <!-- <el-input maxlength="100" v-model="maintenanceProjectForm.maintenanceProjectName"
                        placeholder="请输入维保项目" /> -->
          <el-autocomplete maxlength="100" v-model="maintenanceProjectForm.maintenanceProjectName" :fetch-suggestions="querySearchMaintenanceProjectName" clearable placeholder="请输入维保项目" style="width:100%" @select="handleAutocompleteMaintenanceProjectNameSelect" />
        </el-form-item>
        <el-form-item label="维保项目标准" prop="maintenanceProjectStandard">
          <!-- <el-input maxlength="300" v-model="maintenanceProjectForm.maintenanceProjectStandard"
                        placeholder="请输入维保项目标准" type="textarea" :rows="4" /> -->
          <el-autocomplete maxlength="300" type="textarea" v-model="maintenanceProjectForm.maintenanceProjectStandard" :fetch-suggestions="querySearchMaintenanceProjectStandard" clearable placeholder="请输入维保项目标准" style="width:100%" />
        </el-form-item>
        <el-form-item label="维保项目责任人" prop="maintenanceProjectPersonLiable">
          <el-select v-model="maintenanceProjectForm.maintenanceProjectPersonLiable" filterable placeholder="请选择维保项目责任人" style="width:100%">
            <el-option v-for="item in roleList" :key="item.roleId" :label="item.roleName" :value="item.roleId" />
          </el-select>
        </el-form-item>
        <el-form-item label="维保项目周期" prop="maintenanceProjectCycle">
          <el-select v-model="maintenanceProjectForm.maintenanceProjectCycle" filterable placeholder="请选择维保项目周期" style="width:100%">
            <el-option v-for="item in maintenance_project_cycle" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="自定义维保项目周期" prop="maintenanceProjectCycleCustom" v-if="maintenanceProjectForm.maintenanceProjectCycle == 50">
          <!-- <el-input v-model="maintenanceProjectForm.maintenanceProjectCycleCustom" placeholder="请输入自定义维保项目周期" type="number" /> -->
          <el-input-number v-model="maintenanceProjectForm.maintenanceProjectCycleCustom" :min="1" @change="handleChange" />
        </el-form-item>
      </el-form>
      <el-divider>维保</el-divider>
      <el-card shadow="hover">
        <MaintenanceDescription :maintenance="maintenance" class="margin-top" />
      </el-card>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitMaintenanceProjectForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <MaintenanceApplyDetailsDrawer ref="maintenanceApplyDetailsDrawerRef" @submit="showMaintenanceApplyDetailsDrawerSubmit" />

    <MaintenanceApplySubmitDrawer ref="maintenanceApplySubmitDrawerRef" @close="handleCloseApplyDrawer" />

  </div>
</template>

<script setup name="maintenanceManage">
import {
  listMaintenanceProject,
  getMaintenanceProject,
  delMaintenanceProject,
  addMaintenanceProject,
  updateMaintenanceProject,
  downloadMaintenanceProject,
} from "@/api/maintenanceProject/maintenanceProject";
import { listRole } from "@/api/system/role";
import { addMaintenanceApplyDetails } from "@/utils/maintenanceApplyDetails";
import { overrideProperties } from "@/utils/ruoyi";

import MaintenanceApplyDetailsDrawer from "@/components/MaintenanceApplyDetails/drawer";
import MaintenanceApplySubmitDrawer from "@/components/MaintenanceApply/submit/drawer";
import MaintenanceDescription from "@/components/Maintenance/description";
import ImportData from "@/components/ImportData";
import { watch } from "vue";

const store = useStore();
const route = useRoute();

const props = defineProps({
  modelValue: [String, Number],
  maintenanceList: {
    type: Array,
    default: [],
  },
  maintenanceOptions: {
    type: Array,
    default: [],
  },
  showSidebar: {
    type: [Boolean],
    default: false,
  },
  sidebarSpan: {
    type: [Number],
    default: false,
  },
});

const { modelValue, maintenanceList, showSidebar, sidebarSpan } = toRefs(props);

const emit = defineEmits();

const { proxy } = getCurrentInstance();
const { maintenance_project_cycle } = proxy.useDict(
  "maintenance_project_cycle"
);

const maintenanceProjectList = ref([]);
const roleList = ref([]);

const open = ref(false);
const openMaintenanceDialog = ref(false);
const openMaintenanceProjectDialog = ref(false);
// const showSidebar = ref(true);
// const sidebarSpan = ref(6);

const loadingMaintenanceProject = ref(true);

const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const maintenance = ref({});

const data = reactive({
  maintenanceForm: {},
  maintenanceProjectForm: {
    maintenanceProjectCycleCustom: 1,
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  rules: {
    maintenanceId: [
      {
        required: true,
        message: "维保不能为空",
        trigger: "blur",
      },
    ],
    maintenanceProjectName: [
      {
        required: true,
        message: "维保项目不能为空",
        trigger: "blur",
      },
    ],
    maintenanceProjectStandard: [
      {
        required: true,
        message: "维保项目标准不能为空",
        trigger: "blur",
      },
    ],
    maintenanceProjectPersonLiable: [
      {
        required: true,
        message: "维保项目责任人不能为空",
        trigger: "blur",
      },
    ],
    maintenanceProjectCycle: [
      {
        required: true,
        message: "维保项目周期能为空",
        trigger: "blur",
      },
    ],
    maintenanceProjectCycleCustom: [
      {
        required: true,
        message: "自定义维保项目周期能为空",
        trigger: "blur",
      },
    ],
  },
});

const { queryParams, form, rules, maintenanceForm, maintenanceProjectForm } =
  toRefs(data);

watch(modelValue, (newValue) => {
  queryParams.value.maintenanceId = newValue;
  handleQuery();
});

// watch(
//   () => maintenanceProjectForm.value.maintenanceProjectCycleCustom,
//   (newValue) => {
//     if (newValue < 1) {
//       maintenanceProjectForm.value.maintenanceProjectCycleCustom = 1;
//     }
//   }
// );

const maintenanceApplyDetailsTotal = computed(() => {
  let total = 0;
  total += Object.values(store.state.data.maintenanceApplyDetails).length;
  total += store.state.data.maintenanceApplyDetailsCustomList.length;
  return total;
});

// const maintenanceProjectNameList = computed(() => Array.from(new Set(maintenanceProjectList.value.map(item => item.maintenanceProjectName))).map(item => { return { value: item } }))
// const maintenanceProjectStandardList = computed(() => Array.from(new Set(maintenanceProjectList.value.map(item => item.maintenanceProjectStandard))).map(item => { return { value: item } }))

/** 查询维保管理-维保目录列表 */
function getList() {
  loadingMaintenanceProject.value = true;
  listMaintenanceProject(queryParams.value).then((response) => {
    maintenanceProjectList.value = response.rows;
    total.value = response.total;
    loadingMaintenanceProject.value = false;
  });
}

/** 节点单击事件 */
function handleMaintenanceClick(data) {
  if (queryParams.value.maintenanceId == data.maintenanceId) {
    queryParams.value.maintenanceId = null;
  } else {
    queryParams.value.maintenanceId = data.maintenanceId;
  }
  handleQuery();
}
/** 搜索按钮操作 */
function handleQuery() {
  emit("update:modelValue", queryParams.value.maintenanceId);
  queryParams.value.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 重置操作表单 */
function reset() {
  maintenanceProjectForm.value = {
    maintenanceProjectCycleCustom: 1,
  };
  proxy.resetForm("maintenanceProjectRef");
}
/** 取消按钮 */
function cancel() {
  openMaintenanceProjectDialog.value = false;
  reset();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  //// console.log(selection);
  ids.value = selection.map((item) => item.maintenanceProjectId);
  //// console.log(maintenanceProjectIds.value);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAddMaintenanceProjectForm() {
  reset();
  maintenanceProjectForm.value.maintenanceId = queryParams.value.maintenanceId;
  openMaintenanceProjectDialog.value = true;
  title.value = "添加维保管理-维保项目";
}
/** 删除按钮操作 */
function handleDeleteMaintenanceProject(row) {
  // console.log(row.maintenanceProjectId)
  const maintenanceProjectIds = row.maintenanceProjectId || ids.value;
  const maintenanceProjectListFilter = Array.isArray(maintenanceProjectIds)
    ? maintenanceProjectList.value.filter((item) =>
        maintenanceProjectIds.includes(item.maintenanceProjectId)
      )
    : maintenanceProjectList.value.filter((item) =>
        [row.maintenanceProjectId].includes(item.maintenanceProjectId)
      );
  const maintenanceProjectDeleteList = maintenanceProjectListFilter.map(
    (item) => item.maintenanceProjectName
  );
  proxy.$modal
    .confirm(
      '是否确认删除维保项目为"' + maintenanceProjectDeleteList + '"的数据项？'
    )
    .then(function () {
      return delMaintenanceProject(maintenanceProjectIds);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
/** 修改按钮操作 */
function handleUpdateMaintenanceProject(row) {
  // reset();
  // getTreeselect();
  const maintenanceProjectId = row.maintenanceProjectId || ids.value;
  getMaintenanceProject(maintenanceProjectId).then((response) => {
    maintenanceProjectForm.value = response.data;
    handleMaintenanceProjectFormMaintenanceIdChange(
      response.data.maintenanceId
    );
    openMaintenanceProjectDialog.value = true;
    title.value = "修改维保管理-维保项目";
  });
}
/** 提交按钮 */
function submitMaintenanceProjectForm() {
  proxy.$refs["maintenanceProjectRef"].validate((valid) => {
    if (valid) {
      if (maintenanceProjectForm.value.maintenanceProjectId != undefined) {
        updateMaintenanceProject(maintenanceProjectForm.value).then(
          (response) => {
            proxy.$modal.msgSuccess("修改成功");
            openMaintenanceProjectDialog.value = false;
            getList();
          }
        );
      } else {
        addMaintenanceProject(maintenanceProjectForm.value).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          openMaintenanceProjectDialog.value = false;
          getList();
        });
      }
    }
  });
}
/** 导出按钮操作 */
function handleExportMaintenanceProjectForm() {
  downloadMaintenanceProject(queryParams.value);
}

function handleAddMaintenanceRecordDetails() {
  const maintenanceProjectListFilter =
    maintenanceProjectList.value.filter((item) =>
      ids.value.includes(item.maintenanceProjectId)
    ) || [];
  maintenanceProjectListFilter.map((item, index) => {
    addMaintenanceApplyDetails(item, index == 0);
  });
  //// console.log(maintenanceProjectListFilter)
  // addMaintenanceApplyDetails(...maintenanceProjectListFilter);
}

function showMaintenanceApplyDetailsDrawerSubmit() {
  function isEmpty(value) {
    // console.log(value)
    return value == null || (value + "").trim() == "";
  }
  for (let i in store.state.data.maintenanceApplyDetailsCustomList) {
    let keys = [
      "maintenanceProjectName",
      "maintenanceProjectStandard",
      "maintenanceProjectPersonLiable",
    ];
    // console.log(store.state.data.maintenanceApplyDetailsCustomList[i]['maintenanceId'])
    for (let j in keys) {
      if (
        isEmpty(store.state.data.maintenanceApplyDetailsCustomList[i][keys[j]])
      ) {
        proxy.$modal.msgWarning("请补全自定义维保申请列表");
        return;
      }
    }
  }
  proxy.$refs["maintenanceApplySubmitDrawerRef"].show();
}

function showApplyDrawer() {
  proxy.$refs["maintenanceApplyDetailsDrawerRef"].show();
}
function handleCloseApplyDrawer() {
  proxy.$refs["maintenanceApplyDetailsDrawerRef"].handleClose();
}

async function searchAutocompleteList(key, value) {
  let params = {
    pageNum: 1,
    pageSize: queryParams.value.pageSize,
  };
  params[key] = value;
  let result;
  await listMaintenanceProject(params).then((response) => {
    result = response.rows;
  });
  return Promise.resolve(result);
}

const querySearchMaintenanceProjectName = async (queryString, cb) => {
  const responses = await searchAutocompleteList(
    `maintenanceProjectName`,
    queryString
  );
  const results = Array.from(
    new Set(responses.map((item) => item[`maintenanceProjectName`]))
  ).map((item) => {
    return { value: item };
  });
  cb(results);
};

const querySearchMaintenanceProjectStandard = async (queryString, cb) => {
  const responses = await searchAutocompleteList(
    `maintenanceProjectStandard`,
    queryString
  );
  const results = Array.from(
    new Set(responses.map((item) => item[`maintenanceProjectStandard`]))
  ).map((item) => {
    return { value: item };
  });
  cb(results);
};

const handleAutocompleteMaintenanceProjectNameSelect = (value) => {
  listMaintenanceProject({
    pageNum: 1,
    pageSize: queryParams.value.pageSize,
    maintenanceProjectName: value.value,
  }).then((response) => {
    if (response.rows.length > 0) {
      overrideProperties(maintenanceProjectForm.value, response.rows[0]);
      maintenanceProjectForm.value.maintenanceProjectId = null;
    }
  });
};

function handleToggleShowSidebar() {
  // showSidebar.value = !showSidebar.value;
  // emit("update:showSidebar", showSidebar.value);
  emit("update:showSidebar", !showSidebar.value);
}

function handleSwitchSidebarSpan() {
  let newSidebarSpan = sidebarSpan.value < 12 ? sidebarSpan.value + 3 : 6;
  emit("update:sidebarSpan", newSidebarSpan);
}

function initialData() {
  listRole(
    proxy.addDateRange(
      {
        pageNum: 1,
        pageSize: 9999,
      },
      undefined
    )
  ).then((response) => {
    roleList.value = response.rows;
  });
  getList();
  // console.log(route.query)
  if (route.query.showMaintenanceApplySubmitDrawer == "true") {
    showApplyDrawer();
  }
}

const handleMaintenanceProjectFormMaintenanceIdChange = (maintenanceId) => {
  let _maintenanceList = maintenanceList.value.filter(
    (item) => item.maintenanceId == maintenanceId
  );
  maintenance.value = _maintenanceList[0];
};

onActivated(() => {
  //// console.log("onActivated")
  initialData();
});
onMounted(() => {
  //// console.log("onMounted")
  initialData();
});

// initialData();
</script>


