YY 2 anni fa
parent
commit
e402ac3aa8

+ 6 - 0
src/router/module/system.js

@@ -17,6 +17,12 @@ export default [
     meta: { title: '系统管理-首页图标设置' },
     component: () => import(/* webpackChunkName: "system_indexModule" */ '@/views/system/indexModule/index.vue'),
   },
+  {
+    path: '/system/indexModule/detail',
+    name: 'system_indexModule_detail',
+    meta: { title: '系统管理-首页图标设置-维护信息' },
+    component: () => import(/* webpackChunkName: "system_indexModule_detail" */ '@/views/system/indexModule/detail.vue'),
+  },
   {
     path: '/system/goodsTags',
     name: 'system_goodsTags',

+ 11 - 1
src/store/index.js

@@ -9,6 +9,7 @@ import dictIndex from './module/dev/dictIndex';
 import dictData from './module/dev/dictData';
 import goodsTags from './module/system/goodsTags';
 import banner from './module/system/banner';
+import indexModule from './module/system/indexModule';
 
 Vue.use(Vuex);
 
@@ -16,5 +17,14 @@ export default new Vuex.Store({
   state: { ...ustate },
   mutations: { ...umutations },
   actions: {},
-  modules: { admin, selfShop, goods, dictIndex, dictData, goodsTags, banner },
+  modules: {
+    admin,
+    selfShop,
+    goods,
+    dictIndex,
+    dictData,
+    goodsTags,
+    banner,
+    indexModule,
+  },
 });

+ 44 - 0
src/store/module/system/indexModule.js

@@ -0,0 +1,44 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+const _ = require('lodash');
+Vue.use(Vuex);
+const api = {
+  url: '/point/v1/api/indexModule',
+};
+
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.url}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.url}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/${payload}`);
+    return res;
+  },
+  async update({ commit }, payload) {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await this.$axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.url}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 1 - 1
src/views/system/banner/index.vue

@@ -4,7 +4,7 @@
       <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>
+          <search-1 :form="searchForm" :typeList="typeList" @onSubmit="search" @toReset="toClose"></search-1>
         </el-col>
         <el-col :span="24" class="thr">
           <el-button type="primary" size="mini" @click="toAdd()">新增</el-button>

+ 1 - 1
src/views/system/banner/parts/search-1.vue

@@ -11,7 +11,7 @@
           <el-col :span="6">
             <el-form-item label="类型" prop="type">
               <el-select v-model="form.type" clearable filterable placeholder="请选择" style="width: 100%" size="small">
-                <el-option v-for="item in typeList" :key="item.label" :label="item.label" :value="item.value"></el-option>
+                <el-option v-for="i in typeList" :key="i.label" :label="i.label" :value="i.value"></el-option>
               </el-select>
             </el-form-item>
           </el-col>

+ 120 - 0
src/views/system/indexModule/detail.vue

@@ -0,0 +1,120 @@
+<template>
+  <div id="form-1">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col class="top-btn">
+          <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+        <el-col :span="12" class="one">
+          <data-form :span="24" :fields="fields" v-model="form" :rules="rules" @save="onSubmit">
+            <template #to_type>
+              <el-option v-for="i in typeList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+const moment = require('moment');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('indexModule');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+export default {
+  name: 'form-1',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      form: {},
+      rules: {
+        name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+        to_type: [{ required: true, message: '请选择类型', trigger: 'change' }],
+        to: [{ required: false, message: '请输入跳转至', trigger: 'blur' }],
+        is_use: [{ required: true, message: '请选择是否正在使用', trigger: 'change' }],
+        url: [{ required: true, message: '请选择图标', trigger: 'change' }],
+        sort: [{ required: true, message: '请输入排序', trigger: 'blur' }],
+      },
+      fields: [
+        { label: '名称', model: 'name' },
+        { label: '跳转类型', model: 'to_type', type: 'select' },
+        { label: '跳转至', model: 'to' },
+        { label: '是否正在使用', model: 'status', type: 'select' },
+        { label: '图标', model: 'url', type: 'upload', url: '/files/point/goods/upload' },
+        { label: '排序', model: 'sort', type: 'number' },
+      ],
+      typeList: [],
+      statusList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...mapActions(['fetch', 'create', 'update']),
+    // 查询
+    async search() {
+      if (this.id) {
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      } else {
+        this.$set(this, `form`, {});
+      }
+    },
+    // 提交
+    async onSubmit({ data }) {
+      let res;
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `维护信息成功` });
+        this.toBack();
+      }
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 类型
+      res = await this.dictQuery({ code: 'to_type' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `typeList`, res.data);
+      }
+      res = await this.dictQuery({ code: 'status' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `statusList`, res.data);
+      }
+    },
+    // 返回
+    toBack() {
+      window.history.go('-1');
+    },
+  },
+  computed: {
+    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></style>

+ 152 - 7
src/views/system/indexModule/index.vue

@@ -1,27 +1,172 @@
 <template>
   <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" :typeList="typeList" @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>
 </template>
 
 <script>
-import { mapState, createNamespacedHelpers } from 'vuex';
+const _ = require('lodash');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('indexModule');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
 export default {
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    search1: () => import('./parts/search-1.vue'),
+  },
   data: function () {
-    return {};
+    const that = this;
+    return {
+      // 列表
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      fields: [
+        { label: '名称', model: 'name' },
+        {
+          label: '跳转类型',
+          model: 'to_type',
+          format: (i) => {
+            let data = that.typeList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+        { label: '跳转到', model: 'to' },
+        {
+          label: '是否正在使用',
+          model: 'status',
+          format: (i) => {
+            let data = that.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      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)) {
+        this.$set(this, 'list', res.data);
+        this.$set(this, 'total', res.total);
+      }
+    },
+    // 新增
+    toAdd() {
+      this.$router.push({ path: '/system/indexModule/detail' });
+    },
+    // 修改
+    async toEdit({ data }) {
+      this.$router.push({ path: '/system/indexModule/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: 'to_type' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `typeList`, res.data);
+      }
+      res = await this.dictQuery({ code: 'status' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `statusList`, res.data);
+      }
+    },
   },
   computed: {
     ...mapState(['user']),
   },
-  created() {},
-  methods: {},
   metaInfo() {
     return { title: this.$route.meta.title };
   },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
 };
 </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>

+ 73 - 0
src/views/system/indexModule/parts/search-1.vue

@@ -0,0 +1,73 @@
+<template>
+  <div id="search-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-form :model="form" ref="form" label-width="130px">
+          <el-col :span="6">
+            <el-form-item label="名称" prop="name">
+              <el-input v-model="form.name" placeholder="请输入名称" size="small"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="跳转类型" prop="to_type">
+              <el-select v-model="form.to_type" clearable filterable placeholder="请选择" style="width: 100%" size="small">
+                <el-option v-for="i in typeList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24" class="btn">
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="onSubmit('form')">搜索</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="toReset('form')">重置</el-button>
+          </el-col>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'search-1',
+  props: { form: { type: Object }, typeList: { type: Array } },
+  components: {},
+  data: function () {
+    return {};
+  },
+  created() {},
+  methods: {
+    onSubmit() {
+      this.$emit('onSubmit');
+    },
+    toReset(formName) {
+      this.$refs[formName].resetFields();
+      this.$emit('toReset');
+    },
+  },
+  computed: {
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .btn {
+    text-align: right;
+  }
+  /deep/.el-form-item {
+    float: left;
+    width: 100%;
+    margin: 0 0 10px 0;
+  }
+}
+</style>