123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main">
- <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
- <el-col :span="24" class="container">
- <el-col :span="24" class="top">
- <el-button type="primary" size="mini" @click="$router.push({ path: '/links/detail' })">添加</el-button>
- </el-col>
- <el-col :span="24" class="list">
- <data-table :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
- </el-col>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import breadcrumb from '@c/common/breadcrumb.vue';
- import dataTable from '@/components/frame/filter-page-table.vue';
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: link } = createNamespacedHelpers('link');
- export default {
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- name: 'index',
- props: {},
- components: {
- breadcrumb,
- dataTable,
- },
- data: function() {
- return {
- opera: [
- {
- label: '修改',
- icon: 'el-icon-edit',
- method: 'edit',
- },
- {
- label: '删除',
- icon: 'el-icon-delete',
- method: 'delete',
- },
- ],
- fields: [
- { label: '名称', prop: 'name', filter: 'input' },
- { label: '相关链接', prop: 'url' },
- { label: '图片地址', prop: 'pic' },
- ],
- list: [],
- total: 0,
- };
- },
- created() {
- this.search();
- },
- methods: {
- ...link(['query', 'delete']),
- // 查询列表
- async search({ skip = 0, limit = 10, ...info } = {}) {
- const res = await this.query({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- console.log('asd');
- this.$set(this, `list`, res.data);
- this.$set(this, `total`, res.total);
- }
- },
- // 修改
- toEdit({ data }) {
- this.$router.push({ path: '/links/detail', query: { id: data.id } });
- },
- // 删除
- async toDelete({ data }) {
- const res = await this.delete(data.id);
- if (this.$checkRes(res)) {
- this.$message({
- message: '刪除成功',
- type: 'success',
- });
- this.search();
- }
- },
- },
- computed: {
- ...mapState(['user']),
- },
- };
- </script>
- <style lang="less" scoped>
- .main {
- .top {
- text-align: right;
- margin: 15px 0;
- }
- }
- </style>
|