Browse Source

用户管理

YY 2 years ago
parent
commit
a03003ff82

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

@@ -1,4 +1,10 @@
 export default [
 export default [
+  {
+    path: '/platmanag/user',
+    name: 'platmanag_user',
+    meta: { title: '平台管理-用户管理' },
+    component: () => import('@/views/platmanag/user/index.vue'),
+  },
   {
   {
     path: '/platmanag/goodsTags',
     path: '/platmanag/goodsTags',
     name: 'platmanag_goodsTags',
     name: 'platmanag_goodsTags',

+ 2 - 0
src/store/index.js

@@ -3,6 +3,7 @@ import Vuex from 'vuex';
 import * as ustate from './module/user/state';
 import * as ustate from './module/user/state';
 import * as umutations from './module/user/mutations';
 import * as umutations from './module/user/mutations';
 import admin from './module/user/action';
 import admin from './module/user/action';
+import user from './module/user/user';
 
 
 import todo from './module/statistics/todo';
 import todo from './module/statistics/todo';
 import sellTotal from './module/statistics/sellTotal';
 import sellTotal from './module/statistics/sellTotal';
@@ -48,6 +49,7 @@ export default new Vuex.Store({
   mutations: { ...umutations },
   mutations: { ...umutations },
   actions: {},
   actions: {},
   modules: {
   modules: {
+    user,
     admin,
     admin,
     shop,
     shop,
     goods,
     goods,

+ 4 - 0
src/store/module/system/admin.js

@@ -22,6 +22,10 @@ const actions = {
     const res = await this.$axios.$post(`${api.url}`, payload);
     const res = await this.$axios.$post(`${api.url}`, payload);
     return res;
     return res;
   },
   },
+  async pass({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.url}/toMakeKey`, payload);
+    return res;
+  },
   async email({ commit }, payload) {
   async email({ commit }, payload) {
     const res = await this.$axios.$post(`${api.url}/emailResetPwd`, payload);
     const res = await this.$axios.$post(`${api.url}/emailResetPwd`, payload);
     return res;
     return res;

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

+ 182 - 0
src/views/platmanag/user/index.vue

@@ -0,0 +1,182 @@
+<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">
+          <data-search :fields="searchFields" v-model="searchInfo" @query="search"> </data-search>
+        </el-col>
+        <el-col :span="24" class="four">
+          <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @del="toDel"> </data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+    <e-dialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <data-form :span="24" :fields="fieldsForm" :rules="fieldRules" v-model="fieldform" labelWidth="150px" @save="onSubmit"> </data-form>
+      </template>
+    </e-dialog>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions: user } = createNamespacedHelpers('user');
+const { mapActions: admin } = createNamespacedHelpers('admins');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function () {
+    const that = this;
+    return {
+      // 列表
+      opera: [{ label: '删除', method: 'del' }],
+      fields: [
+        { label: 'openid', model: 'openid' },
+        { label: '用户姓名', model: 'name' },
+        { label: '电话', model: 'phone' },
+        { label: '邮箱', model: 'email' },
+        { label: '出生年月', model: 'birth' },
+        {
+          label: '性别',
+          model: 'gender',
+          format: (i) => {
+            let data = that.genderList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '';
+          },
+        },
+        {
+          label: '状态',
+          model: 'status',
+          format: (i) => {
+            let data = that.useList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '';
+          },
+        },
+      ],
+      list: [],
+      total: 0,
+      // 查询
+      searchInfo: {},
+      searchFields: [{ label: '用户姓名', model: 'name' }],
+      // 性别
+      genderList: [],
+      // 用户状态
+      useList: [],
+      // 弹框
+      dialog: { title: '信息管理', show: false, type: '1' },
+      fieldform: {},
+      fieldsForm: [{ label: '密码', model: 'password', type: 'password' }],
+      fieldRules: { password: [{ required: true, message: '请输入密码', trigger: 'blur' }] },
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...admin({ adminPass: 'pass' }),
+    ...user(['query', 'delete', 'fetch', 'update', 'create']),
+    async search({ skip = 0, limit = this.$limit, ...info } = {}) {
+      let 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);
+      }
+    },
+    // 修改
+    async toDel({ data }) {
+      this.$confirm('是否确认删除,需确认密码', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        this.$set(this.fieldform, 'target', data.id);
+        this.dialog = { title: '信息管理', show: true, type: '1' };
+      });
+    },
+    async onSubmit({ data }) {
+      let res;
+      res = await this.adminPass(data);
+      if (this.$checkRes(res)) {
+        if (res.errcode == 0) {
+          this.$confirm('是否确认删除', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning',
+          }).then(async () => {
+            let info = {
+              key: res.data,
+              target: data.target,
+            };
+            res = await this.delete(info);
+            if (this.$checkRes(res)) {
+              this.$message({ type: `success`, message: `删除成功` });
+              this.toClose();
+            }
+          });
+        }
+      }
+    },
+    // 重置
+    toClose() {
+      this.fieldform = {};
+      this.dialog = { title: '信息管理', show: false, type: '1' };
+      this.search();
+    },
+    async searchOther() {
+      let res;
+      // 性别
+      res = await this.dictQuery({ code: 'gender' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `genderList`, res.data);
+      }
+      // 用户状态
+      res = await this.dictQuery({ code: 'user_status' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `useList`, res.data);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  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>