vipNewActive.vue 17 KB

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