|
@@ -1,27 +1,167 @@
|
|
<template>
|
|
<template>
|
|
<div id="index">
|
|
<div id="index">
|
|
- <p>index</p>
|
|
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
|
+ <el-col :span="24" class="one"> <span>广告图</span> </el-col>
|
|
|
|
+ <el-col :span="24" class="two">
|
|
|
|
+ <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="thr">
|
|
|
|
+ <el-button type="primary" size="mini" @click="toAdd()">新增</el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="four">
|
|
|
|
+ <data-table
|
|
|
|
+ :select="true"
|
|
|
|
+ :selected="selected"
|
|
|
|
+ @handleSelect="handleSelect"
|
|
|
|
+ :fields="fields"
|
|
|
|
+ :opera="opera"
|
|
|
|
+ @query="search"
|
|
|
|
+ :data="list"
|
|
|
|
+ :total="total"
|
|
|
|
+ @edit="toEdit"
|
|
|
|
+ @del="toDel"
|
|
|
|
+ >
|
|
|
|
+ </data-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
|
|
+const _ = require('lodash');
|
|
|
|
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions } = createNamespacedHelpers('banner');
|
|
|
|
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
|
|
export default {
|
|
export default {
|
|
name: 'index',
|
|
name: 'index',
|
|
props: {},
|
|
props: {},
|
|
- components: {},
|
|
|
|
|
|
+ components: {
|
|
|
|
+ search1: () => import('./parts/search-1.vue'),
|
|
|
|
+ },
|
|
data: function () {
|
|
data: function () {
|
|
- return {};
|
|
|
|
|
|
+ const that = this;
|
|
|
|
+ return {
|
|
|
|
+ // 列表
|
|
|
|
+ opera: [
|
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' },
|
|
|
|
+ ],
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '名称', prop: 'name' },
|
|
|
|
+ {
|
|
|
|
+ label: '类型',
|
|
|
|
+ prop: 'type',
|
|
|
|
+ format: (i) => {
|
|
|
|
+ let data = that.typeList.find((f) => f.dict_value == i);
|
|
|
|
+ if (data) return data.dict_label;
|
|
|
|
+ else return '暂无';
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ { label: '路径', prop: 'url' },
|
|
|
|
+ { label: '是否正在使用', prop: 'status' },
|
|
|
|
+ ],
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ // 查询
|
|
|
|
+ searchForm: {},
|
|
|
|
+ // 多选值
|
|
|
|
+ selected: [],
|
|
|
|
+ // 类型列表
|
|
|
|
+ typeList: [],
|
|
|
|
+ // 是否使用
|
|
|
|
+ statusList: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ async created() {
|
|
|
|
+ await this.searchOther();
|
|
|
|
+ await this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...dictData({ dictQuery: 'query' }),
|
|
|
|
+ ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
|
+ // 查询
|
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ const condition = _.cloneDeep(this.searchForm);
|
|
|
|
+ let res = await this.query({ skip, limit, ...condition, ...info });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ this.$set(this, 'list', res.data);
|
|
|
|
+ this.$set(this, 'total', res.total);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 新增
|
|
|
|
+ toAdd() {
|
|
|
|
+ this.$router.push({ path: '/system/banner/detail' });
|
|
|
|
+ },
|
|
|
|
+ // 修改
|
|
|
|
+ async toEdit({ data }) {
|
|
|
|
+ this.$router.push({ path: '/system/banner/detail', query: { id: data._id } });
|
|
|
|
+ },
|
|
|
|
+ async toDel({ data }) {
|
|
|
|
+ let res = await this.delete(data._id);
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$message({ type: `success`, message: `刪除信息成功` });
|
|
|
|
+ this.search();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ toClose() {
|
|
|
|
+ this.searchForm = {};
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ // 多选
|
|
|
|
+ handleSelect(data) {
|
|
|
|
+ this.$set(this, `selected`, data);
|
|
|
|
+ },
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ async searchOther() {
|
|
|
|
+ let res;
|
|
|
|
+ // 类型
|
|
|
|
+ res = await this.dictQuery({ code: 'banner_type' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `typeList`, res.data);
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ }
|
|
|
|
+ res = await this.dictQuery({ code: 'status' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `statusList`, res.data);
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|
|
},
|
|
},
|
|
- created() {},
|
|
|
|
- methods: {},
|
|
|
|
metaInfo() {
|
|
metaInfo() {
|
|
return { title: this.$route.meta.title };
|
|
return { title: this.$route.meta.title };
|
|
},
|
|
},
|
|
|
|
+ watch: {
|
|
|
|
+ test: {
|
|
|
|
+ deep: true,
|
|
|
|
+ immediate: true,
|
|
|
|
+ handler(val) {},
|
|
|
|
+ },
|
|
|
|
+ },
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+.main {
|
|
|
|
+ .one {
|
|
|
|
+ margin: 0 0 10px 0;
|
|
|
|
+
|
|
|
|
+ span:nth-child(1) {
|
|
|
|
+ font-size: 20px;
|
|
|
|
+ font-weight: 700;
|
|
|
|
+ margin-right: 10px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .two {
|
|
|
|
+ margin: 0 0 10px 0;
|
|
|
|
+ }
|
|
|
|
+ .thr {
|
|
|
|
+ margin: 0 0 10px 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|