|
@@ -28,17 +28,26 @@
|
|
|
信息列表
|
|
|
</el-col>
|
|
|
<el-col :span="18" class="btn">
|
|
|
- <el-button type="primary" size="mini" @click="newdialog = true"><i class="el-icon-plus"></i></el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="addnews()"><i class="el-icon-plus"></i></el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="24">
|
|
|
- <data-table :fields="newfields" :opera="newopera" :data="newslist" :total="total" @edit="newtoEdit" @delete="newtoDelete"></data-table>
|
|
|
+ <data-table
|
|
|
+ :fields="newfields"
|
|
|
+ :opera="newopera"
|
|
|
+ :data="newslist"
|
|
|
+ @query="searchnews"
|
|
|
+ :toFormat="toFormat"
|
|
|
+ :total="total"
|
|
|
+ @edit="newtoEdit"
|
|
|
+ @delete="newtoDelete"
|
|
|
+ ></data-table>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-dialog :visible.sync="coldialog" title="栏目" @close="coltoClose" width="30%">
|
|
|
- <data-form :data="colform" :fields="turnBedRoomFields" :rules="{}" @save="turnSave">
|
|
|
+ <data-form :data="colform" :fields="colFields" :rules="{}" @save="turnSave">
|
|
|
<template #options="{item}">
|
|
|
<template v-if="item.model === 'site'">
|
|
|
<el-option label="图片新闻" value="tpxw"></el-option>
|
|
@@ -97,7 +106,7 @@ export default {
|
|
|
column: [],
|
|
|
coldialog: false,
|
|
|
colform: {},
|
|
|
- turnBedRoomFields: [
|
|
|
+ colFields: [
|
|
|
{ label: '名称', model: 'name' },
|
|
|
{ label: '所在位置', model: 'site', type: 'select' },
|
|
|
],
|
|
@@ -115,16 +124,18 @@ export default {
|
|
|
},
|
|
|
],
|
|
|
newfields: [
|
|
|
- { label: '名称', model: 'title' },
|
|
|
- { label: '所属栏目', model: 'column_name' },
|
|
|
+ { label: '名称', prop: 'title', showTip: true },
|
|
|
+ { label: '信息来源', prop: 'orgin' },
|
|
|
+ { label: '所属栏目', prop: 'column_id', format: true },
|
|
|
],
|
|
|
newslist: [],
|
|
|
total: 0,
|
|
|
column_id: '',
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
- this.searchcolumn();
|
|
|
+ async created() {
|
|
|
+ await this.searchcolumn();
|
|
|
+ await this.searchnews();
|
|
|
},
|
|
|
methods: {
|
|
|
...mapColumn({ colquery: 'query', colfetch: 'fetch', coldelete: 'delete', colcreate: 'create', colupdate: 'update' }),
|
|
@@ -195,25 +206,39 @@ export default {
|
|
|
this.$set(this, `column_id`, data.id);
|
|
|
this.searchnews();
|
|
|
},
|
|
|
+ // 查询信息
|
|
|
async searchnews({ skip = 0, limit = 10 } = {}) {
|
|
|
let res = await this.newquery({ skip, limit, column_id: this.column_id });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- for (const val of res.data) {
|
|
|
- let result = await this.colfetch(val.column_id);
|
|
|
- val.column_name = result.data.name;
|
|
|
- }
|
|
|
- console.log(res.data);
|
|
|
this.$set(this, `newslist`, res.data);
|
|
|
this.$set(this, `total`, res.total);
|
|
|
}
|
|
|
},
|
|
|
+ // 过滤栏目
|
|
|
+ toFormat({ model, value }) {
|
|
|
+ if (model == 'column_id') {
|
|
|
+ const res = this.column.find(f => f.id == value);
|
|
|
+ if (res) return res.name;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 添加信息
|
|
|
+ addnews() {
|
|
|
+ this.$router.push({ path: 'government/detail' });
|
|
|
+ },
|
|
|
// 修改信息
|
|
|
newtoEdit({ data }) {
|
|
|
- console.log(data);
|
|
|
+ this.$router.push({ path: 'government/detail', query: { id: data.id } });
|
|
|
},
|
|
|
// 删除信息
|
|
|
- newtoDelete({ data }) {
|
|
|
- console.log(data);
|
|
|
+ async newtoDelete({ data }) {
|
|
|
+ const res = await this.newdelete(data.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '刪除成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.searchnews();
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
computed: {
|