Skip to content

Commit

Permalink
移除加载更多,在一页内加载所有配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Clinkzzzzzz committed Jul 20, 2020
1 parent f828d9d commit 6dfe3bc
Showing 1 changed file with 114 additions and 113 deletions.
227 changes: 114 additions & 113 deletions joyqueue-console/joyqueue-portal/src/views/setting/config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
@on-selection-change="handleSelectionChange" @on-edit="edit" @on-del="del">
</my-table>

<d-button class="right load-btn" v-if="this.curIndex < this.cacheList.length-1" type="primary" @click="getRestList">加载更多
<icon name="refresh-cw" style="margin-left: 3px;"></icon>
</d-button>
<!-- <d-button class="right load-btn" v-if="this.curIndex < this.cacheList.length-1" type="primary" @click="getRestList">加载更多
<icon name="refresh-cw" style="margin-left: 3px;"></icon>
</d-button>-->

<!--新增-->
<my-dialog :dialog="addDialog" @on-dialog-confirm="addConfirm()" @on-dialog-cancel="dialogCancel('addDialog')" >
Expand All @@ -29,128 +29,129 @@

<script>
import myTable from '../../components/common/myTable.vue'
import myDialog from '../../components/common/myDialog.vue'
import configForm from './configForm.vue'
import crud from '../../mixins/crud.js'
import apiRequest from '../../utils/apiRequest'
import ButtonGroup from '../../components/button/button-group'
import myTable from '../../components/common/myTable.vue'
import myDialog from '../../components/common/myDialog.vue'
import configForm from './configForm.vue'
import crud from '../../mixins/crud.js'
import apiRequest from '../../utils/apiRequest'
import ButtonGroup from '../../components/button/button-group'
export default {
name: 'config',
components: {
myTable,
myDialog,
configForm,
ButtonGroup
},
mixins: [ crud ],
data () {
return {
curIndex: 0,
cacheList: [],
searchData: {
keyword: ''
},
tableData: {
rowData: [],
colData: [
{
title: 'ID',
key: 'id',
width: '30%'
},
{
title: '',
key: 'key',
width: '30%'
},
{
title: '分组',
key: 'group',
width: '30%'
}, {
title: '',
key: 'value',
width: '10%'
export default {
name: 'config',
components: {
myTable,
myDialog,
configForm,
ButtonGroup
},
mixins: [ crud ],
data () {
return {
curIndex: 0,
cacheList: [],
searchData: {
keyword: ''
},
tableData: {
rowData: [],
colData: [
{
title: 'ID',
key: 'id',
width: '30%'
},
{
title: '',
key: 'key',
width: '30%'
},
{
title: '分组',
key: 'group',
width: '30%'
}, {
title: '',
key: 'value',
width: '10%'
}
],
btns: [
{
txt: '编辑',
method: 'on-edit'
},
{
txt: '删除',
method: 'on-del'
}
]
},
addDialog: {
visible: false,
title: '新建配置',
showFooter: true
},
addData: {},
editDialog: {
visible: false,
title: '编辑配置',
showFooter: true
},
editData: {}
}
},
methods: {
getList () {
this.tableData.rowData = []
this.showTablePin = true
let data = this.getSearchVal()
apiRequest.post(this.urlOrigin.search, {}, data).then((data) => {
if (data === '') {
return
}
],
btns: [
{
txt: '编辑',
method: 'on-edit'
},
{
txt: '删除',
method: 'on-del'
data.data = data.data || []
data.pagination = data.pagination || {
totalRecord: data.data.length
}
]
},
addDialog: {
visible: false,
title: '新建配置',
showFooter: true
},
addData: {},
editDialog: {
visible: false,
title: '编辑配置',
showFooter: true
},
editData: {}
}
},
methods: {
getList () {
this.tableData.rowData = []
this.showTablePin = true
let data = this.getSearchVal()
apiRequest.post(this.urlOrigin.search, {}, data).then((data) => {
if (data === '') {
return
}
data.data = data.data || []
data.pagination = data.pagination || {
totalRecord: data.data.length
}
this.page.total = data.pagination.totalRecord
this.page.page = data.pagination.page
this.page.size = data.pagination.size
if (data.data.length > this.page.size) {
this.tableData.rowData = data.data.slice(0, this.page.size)
this.curIndex = this.page.size - 1
} else {
this.page.total = data.pagination.totalRecord
this.page.page = data.pagination.page
this.page.size = data.pagination.size
/* if (data.data.length > this.page.size) {
this.tableData.rowData = data.data.slice(0, this.page.size)
this.curIndex = this.page.size - 1
} else {*/
this.tableData.rowData = data.data
this.curIndex = data.data.length - 1
}
this.cacheList = data.data
this.showTablePin = false
})
},
getRestList () {
if (this.curIndex < this.cacheList.length - 1) {
for (let i = 0; i < this.page.size; i++) {
if (this.curIndex < this.cacheList.length - 1) {
this.curIndex += 1
if (!this.tableData.rowData.includes(this.cacheList[this.curIndex])) {
this.tableData.rowData.push(this.cacheList[this.curIndex])
/* }*/
this.cacheList = data.data
this.showTablePin = false
})
}
/*getRestList () {
if (this.curIndex < this.cacheList.length - 1) {
for (let i = 0; i < this.page.size; i++) {
if (this.curIndex < this.cacheList.length - 1) {
this.curIndex += 1
if (!this.tableData.rowData.includes(this.cacheList[this.curIndex])) {
this.tableData.rowData.push(this.cacheList[this.curIndex])
}
} else {
break
}
} else {
break
}
}
}
}*/
},
mounted () {
this.getList()
}
},
mounted () {
this.getList()
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.label{text-align: right; line-height: 32px;}
.val{}
.load-btn { margin-right: 50px;margin-top: -30px;position: relative}
.label{text-align: right; line-height: 32px;}
.val{}
.load-btn { margin-right: 50px;margin-top: -30px;position: relative}
</style>

0 comments on commit 6dfe3bc

Please sign in to comment.