guhongwei há 4 anos atrás
pai
commit
62692ed56b

+ 2 - 0
src/store/index.js

@@ -28,6 +28,7 @@ import expertsuser from '@common/store/market/exportuser';
 import productpact from '@common/store/market/productpact';
 import wxchattest from './user/wxchattest';
 import users from './user';
+import authUser from './user/auth-user';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -61,5 +62,6 @@ export default new Vuex.Store({
     users,
     productpact,
     wxchattest,
+    authUser,
   },
 });

+ 44 - 0
src/store/user/auth-user.js

@@ -0,0 +1,44 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+//用户的菜单选项增删改查
+Vue.use(Vuex);
+const api = {
+  interface: `/api/auth/user`,
+  getMenu: `/api/auth/user/menus`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
+    const res = await this.$axios.$get(api.interface, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    //特殊变化,查用户菜单
+    const res = await this.$axios.$get(`${api.getMenu}`, payload);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/update/${id}`, {
+      ...info,
+    });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 63 - 4
src/views/adminCenter/basicInfo/index.vue

@@ -4,7 +4,18 @@
       <el-col :span="24">
         <el-col :span="24" class="leftTop"> <span>|</span> <span>基本信息</span> </el-col>
         <el-col :span="24" class="info">
-          基本信息
+          <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+            <el-form-item label="用户名" prop="adminuser">
+              <el-input v-model="form.adminuser" placeholder="请输入用户名"></el-input>
+            </el-form-item>
+            <el-form-item label="手机号" prop="phone">
+              <el-input v-model="form.phone" placeholder="请输入用户名" disabled></el-input>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="submitForm('form')">保存</el-button>
+              <el-button @click="resetForm('form')">重置</el-button>
+            </el-form-item>
+          </el-form>
         </el-col>
       </el-col>
     </el-row>
@@ -13,15 +24,63 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: dock } = createNamespacedHelpers('dock');
+const { mapActions: authUser } = createNamespacedHelpers('authUser');
 export default {
   name: 'index',
   props: {},
   components: {},
   data: function() {
-    return {};
+    return {
+      form: {},
+      rules: {
+        adminuser: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
+        phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
+      },
+    };
+  },
+  created() {
+    this.searchInfo();
+  },
+  methods: {
+    ...dock({ dockQuery: 'query', dockFetch: 'fetch', dockUpdate: 'update' }),
+    ...authUser({ authUserFetch: 'fetch', authUserUpdate: 'update' }),
+    async searchInfo() {
+      if (this.user.uid) {
+        let res = await this.dockQuery(this.user.uid);
+        if (this.$checkRes(res)) {
+          for (const val of res.data) {
+            this.$set(this, `form`, val);
+          }
+        }
+      }
+    },
+    async submitForm() {
+      let res = await this.dockUpdate(this.form);
+      if (this.$checkRes(res)) {
+        let data = {};
+        data.id = this.user.uid;
+        data.name = this.form.adminuser;
+        let arr = await this.authUserUpdate(data);
+        if (this.$checkRes(arr)) {
+          console.log(arr);
+          this.$message({
+            message: '修改信息成功',
+            type: 'success',
+          });
+        } else {
+          this.$message({
+            message: '修改信息失败',
+            type: 'error',
+          });
+        }
+      }
+      this.searchInfo();
+    },
+    resetForm() {
+      this.form.adminuser = '';
+    },
   },
-  created() {},
-  methods: {},
   computed: {
     ...mapState(['user']),
     pageTitle() {