Browse Source

修改bug(vip单本授权返显)

asd123a20 3 years ago
parent
commit
d6ef21fbce
2 changed files with 30 additions and 12 deletions
  1. 12 3
      admin-client-vip/src/store/index.js
  2. 18 9
      admin-client-vip/src/views/home.vue

+ 12 - 3
admin-client-vip/src/store/index.js

@@ -11,6 +11,7 @@ const api = {
   intactQuery: '/api/journal/intact/query',
   intactQuery: '/api/journal/intact/query',
   powerCreate: '/api/clientVip/power/create',
   powerCreate: '/api/clientVip/power/create',
   powerupdate: '/api/clientVip/power/update',
   powerupdate: '/api/clientVip/power/update',
+  powerquery: '/api/clientVip/power/query',
   imports: '/api/importandexport/handle/import',
   imports: '/api/importandexport/handle/import',
   progressed: '/api/importandexport/handle/progressed'
   progressed: '/api/importandexport/handle/progressed'
 };
 };
@@ -21,8 +22,8 @@ const state = () => ({
   dict: {},
   dict: {},
   contentList: [],
   contentList: [],
   intactList: [],
   intactList: [],
-  LIST: [],
-  tabList: []
+  tabList: [],
+  powerList: []
 });
 });
 
 
 const actions = {
 const actions = {
@@ -43,7 +44,12 @@ const actions = {
     return res;
     return res;
   },
   },
   async powerupdate ({ commit }, payload) {
   async powerupdate ({ commit }, payload) {
-    const res = await $axios.post(api.powerupdate, { ...payload, id: payload._id });
+    const res = await $axios.post(api.powerupdate, payload);
+    return res;
+  },
+  async powerquery ({ commit }, payload = {}) {
+    const res = await $axios.get(api.powerquery, payload);
+    commit('powerquery', res);
     return res;
     return res;
   },
   },
   async vipCreate ({ commit }, payload) {
   async vipCreate ({ commit }, payload) {
@@ -95,6 +101,9 @@ const mutations = {
     state.vipList = payload.data;
     state.vipList = payload.data;
     state.Total = payload.total;
     state.Total = payload.total;
   },
   },
+  powerquery(state, payload) {
+    state.powerList = payload.data[0];
+  },
   contentsQuery(state, payload) {
   contentsQuery(state, payload) {
     state.contentList = payload.data;
     state.contentList = payload.data;
     // state.list = payload.data;
     // state.list = payload.data;

+ 18 - 9
admin-client-vip/src/views/home.vue

@@ -122,12 +122,11 @@ export default {
           { required: true, message: '请选择绑定内容', trigger: 'change' }
           { required: true, message: '请选择绑定内容', trigger: 'change' }
         ]
         ]
       },
       },
-      vipInfo: {},
-      values: []
+      edit: false
     };
     };
   },
   },
   computed: {
   computed: {
-    ...mapState(['vipList', 'Total', 'dict', 'intactList', 'contentList', 'tabList', 'typeList'])
+    ...mapState(['vipList', 'Total', 'dict', 'intactList', 'contentList', 'tabList', 'typeList', 'powerList'])
   },
   },
   async mounted() {
   async mounted() {
     await this.tabQuery();
     await this.tabQuery();
@@ -135,7 +134,7 @@ export default {
     await this.filterQuery();
     await this.filterQuery();
   },
   },
   methods: {
   methods: {
-    ...mapActions(['vipQuery', 'vipCreate', 'vipUpdate', 'vipDelete', 'statusQuery', 'tabQuery', 'contentsQuery', 'intactQuery', 'typeQuery', 'powerCreate', 'powerupdate']),
+    ...mapActions(['vipQuery', 'vipCreate', 'vipUpdate', 'vipDelete', 'statusQuery', 'tabQuery', 'contentsQuery', 'intactQuery', 'typeQuery', 'powerCreate', 'powerupdate', 'powerquery']),
     // 导出
     // 导出
     async exportvip() {
     async exportvip() {
       console.log('导出');
       console.log('导出');
@@ -158,6 +157,10 @@ export default {
         this.list = this.contentList;
         this.list = this.contentList;
       }
       }
       const label = e == 0 ? '绑定期刊' : '绑定文章';
       const label = e == 0 ? '绑定期刊' : '绑定文章';
+      if (this.edit) {
+        await this.powerquery({ openid: this.formdata.openid, type: e });
+        this.$refs.formData.setForm('list', this.powerList.list);
+      }
       this.formfiled = this.formfiled.filter(e => e.name !== 'list');
       this.formfiled = this.formfiled.filter(e => e.name !== 'list');
       this.formfiled.push({ name: 'list', label, formater: 'slot' });
       this.formfiled.push({ name: 'list', label, formater: 'slot' });
     },
     },
@@ -166,14 +169,15 @@ export default {
       this.formdata = {};
       this.formdata = {};
       this.title = '添加vip';
       this.title = '添加vip';
       this.visibleSync = true;
       this.visibleSync = true;
+      this.edit = false;
     },
     },
     // 修改
     // 修改
-    filtereEdit (e) {
+    async filtereEdit (e) {
       this.formdata = e;
       this.formdata = e;
-      // console.log(e);
       this.tabChange(e.vipTab);
       this.tabChange(e.vipTab);
       this.title = '修改vip';
       this.title = '修改vip';
       this.visibleSync = true;
       this.visibleSync = true;
+      this.edit = true;
     },
     },
     // 删除
     // 删除
     async filterDelete (e) {
     async filterDelete (e) {
@@ -187,7 +191,6 @@ export default {
     },
     },
     // 表单保存
     // 表单保存
     async formSave (e) {
     async formSave (e) {
-      console.log(e);
       if (e.isRevise && e?.isRevise == false) {
       if (e.isRevise && e?.isRevise == false) {
         this.$message.warning('未作修改');
         this.$message.warning('未作修改');
         return;
         return;
@@ -197,15 +200,21 @@ export default {
       // 修改
       // 修改
       if (e._id) {
       if (e._id) {
         res = await this.vipUpdate(e);
         res = await this.vipUpdate(e);
-        if (e.vipTab == 'vip') await this.powerupdate(e);
         msg = 'vip修改成功';
         msg = 'vip修改成功';
       } else {
       } else {
         res = await this.vipCreate(e);
         res = await this.vipCreate(e);
-        if (e.vipTab == 'vip') await this.powerCreate(e);
         msg = 'vip添加成功';
         msg = 'vip添加成功';
       }
       }
+      if (e.vipTab == 'vip') {
+        if (this.powerList.length < 1) {
+          await this.powerCreate(e);
+        } else {
+          await this.powerupdate({ ...e, id: this.powerList._id });
+        }
+      }
       this.$resChange(res, msg);
       this.$resChange(res, msg);
       this.filterQuery();
       this.filterQuery();
+      await this.powerquery({ openid: this.formdata.openid, type: e.type });
       this.visibleSync = false;
       this.visibleSync = false;
       this.formfiled = this.formfiled.filter(e => e.name !== 'list' && e.name !== 'type');
       this.formfiled = this.formfiled.filter(e => e.name !== 'list' && e.name !== 'type');
     },
     },