| | |
| | | <span>信息显隐筛选</span> |
| | | </div> |
| | | <div slot="default" style="margin-left: 20px;margin-top: 20px"> |
| | | <el-table :data="pagedColumns" style="width: 95%; height: 80%;;margin-bottom: 40px;"> |
| | | <el-table :data="getPage" style="width: 95%; height: 80%;;margin-bottom: 40px;"> |
| | | <el-table-column prop="index" label="序号" width="80"></el-table-column> |
| | | <el-table-column prop="label" label="数据名称"></el-table-column> |
| | | <el-table-column prop="visible" label="是否显示"> |
| | |
| | | ></el-pagination> |
| | | </div> |
| | | <div style="position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; text-align: right;"> |
| | | <el-button type="primary" @click="save" v-if="isAdmin()">保 存</el-button> |
| | | <el-button @click="table = false">取 消</el-button> |
| | | <el-button type="primary" @click="resetSort">重 置</el-button> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import {saveHiddenList} from "@/api/projectEngineering/projectInfo"; |
| | | |
| | | import CircularJSON from 'circular-json' |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | table: false, |
| | | currentPage: 1, |
| | | columnRef: null, |
| | | cpList: [] |
| | | cpList: [], |
| | | saveList:[], |
| | | }; |
| | | }, |
| | | props: { |
| | |
| | | columns: { |
| | | type: Array, |
| | | default: () => [], |
| | | }, |
| | | hiddenTotal:{ |
| | | type: Number, |
| | | default: 0, |
| | | }, |
| | | search: { |
| | | type: Boolean, |
| | |
| | | return 10; |
| | | }, |
| | | total() { |
| | | return this.columns.length; |
| | | return this.hiddenTotal; |
| | | }, |
| | | pagedColumns() { |
| | | const start = (this.currentPage - 1) * this.pageSize; |
| | | const end = start + this.pageSize; |
| | | return this.columns.slice(start, end); |
| | | }, |
| | | getPage(){ |
| | | return this.columns; |
| | | } |
| | | }, |
| | | |
| | | methods: { |
| | | isAdmin(){ |
| | | return this.$auth.hasRole("admin") |
| | | }, |
| | | toggleSearch() { |
| | | this.$emit('update:showSearch', !this.showSearch); |
| | | }, |
| | |
| | | this.table = true; |
| | | }, |
| | | switchChange(row) { |
| | | row.sort = row.serialNumber; |
| | | if (row.visible === true){ |
| | | row.display = "1" |
| | | }else { |
| | | row.display = "0" |
| | | } |
| | | if(this.saveList.length === 0){ |
| | | this.saveList.push(row) |
| | | }else { |
| | | let have = true; |
| | | this.saveList.forEach((item ,index)=>{ |
| | | if (item.id === row.id){ |
| | | item[index] =item; |
| | | have =false; |
| | | } |
| | | }) |
| | | if (have){ |
| | | this.saveList.push(row) |
| | | } |
| | | } |
| | | console.log(this.saveList) |
| | | this.$emit('update:columns', row); |
| | | }, |
| | | handlePageChange(page) { |
| | | this.currentPage = page; |
| | | this.$emit('update:page', page); |
| | | // this.currentPage = page; |
| | | // this.queryParams.currentPage = page; |
| | | // getHiddenList(this.queryParams).then(res =>{ |
| | | // //转换 |
| | | // res.data.forEach((item,index)=>{ |
| | | // item.index = index + 1; |
| | | // item.key = index; |
| | | // item.serialNumber = index + 1; |
| | | // item.label = item.name; |
| | | // if(item.display === '0'){ |
| | | // item.visible = false |
| | | // }else { |
| | | // item.visible = true; |
| | | // } |
| | | // if(item.columns ==='usedStatus' ){ |
| | | // if(projectPhase !== '6') { |
| | | // item.visible = false |
| | | // } else { |
| | | // item.visible = true |
| | | // } |
| | | // } |
| | | // }); |
| | | // this.columns = res.data; |
| | | // }) |
| | | |
| | | }, |
| | | save(){ |
| | | //保存逻辑 |
| | | |
| | | if (this.saveList.length !== 0){ |
| | | saveHiddenList(CircularJSON.stringify(this.saveList)).then(res =>{ |
| | | this.$modal.msgSuccess(res.msg); |
| | | }); |
| | | } |
| | | }, |
| | | sortChange(row, val) { |
| | | row.sort = row.serialNumber; |
| | | if (row.visible === true){ |
| | | row.display = "1" |
| | | }else { |
| | | row.display = "0" |
| | | } |
| | | if(this.saveList.length === 0){ |
| | | this.saveList.push(row) |
| | | }else { |
| | | let have = true; |
| | | this.saveList.forEach((item ,index)=>{ |
| | | if (item.id === row.id){ |
| | | item[index] =item; |
| | | have =false; |
| | | } |
| | | }) |
| | | if (have){ |
| | | this.saveList.push(row) |
| | | } |
| | | } |
| | | // // 创建一个新的columns数组,以避免直接修改原始数组 |
| | | // this.cpList = this.columns.map(item => ({ ...item })); // 使用解构来创建对象的浅拷贝 |
| | | // |
| | |
| | | this.$emit('update:sort', row); |
| | | }, |
| | | resetSort() { |
| | | //重置保存集合 |
| | | this.currentPage = 1; |
| | | this.saveList = []; |
| | | this.$emit('update:resetSort'); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | |
| | | this.columns.forEach((item, index) => { |
| | | if (item.visible) { |
| | | |