lex-xin 4 miesięcy temu
rodzic
commit
b56fc95d85

+ 30 - 0
src/teacher/practice-class/practice-setting.module.less

@@ -13,6 +13,36 @@
   }
 }
 
+.showPrice {
+  background: #FFFAEE;
+  border-radius: 4px;
+  border: 1px solid;
+  border-image: linear-gradient(180deg, rgba(250, 237, 215, 1), rgba(251, 233, 206, 1)) 1 1;
+  padding: 9px 6px;
+  line-height: 1;
+  font-size: 13px;
+  color: #F68E3E;
+  margin-bottom: 12px;
+  span {
+    font-weight: 600;
+    font-size: 13px;
+    color: #FF4E1A;
+  }
+}
+
+.tipsAccount {
+  padding-top: 12px;
+  font-size: 14px;
+color: #999999;
+line-height: 24px;
+padding: 0 14px;
+span {
+  color: #FF4E19;
+  font-weight: bold;
+  padding: 0 4px;
+}
+}
+
 .radio-group,
 .checkbox-group {
   display: flex;

+ 55 - 9
src/teacher/practice-class/practice-setting.tsx

@@ -22,6 +22,14 @@ import { verifyNumberIntegerAndFloat } from '@/helpers/toolsValidate'
 import ColHeader from '@/components/col-header'
 import { state } from '@/state'
 import TheSticky from '@/components/the-sticky'
+import { moneyFormat } from '@/helpers/utils'
+
+/** 保留两位小数向上取整 */
+export const numberToTwoUp = (num: number | string) => {
+  num = Number(num)
+
+  return Math.ceil(num * 100) / 100
+}
 
 export default defineComponent({
   name: 'PracticeSetting',
@@ -39,6 +47,9 @@ export default defineComponent({
       classTimeStatus: false,
       subjectStatus: false,
       form: {
+        lowestPrice: 0 as any,
+        highestPrice: 0 as any,
+        coursePrice: 0 as any,
         courseMinutes: null as any,
         freeMinutes: 0,
         subjectIdTemp: '',
@@ -46,7 +57,8 @@ export default defineComponent({
         subjectPrice: [] as any[],
       },
       minutes: [] as any,
-      rate: 0
+      rate: 0,
+      accountPeriod: 0, // 账期
     }
   },
   computed: {
@@ -65,7 +77,7 @@ export default defineComponent({
         {
           params: {
             paramNames:
-              'practice_times_setting,practice_service_fee,vip_course_times_setting'
+              'practice_times_setting,practice_service_fee,vip_course_times_setting,vip_course_service_fee,vip_course_account_period,practice_account_period'
           }
         }
       )
@@ -82,13 +94,20 @@ export default defineComponent({
           })
           this.minutes = [...tempArr]
           if(this.minutes.length > 0) {
-            this.form.courseMinutes = this.minutes[0].courseMinutes
-            this.form.freeMinutes = this.minutes[0].freeMinutes
+            const minute = this.minutes[0]
+            this.form.coursePrice = minute.price
+            this.form.courseMinutes = minute.courseMinutes
+            this.form.freeMinutes = minute.freeMinutes
+            this.form.lowestPrice = minute.lowestPrice || 0
+            this.form.highestPrice = minute.highestPrice || 0
           }
         }
-        if (item.paramName === 'practice_service_fee') {
+        if (item.paramName === (this.courseType === 'VIP' ? 'vip_course_service_fee' : 'practice_service_fee')) {
           this.rate = item.paramValue
         }
+        if (item.paramName === (this.courseType === 'VIP' ? 'vip_course_account_period' : 'practice_account_period')) {
+          this.accountPeriod = item.paramValue
+        }
       })
       //
       const teacher = await request.post('/api-teacher/teacher/querySubject')
@@ -134,6 +153,11 @@ export default defineComponent({
     } catch {}
   },
   methods: {
+    onCalcCoursePrice(price: number | string) {
+      if(!price) { return '-' }
+      const money = Number(price)
+      return moneyFormat(numberToTwoUp(this.rate * money / 100))
+    },
     onSelect(item: any) {
       this.form.courseMinutes = item.courseMinutes
       this.form.freeMinutes = item.freeMinutes
@@ -149,9 +173,10 @@ export default defineComponent({
           (subject: any) => subject.subjectId === item
         )
         if (index === -1) {
+          console.log(this.form, 'this.orm')
           subjectPriceList.push({
             subjectId: item,
-            subjectPrice: this.checkStatus ? 0 : null as any,
+            subjectPrice: this.checkStatus ? 0 : this.form.coursePrice,
             subjectName: ''
           })
         }
@@ -171,6 +196,13 @@ export default defineComponent({
       const subject: any = this.subjectList.find((item: any) => item.id === id)
       return subject ? subject.name : ''
     },
+    validatePrice(rule?: any) {
+      if(Number(rule) > Number(this.form.highestPrice) || Number(rule) < Number(this.form.lowestPrice)) {
+        return false
+      } else {
+        return true
+      }
+    },
     onFormatter(val: any) {
       return verifyNumberIntegerAndFloat(val)
     },
@@ -307,25 +339,39 @@ export default defineComponent({
                   name="singleMins"
                   type="number"
                   labelWidth={'auto'}
+                  readonly={this.courseType === 'PRACTICE' ? true : false}
                   label={`${this.form.courseMinutes || 0}分钟 / `}
                   rules={[
                     {
                       required: true,
-                      message: `请选择声部${this.text}价格`
-                    }
+                      message: `请输入${this.getSubjectName(item.subjectId)}声部${this.text}价格`
+                    },
+                    this.courseType === "VIP" ? {
+                      validator: this.validatePrice,
+                      message: `请输入价格在${this.form.lowestPrice}~${this.form.highestPrice}范围内`
+                    } : {} as any
                   ]}
                   formatter={this.onFormatter}
                   maxlength={8}
-                  placeholder={`请选择声部${this.text}价格`}
+                  placeholder={this.courseType === 'VIP' ? `${this.form.lowestPrice}~${this.form.highestPrice}` :`请选择声部${this.text}价格`}
                   v-slots={{
                     button: () => <span>元</span>
                   }}
                 />
+                <div class={styles.showPrice}>
+                课程预计收入:<span>¥ {this.onCalcCoursePrice(item.subjectPrice)}</span>
+              </div>
               </ColField>
             ))}
           </ColFieldGroup>
         )}
 
+        <div class={styles.tipsAccount}>
+          扣除应缴税金和平台服务费后 <br />
+          实际课程收入按学生实际付款金额计算<br />
+          您的课程收入将在课程结束<span>{this.accountPeriod}</span>天后结算到您的账户
+        </div>
+
         <TheSticky position="bottom">
           <div class={['btnGroup', styles.PracticeSettingBtns]}>
             <Button block round type="primary" native-type="submit">