vipNewActive.vue 16 KB

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