vipNewActive.vue 14 KB

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