From e1023bb3313282b00d6dcdefd5d7e30d7aaa1bfc Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 30 十一月 2023 11:13:29 +0800
Subject: [PATCH] update 优化 代码中存在的警告

---
 src/views/tool/gen/index.vue |  134 ++++++++++++++++++++++----------------------
 1 files changed, 66 insertions(+), 68 deletions(-)

diff --git a/src/views/tool/gen/index.vue b/src/views/tool/gen/index.vue
index c0a099c..cb684f8 100644
--- a/src/views/tool/gen/index.vue
+++ b/src/views/tool/gen/index.vue
@@ -97,8 +97,8 @@
       <el-tabs v-model="preview.activeName">
         <el-tab-pane
           v-for="(value, key) in preview.data"
-          :label="(key as any).substring((key as any).lastIndexOf('/') + 1, (key as any).indexOf('.vm'))"
-          :name="(key as any).substring((key as any).lastIndexOf('/') + 1, (key as any).indexOf('.vm'))"
+          :label="key.substring(key.lastIndexOf('/') + 1, key.indexOf('.vm'))"
+          :name="key.substring(key.lastIndexOf('/') + 1, key.indexOf('.vm'))"
           :key="value"
         >
           <el-link :underline="false" icon="DocumentCopy" v-copyText="value" v-copyText:callback="copyTextSuccess" style="float:right">
@@ -116,9 +116,7 @@
 import { listTable, previewTable, delTable, genCode, synchDb, getDataNames } from '@/api/tool/gen';
 import { TableQuery, TableVO } from '@/api/tool/gen/types';
 import router from '@/router';
-import importTable from './importTable.vue';
-import { ComponentInternalInstance } from 'vue';
-import { ElForm, DateModelType } from 'element-plus';
+import ImportTable from './importTable.vue';
 
 const route = useRoute();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -134,35 +132,35 @@
 const uniqueId = ref("");
 const dataNameList = ref<Array<string>>([]);
 
-const queryFormRef = ref(ElForm);
-const importRef = ref(importTable);
+const queryFormRef = ref<ElFormInstance>();
+const importRef = ref<InstanceType<typeof ImportTable>>();
 
 const queryParams = ref<TableQuery>({
-    pageNum: 1,
-    pageSize: 10,
-    tableName: '',
-    tableComment: '',
-    dataName: ""
+  pageNum: 1,
+  pageSize: 10,
+  tableName: '',
+  tableComment: '',
+  dataName: ""
 })
 
-const preview = ref <any>({
-    data: {},
-    activeName: 'domain.java'
+const preview = ref<any>({
+  data: {},
+  activeName: 'domain.java'
 })
 const dialog = reactive<DialogOption>({
-    visible: false,
-    title: '浠g爜棰勮'
+  visible: false,
+  title: '浠g爜棰勮'
 });
 
 onActivated(() => {
-    const time = route.query.t;
-    if (time != null && time != uniqueId.value) {
-        uniqueId.value = time as string;
-        queryParams.value.pageNum = Number(route.query.pageNum);
-        dateRange.value = ['', ''];
-        queryFormRef.value.resetFields();
-        getList();
-    }
+  const time = route.query.t;
+  if (time != null && time != uniqueId.value) {
+    uniqueId.value = time as string;
+    queryParams.value.pageNum = Number(route.query.pageNum);
+    dateRange.value = ['', ''];
+    queryFormRef.value?.resetFields();
+    getList();
+  }
 })
 
 /** 鏌ヨ澶氭暟鎹簮鍚嶇О */
@@ -173,81 +171,81 @@
 
 /** 鏌ヨ琛ㄩ泦鍚� */
 const getList = async () => {
-    loading.value = true;
-    const res = await listTable(proxy?.addDateRange(queryParams.value, dateRange.value));
-    tableList.value = res.rows;
-    total.value = res.total;
-    loading.value = false;
+  loading.value = true;
+  const res = await listTable(proxy?.addDateRange(queryParams.value, dateRange.value));
+  tableList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
 }
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 const handleQuery = () => {
-    queryParams.value.pageNum = 1;
-    getList();
+  queryParams.value.pageNum = 1;
+  getList();
 }
 /** 鐢熸垚浠g爜鎿嶄綔 */
 const handleGenTable = async (row?: TableVO) => {
-    const tbIds = row?.tableId || ids.value;
-    if (tbIds == "") {
-        proxy?.$modal.msgError('璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁');
-        return;
-    }
-    if (row?.genType === "1") {
-        await genCode(row.tableId);
-        proxy?.$modal.msgSuccess('鎴愬姛鐢熸垚鍒拌嚜瀹氫箟璺緞锛�' + row.genPath);
-    } else {
-        proxy?.$download.zip('/tool/gen/batchGenCode?tableIdStr=' + tbIds, 'ruoyi.zip');
-    }
+  const tbIds = row?.tableId || ids.value;
+  if (tbIds == "") {
+    proxy?.$modal.msgError('璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁');
+    return;
+  }
+  if (row?.genType === "1") {
+    await genCode(row.tableId);
+    proxy?.$modal.msgSuccess('鎴愬姛鐢熸垚鍒拌嚜瀹氫箟璺緞锛�' + row.genPath);
+  } else {
+    proxy?.$download.zip('/tool/gen/batchGenCode?tableIdStr=' + tbIds, 'ruoyi.zip');
+  }
 }
 /** 鍚屾鏁版嵁搴撴搷浣� */
 const handleSynchDb = async (row: TableVO) => {
-    const tableId = row.tableId;
-    await proxy?.$modal.confirm('纭瑕佸己鍒跺悓姝�"' + row.tableName + '"琛ㄧ粨鏋勫悧锛�');
-    await synchDb(tableId);
-    proxy?.$modal.msgSuccess('鍚屾鎴愬姛');
+  const tableId = row.tableId;
+  await proxy?.$modal.confirm('纭瑕佸己鍒跺悓姝�"' + row.tableName + '"琛ㄧ粨鏋勫悧锛�');
+  await synchDb(tableId);
+  proxy?.$modal.msgSuccess('鍚屾鎴愬姛');
 }
 /** 鎵撳紑瀵煎叆琛ㄥ脊绐� */
 const openImportTable = () => {
-    importRef.value.show(queryParams.value.dataName);
+  importRef.value?.show(queryParams.value.dataName);
 }
 /** 閲嶇疆鎸夐挳鎿嶄綔 */
 const resetQuery = () => {
-    dateRange.value = ['', ''];
-    queryFormRef.value.resetFields();
-    handleQuery();
+  dateRange.value = ['', ''];
+  queryFormRef.value?.resetFields();
+  handleQuery();
 }
 /** 棰勮鎸夐挳 */
 const handlePreview = async (row: TableVO) => {
-    const res = await previewTable(row.tableId);
-    preview.value.data = res.data;
-    dialog.visible = true;
-    preview.value.activeName = 'domain.java';
+  const res = await previewTable(row.tableId);
+  preview.value.data = res.data;
+  dialog.visible = true;
+  preview.value.activeName = 'domain.java';
 }
 /** 澶嶅埗浠g爜鎴愬姛 */
 const copyTextSuccess = () => {
-    proxy?.$modal.msgSuccess('澶嶅埗鎴愬姛');
+  proxy?.$modal.msgSuccess('澶嶅埗鎴愬姛');
 }
 // 澶氶�夋閫変腑鏁版嵁
 const handleSelectionChange = (selection: TableVO[]) => {
-    ids.value = selection.map(item => item.tableId);
-    single.value = selection.length != 1;
-    multiple.value = !selection.length;
+  ids.value = selection.map(item => item.tableId);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
 }
 /** 淇敼鎸夐挳鎿嶄綔 */
 const handleEditTable = (row?: TableVO) => {
-    const tableId = row?.tableId || ids.value[0];
-    router.push({ path: '/tool/gen-edit/index/' + tableId, query: { pageNum: queryParams.value.pageNum } });
+  const tableId = row?.tableId || ids.value[0];
+  router.push({ path: '/tool/gen-edit/index/' + tableId, query: { pageNum: queryParams.value.pageNum } });
 }
 /** 鍒犻櫎鎸夐挳鎿嶄綔 */
 const handleDelete = async (row?: TableVO) => {
-    const tableIds = row?.tableId || ids.value;
-    await proxy?.$modal.confirm('鏄惁纭鍒犻櫎琛ㄧ紪鍙蜂负"' + tableIds + '"鐨勬暟鎹」锛�');
-    await delTable(tableIds);
-    getList();
-    proxy?.$modal.msgSuccess('鍒犻櫎鎴愬姛');
+  const tableIds = row?.tableId || ids.value;
+  await proxy?.$modal.confirm('鏄惁纭鍒犻櫎琛ㄧ紪鍙蜂负"' + tableIds + '"鐨勬暟鎹」锛�');
+  await delTable(tableIds);
+  await getList();
+  proxy?.$modal.msgSuccess('鍒犻櫎鎴愬姛');
 }
 
 onMounted(() => {
-    getList();
-    getDataNameList();
+  getList();
+  getDataNameList();
 })
 </script>

--
Gitblit v1.9.3