vipNewActive.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. <template>
  2. <div class="m-container">
  3. <!-- <h2><div class="squrt"></div>VIP活动方案新增 </h2> -->
  4. <h2>
  5. <el-page-header
  6. @back="onCancel"
  7. :content="
  8. 'VIP/乐理课活动方案' + (pageType == 'create' ? '新增' : '修改')
  9. "
  10. ></el-page-header>
  11. </h2>
  12. <div class="m-core">
  13. <el-form
  14. :label-position="labelPosition"
  15. :model="vipform"
  16. ref="vipform"
  17. label-width="120px"
  18. :rules="vipformRules"
  19. class="vipform"
  20. >
  21. <el-form-item label="活动名称" prop="name">
  22. <el-input style="width: 400px" v-model.trim="vipform.name"></el-input>
  23. </el-form-item>
  24. <el-form-item label="适用分部" prop="organ">
  25. <select-all
  26. v-model.trim="vipform.organ"
  27. style="width: 400px"
  28. multiple
  29. filterable
  30. @visible-change="$forceUpdate()"
  31. @change="onOrganChange"
  32. clearable
  33. >
  34. <el-option
  35. v-for="(item, index) in selects.branchs"
  36. :key="index"
  37. :label="item.name"
  38. :value="item.id"
  39. ></el-option>
  40. </select-all>
  41. <!-- <el-button @click="onCheckAllBranch">适用所有分部</el-button> -->
  42. </el-form-item>
  43. <el-form-item label="课程形式" prop="stauts">
  44. <select-all
  45. v-model.trim="vipform.stauts"
  46. style="width: 400px"
  47. @visible-change="$forceUpdate()"
  48. clearable
  49. multiple
  50. >
  51. <el-option
  52. v-for="item in selects.vipGroupCategory"
  53. :key="item.id"
  54. :value="item.id"
  55. :label="item.name"
  56. ></el-option>
  57. </select-all>
  58. </el-form-item>
  59. <el-form-item label="课程调整方式" prop="allowOnlineToOffline">
  60. <el-select
  61. v-model.trim="vipform.allowOnlineToOffline"
  62. placeholder="请选择课程调整方式"
  63. clearable
  64. >
  65. <el-option
  66. :label="item.label"
  67. :value="item.value"
  68. v-for="item in vipResetTypeList"
  69. :key="item.value"
  70. ></el-option>
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item label="使用学员" prop="applyToStudentType">
  74. <el-select
  75. v-model.trim="vipform.applyToStudentType"
  76. placeholder="请选择使用学员"
  77. clearable
  78. >
  79. <el-option label="新学员" :value="1"></el-option>
  80. <el-option label="老学员" :value="0"></el-option>
  81. <el-option label="所有学员" :value="-1"></el-option>
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item label="活动描述" prop="desc">
  85. <el-input
  86. type="textarea"
  87. v-model.trim="vipform.desc"
  88. style="width: 400px"
  89. :rows="5"
  90. placeholder="请输入活动说明"
  91. ></el-input>
  92. </el-form-item>
  93. <el-form-item label="活动时间" prop="activeTime">
  94. <el-date-picker
  95. v-model.trim="vipform.activeTime"
  96. type="datetimerange"
  97. :default-time="['00:00:00', '23:59:59']"
  98. range-separator="至"
  99. value-format="yyyy-MM-dd HH:mm:ss"
  100. start-placeholder="开始日期"
  101. :picker-options="{
  102. firstDayOfWeek: 1,
  103. }"
  104. end-placeholder="结束日期"
  105. ></el-date-picker>
  106. </el-form-item>
  107. <el-form-item label="课程时间" prop="courseTime">
  108. <el-date-picker
  109. v-model.trim="vipform.courseTime"
  110. type="datetimerange"
  111. :default-time="['00:00:00', '23:59:59']"
  112. range-separator="至"
  113. value-format="yyyy-MM-dd HH:mm:ss"
  114. start-placeholder="开始日期"
  115. :picker-options="{
  116. firstDayOfWeek: 1,
  117. }"
  118. end-placeholder="结束日期"
  119. ></el-date-picker>
  120. </el-form-item>
  121. </el-form>
  122. <el-alert
  123. title="活动适用范围&结算标准:"
  124. type="info"
  125. :closable="false"
  126. class="alert"
  127. >
  128. </el-alert>
  129. <div class="activeRange" style="padding-left: 120px">
  130. <!-- <div class="left">
  131. <p>活动适用范围&结算标准:</p>
  132. </div> -->
  133. <div class="right">
  134. <div class="chioseWrap">
  135. <el-checkbox label="线上课" v-model.trim="online"></el-checkbox>
  136. <el-select
  137. v-model.trim="onlineSalary"
  138. disabled
  139. clearable
  140. filterable
  141. >
  142. <el-option
  143. label="老师默认课酬"
  144. value="TEACHER_DEFAULT"
  145. ></el-option>
  146. <el-option
  147. label="实际课程单价比例折扣"
  148. value="RATIO_DISCOUNT"
  149. ></el-option>
  150. <el-option label="固定课酬" value="FIXED_SALARY"></el-option>
  151. </el-select>
  152. <el-input
  153. placeholder="请输入"
  154. v-if="onlineSalary == 'RATIO_DISCOUNT'"
  155. style="width: 200px"
  156. type="number"
  157. @mousewheel.native.prevent
  158. v-model.trim="onlineprice"
  159. >
  160. <template slot="append">%</template>
  161. </el-input>
  162. <el-input
  163. placeholder="请输入"
  164. v-if="onlineSalary == 'FIXED_SALARY'"
  165. style="width: 200px"
  166. type="number"
  167. @mousewheel.native.prevent
  168. v-model.trim="onlineprice"
  169. >
  170. <template slot="append">元</template>
  171. </el-input>
  172. <div
  173. style="width: 200px"
  174. v-if="onlineSalary == 'TEACHER_DEFAULT'"
  175. ></div>
  176. <!-- <el-checkbox label="是否参加梯度"
  177. style="margin-left:20px;"
  178. v-model.trim="onlineClassJoinGradientRewards"></el-checkbox> -->
  179. </div>
  180. <div class="chioseWrap">
  181. <el-checkbox label="线下课" v-model.trim="unonline"></el-checkbox>
  182. <el-select
  183. v-model.trim="unonlineSalary"
  184. clearable
  185. disabled
  186. filterable
  187. >
  188. <el-option
  189. label="老师默认课酬"
  190. value="TEACHER_DEFAULT"
  191. ></el-option>
  192. <el-option
  193. label="实际课程单价比例折扣"
  194. value="RATIO_DISCOUNT"
  195. ></el-option>
  196. <el-option label="固定课酬" value="FIXED_SALARY"></el-option>
  197. </el-select>
  198. <el-input
  199. placeholder="请输入"
  200. v-if="unonlineSalary == 'RATIO_DISCOUNT'"
  201. style="width: 200px"
  202. type="number"
  203. @mousewheel.native.prevent
  204. v-model.trim="unonlineprice"
  205. >
  206. <template slot="append">%</template>
  207. </el-input>
  208. <el-input
  209. placeholder="请输入"
  210. style="width: 200px"
  211. v-if="unonlineSalary == 'FIXED_SALARY'"
  212. type="number"
  213. @mousewheel.native.prevent
  214. v-model.trim="unonlineprice"
  215. >
  216. <template slot="append">元</template>
  217. </el-input>
  218. <div
  219. style="width: 200px"
  220. v-if="unonlineSalary == 'TEACHER_DEFAULT'"
  221. ></div>
  222. <!-- <el-checkbox label="是否参加梯度"
  223. style="margin-left:20px;"
  224. v-model.trim="offlineClassJoinGradientRewards"></el-checkbox> -->
  225. </div>
  226. <!-- <div class="chioseWrap">
  227. <el-checkbox v-model.trim="paymentReadonlyFlag"
  228. label="可自定义单价"></el-checkbox>
  229. <el-checkbox v-model.trim="salaryReadonlyFlag"
  230. label="可自定义课酬"></el-checkbox>
  231. </div> -->
  232. </div>
  233. </div>
  234. <el-alert
  235. title="活动类型:"
  236. type="info"
  237. style="margin-bottom: 15px"
  238. :closable="false"
  239. class="alert"
  240. >
  241. </el-alert>
  242. <div class="activeType">
  243. <!-- <div class="left">
  244. <p>活动类型</p>
  245. </div> -->
  246. <div class="right">
  247. <div>
  248. <div
  249. class="head"
  250. :class="activeType == 'BASE_ACTIVITY' ? 'active' : ''"
  251. @click="
  252. () => {
  253. this.$refs['form'].resetFields();
  254. activeType = 'BASE_ACTIVITY';
  255. courseNumForm = {
  256. minCourseNum: '',
  257. maxCourseNum: '',
  258. studentMaxUsedTimes: '',
  259. };
  260. attribute1 = '';
  261. attribute2 = '';
  262. }
  263. "
  264. >
  265. 基础活动
  266. </div>
  267. <p class="title" v-if="activeType == 'BASE_ACTIVITY'">课程原价</p>
  268. </div>
  269. <div>
  270. <div
  271. class="head"
  272. :class="activeType == 'DISCOUNT' ? 'active' : ''"
  273. @click="activeType = 'DISCOUNT'"
  274. >
  275. 折扣
  276. </div>
  277. <el-input
  278. v-if="activeType == 'DISCOUNT'"
  279. v-model.trim="attribute1"
  280. style="width: 200px !important"
  281. placeholder="请输入折扣数值"
  282. >
  283. <template slot="append">%</template>
  284. </el-input>
  285. <el-form
  286. :model="courseNumForm"
  287. :inline="true"
  288. ref="form"
  289. v-show="activeType == 'DISCOUNT'"
  290. :rules="activeType == 'DISCOUNT' ? courseNumrules : {}"
  291. >
  292. <el-form-item prop="minCourseNum">
  293. <el-input
  294. @change="handleMinChange"
  295. v-model.number="courseNumForm.minCourseNum"
  296. type="number"
  297. style="margin-left: 10px; width: 120px !important"
  298. placeholder="最小课时数"
  299. >
  300. </el-input>
  301. </el-form-item>
  302. <el-form-item prop="maxCourseNum">
  303. <el-input
  304. @change="handleMaxChange"
  305. v-model.number="courseNumForm.maxCourseNum"
  306. type="number"
  307. style="margin-left: 10px; width: 120px !important"
  308. placeholder="最大课时数"
  309. >
  310. </el-input>
  311. </el-form-item>
  312. <el-form-item>
  313. <el-input
  314. v-model.number="courseNumForm.studentMaxUsedTimes"
  315. type="number"
  316. style="margin-left: 10px; width: 120px !important"
  317. placeholder="学员购买次数"
  318. >
  319. </el-input>
  320. </el-form-item>
  321. </el-form>
  322. </div>
  323. <div>
  324. <div
  325. class="head"
  326. :class="activeType == 'GIVE_CLASS' ? 'active' : ''"
  327. @click="
  328. () => {
  329. this.$refs['form'].resetFields();
  330. activeType = 'GIVE_CLASS';
  331. courseNumForm.minCourseNum = '';
  332. courseNumForm.maxCourseNum = '';
  333. attribute1 = '';
  334. attribute2 = '';
  335. }
  336. "
  337. >
  338. 赠送课时
  339. </div>
  340. <el-input
  341. placeholder="多少节开始赠"
  342. v-if="activeType == 'GIVE_CLASS'"
  343. v-model.trim="attribute1"
  344. type="number"
  345. @mousewheel.native.prevent
  346. style="margin-right: 10px; width: 200px !important"
  347. >
  348. <template slot="append">节</template>
  349. </el-input>
  350. <span v-if="activeType == 'GIVE_CLASS'">赠</span>
  351. <el-input
  352. v-if="activeType == 'GIVE_CLASS'"
  353. placeholder="请输入赠送课时数"
  354. type="number"
  355. @mousewheel.native.prevent
  356. v-model.trim="attribute2"
  357. style="margin: 0 10px; width: 200px !important"
  358. >
  359. <template slot="append">节</template>
  360. </el-input>
  361. <el-input
  362. v-show="activeType == 'GIVE_CLASS'"
  363. v-model.number="courseNumForm.studentMaxUsedTimes"
  364. type="number"
  365. style="margin-left: 10px; width: 120px !important"
  366. placeholder="学员购买次数"
  367. >
  368. </el-input>
  369. <!-- <el-checkbox
  370. v-if="activeType=='GIVE_CLASS'"
  371. v-model.trim="giveClassPaySalaryFlag"
  372. label="赠送课时结算课酬"
  373. ></el-checkbox> -->
  374. </div>
  375. </div>
  376. </div>
  377. </div>
  378. <div
  379. class="btnWrap"
  380. style="justify-content: flex-start; padding-left: 120px"
  381. >
  382. <el-button type="primary" @click="submitFrom">确定</el-button>
  383. <el-button type="info" @click="onReSet">重置</el-button>
  384. <!-- <div class="okBtn"
  385. @click="submitFrom">确定</div> -->
  386. <!-- -->
  387. </div>
  388. </div>
  389. </template>
  390. <script>
  391. import { vipGroupCategory, addVipActive } from "@/api/vipSeting";
  392. import { getEmployeeOrgan } from "@/api/buildTeam";
  393. import { vipResetTypeList } from "@/utils/searchArray";
  394. import cleanDeep from "clean-deep";
  395. const MIN_NUMBER = 1;
  396. const MAX_NUMBER = 999;
  397. export default {
  398. name: "vipNewActive",
  399. data() {
  400. return {
  401. vipResetTypeList,
  402. pageType: "",
  403. labelPosition: "right",
  404. vipform: {
  405. name: "",
  406. desc: "",
  407. activeTime: [],
  408. courseTime: [],
  409. organ: [],
  410. },
  411. vipformRules: {
  412. name: [
  413. { required: true, message: "请输入活动名称", trigger: "blur" },
  414. {
  415. min: 1,
  416. max: 25,
  417. message: "长度在 1 到 25 个字符",
  418. trigger: "blur",
  419. },
  420. ],
  421. desc: [
  422. { required: false, message: "请输入文字描述", trigger: "blur" },
  423. {
  424. min: 1,
  425. max: 200,
  426. message: "长度在 1 到 200 个字符",
  427. trigger: "blur",
  428. },
  429. ],
  430. activeTime: [
  431. { required: false, message: "请选择活动时间", trigger: "blur" },
  432. ],
  433. courseTime: [
  434. { required: false, message: "请选择课程时间", trigger: "blur" },
  435. ],
  436. organ: [{ required: true, message: "请选择适用分部", trigger: "blur" }],
  437. stauts: [
  438. { required: true, message: "请选择活动形式", trigger: "blur" },
  439. ],
  440. applyToStudentType: [{ required: true, message: "请选择是否新生专享" }],
  441. allowOnlineToOffline: [
  442. { required: true, message: "请选择课程调整方式" },
  443. ],
  444. },
  445. courseStatusList: [], // 获取所有课程形式
  446. activeType: "",
  447. online: true,
  448. unonline: true,
  449. onlineSalary: "TEACHER_DEFAULT",
  450. unonlineSalary: "TEACHER_DEFAULT",
  451. onlineprice: "",
  452. unonlineprice: "",
  453. salaryReadonlyFlag: false,
  454. paymentReadonlyFlag: false,
  455. attribute1: "",
  456. attribute2: "",
  457. courseNumForm: {
  458. minCourseNum: "",
  459. maxCourseNum: "",
  460. studentMaxUsedTimes: "",
  461. },
  462. giveClassPaySalaryFlag: true,
  463. organList: [],
  464. onlineClassJoinGradientRewards: false,
  465. offlineClassJoinGradientRewards: false,
  466. courseNumrules: {
  467. minCourseNum: [
  468. { required: true, message: "请输入最小课时数", trigger: "blur" },
  469. { validator: this.validateCom, trigger: "blur" },
  470. { validator: this.validateMin, trigger: "blur" },
  471. ],
  472. maxCourseNum: [
  473. { required: true, message: "请输入最大课时数", trigger: "blur" },
  474. { validator: this.validateCom, trigger: "blur" },
  475. { validator: this.validateMax, trigger: "blur" },
  476. ],
  477. },
  478. };
  479. },
  480. activated() {
  481. this.onReSet();
  482. // if (this.$route.query.rules) {
  483. // this.rules = this.$route.query.rules;
  484. // }
  485. // if (this.$route.query.searchForm) {
  486. // this.searchForm = this.$route.query.searchForm;
  487. // }
  488. this.pageType = this.$route.query.type;
  489. this.$refs.vipform.resetFields();
  490. },
  491. async mounted() {
  492. // 首先获取课程形式
  493. // vipGroupCategory().then(res => {
  494. // if (res.code == 200) {
  495. // this.courseStatusList = res.data;
  496. // }
  497. // });
  498. // // 适用分部
  499. // getEmployeeOrgan().then(res => {
  500. // if (res.code == 200) {
  501. // this.organList = res.data;
  502. // }
  503. // });
  504. // 获取类型
  505. await this.$store.dispatch("setVipGroupCategory");
  506. // 获取分部
  507. await this.$store.dispatch("setBranchs");
  508. this.onReSet();
  509. // if (this.$route.query.rules) {
  510. // this.rules = this.$route.query.rules;
  511. // }
  512. // if (this.$route.query.searchForm) {
  513. // this.searchForm = this.$route.query.searchForm;
  514. // }
  515. this.pageType = this.$route.query.type;
  516. this.$refs.vipform.resetFields();
  517. },
  518. methods: {
  519. resetForm() {
  520. this.$refs.form.resetFields();
  521. },
  522. handleMinChange() {
  523. this.$refs.form.validateField("maxCourseNum");
  524. },
  525. handleMaxChange() {
  526. this.$refs.form.validateField("minCourseNum");
  527. },
  528. validateCom(rule, value, callback) {
  529. const one = Number(value);
  530. if (Number.isInteger(one)) {
  531. if (one < MIN_NUMBER) {
  532. return callback(new Error("输入值必须大于0"));
  533. } else if (one > MAX_NUMBER) {
  534. return callback(new Error("输入值必须小于999"));
  535. }
  536. return callback();
  537. }
  538. return callback(new Error("输入值必须为正整数"));
  539. },
  540. validateMin(rule, value, callback) {
  541. const one = Number(value);
  542. const max = Number(this.courseNumForm.maxCourseNum);
  543. if (!max || one <= max) {
  544. return callback();
  545. }
  546. return callback(new Error("输入值不得大于最大课时数"));
  547. },
  548. validateMax(rule, value, callback) {
  549. const one = Number(value);
  550. const min = Number(this.courseNumForm.minCourseNum);
  551. if (!min || one >= min) {
  552. return callback();
  553. }
  554. return callback(new Error("输入值不得小于最小课时数"));
  555. },
  556. changeStauts(val) {
  557. console.log(val);
  558. },
  559. submitFrom() {
  560. this.$refs.form.validate((isok) => {
  561. if (isok) {
  562. this.$refs["vipform"].validate((valid) => {
  563. if (valid) {
  564. // 验证通过
  565. let coursesStartTime = null,
  566. coursesEndTime = null,
  567. startTime = null,
  568. endTime = null;
  569. if (
  570. this.vipform.courseTime &&
  571. this.vipform.courseTime.length > 0
  572. ) {
  573. coursesStartTime = this.vipform.courseTime[0];
  574. coursesEndTime = this.vipform.courseTime[1];
  575. }
  576. if (
  577. this.vipform.activeTime &&
  578. this.vipform.activeTime.length > 0
  579. ) {
  580. startTime = this.vipform.activeTime[0];
  581. endTime = this.vipform.activeTime[1];
  582. }
  583. let organId = this.vipform.organ.join(",");
  584. let type = this.activeType;
  585. if (!type) {
  586. this.$message.error("请选择活动类型");
  587. return;
  588. }
  589. if (!this.online && !this.unonline) {
  590. this.$message.error("请选择活动适用范围");
  591. return;
  592. }
  593. if (type == "DISCOUNT") {
  594. if (!this.attribute1 || this.attribute1 < 0) {
  595. this.$message.error("折扣必须大于等于0");
  596. return;
  597. }
  598. } else if (type == "GIVE_CLASS") {
  599. if (!this.attribute1) {
  600. this.$message.error("请输入多少节开始赠");
  601. return;
  602. }
  603. if (!this.attribute2) {
  604. this.$message.error("请输入赠送课时数");
  605. return;
  606. }
  607. }
  608. let vipGroupCategoryIdList = this.vipform.stauts.join(",");
  609. let onlineSalarySettlement;
  610. let offlineSalarySettlement;
  611. if (this.online) {
  612. // 勾选线上
  613. if (this.onlineSalary == "RATIO_DISCOUNT") {
  614. if (this.onlineprice < 0 || this.onlineprice > 100) {
  615. this.$message.error("折扣比必须大于0且小于100");
  616. return;
  617. }
  618. } else if (this.onlineSalary == "TEACHER_DEFAULT") {
  619. this.onlineprice = 0;
  620. }
  621. onlineSalarySettlement = {
  622. salarySettlementType: this.onlineSalary,
  623. settlementValue: this.onlineprice,
  624. };
  625. } else {
  626. onlineSalarySettlement = null;
  627. }
  628. if (this.unonline) {
  629. // 勾选线下
  630. if (this.unonlineSalary == "RATIO_DISCOUNT") {
  631. if (this.unonlineprice < 0 || this.unonlineprice > 100) {
  632. this.$message.error("折扣比必须大于0且小于100");
  633. return;
  634. }
  635. } else if (this.unonlineSalary == "TEACHER_DEFAULT") {
  636. this.unonlineprice = 0;
  637. }
  638. offlineSalarySettlement = {
  639. salarySettlementType: this.unonlineSalary,
  640. settlementValue: this.unonlineprice,
  641. };
  642. } else {
  643. offlineSalarySettlement = null;
  644. }
  645. let salaryReadonlyFlag = this.salaryReadonlyFlag * 1;
  646. let paymentReadonlyFlag = this.paymentReadonlyFlag * 1;
  647. // let giveClassPaySalaryFlag = this.giveClassPaySalaryFlag * 1;
  648. let vipGroupSalarySettlement = {
  649. onlineSalarySettlement,
  650. offlineSalarySettlement,
  651. };
  652. if (type == "BASE_ACTIVITY") {
  653. this.courseNumForm.studentMaxUsedTimes = -1;
  654. this.courseNumForm.minCourseNum = -1;
  655. this.courseNumForm.maxCourseNum = -1;
  656. } else if (type == "GIVE_CLASS") {
  657. this.courseNumForm.minCourseNum = -1;
  658. this.courseNumForm.maxCourseNum = -1;
  659. }
  660. // 发请求创建活动
  661. addVipActive(
  662. cleanDeep({
  663. coursesStartTime,
  664. coursesEndTime,
  665. startTime,
  666. endTime,
  667. name: this.vipform.name,
  668. description: this.vipform.desc,
  669. applyToStudentType: this.vipform.applyToStudentType,
  670. allowOnlineToOffline: this.vipform.allowOnlineToOffline,
  671. organId,
  672. type,
  673. vipGroupCategoryIdList,
  674. vipGroupSalarySettlement,
  675. salaryReadonlyFlag,
  676. paymentReadonlyFlag,
  677. giveClassPaySalaryFlag: 1,
  678. attribute1: this.attribute1,
  679. attribute2: this.attribute2,
  680. minCourseNum: this.courseNumForm.minCourseNum,
  681. maxCourseNum: this.courseNumForm.maxCourseNum,
  682. studentMaxUsedTimes: this.courseNumForm.studentMaxUsedTimes
  683. ? this.courseNumForm.studentMaxUsedTimes
  684. : -1,
  685. offlineClassJoinGradientRewards:
  686. this.offlineClassJoinGradientRewards * 1,
  687. onlineClassJoinGradientRewards:
  688. this.onlineClassJoinGradientRewards * 1,
  689. })
  690. ).then((res) => {
  691. if (res.code == 200) {
  692. this.$message.success("恭喜你,活动创建成功");
  693. this.onReSet();
  694. this.$store.dispatch("delVisitedViews", this.$route);
  695. this.$router.push({
  696. path: "/vipActiveManager/vipActiveList",
  697. });
  698. }
  699. });
  700. } else {
  701. this.$nextTick(() => {
  702. let isError = document.getElementsByClassName("is-error");
  703. isError[0].scrollIntoView({
  704. block: "center",
  705. behavior: "smooth",
  706. });
  707. });
  708. // this.$message.error("请填写必要参数");
  709. }
  710. });
  711. }
  712. });
  713. // 线上线下课 勾选就传不勾选就不传
  714. // addVipActive().then(res => { })
  715. },
  716. onOrganChange() {
  717. this.$forceUpdate();
  718. },
  719. onCheckAllBranch() {
  720. // 选择所有分部
  721. let vipform = this.vipform;
  722. vipform.organ = [];
  723. this.selects.branchs.forEach((item) => {
  724. vipform.organ.push(item.id);
  725. });
  726. this.$forceUpdate();
  727. },
  728. onCancel() {
  729. this.$store.dispatch("delVisitedViews", this.$route);
  730. this.$router.push({
  731. path: "/vipActiveManager/vipActiveList",
  732. query: { rules: this.rules, searchForm: this.searchForm },
  733. });
  734. },
  735. onReSet() {
  736. this.vipform = {
  737. name: "",
  738. desc: "",
  739. activeTime: [],
  740. courseTime: [],
  741. };
  742. this.activeType = "";
  743. this.online = true;
  744. this.unonline = true;
  745. this.salaryReadonlyFlag = false;
  746. this.onlineSalary = "TEACHER_DEFAULT";
  747. this.unonlineSalary = "TEACHER_DEFAULT";
  748. this.onlineprice = "";
  749. this.unonlineprice = "";
  750. this.onlineClassJoinGradientRewards = false;
  751. this.offlineClassJoinGradientRewards = false;
  752. this.attribute1 = "";
  753. this.attribute2 = "";
  754. this.courseNumForm.maxCourseNum = "";
  755. this.courseNumForm.minCourseNum = "";
  756. this.$refs.vipform.resetFields();
  757. },
  758. },
  759. };
  760. </script>
  761. <style lang="scss" scoped>
  762. .m-core {
  763. font-size: 14px;
  764. width: 100%;
  765. display: flex;
  766. flex-direction: column;
  767. justify-content: center;
  768. // text-align: center;
  769. .activeRange {
  770. display: flex;
  771. flex-direction: row;
  772. justify-content: flex-start;
  773. .left {
  774. height: 72px;
  775. line-height: 72px;
  776. }
  777. .right {
  778. .chioseWrap {
  779. display: flex;
  780. flex-direction: row;
  781. justify-content: flex-start;
  782. height: 72px;
  783. line-height: 72px;
  784. align-items: center;
  785. .el-checkbox {
  786. margin-right: 20px;
  787. }
  788. .el-select {
  789. margin-right: 20px;
  790. }
  791. }
  792. }
  793. }
  794. .activeType {
  795. display: flex;
  796. flex-direction: row;
  797. justify-content: flex-start;
  798. .left {
  799. margin-right: 20px;
  800. p {
  801. height: 40px;
  802. line-height: 40px;
  803. }
  804. }
  805. .right {
  806. > div {
  807. display: flex;
  808. flex-direction: row;
  809. justify-content: flex-start;
  810. height: 40px;
  811. line-height: 40px;
  812. margin-bottom: 20px;
  813. .head {
  814. width: 120px;
  815. height: 40px;
  816. line-height: 40px;
  817. border: 1px solid #ccc;
  818. text-align: center;
  819. border-radius: 5px;
  820. cursor: pointer;
  821. margin-right: 10px;
  822. }
  823. > .head.active {
  824. background-color: #13817a;
  825. color: #fff;
  826. border: none;
  827. }
  828. .title {
  829. line-height: 40px;
  830. height: 40px;
  831. }
  832. }
  833. }
  834. }
  835. }
  836. </style>
  837. <style lang="scss">
  838. .m-core {
  839. .vipform {
  840. .el-select {
  841. width: 400px !important;
  842. .el-input__inner {
  843. width: 400px;
  844. }
  845. }
  846. }
  847. .activeType {
  848. .right {
  849. .el-input {
  850. width: 150px !important;
  851. }
  852. }
  853. }
  854. }
  855. </style>