master
parent
62081d00ff
commit
d67ccfe548
@ -0,0 +1,212 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<div>
|
||||
<div ref="lxHeader">
|
||||
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
|
||||
<div slot="content">
|
||||
<div class="searchwrap" style="display: flex;align-items: center;">
|
||||
<div>
|
||||
<el-input v-model="select.name" placeholder="请输入名称"></el-input>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="select.page=1,getList()">查询</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="editIndex('add')">新增</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</lx-header>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="catalog">
|
||||
<div class="catalog_left">
|
||||
<el-tree @node-click="getSelectedNodes" :data="catalogList" default-expand-all node-key="id" ref="tree"
|
||||
highlight-current :props="defaultProps">
|
||||
</el-tree>
|
||||
</div>
|
||||
<div class="catalog_right">
|
||||
<xy-table :list="list" :total="total" @pageIndexChange="pageIndexChange" @pageSizeChange="pageSizeChange"
|
||||
:table-item="table_item">
|
||||
<template v-slot:btns>
|
||||
<el-table-column align='center' label="操作" width="240" header-align="center">
|
||||
<template slot-scope="scope">
|
||||
<!-- <el-button type="primary" size="small" @click="editIndex('child',scope.row.id,scope.row.name)">子目录</el-button> -->
|
||||
<el-button type="primary" size="small" @click="editIndex('editor',scope.row.id)">编辑</el-button>
|
||||
<el-popconfirm style="margin:0 10px" @confirm="deleteList(scope.row.id)" title="确定删除吗?">
|
||||
<el-button type="danger" size="small" slot="reference">删除</el-button>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
</xy-table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<add-record ref="addRecord" @refresh="getList"></add-record>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import addRecord from './components/addRecord.vue';
|
||||
import {
|
||||
index,
|
||||
destroy
|
||||
} from "@/api/system/baseForm.js"
|
||||
export default {
|
||||
components: {
|
||||
addRecord
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
select: {
|
||||
title: '',
|
||||
table_name: 'records',
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
catalog_id: ''
|
||||
},
|
||||
total: 0,
|
||||
list: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
catalogList: [],
|
||||
table_item: [{
|
||||
type: 'index',
|
||||
width: 50
|
||||
}, {
|
||||
prop: 'title',
|
||||
label: '标题',
|
||||
align: 'left',
|
||||
},
|
||||
// {
|
||||
// prop: 'catalog_name',
|
||||
// label: '所属目录',
|
||||
// align: 'left',
|
||||
// },
|
||||
{
|
||||
prop: 'date',
|
||||
label: '发布日期',
|
||||
align: 'center',
|
||||
width: 120
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//
|
||||
this.getCatalogList()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
async getCatalogList() {
|
||||
const res = await index({
|
||||
page_size: 999,
|
||||
page: 1,
|
||||
sort_type: 'ASC',
|
||||
sort_name: 'sort',
|
||||
table_name: 'catalogs'
|
||||
})
|
||||
if (res.data.length > 0) {
|
||||
this.catalogList = this.base.buildTree(res.data)
|
||||
}
|
||||
},
|
||||
getSelectedNodes(data, node, self) {
|
||||
node.expanded = true
|
||||
this.select.catalog_id = data.id
|
||||
this.select.page = 1
|
||||
this.getList()
|
||||
|
||||
},
|
||||
|
||||
|
||||
editIndex(type, id, pName) {
|
||||
if (type == 'editor') {
|
||||
this.$refs.addRecord.id = id
|
||||
}
|
||||
this.$refs.addRecord.type = type
|
||||
this.$refs.addRecord.isShow = true
|
||||
},
|
||||
pageIndexChange(e) {
|
||||
this.select.page = e
|
||||
this.getList()
|
||||
},
|
||||
pageSizeChange(e) {
|
||||
this.select.page_size = e
|
||||
this.select.page = 1
|
||||
this.getList()
|
||||
},
|
||||
async getList() {
|
||||
const res = await index({
|
||||
page_size: this.select.page_size,
|
||||
page: this.select.page,
|
||||
table_name: this.select.table_name,
|
||||
filter: [{
|
||||
"key": "title",
|
||||
"op": "like",
|
||||
"value": this.select.title
|
||||
}, {
|
||||
key: 'catalog_id',
|
||||
op: 'eq',
|
||||
value: this.select.catalog_id
|
||||
}]
|
||||
})
|
||||
this.list = res.data
|
||||
this.total = res.total
|
||||
},
|
||||
deleteList(id) {
|
||||
var that = this;
|
||||
destroy({
|
||||
id: id,
|
||||
table_name: this.select.table_name
|
||||
}).then(response => {
|
||||
this.$Message.success('操作成功');
|
||||
this.getList()
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
reject(error)
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.searchwrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&>div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 10px;
|
||||
|
||||
span {
|
||||
min-width: 70px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.catalog {
|
||||
display: flex;
|
||||
// align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
&_left {
|
||||
width: 30%;
|
||||
background: #fff;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
&_right {
|
||||
width: 68%
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue