From 5173f8e31d106abd003e123c8679cf53c7940b33 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期一, 30 一月 2023 11:54:12 +0800
Subject: [PATCH] 网格绘制

---
 src/views/systemSetting/device/bayonet/index.vue |  660 +++++++++++++++++++++++++++--------------------------------
 1 files changed, 307 insertions(+), 353 deletions(-)

diff --git a/src/views/systemSetting/device/bayonet/index.vue b/src/views/systemSetting/device/bayonet/index.vue
index 23b3a98..950f502 100644
--- a/src/views/systemSetting/device/bayonet/index.vue
+++ b/src/views/systemSetting/device/bayonet/index.vue
@@ -1,376 +1,330 @@
 <template>
-    <div class="userList">
-        <header>
-            <div class="header-content">
-                <div class="search">
-                    <span style="padding-right:20px">绛涢�夋潯浠�:</span>
-                    <el-select v-model="context" placeholder="璇烽�夋嫨">
-                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
-                        </el-option>
-                    </el-select>
-                    <!-- <el-input placeholder="璇疯緭鍏ュ唴瀹�" v-model="context"></el-input> -->
-                </div>
-            </div>
-        </header>
-        <main>
-            <div class="main-content">
-                <div class="main-title">
-                    <el-button class="el-icon-plus" type="primary" @click="dialogCreate = true">娣诲姞</el-button>
-                    <el-button class="">瀵煎嚭鍗″彛</el-button>
-                </div>
-                <!-- 鏁版嵁灞曠ず -->
-                <el-table ref="multipleTable"
-                    :header-cell-style="{background:'#06122c','font-size':'12px',color:'#4b9bb7','font-weight':'650','line-height':'45px'}"
-                    :data="tableData" style="width: 100%" :row-class-name="tableRowClassName"
-                    @selection-change="tableChange">
-                    <el-table-column type="selection" min-width="5">
-                    </el-table-column>
-                    <el-table-column prop="name" label="鍗″彛鍚嶇О" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="sort" label="缁忕含搴︿綅缃�" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="adminCount" label="鎵�灞炲尯鍩�" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="description" label="鍩熷悕/IP" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="description" label="绔彛鍙�" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="description" label="鍓嶇绫诲瀷" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="description" label="鍑哄叆鍩庣被鍨�" min-width="10">
-                    </el-table-column>
-                    <el-table-column prop="operation" label="鎿嶄綔" min-width="15">
-                        <template slot-scope="scope">
-                            <div class="operation">
-                                <span>缂栬緫</span>
-                            </div>
-                        </template>
-                    </el-table-column>
-                </el-table>
-                <!-- tools -->
-                <!-- <div class="tools">
-                    <div class="funs">
-                        <div class="funsItem">
-                            <el-checkbox v-model="all" @change="selectAll()">鍏ㄩ��</el-checkbox>
-                        </div>
-                        <div class="funsItem">
-                            <el-checkbox v-model="unsame" @change="disSame(tableData)">鍙嶉��</el-checkbox>
-                        </div>
-                        <div class="funsItem">
-                            <el-select v-model="myIdx" placeholder="鎵归噺鎿嶄綔" @change="selectChange">
-                                <el-option v-for="item in options" :key="item.value" :label="item.label"
-                                    :value="item.value" :disabled="item.disabled">
-                                </el-option>
-                            </el-select>
-                        </div>
-                    </div>
-                    <div class="pagination">
-                        <el-pagination background :current-page="currentPage" layout="prev, pager, next"
-                            :total="totalNum" :page-size="pageSize" @current-change="changeCurrentPage"
-                            @prev-click="handlePrev" @next-click="handleNext">
-                        </el-pagination>
-                    </div>
-                </div> -->
-            </div>
-        </main>
-        <footer>
-            <!-- 娣诲姞鍗″彛 -->
-            <el-dialog title="娣诲姞鍗″彛" :visible.sync="dialogCreate" width="60%" :before-close="handleClose">
-                <MyCreate></MyCreate>
-            </el-dialog>
-        </footer>
-    </div>
+  <div class="userList">
+    <header>
+      <div class="header-content">
+        <div class="search">
+          <span style="padding-right: 20px">绛涢�夋潯浠�:</span>
+          <el-input v-model="context" placeholder="璇疯緭鍏�" @change="getBayonetListData"></el-input>
+        </div>
+      </div>
+    </header>
+    <main>
+      <div class="main-content">
+        <div class="main-title">
+          <el-button
+            class="el-icon-plus button-addition"
+            type="primary"
+            @click="showDialog(false, null)"
+            >娣诲姞</el-button
+          >
+          <el-button @click="handleExport">瀵煎嚭鍗″彛</el-button>
+        </div>
+        <!-- 鏁版嵁灞曠ず -->
+        <MyTable :tableOption="tableOption" :get-table-list="getBayonetListData" :tableData="list" :pageShow="false">
+          <template #operation="info">
+            <el-link
+              :underline="false"
+              style="color: #4b9bb7"
+              @click="showDialog(true, info)"
+              >缂栬緫</el-link
+            >
+
+            <span class="line">|</span>
+            <el-link
+              :underline="false"
+              style="color: #4b9bb7"
+              @click="handleDelete(info)"
+              >鍒犻櫎</el-link
+            >
+          </template>
+        </MyTable>
+      </div>
+    </main>
+    <footer>
+      <!-- 娣诲姞鍗″彛 -->
+      <el-dialog
+        :destroy-on-close="true"
+        :title="getDialogTitle"
+        :visible.sync="isShowDialog"
+        width="60%"
+        :before-close="handleClose"
+      >
+        <MyCreate
+          v-if="isShowDialog"
+          @closeDialog="closeDialog"
+          :originalBayonet="originalBayonet"
+          :isEdit="isEdit"
+        ></MyCreate>
+      </el-dialog>
+    </footer>
+  </div>
 </template>
 <script>
-import helper from "@/utils/mydate.js"
-import MyCreate from './create'
-export default {
-    components: {
-        MyCreate
-    },
-    data() {
-        return {
-            tableData: [],
-            context: 0,
-            dialogCreate: false,
-            totalNum: null,
-            pageSize: 10,
-            currentPage: 1,
-            all: false,
-            unsame: false,
-            myIdx: 0,
-            preMyIdx: 0,
-            options: [
-                {
-                    value: 0,
-                    label: '绂荤嚎',
-                },
-                {
-                    value: 1,
-                    label: '鍦ㄧ嚎',
-                }
-            ],
-            tempList: []
-        }
-    },
-    created() {
-    },
-    methods: {
-        async selectChange(list) {
-            console.log(this.tempList);
-            if (this.tempList.length !== 0) {
-                this.preMyIdx = list;
-                if (list === 3) {
-                    await this.handleDelete(this.tempList);
-                } else if (list === 2) {
-                    await this.mulUpdateStatus(this.tempList, 0);
-                } else {
-                    await this.mulUpdateStatus(this.tempList, 1);
-                }
-                this.myIdx = 0;
-            } else {
-                this.myIdx = this.preMyIdx;
-                this.$message({
-                    type: 'warning',
-                    message: '鎮ㄨ繕娌¢�変腑浠讳綍鏁版嵁',
-                })
-            }
-        },
-        mulUpdateStatus(idArr, flag) {
-            this.$confirm(flag === 1 ? "鎮ㄧ‘瀹氳杩涜鎵归噺鍚敤瑙掕壊鍚�?" : '鎮ㄧ‘瀹氳杩涜鎵归噺绂佺敤瑙掕壊鍚�?')
-                .then(_ => {
-                    this.$axios({
-                        method: 'post',
-                        url: 'sccg/role/updateStatusBatch?ids=' + idArr + '&status=' + flag,
-                    })
-                        .then(res => {
-                            if (res.code === 200) {
-                                this.$message({
-                                    type: 'success',
-                                    message: '鏇存敼鐢ㄦ埛鐘舵�佹垚鍔�',
-                                })
-                                this.getUserList();
-                            } else {
-                                this.$message({
-                                    type: 'error',
-                                    message: res.message
-                                })
-                            }
-                            console.log(res);
-                        })
-                })
-                .catch(err => { console.log(err) })
-        },
-        tableChange(list) {
-            this.tempList = [];
-            list.forEach(item => {
-                this.tempList.push(item.id);
-            })
-            if (list.length === this.tableData.length) {
-                this.all = true;
-            } else {
-                this.all = false
-            }
-        },
-        changeTime({ createTime }) {
-            return helper(createTime);
-        },
-        selectAll() {
-            this.$refs.multipleTable.toggleAllSelection();
-        },
-        disSame(list) {
-            list.forEach(row => {
-                this.$refs.multipleTable.toggleRowSelection(row)
-            })
-        },
-        handleDelete(id) {
-            const that = this;
-            // let arr = [];
-            // arr.push(id);
-            this.$confirm('纭鍒犻櫎锛�')
-                .then(_ => {
-                    that.$axios({
-                        method: 'post',
-                        url: 'sccg/role/delete?ids=' + id,
-                    })
-                        .then(res => {
-                            this.myIdx = 0;
-                            this.preMyIdx = 0;
-                            console.log(res);
-                            this.$message({
-                                type: 'success',
-                                message: res.message
-                            })
+import MyCreate from "./create";
+import MyTable from "@/components/Table";
+import bayonet from "@/api/system/bayonet";
+import { downloadFile } from "@/utils/helper";
 
-                            this.getUserList();
-                        })
-                })
-                .catch(_ => { });
+export default {
+  components: {
+    MyCreate,
+    MyTable,
+  },
+  data() {
+    return {
+      isShowDialog: false,
+      context: "",
+      options: [
+        {
+          value: 0,
+          label: "绂荤嚎",
         },
-        // 璁剧疆琛ㄦ牸鏂戦┈绾�
-        tableRowClassName({ row, rowIndex }) {
-            if ((rowIndex + 1) % 2 == 0) {
-                return 'warning-row';
-            } else {
-                return 'success-row';
-            }
-            return '';
+        {
+          value: 1,
+          label: "鍦ㄧ嚎",
         },
-        // 褰撳墠椤垫敼鍙樿Е鍙戜簨浠�
-        changeCurrentPage(page) {
-            this.currentPage = page;
-        },
-        // 涓婁竴椤电偣鍑讳簨浠�
-        handlePrev(page) {
-            this.currentPage = page;
-        },
-        // 涓嬩竴椤电偣鍑讳簨浠�
-        handleNext(page) {
-            this.currentPage = page;
-        },
-        // 鍏抽棴寮圭獥
-        handleClose(done) {
-            this.$confirm('纭鍏抽棴锛�')
-                .then(_ => {
-                    done();
-                })
-                .catch(_ => { });
-        }
-    }
-}
+      ],
+      list: [],
+      current: 1,
+      size: 10,
+      tableOption: {
+        group: [
+          {
+            label: "鍗″彛鍚嶇О",
+            type: "text",
+            prop: "name",
+          },
+          {
+            label: "鍩熷悕/IP",
+            type: "text",
+            prop: "ipAddress",
+          },
+          {
+            label: "绔彛鍙�",
+            type: "text",
+            prop: "port",
+          },
+          {
+            label: "鍓嶇绫诲瀷",
+            type: "text",
+            prop: "frontEndTypeName",
+          },
+          {
+            label: "鍑哄叆鍩庣被鍨�",
+            type: "text",
+            prop: "inOutCityTypeName",
+          },
+          {
+            label: "鎿嶄綔",
+            type: "operation",
+            prop: "operation",
+          },
+        ],
+      },
+      originalBayonet: null,
+      isEdit: false,
+    };
+  },
+
+  computed: {
+    getDialogTitle() {
+      return this.isEdit ? "缂栬緫鍗″彛" : "鏂板缓鍗″彛";
+    },
+  },
+  created() {
+    this.getBayonetListData();
+  },
+  methods: {
+    getBayonetListData() {
+      bayonet
+        .getBayonetList({
+          bayonetName: this.context,
+          current: this.current,
+          size: this.size,
+        })
+        .then(({ records }) => {
+          this.list = records;
+        })
+        .catch((err) => {
+          this.$message({ type: "error", message: err });
+        });
+    },
+    // 寮圭獥鍏抽棴
+    handleClose(done) {
+      this.$confirm("纭鍏抽棴?").then((_) => {
+        done();
+      });
+    },
+
+    closeDialog() {
+      this.isShowDialog = false;
+      this.getBayonetListData();
+    },
+
+    handleExport() {
+      bayonet
+        .exportBayonetList({
+          bayonetName: this.context,
+          current: this.current,
+          size: this.size
+        })
+        .then((res) => {
+          downloadFile(res);
+          this.$message({ type: "success", message: "鎿嶄綔鎴愬姛" });
+        })
+        .catch((err) => {
+          this.$message({ type: "error", message: err });
+        });
+    },
+    handleDelete(data) {
+      this.$confirm("纭鍒犻櫎锛�").then((_) => {
+        bayonet.deleteBayonet(data.info.row.id).then((res) => {
+          this.$message({
+            type: "success",
+            message: "鍒犻櫎鎴愬姛锛�",
+          });
+          this.getBayonetListData();
+        });
+      });
+    },
+    showDialog(isEdit, data) {
+      this.isShowDialog = true;
+      this.isEdit = isEdit;
+      this.originalBayonet = data ? data.info.row : null;
+    },
+  },
+};
 </script>
 <style lang="scss" scoped>
 .userList {
-    text-align: left;
-    margin: 10px 20px;
-    color: #4b9bb7;
+  text-align: left;
+  padding: 10px 20px;
+  // color: #4b9bb7;
+  border: 1px solid #ccc;
+  header {
+    background-color: white;
 
-    header {
-        background-color: #09152f;
-        border: 1pox solid #fff;
+    .header-content {
+      padding: 0;
+      display: flex;
+      line-height: 100px;
+      justify-content: space-between;
+      align-items: center;
 
-        .header-content {
-            padding: 0 40px;
-            display: flex;
-            line-height: 100px;
-            justify-content: space-between;
-            align-items: center;
+      .search {
+        display: flex;
+        justify-content: flex-start;
 
-            .search {
-                display: flex;
-                justify-content: flex-start;
-
-                span {
-                    flex: 1;
-                }
-
-                .el-input {
-                    flex: 2;
-                    color: #1d3f57;
-
-                    &::v-deep .el-input__inner {
-                        background-color: #09152f;
-                        border: 1px solid #17324c;
-                    }
-                }
-
-            }
+        span {
+          flex: 1;
         }
+
+        .el-input {
+          flex: 2;
+          // color: #1d3f57;
+
+          // &::v-deep .el-input__inner {
+          //   background-color: #09152f;
+          //   border: 1px solid #17324c;
+          // }
+        }
+      }
+    }
+  }
+
+  main {
+    // background-color: #09152f;
+    margin-top: 20px;
+    padding-bottom: 50px;
+
+    .main-title {
+      line-height: 60px;
+      padding: 10px 0px;
     }
 
-    main {
-        background-color: #09152f;
-        margin-top: 20px;
-        padding-bottom: 50px;
-        border: 1pox solid #fff;
+    .tools {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      padding: 0 20px;
 
-        .main-title {
-            line-height: 60px;
-            padding: 10px 20px;
+      .funs {
+        display: flex;
+
+        .funsItem {
+          line-height: 28px;
+          display: flex;
+          align-items: center;
+          // border: 1px solid #17324c;
+          border-radius: 4px;
+          font-size: 12px;
+          margin-left: 10px;
+
+          .el-checkbox {
+            width: 80px;
+            padding: 0 10px;
+          }
+
+          .el-select {
+            width: 120px;
+          }
+
+          // &::v-deep .el-input__inner {
+          //   border: none;
+          //   background-color: #09152f;
+          // }
+
+          // &:hover {
+          //   border: 1px solid #4b9bb7;
+          // }
+
+          // &:hover .el-checkbox {
+          //   color: #4b9bb7;
+          // }
         }
+      }
 
-        .tools {
-            display: flex;
-            justify-content: space-between;
-            align-items: center;
-            padding: 0 20px;
+      .pagination {
+        margin-top: 50px;
+        display: flex;
+        line-height: 50px;
+        justify-content: center;
 
-            .funs {
-                display: flex;
+        .el-pagination {
+          // &::v-deep li,
+          // &::v-deep .btn-prev,
+          // &::v-deep .btn-next {
+          //   background-color: #071f39;
+          //   color: #4b9bb7;
+          // }
 
-                .funsItem {
-                    line-height: 28px;
-                    display: flex;
-                    align-items: center;
-                    border: 1px solid #17324c;
-                    border-radius: 4px;
-                    font-size: 12px;
-                    margin-left: 10px;
-
-                    .el-checkbox {
-                        width: 80px;
-                        padding: 0 10px;
-                    }
-
-                    .el-select {
-                        width: 120px;
-                    }
-
-                    &::v-deep .el-input__inner {
-                        border: none;
-                        background-color: #09152f;
-                    }
-
-                    &:hover {
-                        border: 1px solid #4b9bb7;
-                    }
-
-                    &:hover .el-checkbox {
-                        color: #4b9bb7;
-                    }
-                }
-
-            }
-
-            .pagination {
-                margin-top: 50px;
-                display: flex;
-                line-height: 50px;
-                justify-content: center;
-
-                .el-pagination {
-
-                    &::v-deep li,
-                    &::v-deep .btn-prev,
-                    &::v-deep .btn-next {
-                        background-color: #071f39;
-                        color: #4b9bb7;
-                    }
-
-                    &::v-deep .active {
-                        background-color: #409eff;
-                        color: #fff;
-                    }
-                }
-            }
+          // &::v-deep .active {
+          //   background-color: #409eff;
+          //   color: #fff;
+          // }
         }
-
-        .el-table {
-            color: #4b9bb7;
-            font-size: 10px;
-
-            .operation {
-                display: flex;
-
-                .line {
-                    padding: 0 5px;
-                }
-
-                span:hover {
-                    cursor: pointer;
-                }
-            }
-        }
+      }
     }
+
+    .el-table {
+      // color: #4b9bb7;
+      // font-size: 10px;
+
+      .cell {
+        display: flex;
+
+        &::v-deep .line {
+          padding: 0 5px;
+        }
+
+        span:hover {
+          cursor: pointer;
+        }
+      }
+    }
+  }
 }
-</style>
\ No newline at end of file
+.line {
+  padding: 0 5px;
+}
+</style>

--
Gitblit v1.8.0