From 7c124560b27add087b4aa8fc457de1e84f950d9c Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Tue, 23 Nov 2021 15:19:33 +0800
Subject: [PATCH] 样式  (1:搜索按钮放入右侧,2:隐藏表格显影按钮,3:页码改为(15,30,50,100))

---
 src/views/tool/datasource.vue |  482 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 256 insertions(+), 226 deletions(-)

diff --git a/src/views/tool/datasource.vue b/src/views/tool/datasource.vue
index 47e8d00..8a85a51 100644
--- a/src/views/tool/datasource.vue
+++ b/src/views/tool/datasource.vue
@@ -1,30 +1,36 @@
 <template>
-  <basic-container>
-    <avue-crud :option="option"
-               :table-loading="loading"
-               :data="data"
-               :page.sync="page"
-               :permission="permissionList"
-               :before-open="beforeOpen"
-               v-model="form"
-               ref="crud"
-               @row-update="rowUpdate"
-               @row-save="rowSave"
-               @row-del="rowDel"
-               @search-change="searchChange"
-               @search-reset="searchReset"
-               @selection-change="selectionChange"
-               @current-change="currentChange"
-               @size-change="sizeChange"
-               @refresh-change="refreshChange"
-               @on-load="onLoad">
+  <basic-container
+    :class="[$store.state.control.windowWidth >= 1024 ? 'oneRowSearch' : '']"
+  >
+    <avue-crud
+      :option="option"
+      :table-loading="loading"
+      :data="data"
+      :page.sync="page"
+      :permission="permissionList"
+      :before-open="beforeOpen"
+      v-model="form"
+      ref="crud"
+      @row-update="rowUpdate"
+      @row-save="rowSave"
+      @row-del="rowDel"
+      @search-change="searchChange"
+      @search-reset="searchReset"
+      @selection-change="selectionChange"
+      @current-change="currentChange"
+      @size-change="sizeChange"
+      @refresh-change="refreshChange"
+      @on-load="onLoad"
+    >
       <template slot="menuLeft">
-        <el-button type="danger"
-                   size="small"
-                   icon="el-icon-delete"
-                   plain
-                   v-if="permission.datasource_delete"
-                   @click="handleDelete">删 除
+        <el-button
+          type="danger"
+          size="small"
+          icon="el-icon-delete"
+          plain
+          v-if="permission.datasource_delete"
+          @click="handleDelete"
+          >删 除
         </el-button>
       </template>
     </avue-crud>
@@ -32,240 +38,264 @@
 </template>
 
 <script>
-  import {getList, getDetail, add, update, remove} from "@/api/tool/datasource";
-  import {mapGetters} from "vuex";
+import { getList, getDetail, add, update, remove } from "@/api/tool/datasource";
+import { mapGetters } from "vuex";
 
-  export default {
-    data() {
-      return {
-        form: {},
-        query: {},
-        loading: true,
-        page: {
-          pageSize: 10,
-          currentPage: 1,
-          total: 0
-        },
-        selectionList: [],
-        option: {
-          height: 'auto',
-          calcHeight: 30,
-          dialogWidth: 900,
-          tip: false,
-          searchShow: true,
-          searchMenuSpan: 6,
-          border: true,
-          index: true,
-          viewBtn: true,
-          selection: true,
-          dialogClickModal: false,
-          column: [
-            {
-              label: "名称",
-              prop: "name",
-              width: 120,
-              rules: [{
+export default {
+  data() {
+    return {
+      form: {},
+      query: {},
+      loading: true,
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0,
+        ...this.$store.state.control.changePageSize,
+      },
+      selectionList: [],
+      option: {
+        height: "auto",
+        calcHeight: 30,
+        dialogWidth: 900,
+        tip: false,
+        searchShow: true,
+        searchMenuSpan: 6,
+        border: true,
+        index: true,
+        viewBtn: true,
+        selection: true,
+        dialogClickModal: false,
+        ...this.$store.state.control.clearOtherBut,
+        column: [
+          {
+            label: "名称",
+            prop: "name",
+            width: 120,
+            rules: [
+              {
                 required: true,
                 message: "请输入数据源名称",
-                trigger: "blur"
-              }]
-            },
-            {
-              label: "驱动类",
-              prop: "driverClass",
-              type: 'select',
-              dicData: [
-                {
-                  label: 'com.mysql.cj.jdbc.Driver',
-                  value: 'com.mysql.cj.jdbc.Driver',
-                }, {
-                  label: 'org.postgresql.Driver',
-                  value: 'org.postgresql.Driver',
-                }, {
-                  label: 'oracle.jdbc.OracleDriver',
-                  value: 'oracle.jdbc.OracleDriver',
-                }
-              ],
-              width: 200,
-              rules: [{
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "驱动类",
+            prop: "driverClass",
+            type: "select",
+            dicData: [
+              {
+                label: "com.mysql.cj.jdbc.Driver",
+                value: "com.mysql.cj.jdbc.Driver",
+              },
+              {
+                label: "org.postgresql.Driver",
+                value: "org.postgresql.Driver",
+              },
+              {
+                label: "oracle.jdbc.OracleDriver",
+                value: "oracle.jdbc.OracleDriver",
+              },
+            ],
+            width: 200,
+            rules: [
+              {
                 required: true,
                 message: "请输入驱动类",
-                trigger: "blur"
-              }]
-            },
-            {
-              label: "用户名",
-              prop: "username",
-              width: 120,
-              rules: [{
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "用户名",
+            prop: "username",
+            width: 120,
+            rules: [
+              {
                 required: true,
                 message: "请输入用户名",
-                trigger: "blur"
-              }]
-            },
-            {
-              label: "密码",
-              prop: "password",
-              hide: true,
-              rules: [{
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "密码",
+            prop: "password",
+            hide: true,
+            rules: [
+              {
                 required: true,
                 message: "请输入密码",
-                trigger: "blur"
-              }]
-            },
-            {
-              label: "连接地址",
-              prop: "url",
-              span: 24,
-              rules: [{
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "连接地址",
+            prop: "url",
+            span: 24,
+            rules: [
+              {
                 required: true,
                 message: "请输入连接地址",
-                trigger: "blur"
-              }]
-            },
-            {
-              label: "备注",
-              prop: "remark",
-              span: 24,
-              minRows: 3,
-              hide: true,
-              type: "textarea"
-            },
-          ]
-        },
-        data: []
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "备注",
+            prop: "remark",
+            span: 24,
+            minRows: 3,
+            hide: true,
+            type: "textarea",
+          },
+        ],
+      },
+      data: [],
+    };
+  },
+  computed: {
+    ...mapGetters(["permission"]),
+    permissionList() {
+      return {
+        addBtn: this.vaildData(this.permission.datasource_add, false),
+        viewBtn: this.vaildData(this.permission.datasource_view, false),
+        delBtn: this.vaildData(this.permission.datasource_delete, false),
+        editBtn: this.vaildData(this.permission.datasource_edit, false),
       };
     },
-    computed: {
-      ...mapGetters(["permission"]),
-      permissionList() {
-        return {
-          addBtn: this.vaildData(this.permission.datasource_add, false),
-          viewBtn: this.vaildData(this.permission.datasource_view, false),
-          delBtn: this.vaildData(this.permission.datasource_delete, false),
-          editBtn: this.vaildData(this.permission.datasource_edit, false)
-        };
-      },
-      ids() {
-        let ids = [];
-        this.selectionList.forEach(ele => {
-          ids.push(ele.id);
-        });
-        return ids.join(",");
-      }
+    ids() {
+      let ids = [];
+      this.selectionList.forEach((ele) => {
+        ids.push(ele.id);
+      });
+      return ids.join(",");
     },
-    methods: {
-      rowSave(row, done, loading) {
-        add(row).then(() => {
+  },
+  methods: {
+    rowSave(row, done, loading) {
+      add(row).then(
+        () => {
           this.onLoad(this.page);
           this.$message({
             type: "success",
-            message: "操作成功!"
+            message: "操作成功!",
           });
           done();
-        }, error => {
+        },
+        (error) => {
           window.console.log(error);
           loading();
-        });
-      },
-      rowUpdate(row, index, done, loading) {
-        update(row).then(() => {
+        }
+      );
+    },
+    rowUpdate(row, index, done, loading) {
+      update(row).then(
+        () => {
           this.onLoad(this.page);
           this.$message({
             type: "success",
-            message: "操作成功!"
+            message: "操作成功!",
           });
           done();
-        }, error => {
+        },
+        (error) => {
           window.console.log(error);
           loading();
+        }
+      );
+    },
+    rowDel(row) {
+      this.$confirm("确定将选择数据删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          return remove(row.id);
+        })
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!",
+          });
         });
-      },
-      rowDel(row) {
-        this.$confirm("确定将选择数据删除?", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
+    },
+    handleDelete() {
+      if (this.selectionList.length === 0) {
+        this.$message.warning("请选择至少一条数据");
+        return;
+      }
+      this.$confirm("确定将选择数据删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          return remove(this.ids);
         })
-          .then(() => {
-            return remove(row.id);
-          })
-          .then(() => {
-            this.onLoad(this.page);
-            this.$message({
-              type: "success",
-              message: "操作成功!"
-            });
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!",
           });
-      },
-      handleDelete() {
-        if (this.selectionList.length === 0) {
-          this.$message.warning("请选择至少一条数据");
-          return;
-        }
-        this.$confirm("确定将选择数据删除?", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        })
-          .then(() => {
-            return remove(this.ids);
-          })
-          .then(() => {
-            this.onLoad(this.page);
-            this.$message({
-              type: "success",
-              message: "操作成功!"
-            });
-            this.$refs.crud.toggleSelection();
-          });
-      },
-      beforeOpen(done, type) {
-        if (["edit", "view"].includes(type)) {
-          getDetail(this.form.id).then(res => {
-            this.form = res.data.data;
-          });
-        }
-        done();
-      },
-      searchReset() {
-        this.query = {};
-        this.onLoad(this.page);
-      },
-      searchChange(params, done) {
-        this.query = params;
-        this.page.currentPage = 1;
-        this.onLoad(this.page, params);
-        done();
-      },
-      selectionChange(list) {
-        this.selectionList = list;
-      },
-      selectionClear() {
-        this.selectionList = [];
-        this.$refs.crud.toggleSelection();
-      },
-      currentChange(currentPage) {
-        this.page.currentPage = currentPage;
-      },
-      sizeChange(pageSize) {
-        this.page.pageSize = pageSize;
-      },
-      refreshChange() {
-        this.onLoad(this.page, this.query);
-      },
-      onLoad(page, params = {}) {
-        this.loading = true;
-        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
-          const data = res.data.data;
-          this.page.total = data.total;
-          this.data = data.records;
-          this.loading = false;
-          this.selectionClear();
+          this.$refs.crud.toggleSelection();
+        });
+    },
+    beforeOpen(done, type) {
+      if (["edit", "view"].includes(type)) {
+        getDetail(this.form.id).then((res) => {
+          this.form = res.data.data;
         });
       }
-    }
-  };
+      done();
+    },
+    searchReset() {
+      this.query = {};
+      this.onLoad(this.page);
+    },
+    searchChange(params, done) {
+      this.query = params;
+      this.page.currentPage = 1;
+      this.onLoad(this.page, params);
+      done();
+    },
+    selectionChange(list) {
+      this.selectionList = list;
+    },
+    selectionClear() {
+      this.selectionList = [];
+      this.$refs.crud.toggleSelection();
+    },
+    currentChange(currentPage) {
+      this.page.currentPage = currentPage;
+    },
+    sizeChange(pageSize) {
+      this.page.pageSize = pageSize;
+    },
+    refreshChange() {
+      this.onLoad(this.page, this.query);
+    },
+    onLoad(page, params = {}) {
+      this.loading = true;
+      getList(
+        page.currentPage,
+        page.pageSize,
+        Object.assign(params, this.query)
+      ).then((res) => {
+        const data = res.data.data;
+        this.page.total = data.total;
+        this.data = data.records;
+        this.loading = false;
+        this.selectionClear();
+      });
+    },
+  },
+};
 </script>
 
 <style>

--
Gitblit v1.9.3