<template>
|
<div>
|
<a-card
|
:bordered="true"
|
style="height: 50%"
|
>
|
<a-row type="flex">
|
<a-col><a-button
|
type="primary"
|
@click="handleAdd(da)"
|
>新建</a-button></a-col>
|
<a-col><a-button
|
type="primary"
|
@click="handleEdit(da)"
|
>编辑</a-button></a-col>
|
<a-col><a-button
|
type="primary"
|
@click="batchDel(da)"
|
>删除</a-button></a-col>
|
<a-col style="left: 5%"><a-button type="primary">模板</a-button></a-col>
|
<a-col style="left: 5%"><a-button type="primary">导入</a-button></a-col>
|
<a-col style="left: 5%"><a-button type="primary">导出</a-button></a-col>
|
</a-row>
|
</a-card>
|
<a-row
|
type="flex"
|
:gutter="16"
|
>
|
<a-col
|
:md="5"
|
:sm="24"
|
>
|
|
<MomBaseUnitCategoryListLeft
|
ref="MomBaseUnitCategoryListLeft"
|
class="MomBaseUnitCategoryListLeft"
|
@treeSelect="treeSelect"
|
/>
|
|
</a-col>
|
<a-col
|
:md="24 - 5"
|
:sm="24"
|
>
|
<MomBaseUnitCategoryListRight
|
ref="MomBaseUnitCategoryListRight"
|
class="MomBaseUnitCategoryListRight"
|
@searchkeys="selectedKeys"
|
/>
|
</a-col>
|
</a-row>
|
<mom-base-unit-category-modal
|
ref="modalForm"
|
@ok="modalFormOk"
|
></mom-base-unit-category-modal>
|
</div>
|
</template>
|
|
<script>
|
import MomBaseUnitCategoryListLeft from './modules/unitCategory/MomBaseUnitCategoryListLeft'
|
import MomBaseUnitCategoryListRight from './modules/unitCategory/MomBaseUnitCategoryListRight'
|
import MomBaseUnitCategoryModal from './modules/unitCategory/MomBaseUnitCategoryModal'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import { deleteAction } from '@/api/manage'
|
|
export default {
|
name: 'MomBaseUnitCategoryList',
|
mixins: [JeecgListMixin],
|
components: { MomBaseUnitCategoryListLeft, MomBaseUnitCategoryListRight, MomBaseUnitCategoryModal },
|
data() {
|
return {
|
description: '计量单位分类页面',
|
currentOrgCode: '',
|
selectedRowKeys: [],
|
selectionRows: [],
|
url: {
|
list: '/base/getTree',
|
deleteBatch: '/base/delete',
|
},
|
da: [],
|
}
|
},
|
|
methods: {
|
//新增数据(新建按钮触发)
|
handleAdd(da) {
|
if (this.da.length <= 0) {
|
this.$message.warning('请选择一个树节点!')
|
return
|
} else {
|
this.$refs.modalForm.add(da, { cb: this.callback })
|
}
|
},
|
//修改数据(修改按钮触发)
|
handleEdit(da) {
|
if (this.da.length <= 0) {
|
this.$message.warning('请选择一个树节点!')
|
return
|
} else {
|
this.$refs.modalForm.edit(da, { cb: this.loadTree })
|
}
|
},
|
//批量删除右侧数据(删除按钮触发)
|
batchDel(da) {
|
if (!this.url.deleteBatch) {
|
this.$message.error('请设置url.deleteBatch属性!')
|
return
|
}
|
if (this.selectedRowKeys.length <= 0) {
|
this.$message.warning('请选择一条记录!')
|
return
|
} else {
|
var ids = ''
|
for (var a = 0; a < this.selectedRowKeys.length; a++) {
|
ids += this.selectedRowKeys[a] + ','
|
}
|
var that = this
|
this.$confirm({
|
title: '确认删除',
|
content: '是否删除选中数据?',
|
onOk: function () {
|
that.loading = true
|
deleteAction(that.url.deleteBatch, { ids: ids })
|
.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
that.loading = false
|
//重新计算分页问题
|
that.reCalculatePage(that.selectedRowKeys.length)
|
that.onClearSelected()
|
that.$refs.MomBaseUnitCategoryListRight.loadData({ id: da.id })
|
that.loadTree()
|
})
|
},
|
})
|
}
|
},
|
//重新计算分页
|
reCalculatePage(count) {
|
//总数量-count
|
let total = this.ipagination.total - count
|
//获取删除后的分页数
|
let currentIndex = Math.ceil(total / this.ipagination.pageSize)
|
//删除后的分页数<所在当前页
|
if (currentIndex < this.ipagination.current) {
|
this.ipagination.current = currentIndex
|
}
|
console.log('currentIndex', currentIndex)
|
},
|
//清除右侧选中项
|
onClearSelected() {
|
this.selectedRowKeys = []
|
this.selectionRows = []
|
},
|
//左右联动(da为左侧选中树的数据,子控件中返回)
|
treeSelect(da) {
|
let id = da.id
|
this.da = da
|
this.onClearSelected()
|
this.$refs.MomBaseUnitCategoryListRight.loadData({ id })
|
},
|
//右侧列表选中事件
|
selectedKeys(selectedRowKeys) {
|
this.selectedRowKeys = selectedRowKeys
|
},
|
//加载左侧树
|
loadTree() {
|
this.$refs.MomBaseUnitCategoryListLeft.queryTreeData()
|
},
|
//新增编辑保存后回调函数回显页面数据
|
callback(id) {
|
this.$refs.MomBaseUnitCategoryListLeft.queryTreeData()
|
this.$refs.MomBaseUnitCategoryListRight.loadData({ id: id })
|
},
|
},
|
}
|
</script>
|
<style scoped>
|
@import '~@assets/less/common.less';
|
</style>
|