123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main">
- <el-col :span="24" class="top">
- <el-button type="primary" size="mini" @click="add">添加</el-button>
- </el-col>
- <el-col :span="24" class="down">
- <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import dataTable from '@common/src/components/frame/filter-page-table.vue';
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: mappatentnav } = createNamespacedHelpers('patentnav');
- export default {
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- name: 'index',
- props: {},
- components: { dataTable },
- data: function() {
- return {
- opera: [
- {
- label: '编辑',
- method: 'edit',
- },
- {
- label: '删除',
- method: 'delete',
- },
- ],
- fields: [
- { label: '信息标题', prop: 'title' },
- { label: '信息来源', prop: 'origin' },
- { label: '发布时间', prop: 'publish_time' },
- {
- label: '是否展示',
- prop: 'is_show',
- format: item => {
- return item === true ? '展示' : '不展示';
- },
- },
- ],
- list: [],
- total: 0,
- };
- },
- async created() {
- await this.search();
- },
- methods: {
- ...mappatentnav(['query', 'fetch', 'create', 'update', 'delete']),
- async search({ skip = 0, limit = 10, ...info } = {}) {
- info.user_id = this.user.id;
- let res = await this.query({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- this.$set(this, `list`, res.data);
- this.$set(this, `total`, res.total);
- }
- },
- // 修改
- toEdit({ data }) {
- this.$router.push({ path: '/patentnav/detail', query: { id: data.id } });
- },
- // 删除
- async toDelete({ data }) {
- let res = await this.delete(data.id);
- if (this.$checkRes(res)) {
- this.$message({
- message: '信息删除成功',
- type: 'success',
- });
- this.search();
- }
- },
- // 添加数据
- add() {
- this.$router.push({ path: '/dimension/detail' });
- },
- },
- computed: {
- ...mapState(['user']),
- },
- watch: {},
- };
- </script>
- <style lang="less" scoped>
- .main {
- .top {
- text-align: right;
- margin: 0 0 10px 0;
- }
- }
- </style>
|