Jelajahi Sumber

给直播课老师设置课酬

lex 2 tahun lalu
induk
melakukan
17444292ac

+ 17 - 2
src/api/teacherManager.js

@@ -2,6 +2,7 @@
 import request from "@/utils/request";
 import qs from "qs";
 let api = "/api-web";
+import request2 from "@/utils/request2";
 // 分页查询教师列表
 export function teacherQueryPage(data) {
   return request({
@@ -93,8 +94,15 @@ export function vipGroupSalaryList(data) {
 }
 
 // 修改教师vip课酬
+// export function vipGroupSalarySet(data) {
+//   return request({
+//     url: api + "/teacherDefaultVipGroupSalary/upSet",
+//     method: "post",
+//     data: data
+//   });
+// }
 export function vipGroupSalarySet(data) {
-  return request({
+  return request2({
     url: api + "/teacherDefaultVipGroupSalary/upSet",
     method: "post",
     data: data
@@ -207,8 +215,15 @@ export function teacherDefaultPracticeGroupSalary(data) {
 }
 
 // 修改网管课课酬
+// export function PracticeGroupSalaryUpdate(data) {
+//   return request({
+//     url: api + "/teacherDefaultPracticeGroupSalary/update",
+//     method: "post",
+//     data
+//   });
+// }
 export function PracticeGroupSalaryUpdate(data) {
-  return request({
+  return request2({
     url: api + "/teacherDefaultPracticeGroupSalary/update",
     method: "post",
     data

+ 202 - 191
src/views/teacherManager/teacherOperation/components/salarySet.vue

@@ -3,10 +3,7 @@
     <!-- <h4>单次课次参考时长:30min</h4> -->
     <div class="tableList">
       <div class="left">
-        <el-table
-          :data="teamTable"
-          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
-        >
+        <el-table :data="teamTable" :header-cell-style="{ background: '#EDEEF0', color: '#444' }">
           <el-table-column label="乐团课课酬课时结算">
             <template slot-scope="scope">{{
               scope.row.courseScheduleType | coursesType
@@ -44,62 +41,30 @@
           </el-table-column> -->
           <el-table-column label="标准课酬-主教">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.mainTeacher90MinSalary"
-                placeholder="请输入课酬"
-              >
-                <template
-                  slot="append"
-                  v-if="scope.row.courseScheduleType == 'HIGH'"
-                  >元/人</template
-                >
-                <template
-                  slot="append"
-                  v-else-if="scope.row.courseScheduleType == 'CLASSROOM'"
-                  >元/节</template
-                >
-                <template slot="append" v-else
-                  >元/90分钟</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.mainTeacher90MinSalary"
+                placeholder="请输入课酬">
+                <template slot="append" v-if="scope.row.courseScheduleType == 'HIGH'">元/人</template>
+                <template slot="append" v-else-if="scope.row.courseScheduleType == 'CLASSROOM'">元/节</template>
+                <template slot="append" v-else>元/90分钟</template>
                 <!-- <template slot="append">元/{{ (scope.row.courseScheduleType == 'HIGH' || scope.row.courseScheduleType == 'CLASSROOM') ? 45 : 90 }}分钟</template> -->
               </el-input>
             </template>
           </el-table-column>
           <el-table-column label="标准课酬-助教">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.assistantTeacher90MinSalary"
-                placeholder="请输入课酬"
-              >
-                <template
-                  slot="append"
-                  v-if="scope.row.courseScheduleType == 'HIGH'"
-                  >元/人</template
-                >
-                <template
-                  slot="append"
-                  v-else-if="scope.row.courseScheduleType == 'CLASSROOM'"
-                  >元/节</template
-                >
-                <template slot="append" v-else
-                  >元/90分钟</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.assistantTeacher90MinSalary"
+                placeholder="请输入课酬">
+                <template slot="append" v-if="scope.row.courseScheduleType == 'HIGH'">元/人</template>
+                <template slot="append" v-else-if="scope.row.courseScheduleType == 'CLASSROOM'">元/节</template>
+                <template slot="append" v-else>元/90分钟</template>
                 <!-- <template slot="append">元/{{ (scope.row.courseScheduleType == 'HIGH' || scope.row.courseScheduleType == 'CLASSROOM') ? 45 : 90 }}分钟</template> -->
               </el-input>
             </template>
           </el-table-column>
         </el-table>
 
-        <el-table
-          :data="teamSmallTable"
-          style="margin-top: 15px"
-          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
-          v-if="tenantId == 1"
-        >
+        <el-table :data="teamSmallTable" style="margin-top: 15px"
+          :header-cell-style="{ background: '#EDEEF0', color: '#444' }" v-if="tenantId == 1">
           <el-table-column label="">
             <template slot-scope="scope">{{
               scope.row.courseScheduleType | coursesType
@@ -107,85 +72,44 @@
           </el-table-column>
           <el-table-column label="1V1">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.v1"
-                placeholder="请输入课酬"
-              >
-                <template slot="append"
-                  >元/节</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.v1" placeholder="请输入课酬">
+                <template slot="append">元/节</template>
               </el-input>
             </template>
           </el-table-column>
           <el-table-column label="1V2">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.v2"
-                placeholder="请输入课酬"
-              >
-                <template slot="append"
-                  >元/节</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.v2" placeholder="请输入课酬">
+                <template slot="append">元/节</template>
               </el-input>
             </template>
           </el-table-column>
           <el-table-column label="1V3">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.v3"
-                placeholder="请输入课酬"
-              >
-                <template slot="append"
-                  >元/节</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.v3" placeholder="请输入课酬">
+                <template slot="append">元/节</template>
               </el-input>
             </template>
           </el-table-column>
           <el-table-column label="1V4">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.v4"
-                placeholder="请输入课酬"
-              >
-                <template slot="append"
-                  >元/节</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.v4" placeholder="请输入课酬">
+                <template slot="append">元/节</template>
               </el-input>
             </template>
           </el-table-column>
           <el-table-column label="1V5">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.v5"
-                placeholder="请输入课酬"
-              >
-                <template slot="append"
-                  >元/节</template
-                >
+              <el-input type="number" @mousewheel.native.prevent v-model.trim="scope.row.v5" placeholder="请输入课酬">
+                <template slot="append">元/节</template>
               </el-input>
             </template>
           </el-table-column>
         </el-table>
 
-        <el-table
-          :data="vipTable"
-          style="width: 70%; margin-top: 15px"
-          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
-        >
-          <el-table-column
-            label="VIP课课酬参考值"
-            prop="vipGroupCategoryName"
-          ></el-table-column>
+        <el-table :data="vipTable" style="width: 70%; margin-top: 15px"
+          :header-cell-style="{ background: '#EDEEF0', color: '#444' }">
+          <el-table-column label="VIP课课酬参考值" prop="vipGroupCategoryName"></el-table-column>
           <!-- <el-table-column label="线上课">
             <template slot-scope="scope">
               <el-input
@@ -201,78 +125,71 @@
           <el-table-column label="">
             <template slot-scope="scope">
               <div>
-                <el-input
-                  v-if="scope.row.musicTheory"
-                  type="number"
-                  @mousewheel.native.prevent
-                  v-model.trim="scope.row.offlineClassesSalary"
-                  placeholder="请输入内容"
-                >
+                <el-input v-if="scope.row.musicTheory" type="number" @mousewheel.native.prevent
+                  v-model.trim="scope.row.offlineClassesSalary" placeholder="请输入内容">
                   <template slot="append">
-                    人/节</template
-                  >
+                    人/节</template>
                   <!-- <template slot="append" v-else>节/人</template>  v-if="scope.row.musicTheory" -->
                 </el-input>
 
-                <el-input
-                  v-else
-                  type="number"
-                  @mousewheel.native.prevent
-                  v-model.trim="scope.row.offlineClassesSalary"
-                  placeholder="请输入内容"
-                >
+                <el-input v-else type="number" @mousewheel.native.prevent v-model.trim="scope.row.offlineClassesSalary"
+                  placeholder="请输入金额">
                   <template slot="append">
-                    元/节</template
-                  >
+                    元/节</template>
                   <!-- <template slot="append" v-else>节/人</template>  v-if="scope.row.musicTheory" -->
                 </el-input>
               </div>
             </template>
           </el-table-column>
         </el-table>
-        <el-table
-          :data="accompanyTable"
-          style="width: 35%; margin-top: 15px"
-          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
-        >
+
+        <el-table :data="liveTable" style="width: 70%; margin-top: 15px"
+          :header-cell-style="{ background: '#EDEEF0', color: '#444' }">
+          <el-table-column label="直播课课课酬参考值" prop="vipGroupCategoryName">
+            <template slot-scope="scope">
+              {{ scope.row.vipGroupCategoryName }}分钟
+            </template>
+          </el-table-column>
+          <el-table-column label="">
+            <template slot-scope="scope">
+              <div>
+                <el-input v-if="scope.row.musicTheory" type="number" @mousewheel.native.prevent
+                  v-model.trim="scope.row.offlineClassesSalary" placeholder="请输入内容">
+                  <template slot="append">
+                    人/节</template>
+                </el-input>
+
+                <el-input v-else type="number" @mousewheel.native.prevent v-model.trim="scope.row.offlineClassesSalary"
+                  placeholder="请输入金额">
+                  <template slot="append">
+                    元/节</template>
+                </el-input>
+              </div>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <el-table :data="accompanyTable" style="width: 35%; margin-top: 15px"
+          :header-cell-style="{ background: '#EDEEF0', color: '#444' }">
           <el-table-column label="网管课">
             <template slot-scope="scope">
-              <el-input
-                type="number"
-                style="width: 195px"
-                @mousewheel.native.prevent
-                v-model.trim="scope.row.mainTeacherSalary"
-              >
-                <template slot="append"
-                  >元/{{ scope.row.minutes }}分钟</template
-                >
+              <el-input type="number" style="width: 195px" @mousewheel.native.prevent
+                v-model.trim="scope.row.mainTeacherSalary">
+                <template slot="append">元/{{ scope.row.minutes }}分钟</template>
               </el-input>
             </template>
           </el-table-column>
         </el-table>
 
-        <el-form
-          style="margin-top: 20px"
-          ref="salaryForm"
-          :model="updateForm"
-          :rules="rules"
-        >
-          <el-form-item
-            label="是否结算课酬"
-            label-width="120px"
-            prop="isSettlementSalary"
-            :rules="[
-              {
-                required: true,
-                message: '请选择是否结算课酬',
-                trigger: 'change'
-              }
-            ]"
-          >
-            <el-select
-              v-model.trim="updateForm.isSettlementSalary"
-              style="width: 220px !important"
-            >
+        <el-form style="margin-top: 20px" ref="salaryForm" :model="updateForm" :rules="rules">
+          <el-form-item label="是否结算课酬" label-width="120px" prop="isSettlementSalary" :rules="[
+            {
+              required: true,
+              message: '请选择是否结算课酬',
+              trigger: 'change'
+            }
+          ]">
+            <el-select v-model.trim="updateForm.isSettlementSalary" style="width: 220px !important">
               <el-option label="是" :value="1"></el-option>
               <el-option label="否" :value="0"></el-option>
             </el-select>
@@ -303,14 +220,10 @@
 
         <!--  v-permission="pageType == 'create' ? {child: 'teacherDefaultMusicGroupSalary/batchUpset', parent: 'teacherAdd/batchUpset'} : {child: 'teacherDefaultMusicGroupSalary/batchUpset', parent: 'teacherUpdate/batchUpset'}" -->
         <div style="padding-top: 10px">
-          <auth
-            :auths="
-              pageType == 'create'
-                ? ['/teacherOperationAdd', 'teacherDefaultCreateSave']
-                : ['/teacherOperationUpdate', 'teacherDefaultUpdateSave']
-            "
-            mulit
-          >
+          <auth :auths="pageType == 'create'
+            ? ['/teacherOperationAdd', 'teacherDefaultCreateSave']
+            : ['/teacherOperationUpdate', 'teacherDefaultUpdateSave']
+            " mulit>
             <el-button @click="onSave()" type="primary">保存</el-button>
           </auth>
         </div>
@@ -437,6 +350,7 @@ export default {
         }
       ],
       vipTable: [],
+      liveTable: [],
       musicGroupTable: [],
       ruleList: [],
       vipList: [],
@@ -463,7 +377,6 @@ export default {
       studentRuleNum: ""
     };
   },
-  created() {},
   async mounted() {
     // this.pageType = this.$route.query.type;
     try {
@@ -476,10 +389,6 @@ export default {
     this.tenantId = this.$helpers.tenantId;
     this.__init();
   },
-  // activated () {
-  //   this.pageType = this.$route.query.type;
-  //   this.__init();
-  // },
   methods: {
     __init() {
       if (this.$route.query.search) {
@@ -524,6 +433,36 @@ export default {
           });
         }
       });
+
+      // 获取课程形态 设置vip课酬
+      findTeacherDefaultSalary({ userId: this.teacherId, groupType: 'LIVE' }).then(res => {
+        if (res.code == 200 && res.data.length > 0) {
+          let liveData = [];
+          res.data.forEach(item => {
+            liveData.push({
+              offlineClassesSalary: null,
+              onlineClassesSalary: null,
+              vipGroupCategoryId: item.id,
+              vipGroupCategoryName: item.name,
+              userId: this.teacherId,
+              musicTheory: item.musicTheory
+            });
+          });
+
+          // 直播课课列表
+          vipGroupSalaryList({
+            rows: 9999,
+            page: 1,
+            search: this.teacherId,
+            groupType: 'LIVE'
+          }).then(res => {
+            if (res.code == 200) {
+              const rows = res.data.rows;
+              this.liveListCompare(liveData, rows);
+            }
+          });
+        }
+      });
       // 乐团
       teacherSalaryList({
         rows: 9999,
@@ -564,6 +503,7 @@ export default {
               onlineClassesSalary: c.onlineClassesSalary,
               vipGroupCategoryName: c.vipGroupCategoryName,
               userId: c.userId,
+              groupType: c.groupType,
               musicTheory: c.musicTheory
             });
           }
@@ -581,6 +521,43 @@ export default {
       this.vipTable = result;
     },
 
+    liveListCompare(liveData, rows) {
+      // 直播课 做对比
+      if (!rows) {
+        // 判断是否有数据
+        this.liveTable = liveData;
+        return;
+      }
+      let result = [];
+      liveData.forEach(item => {
+        rows.forEach(c => {
+          if (item.vipGroupCategoryId == c.vipGroupCategoryId) {
+            item.checked = true;
+            result.push({
+              vipGroupCategoryId: c.vipGroupCategoryId,
+              offlineClassesSalary: c.offlineClassesSalary,
+              onlineClassesSalary: c.onlineClassesSalary,
+              vipGroupCategoryName: c.vipGroupCategoryName,
+              userId: c.userId,
+              groupType: c.groupType,
+              musicTheory: c.musicTheory
+            });
+          }
+        });
+      });
+      if (result.length > 0) {
+        liveData.forEach(item => {
+          if (!item.checked) {
+            result.push(item);
+          }
+        });
+      } else {
+        result = liveData;
+      }
+      console.log(result, 'result')
+      this.liveTable = result;
+    },
+
     teacherSalaryMoney(rows) {
       // 判断是否有数据
       if (!rows || rows.length <= 0) return;
@@ -703,6 +680,15 @@ export default {
           return;
         }
       });
+
+      this.liveTable.forEach(item => {
+        // console.log(item)
+        if (item.offlineClassesSalary < 0 || item.onlineClassesSalary < 0) {
+          this.$message.error("输入课酬不能为负数");
+          checkStatus = false;
+          return;
+        }
+      });
       this.accompanyTable.forEach(item => {
         if (item.mainTeacherSalary < 0) {
           this.$message.error("输入课酬不能为负数");
@@ -739,33 +725,53 @@ export default {
               teacherSalaryBatchUpset({
                 teacherDefaultMusicGroupSalaries: params
                 // startDate: updateForm.startDate
-              }).then(res => {
+              }).then(async (res) => {
                 if (res.code == 200) {
                   // 判断输入的值是否正确
-                  vipGroupSalarySet({
-                    teacherDefaultVipGroupSalaries: this.vipTable
-                    // startDate: updateForm.startDate
-                  }).then(res => {
-                    if (res.code == 200) {
-                      PracticeGroupSalaryUpdate({
-                        // startDate: updateForm.startDate,
-                        teacherDefaultPracticeGroupSalaries: this.accompanyTable
-                      }).then(res => {
-                        if (res.code == 200) {
-                          this.$message.success("保存成功");
-                          this.$store.dispatch("delVisitedViews", this.$route);
-                          this.$router.push({
-                            path: "/teacherManager/teacherList",
-                            query: { rules: this.Frules, search: this.Fsearch }
-                          });
-                        }
-                      });
-                    }
-                  });
+                  // vipGroupSalarySet({
+                  //   teacherDefaultVipGroupSalaries: this.vipTable
+                  //   // startDate: updateForm.startDate
+                  // }).then(res => {
+                  //   if (res.code == 200) {
+                  //     PracticeGroupSalaryUpdate({
+                  //       // startDate: updateForm.startDate,
+                  //       teacherDefaultPracticeGroupSalaries: this.accompanyTable
+                  //     }).then(res => {
+                  //       if (res.code == 200) {
+                  //         this.$message.success("保存成功");
+                  //         this.$store.dispatch("delVisitedViews", this.$route);
+                  //         this.$router.push({
+                  //           path: "/teacherManager/teacherList",
+                  //           query: { rules: this.Frules, search: this.Fsearch }
+                  //         });
+                  //       }
+                  //     });
+                  //   }
+                  // });
+                  try {
+                    await vipGroupSalarySet({
+                      teacherDefaultVipGroupSalaries: this.vipTable
+                    })
+                    await vipGroupSalarySet({
+                      teacherDefaultVipGroupSalaries: this.liveTable
+                    })
+                    await PracticeGroupSalaryUpdate({
+                      // startDate: updateForm.startDate,
+                      teacherDefaultPracticeGroupSalaries: this.accompanyTable
+                    })
+                    this.$message.success("保存成功");
+                    this.$store.dispatch("delVisitedViews", this.$route);
+                    this.$router.push({
+                      path: "/teacherManager/teacherList",
+                      query: { rules: this.Frules, search: this.Fsearch }
+                    });
+                  } catch {
+                    //
+                  }
                 }
               });
             })
-            .catch(() => {});
+            .catch(() => { });
         }
       });
       // 判断输入的值是否正确
@@ -786,14 +792,18 @@ export default {
     color: #444;
     font-weight: normal;
   }
+
   .tableList {
+
     .left,
     .right {
       float: left;
     }
+
     .left {
       width: 100%;
     }
+
     .right {
       width: 56%;
       margin-left: 2%;
@@ -808,6 +818,7 @@ export default {
     }
   }
 }
+
 ::v-deep .el-input-group__append {
   min-width: 103px;
   background-color: #f5f7fa;