From fee8a5955b61ce8e880f376c68b03a2ec8ac7dbb Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 02 十二月 2019 09:28:11 +0800
Subject: [PATCH] 若依 2.0

---
 ruoyi-ui/src/views/tool/gen/index.vue |  286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 284 insertions(+), 2 deletions(-)

diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue
index c0c0673..0c159a0 100644
--- a/ruoyi-ui/src/views/tool/gen/index.vue
+++ b/ruoyi-ui/src/views/tool/gen/index.vue
@@ -1,5 +1,287 @@
 <template>
   <div class="app-container">
-   浠g爜鐢熸垚
+    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
+      <el-form-item label="琛ㄥ悕绉�" prop="tableName">
+        <el-input
+          v-model="queryParams.tableName"
+          placeholder="璇疯緭鍏ヨ〃鍚嶇О"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="琛ㄦ弿杩�" prop="tableComment">
+        <el-input
+          v-model="queryParams.tableComment"
+          placeholder="璇疯緭鍏ヨ〃鎻忚堪"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="鍒涘缓鏃堕棿">
+        <el-date-picker
+          v-model="dateRange"
+          size="small"
+          style="width: 240px"
+          value-format="yyyy-MM-dd"
+          type="daterange"
+          range-separator="-"
+          start-placeholder="寮�濮嬫棩鏈�"
+          end-placeholder="缁撴潫鏃ユ湡"
+        ></el-date-picker>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          icon="el-icon-download"
+          size="mini"
+          @click="handleGenTable"
+          v-hasPermi="['tool:gen:code']"
+        >鐢熸垚</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          icon="el-icon-upload"
+          size="mini"
+          @click="openImportTable"
+          v-hasPermi="['tool:gen:import']"
+        >瀵煎叆</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleEditTable"
+          v-hasPermi="['tool:gen:edit']"
+        >淇敼</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['tool:gen:remove']"
+        >鍒犻櫎</el-button>
+      </el-col>
+    </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="50px" />
+      <el-table-column
+        label="琛ㄥ悕绉�"
+        align="center"
+        prop="tableName"
+        :show-overflow-tooltip="true"
+        width="130"
+      />
+      <el-table-column
+        label="琛ㄦ弿杩�"
+        align="center"
+        prop="tableComment"
+        :show-overflow-tooltip="true"
+        width="130"
+      />
+      <el-table-column
+        label="瀹炰綋"
+        align="center"
+        prop="className"
+        :show-overflow-tooltip="true"
+        width="130"
+      />
+      <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="160" />
+      <el-table-column label="鏇存柊鏃堕棿" align="center" prop="updateTime" width="160" />
+      <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            type="text"
+            size="small"
+            icon="el-icon-view"
+            @click="handlePreview(scope.row)"
+            v-hasPermi="['tool:gen:preview']"
+          >棰勮</el-button>
+          <el-button
+            type="text"
+            size="small"
+            icon="el-icon-edit"
+            @click="handleEditTable(scope.row)"
+            v-hasPermi="['tool:gen:edit']"
+          >缂栬緫</el-button>
+          <el-button
+            type="text"
+            size="small"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['tool:gen:remove']"
+          >鍒犻櫎</el-button>
+          <el-button
+            type="text"
+            size="small"
+            icon="el-icon-download"
+            @click="handleGenTable(scope.row)"
+            v-hasPermi="['tool:gen:code']"
+          >鐢熸垚浠g爜</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+    <!-- 棰勮鐣岄潰 -->
+    <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh">
+      <el-tabs v-model="preview.activeName">
+        <el-tab-pane
+          v-for="(value, key) in preview.data"
+          :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
+          :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
+          :key="key"
+        >
+          <pre>{{ value }}</pre>
+        </el-tab-pane>
+      </el-tabs>
+    </el-dialog>
+    <import-table ref="import" @ok="handleQuery" />
   </div>
-</template>
\ No newline at end of file
+</template>
+
+<script>
+import { listTable, previewTable, delTable } from "@/api/tool/gen";
+import importTable from "./importTable";
+import { downLoadZip } from "@/utils/zipdownload";
+export default {
+  name: "Gen",
+  components: { importTable },
+  data() {
+    return {
+      // 閬僵灞�
+      loading: true,
+      // 鍞竴鏍囪瘑绗�
+      uniqueId: "",
+      // 閫変腑鏁扮粍
+      ids: [],
+      // 閫変腑琛ㄦ暟缁�
+      tableNames: [],
+      // 闈炲崟涓鐢�
+      single: true,
+      // 闈炲涓鐢�
+      multiple: true,
+      // 鎬绘潯鏁�
+      total: 0,
+      // 琛ㄦ暟鎹�
+      tableList: [],
+      // 鏃ユ湡鑼冨洿
+      dateRange: "",
+      // 鏌ヨ鍙傛暟
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        tableName: undefined,
+        tableComment: undefined
+      },
+      // 棰勮鍙傛暟
+      preview: {
+        open: false,
+        title: "浠g爜棰勮",
+        data: {},
+        activeName: "domain.java"
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  activated() {
+    const time = this.$route.query.t;
+    if (time != null && time != this.uniqueId) {
+      this.uniqueId = time;
+      this.resetQuery();
+    }
+  },
+  methods: {
+    /** 鏌ヨ琛ㄩ泦鍚� */
+    getList() {
+      this.loading = true;
+      listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
+          this.tableList = response.rows;
+          this.total = response.total;
+          this.loading = false;
+        }
+      );
+    },
+    /** 鎼滅储鎸夐挳鎿嶄綔 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 鐢熸垚浠g爜鎿嶄綔 */
+    handleGenTable(row) {
+      const tableNames = row.tableName || this.tableNames;
+      if (tableNames == "") {
+        this.msgError("璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁");
+        return;
+      }
+      downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
+    },
+    /** 鎵撳紑瀵煎叆琛ㄥ脊绐� */
+    openImportTable() {
+      this.$refs.import.show();
+    },
+    /** 閲嶇疆鎸夐挳鎿嶄綔 */
+    resetQuery() {
+      this.dateRange = [];
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    /** 棰勮鎸夐挳 */
+    handlePreview(row) {
+      previewTable(row.tableId).then(response => {
+        this.preview.data = response.data;
+        this.preview.open = true;
+      });
+    },
+    // 澶氶�夋閫変腑鏁版嵁
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.tableId);
+      this.tableNames = selection.map(item => item.tableName);
+      this.single = selection.length != 1;
+      this.multiple = !selection.length;
+    },
+    /** 淇敼鎸夐挳鎿嶄綔 */
+    handleEditTable(row) {
+      const tableId = row.tableId || this.ids[0];
+      this.$router.push({ path: "/gen/edit", query: { tableId: tableId } });
+    },
+    /** 鍒犻櫎鎸夐挳鎿嶄綔 */
+    handleDelete(row) {
+      const tableIds = row.tableId || this.ids;
+      this.$confirm('鏄惁纭鍒犻櫎琛ㄧ紪鍙蜂负"' + tableIds + '"鐨勬暟鎹」?', "璀﹀憡", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning"
+      }).then(function() {
+          return delTable(tableIds);
+      }).then(() => {
+          this.getList();
+          this.msgSuccess("鍒犻櫎鎴愬姛");
+      }).catch(function() {});
+    }
+  }
+};
+</script>
\ No newline at end of file

--
Gitblit v1.9.3