From 2af534eea471f4adb104906c7a814bcc66d4d68d Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期一, 13 九月 2021 13:03:58 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev

---
 ruoyi-ui/src/views/tool/gen/index.vue |   82 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 14 deletions(-)

diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue
index 4e8623c..87fc796 100644
--- a/ruoyi-ui/src/views/tool/gen/index.vue
+++ b/ruoyi-ui/src/views/tool/gen/index.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="琛ㄥ悕绉�" prop="tableName">
         <el-input
           v-model="queryParams.tableName"
@@ -41,6 +41,7 @@
       <el-col :span="1.5">
         <el-button
           type="primary"
+          plain
           icon="el-icon-download"
           size="mini"
           @click="handleGenTable"
@@ -50,6 +51,7 @@
       <el-col :span="1.5">
         <el-button
           type="info"
+          plain
           icon="el-icon-upload"
           size="mini"
           @click="openImportTable"
@@ -59,6 +61,7 @@
       <el-col :span="1.5">
         <el-button
           type="success"
+          plain
           icon="el-icon-edit"
           size="mini"
           :disabled="single"
@@ -69,6 +72,7 @@
       <el-col :span="1.5">
         <el-button
           type="danger"
+          plain
           icon="el-icon-delete"
           size="mini"
           :disabled="multiple"
@@ -76,31 +80,36 @@
           v-hasPermi="['tool:gen:remove']"
         >鍒犻櫎</el-button>
       </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55"></el-table-column>
-      <el-table-column label="搴忓彿" align="center" prop="tableId" width="60px" />
+      <el-table-column type="selection" align="center" width="55"></el-table-column>
+      <el-table-column label="搴忓彿" type="index" width="50" align="center">
+        <template slot-scope="scope">
+          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
+        </template>
+      </el-table-column>
       <el-table-column
         label="琛ㄥ悕绉�"
         align="center"
         prop="tableName"
         :show-overflow-tooltip="true"
-        width="130"
+        width="120"
       />
       <el-table-column
         label="琛ㄦ弿杩�"
         align="center"
         prop="tableComment"
         :show-overflow-tooltip="true"
-        width="130"
+        width="120"
       />
       <el-table-column
         label="瀹炰綋"
         align="center"
         prop="className"
         :show-overflow-tooltip="true"
-        width="130"
+        width="120"
       />
       <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="160" />
       <el-table-column label="鏇存柊鏃堕棿" align="center" prop="updateTime" width="160" />
@@ -130,6 +139,13 @@
           <el-button
             type="text"
             size="small"
+            icon="el-icon-refresh"
+            @click="handleSynchDb(scope.row)"
+            v-hasPermi="['tool:gen:edit']"
+          >鍚屾</el-button>
+          <el-button
+            type="text"
+            size="small"
             icon="el-icon-download"
             @click="handleGenTable(scope.row)"
             v-hasPermi="['tool:gen:code']"
@@ -145,7 +161,7 @@
       @pagination="getList"
     />
     <!-- 棰勮鐣岄潰 -->
-    <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
+    <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body class="scrollbar">
       <el-tabs v-model="preview.activeName">
         <el-tab-pane
           v-for="(value, key) in preview.data"
@@ -153,7 +169,7 @@
           :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
           :key="key"
         >
-          <pre>{{ value }}</pre>
+        <pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
         </el-tab-pane>
       </el-tabs>
     </el-dialog>
@@ -162,9 +178,18 @@
 </template>
 
 <script>
-import { listTable, previewTable, delTable } from "@/api/tool/gen";
+import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
 import importTable from "./importTable";
-import { downLoadZip } from "@/utils/zipdownload";
+import { downLoadZip } from "@/utils/download";
+import hljs from "highlight.js/lib/highlight";
+import "highlight.js/styles/github-gist.css";
+hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
+hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
+hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"));
+hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"));
+hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript"));
+hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
+
 export default {
   name: "Gen",
   components: { importTable },
@@ -182,6 +207,8 @@
       single: true,
       // 闈炲涓鐢�
       multiple: true,
+      // 鏄剧ず鎼滅储鏉′欢
+      showSearch: true,
       // 鎬绘潯鏁�
       total: 0,
       // 琛ㄦ暟鎹�
@@ -211,7 +238,8 @@
     const time = this.$route.query.t;
     if (time != null && time != this.uniqueId) {
       this.uniqueId = time;
-      this.resetQuery();
+      this.queryParams.pageNum = Number(this.$route.query.pageNum);
+      this.getList();
     }
   },
   methods: {
@@ -237,7 +265,26 @@
         this.msgError("璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁");
         return;
       }
-      downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
+      if(row.genType === "1") {
+        genCode(row.tableName).then(response => {
+          this.msgSuccess("鎴愬姛鐢熸垚鍒拌嚜瀹氫箟璺緞锛�" + row.genPath);
+        });
+      } else {
+        downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
+      }
+    },
+    /** 鍚屾鏁版嵁搴撴搷浣� */
+    handleSynchDb(row) {
+      const tableName = row.tableName;
+      this.$confirm('纭瑕佸己鍒跺悓姝�"' + tableName + '"琛ㄧ粨鏋勫悧锛�', "璀﹀憡", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning"
+      }).then(function() {
+          return synchDb(tableName);
+      }).then(() => {
+          this.msgSuccess("鍚屾鎴愬姛");
+      }).catch(() => {});
     },
     /** 鎵撳紑瀵煎叆琛ㄥ脊绐� */
     openImportTable() {
@@ -256,6 +303,13 @@
         this.preview.open = true;
       });
     },
+    /** 楂樹寒鏄剧ず */
+    highlightedCode(code, key) {
+      const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
+      var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
+      const result = hljs.highlight(language, code || "", true);
+      return result.value || '&nbsp;';
+    },
     // 澶氶�夋閫変腑鏁版嵁
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.tableId);
@@ -266,7 +320,7 @@
     /** 淇敼鎸夐挳鎿嶄綔 */
     handleEditTable(row) {
       const tableId = row.tableId || this.ids[0];
-      this.$router.push({ path: "/gen/edit", query: { tableId: tableId } });
+      this.$router.push({ path: '/tool/gen-edit/index', query: { tableId: tableId, pageNum: this.queryParams.pageNum } });
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
@@ -280,7 +334,7 @@
       }).then(() => {
           this.getList();
           this.msgSuccess("鍒犻櫎鎴愬姛");
-      }).catch(function() {});
+      }).catch(() => {});
     }
   }
 };

--
Gitblit v1.9.3