共{{ (mainData.total / costSearch.pageSize) === 0 ? 0 : Math.ceil(mainData.total / costSearch.pageSize) }}页/{{mainData.total}}条数据
:current-page="costSearch.pageNum" layout="sizes, prev, pager, next, jumper" :total='mainData.total'>
.dialog-footer {
text-align: center;
margin-top: 20px;
}
// import Global from '@/js/global.js';
export default {
props: ["ledgerCode"],
data() {
return {
URL: "", //生产环境路径
//URL: Global.test, //ci环境路径
//rootURL: "http://10.118.150.100:8080", //后台测试。连接本地
tableData: [],
mainData: [], //保存分页数据
selections: [],
costSearch: {
pageNum: 1,
pageSize: 10,
id: '',
name: '',
code: '',
ledgerCode: '',//账套ID
// companySegmentValCode: '', //所属公司段 请求中没有此字段
// companySegment:'' , //所属公司段 请求中没有此字段
// segmentType:'SEGMENT1',
}
}
},
//生产环境路径
created() {
// debugger
//this.URL = `${this.$root.loadUrl}/mdm-service`;
this.URL = `${this.$root.loadUrl}`;
this.mainData.total = 0;
},
mounted() {
//父组件带值
this.costSearch.ledgerCode = this.ledgerCode;
this.searchAction();
},
methods: {
//取消关闭
colseAction() {
//console.log('关闭')
// for (var prop in this.costSearch) {
// this.costSearch[prop] = '';
// }
this.$emit('closedCost')
},
//查询
searchAction() {
this.$http.post(this.URL + '/flexValues/queryCostCenter', this.costSearch).then((res) => {
var result = res.body;
// console.log(result)
if (result.code == '000000') {
this.tableData = result.data.list;
this.mainData = result.data;
}
})
},
//保存
saveAction() {
if (this.selections.length == 0) {
this.$message({ type: 'info', message: '请选择数据再保存' });
return;
} else if (this.selections.length > 1) {
this.$message({ type: 'info', message: '仅可选择一条数据进行保存' });
return;
} else {
this.costSearch.name = this.selections[0].name;
this.costSearch.code = this.selections[0].code;
this.costSearch.id = this.selections[0].id;
// debugger
this.$emit('saveCostData', this.costSearch)
}
},
//table框选择
selectItem(selections) {
this.selections = selections;
},
//多选
selection(selections) {
this.selections = selections;
},
//当前页数
handleCurrentChange(currentPage) {
// console.log(`当前 ${currentPage} 页`)
this.costSearch.pageNum = currentPage;
this.searchAction()
},
//当前每页条数
handleSizeChange(pageSize) {
//console.log(`每页 ${pageSize} 条`);
this.costSearch.pageSize = pageSize;
this.searchAction()
}
}
}