123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <div class="">
- <toolbar @on-filter="filterData" @on-reset="filterData" />
- <div class="m-10 bg-w p-20 br-10">
- <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
- >新增</el-button
- >
- <base-table
- :columns="columns"
- :items="items"
- :pagination="pagination"
- :page-change="pageChange"
- />
- </div>
- </div>
- </template>
- <script>
- import toolbar from './toolbar';
- import mxFilterList from '@/mixins/filterList';
- import { getList, delItem } from '@/api/base/info';
- export default {
- name: 'InfoManagement',
- components: { toolbar },
- mixins: [
- mxFilterList({
- fetchList: getList // 在下方data再声明一个 fetchList: iGetList 同等效果
- })
- ],
- data() {
- return {
- columns: [
- {
- key: 'title',
- name: '标题',
- minWidth: '240'
- },
- {
- key: 'author',
- name: '作者',
- width: '160'
- },
- {
- key: 'createAt',
- name: '发布时间',
- width: '140'
- },
- {
- key: 'looks',
- name: '阅读',
- width: '120',
- render: (h, { row }) => h('span', row.looks)
- },
- {
- key: 'likes',
- name: '点赞',
- width: '120',
- render: (h, { row }) => h('span', row.likes)
- },
- {
- key: 'collections',
- name: '收藏',
- width: '120',
- render: (h, { row }) => h('span', row.collections)
- },
- {
- key: 'sort',
- name: '排序',
- width: '80'
- },
- {
- key: 'isShow',
- name: '状态',
- width: '80',
- type: 'tag',
- fetchTagType: val => (val ? 'success' : 'info'),
- tagName: row => (row.isShow ? '显示' : '隐藏')
- },
- {
- key: 'action',
- name: '操作',
- width: '120',
- render: (h, { row }) => {
- const action = [];
- action.push(
- h(
- 'el-button',
- {
- props: {
- type: 'text'
- },
- on: {
- click: () =>
- this.$InfoItemModal({
- id: row.id
- })
- }
- },
- '编辑'
- )
- );
- action.push(
- h(
- 'BaseBtn',
- {
- props: {
- popip: true,
- txt: '删除',
- type: 'text'
- },
- class: 'ml-10',
- on: {
- ok: () => this.handleDelItem(row)
- }
- },
- '删除'
- )
- );
- return h('div', action);
- }
- }
- ]
- };
- },
- created() {
- this.$g_on('base_info_reload', this.reload);
- },
- beforeDestroy() {
- this.$g_off('base_info_reload', this.reload);
- },
- methods: {
- handleAdd() {
- this.$InfoItemModal();
- },
- async handleDelItem(item) {
- const { success, msg } = await delItem({
- id: item.id
- });
- if (success) {
- this.$success('删除成功!');
- this.$g_emit('base_info_reload');
- }
- }
- }
- };
- </script>
- <style type="scss" scoped></style>
|