You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
5.2 KiB

<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.biaoti" placeholder="请输入标题"></el-input>
</div>
<div>
<el-select v-model="select.leibie" placeholder="请选择类别" clearable>
<el-option v-for="item in leibie_options" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
<div>
<el-button type="primary" size="small" @click="getList">查询</el-button>
</div>
<div>
<el-button type="primary" size="small" @click="editNotice('add')">新增</el-button>
</div>
</div>
</div>
</lx-header>
</div>
</div>
<div>
<xy-table :list="list" :total="total" :table-item="table_item">
<template v-slot:btns>
<el-table-column align='center' label="操作" width="180" header-align="center">
<template slot-scope="scope">
<el-button type="primary" size="small" @click="editNotice('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>
<add-notice ref="addNotice" @refresh="getList"></add-notice>
</div>
</template>
<script>
import addNotice from './components/addNotice.vue';
import {
index,
destroy
} from "@/api/system/baseForm.js"
export default {
components: {
addNotice
},
data() {
return {
select: {
biaoti: '',
leibie: '',
table_name: 'notices',
page: 1,
page_size: 10
},
leibie_options: [{
id: 1,
value: '公告'
}, {
id: 2,
value: '通知'
}],
gzh_options:[{
id:0,
value:'否'
},{
id:1,
value:'是'
}],
zt_options:[{
id:0,
value:'待发布'
},{
id:1,
value:'发布'
}],
list: [],
total: 0,
table_item: [{
prop: 'biaoti',
label: '标题',
align: 'left'
}, {
prop: 'leibie',
label: '类别',
align: 'center',
width: 160,
customFn: (row) => {
return this.leibie_options.map(item=>{
if(item.id===row.leibie){
return item.value
}
})
}
}, {
prop: 'shifoutongbugongzhonghao',
label: '是否同步公众号',
align: 'center',
width: 160,
customFn: (row) => {
return this.gzh_options.map(item=>{
if(item.id===row.shifoutongbugongzhonghao){
return item.value
}
})
}
}, {
prop: 'zhuangtai',
label: '发布状态',
align: 'center',
width: 160,
customFn: (row) => {
return this.zt_options.map(item=>{
if(item.id===row.zhuangtai){
return item.value
}
})
}
}]
}
},
created() {
this.getList()
},
methods: {
editNotice(type, id) {
if(type=='editor'){
this.$refs.addNotice.id = id
}
this.$refs.addNotice.type = type
this.$refs.addNotice.isShow = true
},
async getList() {
const res = await index({
page_size: this.select.page_size,
page: this.select.page,
table_name: this.select.table_name,
filter: [{
"key": "biaoti",
"op": "like",
"value": this.select.biaoti
},
{
"key": "leibie",
"op": "eq",
"value": this.select.leibie
}
],
})
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;
}
}
}
</style>