From 5b2dd794ec680d47e907ff43a264a7f82c30a130 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期二, 18 十月 2022 16:23:55 +0800 Subject: [PATCH] 部门编辑优化 --- src/views/systemSetting/baseSetting/role/index.vue | 220 +++++++++++++++++++++++++++++-------------------------- 1 files changed, 116 insertions(+), 104 deletions(-) diff --git a/src/views/systemSetting/baseSetting/role/index.vue b/src/views/systemSetting/baseSetting/role/index.vue index fceb8a6..38ead8d 100644 --- a/src/views/systemSetting/baseSetting/role/index.vue +++ b/src/views/systemSetting/baseSetting/role/index.vue @@ -12,7 +12,7 @@ <div class="addUser"> <el-button class="addBtn" type="primary" @click="dialogCreate = true">鏂板缓瑙掕壊</el-button> <el-dialog :visible.sync="dialogCreate" title="鏂板瑙掕壊" width="45%" v-if="dialogCreate" - :before-close="handleClose"> + :before-close="handleClose2"> <createUser :refresh="context==='' ? getUserList : search" /> </el-dialog> </div> @@ -40,8 +40,9 @@ </el-table-column> <el-table-column prop="status" label="鍚敤" min-width="5"> <template slot-scope="scope"> - <el-switch class="switchStyle" v-model="scope.row.status" active-text="寮�" inactive-text="鍏�" - active-color="#3fef9a" inactive-color="#000212" @change="handleChangeStatus(scope.row)"> + <!-- active-text="寮�" inactive-text="鍏�" --> + <el-switch class="switchStyle" v-model="scope.row.status" + active-color="#3fef9a" inactive-color="#000212" disabled> </el-switch> </template> </el-table-column> @@ -55,23 +56,28 @@ <!-- <span>鍒犻櫎</span> --> <span @click="handleUpdate(scope.row)">鏉冮檺璁剧疆</span> <span class="line">|</span> - <span @click="handleStop(scope.row)">鍋滅敤</span> + <span @click="handleChangeStatus(scope.row)">{{scope.row.status === true ?'鍋滅敤':'鍚敤' }}</span> <span class="line">|</span> - <span @click="handleDelete(scope.row)">鍒犻櫎</span> + <span @click="handleDelete([scope.row.id])">鍒犻櫎</span> </div> </template> </el-table-column> </el-table> - <!-- 鏌ョ湅淇敼椤甸潰 --> + <!-- 淇敼椤甸潰 --> <el-dialog :visible.sync="dialogUpdate" width="45%" :title="updateFlag ? '鏉冮檺璁剧疆' :'鏌ョ湅瑙掕壊淇℃伅'" v-if="dialogUpdate" :before-close="handleClose"> <updateUser :updateFlag="updateFlag" :userInfo=userInfo :getUserList=" context ? getUserList : getUserList" @changeDialog="changeDialog" /> </el-dialog> + <!-- 鏌ョ湅椤甸潰 --> + <el-dialog :visible.sync="dialogView" width="45%" title="鏌ョ湅瑙掕壊淇℃伅" + v-if="dialogView" :before-close="handleClose"> + <MyView :userInfo=userInfo @changeDialog="changeDialog" /> + </el-dialog> <!-- tools --> <div class="tools"> <div class="funs"> - <div class="funsItem"> + <!-- <div class="funsItem"> <el-checkbox v-model="all" @change="selectAll()">鍏ㄩ��</el-checkbox> </div> <div class="funsItem"> @@ -83,7 +89,7 @@ :value="item.value" :disabled="item.disabled"> </el-option> </el-select> - </div> + </div> --> </div> <div class="pagination"> <el-pagination background :current-page="currentPage" layout="prev, pager, next" @@ -100,9 +106,10 @@ import createUser from "./createUser" import updateUser from "./updateUser" import helper from "@/utils/mydate.js" +import MyView from './viewRole' export default { components: { - createUser, updateUser + createUser, updateUser,MyView }, data() { return { @@ -110,6 +117,7 @@ context: "", dialogCreate: false, dialogUpdate: false, + dialogView:false, updateFlag: false, userInfo: '', totalNum: null, @@ -118,6 +126,7 @@ all: false, unsame: false, myIdx: 0, + preMyIdx: 0, options: [ { value: 0, @@ -144,12 +153,56 @@ this.getUserList(); }, methods: { - selectChange(list) { - console.log(list); + 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; + this.tempList = []; + list.forEach(item => { + this.tempList.push(item.id); + }) if (list.length === this.tableData.length) { this.all = true; } else { @@ -160,27 +213,26 @@ return helper(createTime); }, selectAll() { - this.$refs.multipleTable.toggleAllSelection(); }, disSame(list) { - // console.log(this.$refs.multipleTable); - // const row = this.$refs.table.data list.forEach(row => { this.$refs.multipleTable.toggleRowSelection(row) }) }, - handleDelete({ id }) { + handleDelete(id) { const that = this; - let arr = []; - arr.push(id); + // let arr = []; + // arr.push(id); this.$confirm('纭鍒犻櫎锛�') .then(_ => { that.$axios({ method: 'post', - url: 'sccg/role/delete?ids=' + arr, + url: 'sccg/role/delete?ids=' + id, }) .then(res => { + this.myIdx = 0; + this.preMyIdx = 0; console.log(res); this.$message({ type: 'success', @@ -201,19 +253,12 @@ // 淇敼鐢ㄦ埛鐘舵�� handleChangeStatus(obj) { let { id, status } = obj; - status == true ? status = 1 : status = 0; - console.log(id, status); + status == true ? status = 0 : status = 1; this.$axios.post(`/sccg/role/updateStatus/` + id + '?status=' + status).then(res => { - console.log(res); + if(res.code ===200){ + this.search(); + } }) - }, - handleStop(obj) { - // let { id, status } = obj; - // status == true ? status = 1 : status = 0; - // console.log(id, status); - // this.$axios.post(`/sccg/role/updateStatus/` + id + '?status=' + status).then(res => { - // this.getUserList(); - // }) }, // 鑾峰彇鐢ㄦ埛鍒楄〃 getUserList() { @@ -268,8 +313,7 @@ }, // 鏌ョ湅鐢ㄦ埛淇℃伅(涓嶅彲淇敼) handleFind(rowData) { - this.dialogUpdate = true; - this.updateFlag = false; + this.dialogView = true; this.userInfo = rowData; }, // 淇敼鐢ㄦ埛閮ㄩ棬淇℃伅 @@ -293,15 +337,28 @@ this.currentPage = page; this.search(); }, - changeDialog(val) { - this.dialogUpdate = val.dialogUpdate; - console.log(val); + changeDialog({flag}) { + this.dialogUpdate = flag; + this.dialogCreate = flag; + this.dialogView = flag; }, handleClose(done) { - this.$confirm('纭鍏抽棴锛�') + if(this.updateFlag){ + this.$confirm('纭鍏抽棴锛�') .then(_ => { this.dialogUpdate = false; this.dialogCreate = false; + this.updateFlag = false; + done(); + }) + .catch(_ => { }); + }else{ + done(); + } + }, + handleClose2(done){ + this.$confirm('纭鍏抽棴锛�') + .then(_ => { done(); }) .catch(_ => { }); @@ -447,15 +504,6 @@ .el-table { color: #4b9bb7; font-size: 10px; - - &::v-deep .el-table__empty-block { - background-color: #09152f; - } - - &::v-deep .el-table__empty-block { - color: #4b9bb7; - } - .operation { display: flex; @@ -468,70 +516,34 @@ } } } + // &::v-deep .switchStyle .el-switch__label { + // position: absolute; + // display: none; + // color: #fff; + // } - .el-table::v-deep .warning-row { - background: #06122c; - } + // &::v-deep .el-switch__core { + // background-color: rgba(166, 166, 166, 1); + // } - .el-table::v-deep .success-row { - background: #071f39; - } + // &::v-deep .switchStyle .el-switch__label--left { + // z-index: 9; + // left: 20px; + // } - &::v-deep .switchStyle .el-switch__label { - position: absolute; - display: none; - color: #fff; - } + // &::v-deep .switchStyle .el-switch__label--right { + // z-index: 9; + // left: 4px; + // } - &::v-deep .el-switch__core { - background-color: rgba(166, 166, 166, 1); - } + // &::v-deep .switchStyle .el-switch__label.is-active { + // display: block; + // } - &::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; - } - } - - &::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: #4b9bb7; - } - - &::v-deep .el-dialog__close { - width: 20px; - height: 20px; - // color: #fff; - } - - &::v-deep .el-dialog__body { - padding: 0; + // &::v-deep .switchStyle.el-switch .el-switch__core, + // &::v-deep .el-switch .el-switch__label { + // width: 50px !important; + // } } } </style> \ No newline at end of file -- Gitblit v1.8.0