|
@@ -1,33 +1,77 @@
|
|
|
<template>
|
|
|
<div id="mtjj">
|
|
|
- <el-row>
|
|
|
- <el-col :span="24" class="main"> test </el-col>
|
|
|
- </el-row>
|
|
|
+ <list-page v-bind="$attrs" :total="total" v-if="!id" @toSearch="search" :pageSize="pageSize" searchModel="title">
|
|
|
+ <component :is="model" :list="list"></component>
|
|
|
+ </list-page>
|
|
|
+ <template v-else> 详情 </template>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+const _ = require('lodash');
|
|
|
+import listPage from '@c/list/list-page.vue';
|
|
|
+const { newsColumn } = require('@common/dict/index');
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: news } = createNamespacedHelpers('news');
|
|
|
export default {
|
|
|
name: 'mtjj',
|
|
|
- props: {},
|
|
|
- components: {},
|
|
|
+ props: ['listModel'],
|
|
|
+ components: {
|
|
|
+ listPage,
|
|
|
+ model3: () => import('../list-model/model-3.vue'),
|
|
|
+ },
|
|
|
data: function () {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ // 栏目
|
|
|
+ column: newsColumn,
|
|
|
+ // 列表
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ pageSize: 7,
|
|
|
+ // 详情
|
|
|
+ detail: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...news(['query', 'fetch']),
|
|
|
+ async search({ skip = 0, limit = this.pageSize, ...info } = {}) {
|
|
|
+ info.column_name = this.column[this.listModel];
|
|
|
+ let res = await this.query({ skip, limit, ...info });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 查询详情
|
|
|
+ async searchInfo() {
|
|
|
+ let res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `detail`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
- created() {},
|
|
|
- methods: {},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
+ model() {
|
|
|
+ const moduleNumber = this.listModel || 0;
|
|
|
+ return `model${moduleNumber}`;
|
|
|
+ },
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
},
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
|
},
|
|
|
watch: {
|
|
|
- test: {
|
|
|
- deep: true,
|
|
|
+ id: {
|
|
|
+ handler(ne) {
|
|
|
+ if (ne) this.searchInfo();
|
|
|
+ },
|
|
|
immediate: true,
|
|
|
- handler(val) {},
|
|
|
},
|
|
|
},
|
|
|
};
|