vipNewActive.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <div class="m-container">
  3. <!-- <h2><div class="squrt"></div>VIP活动方案新增 </h2> -->
  4. <h2>
  5. <el-page-header @back="onCancel"
  6. :content="'VIP活动方案' + (pageType == 'create' ? '新增' : '修改')"></el-page-header>
  7. </h2>
  8. <div class="m-core">
  9. <el-form :label-position="labelPosition"
  10. :model="vipform"
  11. ref="vipform"
  12. :rules="vipformRules"
  13. class="vipform">
  14. <el-form-item label="活动名称"
  15. prop="name">
  16. <el-input style="width:400px"
  17. v-model.trim="vipform.name"></el-input>
  18. </el-form-item>
  19. <el-form-item label="适用分部"
  20. prop="organ">
  21. <el-select v-model.trim="vipform.organ"
  22. multiple
  23. filterable
  24. @visible-change="$forceUpdate()"
  25. @change="onOrganChange"
  26. clearable>
  27. <el-option v-for="(item,index) in organList"
  28. :key="index"
  29. :label="item.name"
  30. :value="item.id"></el-option>
  31. </el-select>
  32. <el-button @click="onCheckAllBranch">适用所有分部</el-button>
  33. </el-form-item>
  34. <el-form-item label="课程形式"
  35. prop="stauts">
  36. <el-select v-model.trim="vipform.stauts"
  37. @visible-change="$forceUpdate()"
  38. clearable
  39. multiple>
  40. <el-option v-for="item in courseStatusList"
  41. :key="item.id"
  42. :value="item.id"
  43. :label="item.name"></el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="活动描述"
  47. prop="desc">
  48. <el-input type="textarea"
  49. v-model.trim="vipform.desc"
  50. style="width:400px"
  51. :rows="5"
  52. placeholder="请输入活动说明"></el-input>
  53. </el-form-item>
  54. <el-form-item label="活动时间"
  55. prop="activeTime">
  56. <el-date-picker v-model.trim="vipform.activeTime"
  57. type="datetimerange"
  58. range-separator="至"
  59. value-format="yyyy-MM-dd HH:mm:ss"
  60. start-placeholder="开始日期"
  61. :picker-options="{
  62. firstDayOfWeek:1
  63. }"
  64. end-placeholder="结束日期"></el-date-picker>
  65. </el-form-item>
  66. <el-form-item label="课程时间"
  67. prop="courseTime">
  68. <el-date-picker v-model.trim="vipform.courseTime"
  69. type="datetimerange"
  70. range-separator="至"
  71. value-format="yyyy-MM-dd HH:mm:ss"
  72. start-placeholder="开始日期"
  73. :picker-options="{
  74. firstDayOfWeek:1
  75. }"
  76. end-placeholder="结束日期"></el-date-picker>
  77. </el-form-item>
  78. </el-form>
  79. <div class="activeRange">
  80. <div class="left">
  81. <p>活动适用范围&结算标准:</p>
  82. </div>
  83. <div class="right">
  84. <div class="chioseWrap">
  85. <el-checkbox label="线上课"
  86. v-model.trim="online"></el-checkbox>
  87. <el-select v-model.trim="onlineSalary"
  88. clearable
  89. filterable>
  90. <el-option label="老师默认课酬"
  91. value="TEACHER_DEFAULT"></el-option>
  92. <el-option label="实际课程单价比例折扣"
  93. value="RATIO_DISCOUNT"></el-option>
  94. <el-option label="固定课酬"
  95. value="FIXED_SALARY"></el-option>
  96. </el-select>
  97. <el-input placeholder="请输入"
  98. v-if="onlineSalary== 'RATIO_DISCOUNT'"
  99. style="width:200px;"
  100. type="number"
  101. @mousewheel.native.prevent
  102. v-model.trim="onlineprice">
  103. <template slot="append">%</template>
  104. </el-input>
  105. <el-input placeholder="请输入"
  106. v-if="onlineSalary == 'FIXED_SALARY'"
  107. style="width:200px;"
  108. type="number"
  109. @mousewheel.native.prevent
  110. v-model.trim="onlineprice">
  111. <template slot="append">元</template>
  112. </el-input>
  113. <div style="width:200px;"
  114. v-if="onlineSalary== 'TEACHER_DEFAULT'"></div>
  115. <el-checkbox label="是否参加梯度"
  116. style="margin-left:20px;"
  117. v-model.trim="onlineClassJoinGradientRewards"></el-checkbox>
  118. </div>
  119. <div class="chioseWrap">
  120. <el-checkbox label="线下课"
  121. v-model.trim="unonline"></el-checkbox>
  122. <el-select v-model.trim="unonlineSalary"
  123. clearable
  124. filterable>
  125. <el-option label="老师默认课酬"
  126. value="TEACHER_DEFAULT"></el-option>
  127. <el-option label="实际课程单价比例折扣"
  128. value="RATIO_DISCOUNT"></el-option>
  129. <el-option label="固定课酬"
  130. value="FIXED_SALARY"></el-option>
  131. </el-select>
  132. <el-input placeholder="请输入"
  133. v-if="unonlineSalary== 'RATIO_DISCOUNT'"
  134. style="width:200px;"
  135. type="number"
  136. @mousewheel.native.prevent
  137. v-model.trim="unonlineprice">
  138. <template slot="append">%</template>
  139. </el-input>
  140. <el-input placeholder="请输入"
  141. style="width:200px;"
  142. v-if="unonlineSalary== 'FIXED_SALARY'"
  143. type="number"
  144. @mousewheel.native.prevent
  145. v-model.trim="unonlineprice">
  146. <template slot="append">元</template>
  147. </el-input>
  148. <div style="width:200px;"
  149. v-if="unonlineSalary== 'TEACHER_DEFAULT'"></div>
  150. <el-checkbox label="是否参加梯度"
  151. style="margin-left:20px;"
  152. v-model.trim="offlineClassJoinGradientRewards"></el-checkbox>
  153. </div>
  154. <div class="chioseWrap">
  155. <el-checkbox v-model.trim="paymentReadonlyFlag"
  156. label="可自定义单价"></el-checkbox>
  157. <!-- <el-checkbox v-model.trim="salaryReadonlyFlag"
  158. label="可自定义课酬"></el-checkbox> -->
  159. </div>
  160. </div>
  161. </div>
  162. <div class="activeType">
  163. <div class="left">
  164. <p>活动类型</p>
  165. </div>
  166. <div class="right">
  167. <div>
  168. <div class="head"
  169. :class="activeType=='BASE_ACTIVITY'?'active':''"
  170. @click="activeType='BASE_ACTIVITY'">基础活动</div>
  171. <p class="title"
  172. v-if="activeType=='BASE_ACTIVITY'">课程原价</p>
  173. </div>
  174. <div>
  175. <div class="head"
  176. :class="activeType=='DISCOUNT'?'active':''"
  177. @click="activeType='DISCOUNT'">折扣</div>
  178. <el-input v-if="activeType=='DISCOUNT'"
  179. v-model.trim="attribute1"
  180. style="width:200px!important"
  181. placeholder="请输入折扣数值">
  182. <template slot="append">%</template>
  183. </el-input>
  184. </div>
  185. <div>
  186. <div class="head"
  187. :class="activeType=='GIVE_CLASS'?'active':''"
  188. @click="activeType='GIVE_CLASS'">赠送课时</div>
  189. <el-input placeholder="多少节开始赠"
  190. v-if="activeType=='GIVE_CLASS'"
  191. v-model.trim="attribute1"
  192. type="number"
  193. @mousewheel.native.prevent
  194. style="margin-right:10px;width:200px!important">
  195. <template slot="append">节</template>
  196. </el-input>
  197. <span v-if="activeType=='GIVE_CLASS'">赠</span>
  198. <el-input v-if="activeType=='GIVE_CLASS'"
  199. placeholder="请输入赠送课时数"
  200. type="number"
  201. @mousewheel.native.prevent
  202. v-model.trim="attribute2"
  203. style="margin:0 10px;width:200px!important">
  204. <template slot="append">节</template>
  205. </el-input>
  206. <!-- <el-checkbox
  207. v-if="activeType=='GIVE_CLASS'"
  208. v-model.trim="giveClassPaySalaryFlag"
  209. label="赠送课时结算课酬"
  210. ></el-checkbox> -->
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. <div class="btnWrap"
  216. style="justify-content:flex-start">
  217. <div class="closeBtn"
  218. @click="onReSet">重置</div>
  219. <div class="okBtn"
  220. @click="submitFrom">确定</div>
  221. </div>
  222. </div>
  223. </template>
  224. <script>
  225. import { vipGroupCategory, addVipActive } from "@/api/vipSeting";
  226. import { getEmployeeOrgan } from "@/api/buildTeam";
  227. export default {
  228. name: "vipNewActive",
  229. data () {
  230. return {
  231. pageType: '',
  232. labelPosition: "left",
  233. vipform: {
  234. name: "",
  235. desc: "",
  236. activeTime: [],
  237. courseTime: [],
  238. organ: []
  239. },
  240. vipformRules: {
  241. name: [
  242. { required: true, message: "请输入活动名称", trigger: "blur" },
  243. { min: 1, max: 25, message: "长度在 1 到 25 个字符", trigger: "blur" }
  244. ],
  245. desc: [
  246. { required: false, message: "请输入文字描述", trigger: "blur" },
  247. {
  248. min: 1,
  249. max: 200,
  250. message: "长度在 1 到 200 个字符",
  251. trigger: "blur"
  252. }
  253. ],
  254. activeTime: [
  255. { required: false, message: "请选择活动时间", trigger: "blur" }
  256. ],
  257. courseTime: [
  258. { required: false, message: "请选择课程时间", trigger: "blur" }
  259. ],
  260. organ: [{ required: true, message: "请选择适用分部", trigger: "blur" }],
  261. stauts: [{ required: true, message: "请选择活动形式", trigger: "blur" }]
  262. },
  263. courseStatusList: [], // 获取所有课程形式
  264. activeType: "",
  265. online: true,
  266. unonline: true,
  267. onlineSalary: "TEACHER_DEFAULT",
  268. unonlineSalary: "TEACHER_DEFAULT",
  269. onlineprice: "",
  270. unonlineprice: "",
  271. salaryReadonlyFlag: false,
  272. paymentReadonlyFlag: true,
  273. attribute1: "",
  274. attribute2: "",
  275. attribute3: "",
  276. giveClassPaySalaryFlag: true,
  277. organList: [],
  278. onlineClassJoinGradientRewards: false,
  279. offlineClassJoinGradientRewards: false
  280. };
  281. },
  282. activated () {
  283. this.onReSet()
  284. if (this.$route.query.rules) {
  285. this.rules = this.$route.query.rules;
  286. }
  287. if (this.$route.query.searchForm) {
  288. this.searchForm = this.$route.query.searchForm;
  289. }
  290. this.pageType = this.$route.query.type
  291. this.$refs.vipform.resetFields();
  292. },
  293. mounted () {
  294. // 首先获取课程形式
  295. vipGroupCategory().then(res => {
  296. if (res.code == 200) {
  297. this.courseStatusList = res.data;
  298. }
  299. });
  300. // 适用分部
  301. getEmployeeOrgan().then(res => {
  302. if (res.code == 200) {
  303. this.organList = res.data;
  304. }
  305. });
  306. },
  307. methods: {
  308. changeStauts (val) {
  309. console.log(val)
  310. },
  311. submitFrom () {
  312. this.$refs["vipform"].validate(valid => {
  313. if (valid) {
  314. // 验证通过
  315. let coursesStartTime = this.vipform.courseTime[0];
  316. let coursesEndTime = this.vipform.courseTime[1];
  317. let startTime = this.vipform.activeTime[0];
  318. let endTime = this.vipform.activeTime[1];
  319. let organId = this.vipform.organ.join(",");
  320. let type = this.activeType;
  321. if (type == 'DISCOUNT') {
  322. if (this.attribute1 < 0 || this.attribute1 > 100) {
  323. this.$message.error('折扣必须大于0且小于100')
  324. return
  325. }
  326. }
  327. let vipGroupCategoryIdList = this.vipform.stauts.join(",");
  328. let onlineSalarySettlement;
  329. let offlineSalarySettlement;
  330. if (this.online) {
  331. // 勾选线上
  332. if (this.onlineSalary == 'RATIO_DISCOUNT') {
  333. if (this.onlineprice < 0 || this.onlineprice > 100) {
  334. this.$message.error('折扣比必须大于0且小于100')
  335. return
  336. }
  337. }
  338. onlineSalarySettlement = {
  339. salarySettlementType: this.onlineSalary,
  340. settlementValue: this.onlineprice
  341. };
  342. } else {
  343. onlineSalarySettlement = null;
  344. }
  345. if (this.unonline) {
  346. // 勾选线下
  347. if (this.unonlineSalary == 'RATIO_DISCOUNT') {
  348. if (this.unonlineprice < 0 || this.unonlineprice > 100) {
  349. this.$message.error('折扣比必须大于0且小于100')
  350. return
  351. }
  352. }
  353. offlineSalarySettlement = {
  354. salarySettlementType: this.unonlineSalary,
  355. settlementValue: this.unonlineprice
  356. };
  357. } else {
  358. offlineSalarySettlement = null;
  359. }
  360. let salaryReadonlyFlag = this.salaryReadonlyFlag * 1;
  361. let paymentReadonlyFlag = this.paymentReadonlyFlag * 1;
  362. // let giveClassPaySalaryFlag = this.giveClassPaySalaryFlag * 1;
  363. let vipGroupSalarySettlement = {
  364. onlineSalarySettlement,
  365. offlineSalarySettlement
  366. };
  367. // 发请求创建活动
  368. addVipActive({
  369. coursesStartTime,
  370. coursesEndTime,
  371. startTime,
  372. endTime,
  373. name: this.vipform.name,
  374. description: this.vipform.desc,
  375. organId,
  376. type,
  377. vipGroupCategoryIdList,
  378. vipGroupSalarySettlement,
  379. salaryReadonlyFlag,
  380. paymentReadonlyFlag,
  381. giveClassPaySalaryFlag: 1,
  382. attribute1: this.attribute1,
  383. attribute2: this.attribute2,
  384. attribute3: this.attribute3,
  385. offlineClassJoinGradientRewards: this.offlineClassJoinGradientRewards * 1,
  386. onlineClassJoinGradientRewards: this.onlineClassJoinGradientRewards * 1
  387. }).then(res => {
  388. if (res.code == 200) {
  389. this.$message.success("恭喜你,活动创建成功");
  390. this.onReSet();
  391. this.$router.push({
  392. path: "/vipClassSet/vipActiveList",
  393. query: { rules: this.rules, searchForm: this.searchForm }
  394. });
  395. }
  396. });
  397. } else {
  398. this.$message.error("请填写必要参数");
  399. }
  400. });
  401. // 线上线下课 勾选就传不勾选就不传
  402. // addVipActive().then(res => { })
  403. },
  404. onOrganChange () {
  405. this.$forceUpdate()
  406. },
  407. onCheckAllBranch () {
  408. // 选择所有分部
  409. let vipform = this.vipform
  410. vipform.organ = [];
  411. this.organList.forEach(item => {
  412. vipform.organ.push(item.id);
  413. });
  414. this.$forceUpdate()
  415. },
  416. onCancel () {
  417. this.$router.push({
  418. path: "/vipClassSet/vipActiveList",
  419. query: { rules: this.rules, searchForm: this.searchForm }
  420. });
  421. },
  422. onReSet () {
  423. this.vipform = {
  424. name: "",
  425. desc: "",
  426. activeTime: [],
  427. courseTime: []
  428. };
  429. this.activeType = "";
  430. this.online = true;
  431. this.unonline = true;
  432. this.salaryReadonlyFlag = false;
  433. this.onlineSalary = "TEACHER_DEFAULT";
  434. this.unonlineSalary = "TEACHER_DEFAULT";
  435. this.onlineprice = "";
  436. this.unonlineprice = "";
  437. this.onlineClassJoinGradientRewards = false;
  438. this.offlineClassJoinGradientRewards = false;
  439. this.attribute1 = ''
  440. this.attribute2 = ''
  441. this.attribute3 = ''
  442. this.$refs.vipform.resetFields();
  443. }
  444. }
  445. };
  446. </script>
  447. <style lang="scss" scoped>
  448. .m-core {
  449. font-size: 14px;
  450. width: 100%;
  451. display: flex;
  452. flex-direction: column;
  453. justify-content: center;
  454. // text-align: center;
  455. .activeRange {
  456. display: flex;
  457. flex-direction: row;
  458. justify-content: flex-start;
  459. .left {
  460. height: 72px;
  461. line-height: 72px;
  462. }
  463. .right {
  464. .chioseWrap {
  465. display: flex;
  466. flex-direction: row;
  467. justify-content: flex-start;
  468. height: 72px;
  469. line-height: 72px;
  470. align-items: center;
  471. .el-checkbox {
  472. margin-right: 20px;
  473. }
  474. .el-select {
  475. margin-right: 20px;
  476. }
  477. }
  478. }
  479. }
  480. .activeType {
  481. display: flex;
  482. flex-direction: row;
  483. justify-content: flex-start;
  484. .left {
  485. margin-right: 20px;
  486. p {
  487. height: 40px;
  488. line-height: 40px;
  489. }
  490. }
  491. .right {
  492. > div {
  493. display: flex;
  494. flex-direction: row;
  495. justify-content: flex-start;
  496. height: 40px;
  497. line-height: 40px;
  498. margin-bottom: 20px;
  499. .head {
  500. width: 120px;
  501. height: 40px;
  502. line-height: 40px;
  503. border: 1px solid #ccc;
  504. text-align: center;
  505. border-radius: 5px;
  506. cursor: pointer;
  507. margin-right: 10px;
  508. }
  509. > .head.active {
  510. background-color: #13817a;
  511. color: #fff;
  512. border: none;
  513. }
  514. .title {
  515. line-height: 40px;
  516. height: 40px;
  517. }
  518. }
  519. }
  520. }
  521. }
  522. </style>
  523. <style lang="scss">
  524. .m-core {
  525. .vipform {
  526. .el-select {
  527. width: 400px !important;
  528. .el-input__inner {
  529. width: 400px;
  530. }
  531. }
  532. }
  533. .activeType {
  534. .right {
  535. .el-input {
  536. width: 150px !important;
  537. }
  538. }
  539. }
  540. }
  541. </style>