|
@@ -0,0 +1,141 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="index">
|
|
|
|
+ <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">
|
|
|
|
+ <el-autocomplete v-model="goods" :fetch-suggestions="querySearchAsync" placeholder="请输入商品名称"
|
|
|
|
+ @select="handleSelect"></el-autocomplete>
|
|
|
|
+ </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 :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @add="toAdd">
|
|
|
|
+ </data-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+const _ = require('lodash');
|
|
|
|
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions } = createNamespacedHelpers('goodsJoinAct');
|
|
|
|
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
|
|
|
|
+const { mapActions: goods } = createNamespacedHelpers('goods');
|
|
|
|
+export default {
|
|
|
|
+ name: 'index',
|
|
|
|
+ props: {},
|
|
|
|
+ components: {},
|
|
|
|
+ data: function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ return {
|
|
|
|
+ // 列表
|
|
|
|
+ opera: [{ label: '添加', method: 'add' }],
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '活动标题', model: 'title' },
|
|
|
|
+ { label: '活动时间', model: 'act_time.value' },
|
|
|
|
+ {
|
|
|
|
+ label: '是否开启',
|
|
|
|
+ model: 'is_use',
|
|
|
|
+ format: (i) => {
|
|
|
|
+ let data = that.isuseList.find((f) => f.value == i);
|
|
|
|
+ if (data) return data.label;
|
|
|
|
+ else return '暂无';
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '是否在首页显示',
|
|
|
|
+ model: 'show_index',
|
|
|
|
+ format: (i) => {
|
|
|
|
+ let data = that.isuseList.find((f) => f.value == i);
|
|
|
|
+ if (data) return data.label;
|
|
|
|
+ else return '暂无';
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ // 商品搜索
|
|
|
|
+ goods: '',
|
|
|
|
+ goodsList: [],
|
|
|
|
+ // 是否开启
|
|
|
|
+ isuseList: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ async created() {
|
|
|
|
+ await this.searchOther();
|
|
|
|
+ await this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...dictData({ dictQuery: 'query' }),
|
|
|
|
+ ...goods({ gQuery: 'query' }),
|
|
|
|
+ ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
|
+ // 查询
|
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ const condition = _.cloneDeep(this.searchForm);
|
|
|
|
+ let res = await this.gQuery({ skip, limit, ...condition, ...info });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, 'goodsList', res.data);
|
|
|
|
+ // this.$set(this, 'total', res.total);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 新增
|
|
|
|
+ toAdd({ data }) {
|
|
|
|
+ console.log(data);
|
|
|
|
+ },
|
|
|
|
+ // 重置
|
|
|
|
+ toClose() {
|
|
|
|
+ this.goods = '';
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ async searchOther() {
|
|
|
|
+ let res;
|
|
|
|
+ // 是否使用
|
|
|
|
+ res = await this.dictQuery({ code: 'use' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `isuseList`, res.data);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['user']),
|
|
|
|
+ id() {
|
|
|
|
+ return this.$route.query.id;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ metaInfo() {
|
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ test: {
|
|
|
|
+ deep: true,
|
|
|
|
+ immediate: true,
|
|
|
|
+ handler(val) { },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<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>
|