Browse Source

baseinfo store

wolyshaw 4 years ago
parent
commit
e888f93c89

+ 8 - 1
src/views/resetTeaming/api.js

@@ -52,4 +52,11 @@ export const makesureSchoolePaid = data => request2({
   data,
   method: 'post',
   requestType: 'form'
-})
+})
+
+export const queryByOrganIdAndCourseType = data => request2({
+  url: '/organizationCourseDurationSettings/queryByOrganIdAndCourseType',
+  data,
+  method: 'get',
+  requestType: 'form'
+})

+ 6 - 0
src/views/resetTeaming/modals/user-pay-form.vue

@@ -211,6 +211,12 @@ export default {
       }
       return data;
     },
+    organId() {
+      if (this.baseInfo && this.baseInfo.musicGroup) {
+        return this.baseInfo.musicGroup.organId
+      }
+      return ''
+    },
     paymentAmountDisabled() {
       return (this.isUserType || (this.isCommon && this.isUserType)) && this.isDisabled
     },

+ 37 - 0
src/views/resetTeaming/store.js

@@ -0,0 +1,37 @@
+/* eslint-disable no-empty */
+import Vuex from 'vuex'
+import { getTeamBaseInfo } from '@/api/buildTeam'
+
+const store = new Vuex.Store({
+  state: {
+    res: null,
+    baseInfo: null,
+    musicGroup: {}
+  },
+  mutations: {
+    updateBaseinfo(state, res) {
+      state.res = res
+      state.baseInfo = res.data
+      if (res.data.musicGroup) {
+        state.musicGroup = {...res.data.musicGroup}
+      } else {
+        state.musicGroup = {}
+      }
+    }
+  },
+  actions: {
+    async getBaseInfo({ commit, state }, payload) {
+      try {
+        if (payload.data?.musicGroupId !== state.musicGroup.id || payload.force) {
+          const res = await getTeamBaseInfo(payload.data)
+          commit('updateBaseinfo', res)
+          return Promise.resolve(res)
+        }
+        return Promise.resolve(state.res)
+      } catch (error) {}
+      return Promise.reject()
+    }
+  }
+})
+
+export default store

+ 5 - 2
src/views/teamBuild/components/teamBaseInfo.vue

@@ -495,6 +495,7 @@ import store from "@/store";
 import numeral from "numeral";
 import { formatData } from "@/utils/utils";
 import qs from "qs";
+import MusicStore from '@/views/resetTeaming/store'
 export default {
   name: "teamBaseInfo",
   props: ["getTeamList"],
@@ -707,7 +708,9 @@ export default {
       ) {
         // 单团修改
         this.teamid = this.$route.query.id;
-        getTeamBaseInfo({ musicGroupId: this.teamid }).then((res) => {
+        MusicStore.dispatch('getBaseInfo', {
+          data: { musicGroupId: this.teamid }
+        }).then((res) => {
           if (res.code == 200) {
             if (this.$listeners.getBaseInfo) {
               this.$listeners.getBaseInfo(res.data)
@@ -1142,7 +1145,7 @@ export default {
             if (res.code == 200) {
               if (this.teamStatus == "teamDraft") {
                 this.$message.success("保存成功");
-                // 跳到第二页 
+                // 跳到第二页
 
                 this.$emit("chiosetab", 1);
               } else {