From c25842a0e5cb8d1c4b9ee80e38dbfc4192b95adb Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail>
Date: 星期一, 17 四月 2023 20:50:00 +0800
Subject: [PATCH] remove console.log

---
 src/views/tool/gen/importTable.vue |  108 ++++++++++++++++++++++++------------------------------
 1 files changed, 48 insertions(+), 60 deletions(-)

diff --git a/src/views/tool/gen/importTable.vue b/src/views/tool/gen/importTable.vue
index 33b5633..5ff0145 100644
--- a/src/views/tool/gen/importTable.vue
+++ b/src/views/tool/gen/importTable.vue
@@ -1,22 +1,12 @@
 <template>
   <!-- 瀵煎叆琛� -->
   <el-dialog title="瀵煎叆琛�" v-model="visible" width="800px" top="5vh" append-to-body>
-    <el-form :model="queryParams" ref="queryRef" :inline="true">
+    <el-form :model="queryParams" ref="queryFormRef" :inline="true">
       <el-form-item label="琛ㄥ悕绉�" prop="tableName">
-        <el-input
-          v-model="queryParams.tableName"
-          placeholder="璇疯緭鍏ヨ〃鍚嶇О"
-          clearable
-          @keyup.enter="handleQuery"
-        />
+        <el-input v-model="queryParams.tableName" placeholder="璇疯緭鍏ヨ〃鍚嶇О" clearable @keyup.enter="handleQuery" />
       </el-form-item>
       <el-form-item label="琛ㄦ弿杩�" prop="tableComment">
-        <el-input
-          v-model="queryParams.tableComment"
-          placeholder="璇疯緭鍏ヨ〃鎻忚堪"
-          clearable
-          @keyup.enter="handleQuery"
-        />
+        <el-input v-model="queryParams.tableComment" placeholder="璇疯緭鍏ヨ〃鎻忚堪" clearable @keyup.enter="handleQuery" />
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button>
@@ -24,20 +14,14 @@
       </el-form-item>
     </el-form>
     <el-row>
-      <el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
+      <el-table @row-click="clickRow" ref="tableRef" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
         <el-table-column type="selection" width="55"></el-table-column>
         <el-table-column prop="tableName" label="琛ㄥ悕绉�" :show-overflow-tooltip="true"></el-table-column>
         <el-table-column prop="tableComment" label="琛ㄦ弿杩�" :show-overflow-tooltip="true"></el-table-column>
         <el-table-column prop="createTime" label="鍒涘缓鏃堕棿"></el-table-column>
         <el-table-column prop="updateTime" label="鏇存柊鏃堕棿"></el-table-column>
       </el-table>
-      <pagination
-        v-show="total>0"
-        :total="total"
-        v-model:page="queryParams.pageNum"
-        v-model:limit="queryParams.pageSize"
-        @pagination="getList"
-      />
+      <pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
     </el-row>
     <template #footer>
       <div class="dialog-footer">
@@ -48,71 +32,75 @@
   </el-dialog>
 </template>
 
-<script setup>
-import { listDbTable, importTable } from "@/api/tool/gen";
+<script setup lang="ts">
+import { listDbTable, importTable } from '@/api/tool/gen';
+import { DbTableQuery, DbTableVO } from '@/api/tool/gen/types';
+import { ComponentInternalInstance } from 'vue';
+import { ElTable, ElForm } from 'element-plus';
 
 const total = ref(0);
 const visible = ref(false);
-const tables = ref([]);
-const dbTableList = ref([]);
-const { proxy } = getCurrentInstance();
+const tables = ref<Array<string>>([]);
+const dbTableList = ref<Array<DbTableVO>>([]);
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
-const queryParams = reactive({
-  pageNum: 1,
-  pageSize: 10,
-  tableName: undefined,
-  tableComment: undefined
+const tableRef = ref(ElTable);
+const queryFormRef = ref(ElForm);
+
+const queryParams = reactive<DbTableQuery>({
+    pageNum: 1,
+    pageSize: 10,
+    tableName: '',
+    tableComment: ''
 });
 
 const emit = defineEmits(["ok"]);
 
 /** 鏌ヨ鍙傛暟鍒楄〃 */
-function show() {
-  getList();
-  visible.value = true;
+const show = () => {
+    getList();
+    visible.value = true;
 }
 /** 鍗曞嚮閫夋嫨琛� */
-function clickRow(row) {
-  proxy.$refs.table.toggleRowSelection(row);
+const clickRow = (row: DbTableVO) => {
+    tableRef.value.toggleRowSelection(row);
 }
 /** 澶氶�夋閫変腑鏁版嵁 */
-function handleSelectionChange(selection) {
-  tables.value = selection.map(item => item.tableName);
+const handleSelectionChange = (selection: DbTableVO[]) => {
+    tables.value = selection.map(item => item.tableName);
 }
 /** 鏌ヨ琛ㄦ暟鎹� */
-function getList() {
-  listDbTable(queryParams).then(res => {
+const getList = async () => {
+    const res = await listDbTable(queryParams);
     dbTableList.value = res.rows;
     total.value = res.total;
-  });
 }
 /** 鎼滅储鎸夐挳鎿嶄綔 */
-function handleQuery() {
-  queryParams.pageNum = 1;
-  getList();
+const handleQuery = () => {
+    queryParams.pageNum = 1;
+    getList();
 }
 /** 閲嶇疆鎸夐挳鎿嶄綔 */
-function resetQuery() {
-  proxy.resetForm("queryRef");
-  handleQuery();
+const resetQuery = () => {
+    queryFormRef.value.resetFields();
+    handleQuery();
 }
 /** 瀵煎叆鎸夐挳鎿嶄綔 */
-function handleImportTable() {
-  const tableNames = tables.value.join(",");
-  if (tableNames == "") {
-    proxy.$modal.msgError("璇烽�夋嫨瑕佸鍏ョ殑琛�");
-    return;
-  }
-  importTable({ tables: tableNames }).then(res => {
-    proxy.$modal.msgSuccess(res.msg);
-    if (res.code === 200) {
-      visible.value = false;
-      emit("ok");
+const handleImportTable = async () => {
+    const tableNames = tables.value.join(",");
+    if (tableNames == "") {
+        proxy?.$modal.msgError("璇烽�夋嫨瑕佸鍏ョ殑琛�");
+        return;
     }
-  });
+    const res = await importTable({ tables: tableNames });
+    proxy?.$modal.msgSuccess(res.msg);
+    if (res.code === 200) {
+        visible.value = false;
+        emit("ok");
+    }
 }
 
 defineExpose({
-  show,
+    show,
 });
 </script>

--
Gitblit v1.9.3