Explorar o código

修改账号管理

YY %!s(int64=2) %!d(string=hai) anos
pai
achega
606596f925

+ 2 - 0
src/store/index.js

@@ -21,6 +21,7 @@ import actTags from './module/system/actTags';
 import config from './module/system/config';
 import platformAct from './module/system/platformAct';
 import goodsJoinAct from './module/system/goodsJoinAct';
+import admins from './module/system/admin';
 
 import shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
@@ -69,5 +70,6 @@ export default new Vuex.Store({
     goodsRate,
     getBill,
     outBill,
+    admins,
   },
 });

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

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

@@ -94,7 +94,6 @@ export default {
         this.$set(this, `list`, res.data);
         this.$set(this, `total`, res.total);
       }
-      console.log(this.list);
     },
     // 新增
     toAdd() {

+ 76 - 78
src/views/platmanag/storeAcc/detail.vue

@@ -12,7 +12,17 @@
         </template>
       </data-search>
       <data-btn :fields="btnList" @add="toAdd"></data-btn>
-      <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" :limit="limit" @query="search"></data-table>
+      <data-table
+        ref="dataTable"
+        :fields="fields"
+        :opera="opera"
+        :data="list"
+        :total="total"
+        :limit="limit"
+        @query="search"
+        @edit="toEdit"
+        @del="toDel"
+      ></data-table>
     </template>
     <template v-else>
       <el-row>
@@ -21,11 +31,8 @@
         </el-col>
         <el-col :span="24">
           <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
-            <template #act_tags>
-              <el-option v-for="i in act_tagsList" :key="i.value" :label="i.label" :value="i.value"></el-option>
-            </template>
-            <template #status>
-              <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            <template #role>
+              <el-option v-for="i in roleList" :key="i._id" :label="i.name" :value="i._id"></el-option>
             </template>
           </data-form>
         </el-col>
@@ -38,6 +45,8 @@
 const _ = require('lodash');
 import methodsUtil from '@/util/opera';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: admins } = createNamespacedHelpers('admins');
+const { mapActions: role } = createNamespacedHelpers('role');
 export default {
   name: 'index',
   props: {},
@@ -46,50 +55,30 @@ export default {
     return {
       view: 'list',
       fields: [
-        { label: '姓名', model: 'name' },
-        { label: '店铺名称', model: 'shop.name' },
-        { label: '电话', model: 'phone' },
-        // { label: '商品分类', model: 'tags', format: (i) => this.getTags(i) },
-        // { label: '活动标签', model: 'act_tags', format: (i) => this.getAct_tags(i) },
-        // { label: '商品状态', model: 'status', format: (i) => this.getStatus(i) },
+        { label: '名称', model: 'name' },
+        { label: '账号', model: 'account' },
+        { label: '角色', model: 'role.name' },
       ],
       opera: [
-        // { label: '修改', method: 'edit' },
-        // { label: '上架', method: 'puton', display: (i) => i.status == '0' },
-        // { label: '下架', method: 'lower', display: (i) => i.status == '1' },
-        // { label: '库存管理', method: 'spec' },
-        // { label: '删除', method: 'delete', confirm: true, type: 'danger' },
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
       ],
       btnList: [{ label: '添加', method: 'add' }],
       searchFields: [{ label: '名称', model: 'name' }],
       searchInfo: {},
-      list: [{ name: '222' }],
+      list: [],
       total: 0,
       limit: 10,
       // info部分
       infoFields: [
-        { label: '姓名', model: 'name' },
-        { label: '电话', model: 'phone' },
-        // { label: '商品分类', model: 'tags', custom: true },
-        // { label: '活动标签', model: 'act_tags', type: 'selectMany' },
-        // { label: '简短简介', model: 'shot_brief', maxLength: 50 },
-        // { label: '预计发货时间', model: 'send_time' },
-        // { label: '商品状态', model: 'status', type: 'select' },
-        // { label: '商品来源', model: 'source' },
-        // { label: '网址', model: 'url' },
-        // { label: '排序', model: 'sort', type: 'number' },
-        // { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
-        // { label: '商品介绍', model: 'brief', custom: true },
+        { label: '名称', model: 'name' },
+        { label: '账号', model: 'account' },
+        { label: '角色', model: 'role', type: 'select' },
+        { label: '密码', model: 'password', type: 'password' },
       ],
       rules: {},
       form: {},
-      // 商品分类
-      tagsList: [],
-      props: { multiple: true, label: 'label', value: 'code' },
-      // 活动标签
-      act_tagsList: [],
-      goodsStatusList: [],
-      shop: {},
+      roleList: [],
     };
   },
   created() {
@@ -98,52 +87,56 @@ export default {
   },
   methods: {
     ...methodsUtil,
+    ...role({ roleQuery: 'query' }),
+    ...admins(['query', 'delete', 'fetch', 'update', 'create']),
     async search({ skip = 0, limit = this.limit, ...others } = {}) {
-      // let query = { skip, limit, ...others };
-      // if (Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
-      // const res = await this.getGoods(query);
-      // if (this.$checkRes(res)) {
-      //   this.$set(this, `list`, res.data);
-      //   this.$set(this, `total`, res.total);
-      // }
+      others.shop = this.id;
+      let query = { skip, limit, ...others };
+      if (Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
+      const res = await this.query(query);
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     initAddData() {
-      const obj = {
-        // status: '1',
-        // shop: _.get(this.shop, '_id'),
-      };
+      const obj = { shop: this.id };
       this.$set(this, 'form', obj);
     },
-    async searchOthers() {},
-    // getStatus(data) {
-    //   const res = this.goodsStatusList.find((f) => f.value === data);
-    //   if (res) return res.label;
-    //   return '';
-    // },
-    // getAct_tags(data) {
-    //   const arr = [];
-    //   for (const val of data) {
-    //     const r = this.act_tagsList.find((f) => f.value === val);
-    //     if (r) arr.push(r.label);
-    //   }
-    //   return arr.join(';');
-    // },
-    // getTags(data) {
-    //   let list = this.tagsList;
-    //   const getChildren = (list) =>
-    //     list.map((i) => {
-    //       if (i.children) return getChildren(i.children);
-    //       return i;
-    //     });
-    //   list = _.flattenDeep(getChildren(list));
-    //   const arr = [];
-    //   for (const ts of data) {
-    //     const last = _.last(ts);
-    //     const r = list.find((f) => f.code === last);
-    //     if (r) arr.push(r.label);
-    //   }
-    //   return arr.join(';');
-    // },
+    async toEdit({ data }) {
+      const res = await this.fetch(data._id);
+      if (this.$checkRes(res)) {
+        let data = res.data;
+        this.$set(this, `form`, data);
+        this.view = 'info';
+      } else {
+        this.$message.error('未找到指定数据');
+      }
+    },
+    // 删除
+    async toDel({ data }) {
+      let res = await this.delete(data._id);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `刪除信息成功` });
+        this.search();
+      }
+    },
+    async toSave({ 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.search();
+        this.toBackList();
+      }
+    },
+    async searchOthers() {
+      let res = await this.roleQuery();
+      if (this.$checkRes(res)) {
+        this.$set(this, `roleList`, res.data);
+      }
+    },
     toBack() {
       window.history.go('-1');
     },
@@ -152,6 +145,11 @@ export default {
       this.form = {};
     },
   },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
 };
 </script>
 

+ 1 - 1
src/views/platmanag/storeAcc/index.vue

@@ -86,7 +86,7 @@ export default {
     },
     // 账号管理
     async toManage({ data }) {
-      this.$router.push({ path: '/platmanag/storeAcc/detail', query: { id: data.id } });
+      this.$router.push({ path: '/platmanag/storeAcc/detail', query: { id: data._id } });
     },
     // 重置
     toClose() {