lrf 2 лет назад
Родитель
Сommit
0e0e6b2991

+ 1 - 1
src/layout/Home.vue

@@ -13,7 +13,7 @@
                   <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
                   <el-col :span="24" class="container" style="padding: 15px">
                     <el-scrollbar style="height: 81vh">
-                      <router-view style="height: 70vh" :key="viewKey"></router-view>
+                      <router-view style="height: 70vh; padding: 20px" :key="viewKey"></router-view>
                     </el-scrollbar>
                   </el-col>
                 </el-row>

+ 6 - 0
src/layout/data/menu.js

@@ -26,6 +26,12 @@ export const adminMenu = [
         name: '广告图',
         index: '2-2',
       },
+      {
+        icon: 'icon-rencai',
+        path: '/system/goodsTags',
+        name: '商品标签',
+        index: '2-3',
+      },
     ],
   },
   {

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

@@ -11,4 +11,10 @@ export default [
     meta: { title: '系统管理-首页图标设置' },
     component: () => import(/* webpackChunkName: "system_indexModule" */ '@/views/system/indexModule/index.vue'),
   },
+  {
+    path: '/system/goodsTags',
+    name: 'system_goodsTags',
+    meta: { title: '系统管理-首页图标设置' },
+    component: () => import(/* webpackChunkName: "system_goodsTags" */ '@/views/system/goodsTags/index.vue'),
+  },
 ];

+ 2 - 1
src/store/index.js

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

+ 44 - 0
src/store/module/system/goodsTags.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/goodsTags',
+};
+
+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,
+};

+ 8 - 0
src/views/dev/dict/data.vue

@@ -1,6 +1,11 @@
 <template>
   <div id="data">
     <template v-if="view === 'list'">
+      <el-row>
+        <el-col :span="24" style="padding: 10px">
+          <el-button icon="el-icon-back" size="mini" @click="toBackIndex()">返回</el-button>
+        </el-col>
+      </el-row>
       <data-search :fields="searchFields" v-model="searchInfo" @query="search">
         <template #status>
           <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
@@ -91,6 +96,9 @@ export default {
       this.form.code = this.code;
       this.form.status = '0';
     },
+    toBackIndex() {
+      this.$router.push('/dev/dict');
+    },
   },
   metaInfo() {
     return { title: this.$route.meta.title };

+ 1 - 0
src/views/dev/dict/index.vue

@@ -31,6 +31,7 @@
 </template>
 
 <script>
+const _ = require('lodash');
 import methodUtil from '@/util/opera';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('dictIndex');

+ 2 - 5
src/views/index.vue

@@ -1,16 +1,13 @@
 <template>
-  <div id="index">
-    <tlist></tlist>
-  </div>
+  <div id="index">count</div>
 </template>
 
 <script>
-import tlist from '@/template/list.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'index',
   props: {},
-  components: { tlist },
+  components: {},
   data: function () {
     return {};
   },

+ 130 - 0
src/views/system/goodsTags/index.vue

@@ -0,0 +1,130 @@
+<template>
+  <div id="index">
+    <template v-if="view === 'list'">
+      <el-row>
+        <el-col :span="24" style="padding: 10px">
+          <el-button icon="el-icon-back" size="mini" @click="backLevel()" v-if="levelList.length > 0">返回</el-button>
+        </el-col>
+      </el-row>
+      <data-search :fields="searchFields" v-model="searchInfo" @query="search">
+        <template #status>
+          <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+        </template>
+      </data-search>
+      <data-btn :fields="btnFields" @add="toAdd" />
+      <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete">
+        <template #code="{ row, item }">
+          <el-link type="primary" @click="toData(row)">{{ row[item.model] }}</el-link>
+        </template>
+      </data-table>
+    </template>
+    <template v-else>
+      <el-row>
+        <el-col :span="24">
+          <el-button icon="el-icon-back" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+        <el-col :span="24">
+          <data-form :span="12" :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
+            <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-row>
+    </template>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import methodUtil from '@/util/opera';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('goodsTags');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      view: 'list',
+      fields: [
+        { label: '显示名称', model: 'label' },
+        { label: '标签编码', model: 'code', custom: true },
+        { label: '状态', model: 'status', format: (i) => (i === '0' ? '使用中' : '已禁用') },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'delete', confirm: true, type: 'danger' },
+      ],
+      list: [],
+      total: 0,
+      limit: 20,
+      btnFields: [{ label: '添加', method: 'add' }],
+      defaultSearch: {},
+      searchInfo: {},
+      searchFields: [
+        { label: '显示名称', model: 'label' },
+        { label: '标签编码', model: 'code' },
+        { label: '状态', model: 'status', type: 'select' },
+      ],
+      infoFields: [
+        { label: '显示名称', model: 'label' },
+        { label: '标签编码', model: 'code' },
+        { label: '状态', model: 'status', type: 'select' },
+      ],
+      rules: {},
+      form: {},
+      statusList: [],
+
+      levelList: [],
+    };
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  created() {
+    this.searchOthers();
+    this.search();
+  },
+  methods: {
+    ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
+    ...dictData({ getDict: 'query' }),
+    ..._.cloneDeep(methodUtil),
+    //执行查询
+    async search({ skip = 0, limit = this.limit || 10, ...others } = {}) {
+      let query = { skip, limit, ...others };
+      if (this.searchInfo && Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
+      if (this.defaultSearch && Object.keys(this.defaultSearch).length > 0) query = { ...query, ...this.defaultSearch };
+      if (this.levelList.length > 0) query.pid = _.last(this.levelList);
+      const res = await this.query(query);
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async searchOthers() {
+      const res = await this.getDict({ code: 'use' });
+      if (this.$checkRes(res)) this.$set(this, 'statusList', res.data);
+    },
+    initAddData() {
+      const pid = _.last(this.levelList);
+      if (pid) this.form.pid = pid;
+    },
+    toData(row) {
+      const id = _.get(row, '_id');
+      this.levelList.push(id);
+      this.search();
+    },
+    backLevel() {
+      this.levelList.pop();
+      this.search();
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>