From bf9a412b20afe9f22e99448eb002ff9e92fd30cb Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期四, 09 二月 2023 10:17:04 +0800 Subject: [PATCH] 统一table操作按钮样式 --- src/views/operate/message/mycontrol/index.vue | 917 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 477 insertions(+), 440 deletions(-) diff --git a/src/views/operate/message/mycontrol/index.vue b/src/views/operate/message/mycontrol/index.vue index 85b8475..575262e 100644 --- a/src/views/operate/message/mycontrol/index.vue +++ b/src/views/operate/message/mycontrol/index.vue @@ -1,470 +1,507 @@ <template> - <div class="userList"> - <main> - <div class="mainContent"> - <div class="main-nav"> - <span>鏁版嵁鍒楄〃</span> - <el-button class="button-addition" type="primary" icon="el-icon-plus" @click="dialogCreate = true">娣诲姞</el-button> - </div> - <!-- 鏁版嵁灞曠ず --> - <el-table - border - stripe - ref="multipleTable" - :header-cell-style="{ 'background':'#F5F5F5','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="columnName" label="鏍忕洰鍚嶇О" min-width="10"> - </el-table-column> - <el-table-column prop="updateTime" label="淇敼鏃堕棿" min-width="10"> - <template slot-scope="scope"> - <span>{{changeTime(scope.row)}}</span> - </template> - </el-table-column> - <el-table-column prop="noticeAmount" label="鍏憡鏁伴噺" min-width="10"> - </el-table-column> - <el-table-column prop="isShow" label="鏄剧ず" min-width="5"> - <template slot-scope="scope"> - <el-switch class="switchStyle" v-model="scope.row.isShow" active-text="寮�" inactive-text="鍏�" - active-color="#3fef9a" inactive-color="#000212" @change="handleChangeStatus(scope.row)"> - </el-switch> - </template> - </el-table-column> - <el-table-column prop="operation" label="鎿嶄綔" min-width="15"> - <template slot-scope="scope"> - <div class="operation"> - <el-link icon="el-icon-edit" :underline="false" @click="handleEdit(scope.row)">缂栬緫</el-link> - <el-link class="leftPx" icon="el-icon-delete-solid" :underline="false" - @click="handleDelete([scope.row.id])">鍒犻櫎</el-link> - </div> - </template> - </el-table-column> - </el-table> - <!-- 鍒涘缓椤甸潰 --> - <el-dialog title="娣诲姞鏍忕洰" :visible.sync="dialogCreate" v-if="dialogCreate" width="45%" - :before-close="handleClose"> - <MyCreate @closeDialog="closeDialog"></MyCreate> - </el-dialog> - <!-- 缂栬緫椤甸潰 --> - <el-dialog title="淇敼鏍忕洰" :visible.sync="dialogEdit" v-if="dialogEdit" width="45%" - :before-close="handleClose"> - <MyEdit @closeDialog="closeDialog" :info="info"></MyEdit> - </el-dialog> - </div> - </main> - </div> + <div class="userList"> + <main> + <div class="mainContent"> + <div class="main-nav"> + <span>鏁版嵁鍒楄〃</span> + <el-button + class="button-addition" + type="primary" + icon="el-icon-plus" + @click="dialogCreate = true" + >娣诲姞</el-button + > + </div> + <!-- 鏁版嵁灞曠ず --> + <el-table + border + stripe + ref="multipleTable" + :header-cell-style="{ + background: '#F5F5F5', + '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="columnName" label="鏍忕洰鍚嶇О" min-width="10"> + </el-table-column> + <el-table-column prop="updateTime" label="淇敼鏃堕棿" min-width="10"> + <template slot-scope="scope"> + <span>{{ changeTime(scope.row) }}</span> + </template> + </el-table-column> + <el-table-column prop="noticeAmount" label="鍏憡鏁伴噺" min-width="10"> + </el-table-column> + <el-table-column prop="isShow" label="鏄剧ず" min-width="5"> + <template slot-scope="scope"> + <el-switch + class="switchStyle" + v-model="scope.row.isShow" + active-text="寮�" + inactive-text="鍏�" + active-color="#3fef9a" + inactive-color="#000212" + @change="handleChangeStatus(scope.row)" + > + </el-switch> + </template> + </el-table-column> + <el-table-column prop="operation" label="鎿嶄綔" min-width="15"> + <template slot-scope="scope"> + <div class="operation"> + <el-link + icon="el-icon-edit" + :underline="false" + @click="handleEdit(scope.row)" + >缂栬緫</el-link + > + <el-link + class="leftPx" + icon="el-icon-delete-solid" + :underline="false" + @click="handleDelete([scope.row.id])" + >鍒犻櫎</el-link + > + </div> + </template> + </el-table-column> + </el-table> + <!-- 鍒涘缓椤甸潰 --> + <el-dialog + title="娣诲姞鏍忕洰" + :visible.sync="dialogCreate" + v-if="dialogCreate" + width="45%" + :before-close="handleClose" + > + <MyCreate @closeDialog="closeDialog"></MyCreate> + </el-dialog> + <!-- 缂栬緫椤甸潰 --> + <el-dialog + title="淇敼鏍忕洰" + :visible.sync="dialogEdit" + v-if="dialogEdit" + width="45%" + :before-close="handleClose" + > + <MyEdit @closeDialog="closeDialog" :info="info"></MyEdit> + </el-dialog> + </div> + </main> + </div> </template> <script> // 寮曞叆鍒涘缓鏍忕洰缁勪欢 -import MyCreate from './createUser' +import MyCreate from "./createUser"; // 寮曞叆缂栬緫缁勪欢 -import MyEdit from './update' +import MyEdit from "./update"; // 寮曞叆鏃ユ湡js -import helper from '@/utils/mydate' +import helper from "@/utils/mydate"; export default { - components: { - MyCreate,MyEdit + components: { + MyCreate, + MyEdit, + }, + data() { + return { + tableData: [], + dialogCreate: false, + dialogEdit: false, + pageSize: 10, + currentPage: 1, + all: false, + unsame: false, + myIdx: 0, + preMyIdx: 0, + info: "", + options: [ + { + value: 0, + label: "鎵归噺鎿嶄綔", + disabled: true, + }, + { + value: 1, + label: "鎵归噺鍚敤", + }, + { + value: 2, + label: "鎵归噺绂佺敤", + }, + { + value: 3, + label: "鎵归噺鍒犻櫎", + }, + ], + tempList: [], + }; + }, + created() { + this.setTableData(); + }, + methods: { + // 缂栬緫 + handleEdit(data) { + this.info = data; + this.dialogEdit = true; }, - data() { - return { - tableData: [], - dialogCreate: false, - dialogEdit:false, - pageSize: 10, - currentPage: 1, - all: false, - unsame: false, - myIdx: 0, - preMyIdx: 0, - info:'', - options: [ - { - value: 0, - label: '鎵归噺鎿嶄綔', - disabled: true, - }, - { - value: 1, - label: '鎵归噺鍚敤', - }, - { - value: 2, - label: '鎵归噺绂佺敤', - }, - { - value: 3, - label: '鎵归噺鍒犻櫎', - } - ], - tempList: [] + // 鍒犻櫎鏁版嵁 + handleDelete(idArr) { + this.$confirm("鏄惁纭畾纭畾鍒犻櫎鏍忕洰?") + .then((_) => { + this.$axios({ + method: "post", + url: "sccg/message_column/delete" + "?ids=" + idArr, + }).then((res) => { + if (res.code === 200) { + this.$message({ + type: "success", + message: "鍒犻櫎鎴愬姛", + }); + this.setTableData(); + } + }); + }) + .catch((err) => {}); + }, + // 淇敼鏍忕洰鐘舵�� + handleChangeStatus({ id, isShow }) { + this.$axios({ + method: "post", + url: `sccg/message_column/update/${id}`, + data: { + isShow: Number(isShow), + }, + }).then((res) => { + if (res.code === 200) { + this.setTableData(); } + }); }, - created() { + // 鑾峰彇鍏ㄩ儴鏍忕洰 + async getColumnList() { + let arr = []; + await this.$axios({ + method: "get", + url: "sccg/message_column/getAllColumn", + }).then((res) => { + res.data.forEach((item) => { + item.isShow === 1 ? (item.isShow = true) : (item.isShow = false); + }); + arr = res.data; + }); + return arr; + }, + // 璁剧疆琛ㄦ牸鏁版嵁 + async setTableData() { + this.tableData = await this.getColumnList(); + }, + // 涓嬫媺妗嗙洃鍚� + async selectChange(list) { + 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, + }); + } + }); + }) + .catch((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({ updateTime }) { + return helper(updateTime); + }, + // 鍏ㄩ�� + selectAll() { + this.$refs.multipleTable.toggleAllSelection(); + }, + // 鍙嶉�� + disSame(list) { + list.forEach((row) => { + this.$refs.multipleTable.toggleRowSelection(row); + }); + }, + // 璁剧疆琛ㄦ牸鏂戦┈绾� + tableRowClassName({ row, rowIndex }) { + if ((rowIndex + 1) % 2 == 0) { + return "warning-row"; + } else { + return "success-row"; + } + return ""; + }, + // 褰撳墠椤垫敼鍙樿Е鍙戜簨浠� + changeCurrentPage(page) { + this.currentPage = page; + this.search(); + }, + // 涓婁竴椤电偣鍑讳簨浠� + handlePrev(page) { + this.currentPage = page; + this.search(); + }, + // 涓嬩竴椤电偣鍑讳簨浠� + handleNext(page) { + this.currentPage = page; + this.search(); + }, + // 鍏抽棴寮圭獥 + handleClose(done) { + this.$confirm("纭畾鍏抽棴?") + .then((_) => { + done(); + }) + .catch((err) => {}); + }, + // 鑷畾涔夊叧闂脊绐� + closeDialog({ flag, index }) { + this.dialogCreate = flag; + this.dialogEdit = flag; + if (index === 1) { this.setTableData(); + } }, - methods: { - // 缂栬緫 - handleEdit(data){ - this.info = data; - this.dialogEdit = true; - }, - // 鍒犻櫎鏁版嵁 - handleDelete(idArr) { - this.$confirm('鏄惁纭畾纭畾鍒犻櫎鏍忕洰?') - .then(_ => { - this.$axios({ - method: 'post', - url: 'sccg/message_column/delete' + '?ids=' + idArr, - }) - .then(res => { - if (res.code === 200) { - this.$message({ - type: 'success', - message: '鍒犻櫎鎴愬姛', - }); - this.setTableData(); - } - }) - }) - .catch(err=>{ - }) - }, - // 淇敼鏍忕洰鐘舵�� - handleChangeStatus({ id, isShow }) { - this.$axios({ - method: 'post', - url: `sccg/message_column/update/${id}`, - data: { - isShow: Number(isShow), - } - }) - .then(res => { - if (res.code === 200) { - this.setTableData(); - } - }) - }, - // 鑾峰彇鍏ㄩ儴鏍忕洰 - async getColumnList() { - let arr = []; - await this.$axios({ - method: 'get', - url: 'sccg/message_column/getAllColumn', - }) - .then(res => { - res.data.forEach(item => { - item.isShow === 1 ? item.isShow = true : item.isShow = false; - }) - arr = res.data - }) - return arr; - }, - // 璁剧疆琛ㄦ牸鏁版嵁 - async setTableData() { - this.tableData = await this.getColumnList(); - }, - // 涓嬫媺妗嗙洃鍚� - async selectChange(list) { - 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 - }) - } - }) - }) - .catch(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({ updateTime }) { - return helper(updateTime); - }, - // 鍏ㄩ�� - selectAll() { - this.$refs.multipleTable.toggleAllSelection(); - }, - // 鍙嶉�� - disSame(list) { - list.forEach(row => { - this.$refs.multipleTable.toggleRowSelection(row) - }) - }, - // 璁剧疆琛ㄦ牸鏂戦┈绾� - tableRowClassName({ row, rowIndex }) { - if ((rowIndex + 1) % 2 == 0) { - return 'warning-row'; - } else { - return 'success-row'; - } - return ''; - }, - // 褰撳墠椤垫敼鍙樿Е鍙戜簨浠� - changeCurrentPage(page) { - this.currentPage = page; - this.search(); - }, - // 涓婁竴椤电偣鍑讳簨浠� - handlePrev(page) { - this.currentPage = page; - this.search(); - }, - // 涓嬩竴椤电偣鍑讳簨浠� - handleNext(page) { - this.currentPage = page; - this.search(); - }, - // 鍏抽棴寮圭獥 - handleClose(done) { - this.$confirm('纭畾鍏抽棴?') - .then(_ => { - done(); - }) - .catch(err => { - }) - }, - // 鑷畾涔夊叧闂脊绐� - closeDialog({ flag, index }) { - this.dialogCreate = flag; - this.dialogEdit = flag; - if (index === 1) { - this.setTableData(); - } - } - } -} + }, +}; </script> <style lang="scss" scoped> .userList { - text-align: left; - padding: 10px 20px; - color: #606266; + text-align: left; + padding: 10px 20px; + color: #606266; border: 1px solid #ccc; - main { - background-color: white; - margin-top: 20px; - padding-bottom: 50px; - border: 1px solid #fff; + main { + background-color: white; + margin-top: 20px; + padding-bottom: 50px; + border: 1px solid #fff; - .mainTitle { - line-height: 60px; - } - - .main-nav { - line-height: 40px; - display: flex; - padding: 10px; - justify-content: space-between; - } - - .tools { - display: flex; - justify-content: space-between; - align-items: center; - padding: 0 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; - } - } - - } - - .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; - // } - //} - } - } - - .el-table { - // color: #606266; - // font-size: 10px; - - &::v-deep .el-table__empty-block { - //background-color: #09152f; - } - - &::v-deep .el-table__empty-block { - color: #4b9bb7; - } - - .operation { - display: flex; - - .el-link { - color: #4b9bb7; - } - - .leftPx { - margin-left: 10px; - } - - .line { - padding: 0 5px; - } - - span:hover { - cursor: pointer; - } - } - } - - //.el-table::v-deep .warning-row { - // background: #06122c; - //} - // - //.el-table::v-deep .success-row { - // background: #071f39; - //} - - &::v-deep .switchStyle .el-switch__label { - position: absolute; - display: none; - color: #fff; - } - - &::v-deep .el-switch__core { - background-color: rgba(166, 166, 166, 1); - } - - &::v-deep .switchStyle .el-switch__label--left { - z-index: 9; - left: 20px; - } - - &::v-deep .switchStyle .el-switch__label--right { - z-index: 9; - left: 4px; - } - - &::v-deep .switchStyle .el-switch__label.is-active { - display: block; - } - - &::v-deep .switchStyle.el-switch .el-switch__core, - &::v-deep .el-switch .el-switch__label { - width: 50px !important; - } + .mainTitle { + line-height: 60px; } - //&::v-deep .el-dialog__header, - //&::v-deep .el-dialog__body { - // background-color: #06122c; + .main-nav { + line-height: 40px; + display: flex; + padding: 10px; + justify-content: space-between; + } + + .tools { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 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; + } + } + } + + .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; + // } + //} + } + } + + .el-table { + // color: #606266; + // font-size: 10px; + + &::v-deep .el-table__empty-block { + //background-color: #09152f; + } + + &::v-deep .el-table__empty-block { + color: #4b9bb7; + } + + .operation { + display: flex; + + .el-link { + color: #4b9bb7; + } + color: var(--operation-color); + .leftPx { + margin-left: 10px; + } + + .line { + padding: 0 5px; + } + + span:hover { + cursor: pointer; + } + } + } + + //.el-table::v-deep .warning-row { + // background: #06122c; + //} + // + //.el-table::v-deep .success-row { + // background: #071f39; //} - &::v-deep .el-dialog__header { - display: flex; - align-items: center; - background-color: #fff; - padding: 20px; - line-height: 60px; + &::v-deep .switchStyle .el-switch__label { + position: absolute; + display: none; + color: #fff; } - &::v-deep .el-dialog__title { - color: #606266; + &::v-deep .el-switch__core { + background-color: rgba(166, 166, 166, 1); } - &::v-deep .el-dialog__close { - width: 20px; - height: 20px; - // color: #fff; + &::v-deep .switchStyle .el-switch__label--left { + z-index: 9; + left: 20px; } - &::v-deep .el-dialog__body { - padding: 0; + &::v-deep .switchStyle .el-switch__label--right { + z-index: 9; + left: 4px; } + + &::v-deep .switchStyle .el-switch__label.is-active { + display: block; + } + + &::v-deep .switchStyle.el-switch .el-switch__core, + &::v-deep .el-switch .el-switch__label { + width: 50px !important; + } + } + + //&::v-deep .el-dialog__header, + //&::v-deep .el-dialog__body { + // background-color: #06122c; + //} + + &::v-deep .el-dialog__header { + display: flex; + align-items: center; + background-color: #fff; + padding: 20px; + line-height: 60px; + } + + &::v-deep .el-dialog__title { + color: #606266; + } + + &::v-deep .el-dialog__close { + width: 20px; + height: 20px; + // color: #fff; + } + + &::v-deep .el-dialog__body { + padding: 0; + } } </style> -- Gitblit v1.8.0