vipActiveList.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. <template >
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. VIP活动方案
  6. </h2>
  7. <div class="m-core">
  8. <el-button type="primary" style="margin-bottom: 20px" v-permission="'/vipNewActive'" @click="gotoNewActive">新建</el-button>
  9. <save-form
  10. :inline="true"
  11. class="searchForm"
  12. ref="searchForm"
  13. @submit="search"
  14. @reset="onReset"
  15. :model="searchForm"
  16. >
  17. <el-form-item prop="search">
  18. <el-input
  19. v-model.trim="searchForm.search"
  20. placeholder="请输入活动编号、名称"
  21. ></el-input>
  22. </el-form-item>
  23. <el-form-item prop="organId">
  24. <el-select
  25. class="multiple"
  26. filterable
  27. style="width: 180px !important"
  28. v-model.trim="searchForm.organId"
  29. clearable
  30. placeholder="请选择分部"
  31. >
  32. <el-option
  33. v-for="(item, index) in selects.branchs"
  34. :key="index"
  35. :label="item.name"
  36. :value="item.id"
  37. ></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item prop="enable">
  41. <el-select
  42. filterable
  43. style="width: 180px !important"
  44. v-model="searchForm.enable"
  45. clearable
  46. @clear="resetEnable"
  47. placeholder="活动状态"
  48. >
  49. <el-option label="开启" :value="true"></el-option>
  50. <el-option label="关闭" :value="false"></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button native-type="submit" type="danger">搜索</el-button>
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button type="primary" native-type="reset">重置</el-button>
  58. </el-form-item>
  59. </save-form>
  60. <div class="tableWrap">
  61. <el-table
  62. :data="tableList"
  63. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  64. >
  65. <el-table-column
  66. align="center"
  67. prop="id"
  68. label="活动编号"
  69. ></el-table-column>
  70. <el-table-column
  71. align="center"
  72. prop="name"
  73. label="活动名称"
  74. ></el-table-column>
  75. <el-table-column
  76. align="center"
  77. prop="vipGroupCategoryNames"
  78. label="适用课程形式"
  79. ></el-table-column>
  80. <el-table-column
  81. align="center"
  82. prop="type"
  83. :formatter="fommatterType"
  84. label="活动类型"
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. label="适用课时类型"
  89. :formatter="fommatterCourseType"
  90. ></el-table-column>
  91. <el-table-column align="center" label="结算标准">
  92. <template slot-scope="scope">
  93. <div>
  94. <p>{{ scope.row.salarySettlementJson | onlinePip }}</p>
  95. <p>{{ scope.row.salarySettlementJson | unonlinePip }}</p>
  96. </div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column align="center" label="结算说明">
  100. <template slot-scope="scope">
  101. <div>
  102. <p>{{ scope.row.salarySettlementJson | onlineDesc }}</p>
  103. <p>{{ scope.row.salarySettlementJson | unonlineDesc }}</p>
  104. </div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. align="center"
  109. label="启用状态"
  110. prop="enable"
  111. :formatter="fommatterEnable"
  112. ></el-table-column>
  113. <el-table-column align="center" width="130px" label="活动持续时间">
  114. <template slot-scope="scope">
  115. <div>
  116. <p>{{ scope.row.startTime | formatTimer }}</p>
  117. <p>{{ scope.row.endTime | formatTimer }}</p>
  118. </div>
  119. </template>
  120. </el-table-column>
  121. <el-table-column align="center" width="130px" label="课程安排时间">
  122. <template slot-scope="scope">
  123. <div>
  124. <p>{{ scope.row.coursesStartTime | formatTimer }}</p>
  125. <p>{{ scope.row.coursesEndTime | formatTimer }}</p>
  126. </div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column align="center" label="操作">
  130. <template slot-scope="scope">
  131. <div>
  132. <!-- v-if="scope.row.enable > 0" -->
  133. <el-button
  134. type="text"
  135. v-permission="'vipGroupActivity/update'"
  136. @click="reset(scope.row)"
  137. >修改</el-button
  138. >
  139. <!-- <el-button type='text'
  140. @click="remove(scope.row)">删除</el-button>-->
  141. <el-popover
  142. placement="top"
  143. width="160"
  144. v-permission="'vipGroupActivity/delete'"
  145. :ref="scope.$index"
  146. >
  147. <p>确定删除?</p>
  148. <div style="text-align: right; margin: 0">
  149. <el-button
  150. size="mini"
  151. type="text"
  152. @click="scope._self.$refs[scope.$index].doClose()"
  153. >取消</el-button
  154. >
  155. <el-button type="primary" size="mini" @click="remove(scope)"
  156. >确定</el-button
  157. >
  158. </div>
  159. <el-button type="text" slot="reference">删除</el-button>
  160. </el-popover>
  161. </div>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <!-- 分页器 -->
  166. <pagination
  167. :total.sync="rules.total"
  168. sync
  169. :page.sync="rules.page"
  170. :limit.sync="rules.limit"
  171. :page-sizes="rules.page_size"
  172. @pagination="getList"
  173. />
  174. </div>
  175. </div>
  176. <el-dialog
  177. title="修改VIP活动"
  178. width="650px"
  179. :before-close="closeVipform"
  180. :visible.sync="dialogVisible"
  181. >
  182. <div>
  183. <el-form
  184. :label-position="labelPosition"
  185. :model="resetForm"
  186. ref="vipform"
  187. :rules="resetFormRules"
  188. class="vipform"
  189. >
  190. <el-form-item label="活动名称" label-width="120px" prop="name">
  191. <el-input
  192. style="width: 400px"
  193. v-model.trim="resetForm.name"
  194. ></el-input>
  195. </el-form-item>
  196. <el-form-item label="适用分部" label-width="120px" prop="organ">
  197. <el-select
  198. v-model.trim="resetForm.organ"
  199. filterable
  200. disabled
  201. multiple
  202. clearable
  203. >
  204. <el-option
  205. v-for="(item, index) in selects.branchs"
  206. :key="index"
  207. :label="item.name"
  208. :value="item.id"
  209. ></el-option>
  210. </el-select>
  211. <!-- <el-button @click="onCheckAllBranch">适用所有分部</el-button> -->
  212. </el-form-item>
  213. <el-form-item label="课程形式" label-width="120px" prop="stauts">
  214. <el-select
  215. v-model.trim="resetForm.stauts"
  216. filterable
  217. clearable
  218. multiple
  219. disabled
  220. >
  221. <el-option
  222. v-for="(item, index) in selects.vipGroupCategory"
  223. :key="index"
  224. :value="item.id"
  225. :label="item.name"
  226. ></el-option>
  227. </el-select>
  228. </el-form-item>
  229. <el-form-item label="活动描述" label-width="120px" prop="desc">
  230. <el-input
  231. type="textarea"
  232. v-model.trim="resetForm.desc"
  233. style="width: 400px"
  234. :rows="5"
  235. placeholder="请输入活动说明"
  236. ></el-input>
  237. </el-form-item>
  238. <el-form-item label="活动时间" label-width="120px" prop="activeTime">
  239. <el-date-picker
  240. v-model.trim="resetForm.activeTime"
  241. style="width: 100%"
  242. type="datetimerange"
  243. range-separator="至"
  244. value-format="yyyy-MM-dd HH:mm:ss"
  245. :picker-options="{
  246. firstDayOfWeek: 1,
  247. }"
  248. start-placeholder="开始日期"
  249. end-placeholder="结束日期"
  250. ></el-date-picker>
  251. </el-form-item>
  252. <el-form-item label="课程时间" label-width="120px" prop="courseTime">
  253. <el-date-picker
  254. v-model.trim="resetForm.courseTime"
  255. style="width: 100%"
  256. type="datetimerange"
  257. :picker-options="{
  258. firstDayOfWeek: 1,
  259. }"
  260. range-separator="至"
  261. value-format="yyyy-MM-dd HH:mm:ss"
  262. start-placeholder="开始日期"
  263. end-placeholder="结束日期"
  264. ></el-date-picker>
  265. </el-form-item>
  266. </el-form>
  267. <el-alert
  268. title="活动适用范围&结算标准"
  269. type="info"
  270. :closable="false"
  271. class="alert">
  272. </el-alert>
  273. <div class="activeRange">
  274. <!-- <div class="left">
  275. <p>活动适用范围&结算标准:</p>
  276. </div> -->
  277. <div class="right">
  278. <div class="chioseWrap">
  279. <el-checkbox label="线上课" v-model.trim="online"></el-checkbox>
  280. <el-select v-model.trim="onlineSalary" clearable filterable>
  281. <el-option
  282. label="老师默认课酬"
  283. value="TEACHER_DEFAULT"
  284. ></el-option>
  285. <el-option
  286. label="实际课程单价比例折扣"
  287. value="RATIO_DISCOUNT"
  288. ></el-option>
  289. <el-option label="固定课酬" value="FIXED_SALARY"></el-option>
  290. </el-select>
  291. <!-- v-show='onlineSalary!= "TEACHER_DEFAULT"' -->
  292. <el-input
  293. placeholder="请输入"
  294. style="width: 150px"
  295. type="number"
  296. @mousewheel.native.prevent
  297. v-if="onlineSalary == 'FIXED_SALARY'"
  298. v-model.trim="onlineprice"
  299. >
  300. <template slot="append">元</template>
  301. </el-input>
  302. <el-input
  303. placeholder="请输入"
  304. style="width: 150px"
  305. type="number"
  306. @mousewheel.native.prevent
  307. v-else-if="onlineSalary == 'RATIO_DISCOUNT'"
  308. v-model.trim="onlineprice"
  309. >
  310. <template slot="append">%</template>
  311. </el-input>
  312. <el-checkbox
  313. label="是否参加梯度"
  314. style="margin-left: 20px"
  315. v-model.trim="onlineClassJoinGradientRewards"
  316. ></el-checkbox>
  317. </div>
  318. <div class="chioseWrap">
  319. <el-checkbox label="线下课" v-model.trim="unonline"></el-checkbox>
  320. <el-select v-model.trim="unonlineSalary" filterable clearable>
  321. <el-option
  322. label="老师默认课酬"
  323. value="TEACHER_DEFAULT"
  324. ></el-option>
  325. <el-option
  326. label="实际课程单价比例折扣"
  327. value="RATIO_DISCOUNT"
  328. ></el-option>
  329. <el-option label="固定课酬" value="FIXED_SALARY"></el-option>
  330. </el-select>
  331. <!-- unonlineSalary -->
  332. <el-input
  333. placeholder="请输入"
  334. style="width: 150px"
  335. type="number"
  336. @mousewheel.native.prevent
  337. v-if="unonlineSalary == 'FIXED_SALARY'"
  338. v-model.trim="unonlineprice"
  339. >
  340. <template slot="append">元</template>
  341. </el-input>
  342. <el-input
  343. placeholder="请输入"
  344. style="width: 150px"
  345. type="number"
  346. @mousewheel.native.prevent
  347. v-else-if="unonlineSalary == 'RATIO_DISCOUNT'"
  348. v-model.trim="unonlineprice"
  349. >
  350. <template slot="append">%</template>
  351. </el-input>
  352. <el-checkbox
  353. label="是否参加梯度"
  354. style="margin-left: 20px"
  355. v-model.trim="offlineClassJoinGradientRewards"
  356. ></el-checkbox>
  357. </div>
  358. <div class="chioseWrap">
  359. <el-checkbox
  360. v-model.trim="paymentReadonlyFlag"
  361. label="可自定义单价"
  362. ></el-checkbox>
  363. <!-- <el-checkbox v-model.trim="salaryReadonlyFlag"
  364. disabled
  365. label="可自定义课酬"></el-checkbox> -->
  366. </div>
  367. </div>
  368. </div>
  369. <el-alert
  370. title="活动类型"
  371. type="info"
  372. :closable="false"
  373. style="margin-bottom: 15px;"
  374. class="alert">
  375. </el-alert>
  376. <div class="activeType">
  377. <!-- <div class="left">
  378. <p style="width: 60px">活动类型</p>
  379. </div> -->
  380. <div class="right">
  381. <div>
  382. <div
  383. class="head"
  384. @click="activeType = 'BASE_ACTIVITY'"
  385. :class="activeType == 'BASE_ACTIVITY' ? 'active' : ''"
  386. >
  387. 基础活动
  388. </div>
  389. <p class="title" v-if="activeType == 'BASE_ACTIVITY'">课程原价</p>
  390. </div>
  391. <div>
  392. <div
  393. class="head"
  394. @click="activeType = 'DISCOUNT'"
  395. :class="activeType == 'DISCOUNT' ? 'active' : ''"
  396. >
  397. 折扣
  398. </div>
  399. <el-input
  400. v-if="activeType == 'DISCOUNT'"
  401. v-model.trim="attribute1"
  402. placeholder="请输入折扣数值"
  403. >
  404. <template slot="append">%</template>
  405. </el-input>
  406. </div>
  407. <div>
  408. <div
  409. class="head"
  410. @click="activeType = 'GIVE_CLASS'"
  411. :class="activeType == 'GIVE_CLASS' ? 'active' : ''"
  412. >
  413. 赠送课时
  414. </div>
  415. <el-input
  416. placeholder="多少节开始赠"
  417. v-if="activeType == 'GIVE_CLASS'"
  418. v-model.trim="attribute1"
  419. style="margin-right: 10px"
  420. ></el-input>
  421. <span v-if="activeType == 'GIVE_CLASS'">赠</span>
  422. <el-input
  423. v-if="activeType == 'GIVE_CLASS'"
  424. placeholder="请输入赠送课时数"
  425. v-model.trim="attribute2"
  426. style="margin: 0 10px"
  427. ></el-input>
  428. <!-- <el-checkbox v-if="activeType=='GIVE_CLASS'"
  429. v-model.trim="giveClassPaySalaryFlag"
  430. label="赠送课时结算课酬"></el-checkbox> -->
  431. </div>
  432. </div>
  433. </div>
  434. </div>
  435. <span slot="footer" class="dialog-footer">
  436. <el-button @click="dialogVisible = false">取 消</el-button>
  437. <el-button type="primary" @click="resetRow">确 定</el-button>
  438. </span>
  439. </el-dialog>
  440. </div>
  441. </template>
  442. <script>
  443. import pagination from "@/components/Pagination/index";
  444. import {
  445. vipGroupActivity,
  446. vipGroupCategory,
  447. addVipActive,
  448. resetVipActive,
  449. removeVipActive,
  450. } from "@/api/vipSeting";
  451. export default {
  452. name: "vipActiveList",
  453. components: { pagination },
  454. data() {
  455. return {
  456. labelPosition: "right",
  457. tableList: [],
  458. rules: {
  459. // 分页规则
  460. limit: 10, // 限制显示条数
  461. page: 1, // 当前页
  462. total: 0, // 总条数
  463. page_size: [10, 20, 40, 50], // 选择限制显示条数
  464. },
  465. searchForm: { organId: null, enable: null, search: "" },
  466. dialogVisible: false,
  467. resetForm: {
  468. name: "",
  469. desc: "",
  470. activeTime: [],
  471. courseTime: [],
  472. stauts: [],
  473. organ: [],
  474. }, // 修改信息
  475. resetFormRules: {
  476. name: [
  477. { required: true, message: "请输入活动名称", trigger: "blur" },
  478. {
  479. min: 1,
  480. max: 25,
  481. message: "长度在 1 到 25 个字符",
  482. trigger: "blur",
  483. },
  484. ],
  485. desc: [
  486. { required: false, message: "请输入文字描述", trigger: "blur" },
  487. {
  488. min: 1,
  489. max: 200,
  490. message: "长度在 1 到 200 个字符",
  491. trigger: "blur",
  492. },
  493. ],
  494. activeTime: [
  495. { required: false, message: "请选择活动时间", trigger: "blur" },
  496. ],
  497. courseTime: [
  498. { required: false, message: "请选择课程时间", trigger: "blur" },
  499. ],
  500. organ: [{ required: true, message: "请选择分部", trigger: "blur" }],
  501. stauts: [
  502. { required: true, message: "请选择活动形式", trigger: "blur" },
  503. ],
  504. },
  505. courseStatusList: [],
  506. activeType: "",
  507. online: true,
  508. unonline: true,
  509. onlineClassJoinGradientRewards: false,
  510. offlineClassJoinGradientRewards: false,
  511. onlineSalary: "TEACHER_DEFAULT",
  512. unonlineSalary: "TEACHER_DEFAULT",
  513. onlineprice: "",
  514. unonlineprice: "",
  515. salaryReadonlyFlag: false,
  516. paymentReadonlyFlag: true,
  517. attribute1: "",
  518. attribute2: "",
  519. attribute3: "",
  520. giveClassPaySalaryFlag: false,
  521. activeId: "",
  522. isReset: false,
  523. };
  524. },
  525. // created() {
  526. // this.init();
  527. // },
  528. // activated() {
  529. // this.init();
  530. // },
  531. mounted() {
  532. this.init()
  533. },
  534. filters: {
  535. onlinePip(val) {
  536. let obj = JSON.parse(val);
  537. // debugger;
  538. if (
  539. obj &&
  540. obj.onlineSalarySettlement &&
  541. obj.onlineSalarySettlement.salarySettlementType
  542. ) {
  543. switch (obj.onlineSalarySettlement.salarySettlementType) {
  544. case "RATIO_DISCOUNT": {
  545. return "线上:比例结算";
  546. break;
  547. }
  548. case "TEACHER_DEFAULT": {
  549. return "线上:老师默认";
  550. break;
  551. }
  552. case "FIXED_SALARY": {
  553. return "线上:固定课酬";
  554. break;
  555. }
  556. }
  557. }
  558. },
  559. unonlinePip(val) {
  560. let obj = JSON.parse(val);
  561. if (
  562. obj &&
  563. obj.offlineSalarySettlement &&
  564. obj.offlineSalarySettlement.salarySettlementType
  565. ) {
  566. switch (obj.offlineSalarySettlement.salarySettlementType) {
  567. case "RATIO_DISCOUNT": {
  568. return "线下:比例结算";
  569. break;
  570. }
  571. case "TEACHER_DEFAULT": {
  572. return "线下:老师默认";
  573. break;
  574. }
  575. case "FIXED_SALARY": {
  576. return "线下:固定课酬";
  577. break;
  578. }
  579. }
  580. }
  581. },
  582. onlineDesc(val) {
  583. let obj = JSON.parse(val);
  584. // debugger;
  585. if (
  586. obj &&
  587. obj.onlineSalarySettlement &&
  588. obj.onlineSalarySettlement.salarySettlementType
  589. ) {
  590. switch (obj.onlineSalarySettlement.salarySettlementType) {
  591. case "RATIO_DISCOUNT": {
  592. if (obj.onlineSalarySettlement.settlementValue) {
  593. return `线上:${obj.onlineSalarySettlement.settlementValue}%`;
  594. } else {
  595. return "-";
  596. }
  597. break;
  598. }
  599. case "TEACHER_DEFAULT": {
  600. return "线上:默认";
  601. break;
  602. }
  603. case "FIXED_SALARY": {
  604. if (obj.onlineSalarySettlement.settlementValue) {
  605. return `线上:${obj.onlineSalarySettlement.settlementValue}/次`;
  606. } else {
  607. return "-";
  608. }
  609. break;
  610. }
  611. }
  612. }
  613. },
  614. unonlineDesc(val) {
  615. let obj = JSON.parse(val);
  616. if (
  617. obj &&
  618. obj.offlineSalarySettlement &&
  619. obj.offlineSalarySettlement.salarySettlementType
  620. ) {
  621. switch (obj.offlineSalarySettlement.salarySettlementType) {
  622. case "RATIO_DISCOUNT": {
  623. if (obj.offlineSalarySettlement.settlementValue) {
  624. return `线下:${obj.offlineSalarySettlement.settlementValue}%`;
  625. } else {
  626. return "-";
  627. }
  628. break;
  629. }
  630. case "TEACHER_DEFAULT": {
  631. return "线下:默认";
  632. break;
  633. }
  634. case "FIXED_SALARY": {
  635. if (obj.offlineSalarySettlement.settlementValue) {
  636. return `线下:${obj.offlineSalarySettlement.settlementValue}/次`;
  637. } else {
  638. return "-";
  639. }
  640. break;
  641. }
  642. }
  643. }
  644. },
  645. },
  646. methods: {
  647. async init() {
  648. // 获取类型
  649. await this.$store.dispatch('setVipGroupCategory')
  650. // 获取分部
  651. await this.$store.dispatch('setBranchs')
  652. this.getList();
  653. },
  654. loadNumber(event) {
  655. var el = event.currentTarget;
  656. var elValue = el.value;
  657. console.log(elValue);
  658. var reg = /^((?!0)\d{1,2}|100)$/;
  659. if (!elValue.match(reg)) {
  660. elValue = "";
  661. return false;
  662. } else {
  663. return true;
  664. }
  665. },
  666. onCheckAllBranch() {
  667. // 适用所有分部
  668. this.resetForm.organ = [];
  669. this.organList.forEach((item) => {
  670. this.resetForm.organ.push(item.id);
  671. });
  672. },
  673. search() {
  674. this.rules.page = 1;
  675. this.getList();
  676. },
  677. onReset() {
  678. // this.searchForm = {
  679. // enable: null,
  680. // search: null,
  681. // organId: null,
  682. // }
  683. this.$refs["searchForm"].resetFields();
  684. this.search();
  685. },
  686. getList() {
  687. let enable = this.searchForm.enable;
  688. let search = this.searchForm.search;
  689. vipGroupActivity({
  690. organId: this.searchForm.organId,
  691. rows: this.rules.limit,
  692. page: this.rules.page,
  693. enable,
  694. search,
  695. }).then((res) => {
  696. if (res.code == 200) {
  697. this.tableList = res.data.rows;
  698. this.rules.total = res.data.total;
  699. }
  700. });
  701. },
  702. resetEnable(val) {
  703. val = null;
  704. },
  705. // 格式化活动类型
  706. fommatterType(row, column) {
  707. switch (row.type) {
  708. case "BASE_ACTIVITY": {
  709. return "基础";
  710. break;
  711. }
  712. case "DISCOUNT": {
  713. return "折扣";
  714. break;
  715. }
  716. case "GIVE_CLASS": {
  717. if (row.giveClassPaySalaryFlag) {
  718. return "买赠(赠课结算)";
  719. } else {
  720. return "买赠(不结算)";
  721. }
  722. break;
  723. }
  724. }
  725. },
  726. // 格式化课时类型
  727. fommatterCourseType(row) {
  728. let date = JSON.parse(row.salarySettlementJson);
  729. let str = "";
  730. if (date && date.onlineSalarySettlement) {
  731. str += "线上 ";
  732. }
  733. if (date && date.offlineSalarySettlement) {
  734. str += "线下";
  735. }
  736. return str;
  737. },
  738. // 格式化启用状态
  739. fommatterEnable(row) {
  740. switch (row.enable) {
  741. case 0: {
  742. return "关闭";
  743. break;
  744. }
  745. case 1: {
  746. return "开启";
  747. break;
  748. }
  749. }
  750. },
  751. // 点击列表修改同步状态
  752. reset(row) {
  753. this.isReset = true;
  754. this.activeId = row.id;
  755. this.dialogVisible = true;
  756. this.resetForm.name = row.name;
  757. this.resetForm.desc = row.description;
  758. if (row.organId) {
  759. this.resetForm.organ = row.organId.split(",").map((res) => {
  760. return parseInt(res);
  761. });
  762. }
  763. if (row.vipGroupCategoryIdList) {
  764. this.resetForm.stauts = row.vipGroupCategoryIdList
  765. .split(",")
  766. .map((res) => {
  767. return parseInt(res);
  768. });
  769. }
  770. // 同步活动时间
  771. if (row.startTime && row.endTime) {
  772. this.resetForm.activeTime = [row.startTime, row.endTime];
  773. }
  774. if (row.coursesStartTime && row.coursesEndTime) {
  775. this.resetForm.courseTime = [row.coursesStartTime, row.coursesEndTime];
  776. }
  777. // 同步适用范围
  778. let obj = JSON.parse(row.salarySettlementJson);
  779. // 同步线上课状态
  780. obj.onlineSalarySettlement ? (this.online = true) : (this.online = false);
  781. if (obj.onlineSalarySettlement) {
  782. this.onlineSalary = obj.salarySettlementType;
  783. if (obj.onlineSalarySettlement.settlementValue) {
  784. this.onlineprice = obj.onlineSalarySettlement.settlementValue;
  785. }
  786. if (obj.onlineSalarySettlement.salarySettlementType)
  787. this.onlineSalary = obj.onlineSalarySettlement.salarySettlementType;
  788. } else {
  789. this.onlineSalary = "TEACHER_DEFAULT";
  790. this.onlineprice = "";
  791. }
  792. // 同步线下课状态
  793. obj.offlineSalarySettlement
  794. ? (this.unonline = true)
  795. : (this.unonline = false);
  796. if (obj.offlineSalarySettlement) {
  797. this.unonlineSalary = obj.offlineSalarySettlement;
  798. if (obj.offlineSalarySettlement.settlementValue) {
  799. this.unonlineprice = obj.offlineSalarySettlement.settlementValue;
  800. }
  801. if (obj.offlineSalarySettlement.salarySettlementType)
  802. this.unonlineSalary =
  803. obj.offlineSalarySettlement.salarySettlementType;
  804. } else {
  805. this.unonlineSalary = "TEACHER_DEFAULT";
  806. this.unonlineprice = "";
  807. }
  808. //
  809. this.salaryReadonlyFlag = !!parseInt(row.salaryReadonlyFlag);
  810. this.paymentReadonlyFlag = !!parseInt(row.paymentReadonlyFlag);
  811. this.offlineClassJoinGradientRewards = !!parseInt(
  812. row.offlineClassJoinGradientRewards
  813. );
  814. this.onlineClassJoinGradientRewards = !!parseInt(
  815. row.onlineClassJoinGradientRewards
  816. );
  817. this.activeType = row.type;
  818. this.attribute1 = row.attribute1;
  819. this.attribute2 = row.attribute2;
  820. this.giveClassPaySalaryFlag =
  821. row.giveClassPaySalaryFlag == 1 ? true : false;
  822. },
  823. // 点击确认按钮发送修改请求
  824. resetRow() {
  825. this.$refs["vipform"].validate((valid) => {
  826. if (valid) {
  827. // 验证通过
  828. let coursesStartTime;
  829. let coursesEndTime;
  830. let startTime;
  831. let endTime;
  832. if (!this.resetForm.courseTime) {
  833. this.resetForm.courseTime = [];
  834. // coursesStartTime = null;
  835. // coursesEndTime = null;
  836. }
  837. if (!this.resetForm.activeTime) {
  838. this.resetForm.activeTime = [];
  839. // startTime = null;
  840. // endTime = null;
  841. }
  842. let id = this.activeId;
  843. coursesStartTime = this.resetForm.courseTime[0] || null;
  844. coursesEndTime = this.resetForm.courseTime[1] || null;
  845. startTime = this.resetForm.activeTime[0] || null;
  846. endTime = this.resetForm.activeTime[1] || null;
  847. let organId = this.resetForm.organ.join(",");
  848. let type = this.activeType;
  849. if (type == "DISCOUNT") {
  850. if (this.attribute1 < 0 || this.attribute1 > 100) {
  851. this.$message.error("折扣必须大于0且小于100");
  852. return;
  853. }
  854. }
  855. let vipGroupCategoryIdList = this.resetForm.stauts.join(",");
  856. let onlineSalarySettlement;
  857. let offlineSalarySettlement;
  858. if (this.online) {
  859. // 勾选线上
  860. // 判断勾选的是折扣还是现金
  861. if (this.onlineSalary == "RATIO_DISCOUNT") {
  862. if (this.onlineprice < 0 || this.onlineprice > 100) {
  863. this.$message.error("折扣比必须大于0且小于100");
  864. return;
  865. }
  866. }else if(this.onlineSalary == 'TEACHER_DEFAULT'){
  867. this.onlineprice = 0;
  868. }
  869. onlineSalarySettlement = {
  870. salarySettlementType: this.onlineSalary,
  871. settlementValue: this.onlineprice,
  872. };
  873. } else {
  874. onlineSalarySettlement = null;
  875. }
  876. if (this.unonline) {
  877. // 勾选线下
  878. if (this.unonlineSalary == "RATIO_DISCOUNT") {
  879. if (this.unonlineprice < 0 || this.unonlineprice > 100) {
  880. this.$message.error("折扣比必须大于0且小于100");
  881. return;
  882. }
  883. }else if(this.unonlineSalary == 'TEACHER_DEFAULT'){
  884. this.unonlineprice = 0;
  885. }
  886. offlineSalarySettlement = {
  887. salarySettlementType: this.unonlineSalary,
  888. settlementValue: this.unonlineprice,
  889. };
  890. } else {
  891. offlineSalarySettlement = null;
  892. }
  893. let salaryReadonlyFlag = this.salaryReadonlyFlag * 1;
  894. let paymentReadonlyFlag = this.paymentReadonlyFlag * 1;
  895. // let giveClassPaySalaryFlag = this.giveClassPaySalaryFlag * 1;
  896. let vipGroupSalarySettlement = {
  897. onlineSalarySettlement,
  898. offlineSalarySettlement,
  899. };
  900. // 发请求创建活动
  901. resetVipActive({
  902. paymentReadonlyFlag,
  903. id,
  904. coursesStartTime,
  905. coursesEndTime,
  906. startTime,
  907. endTime,
  908. name: this.resetForm.name,
  909. description: this.resetForm.desc,
  910. organId,
  911. type,
  912. vipGroupCategoryIdList,
  913. vipGroupSalarySettlement,
  914. salaryReadonlyFlag,
  915. giveClassPaySalaryFlag: 1,
  916. attribute1: this.attribute1,
  917. attribute2: this.attribute2,
  918. attribute3: this.attribute3,
  919. onlineClassJoinGradientRewards:
  920. this.onlineClassJoinGradientRewards * 1,
  921. offlineClassJoinGradientRewards:
  922. this.offlineClassJoinGradientRewards * 1,
  923. }).then((res) => {
  924. if (res.code == 200) {
  925. this.$message.success("恭喜你,活动修改成功");
  926. this.dialogVisible = false;
  927. this.getList();
  928. }
  929. });
  930. } else {
  931. this.$message.error("请填写必要参数");
  932. }
  933. });
  934. },
  935. remove(scope) {
  936. let id = scope.row.id;
  937. removeVipActive({ id }).then((res) => {
  938. if (res.code == 200) {
  939. this.$message.success("恭喜您删除成功");
  940. this.getList();
  941. }
  942. scope._self.$refs[scope.$index].doClose();
  943. });
  944. },
  945. gotoNewActive() {
  946. // 带参数 searchForm: { organId: null } 搜索条件
  947. let rules = JSON.stringify(this.rules);
  948. let searchForm = JSON.stringify(this.searchForm);
  949. this.$router.push({
  950. path: "/vipClassSet/vipNewActive?type=create",
  951. query: { rules, searchForm },
  952. });
  953. },
  954. closeVipform() {
  955. this.$refs["vipform"].resetFields();
  956. this.dialogVisible = false;
  957. },
  958. },
  959. };
  960. </script>
  961. <style lang="scss" scoped>
  962. .activeType {
  963. .right {
  964. .el-input {
  965. width: 150px !important;
  966. }
  967. }
  968. }
  969. .activeRange {
  970. display: flex;
  971. flex-direction: row;
  972. justify-content: flex-start;
  973. .left {
  974. height: 72px;
  975. line-height: 72px;
  976. }
  977. .right {
  978. .chioseWrap {
  979. display: flex;
  980. flex-direction: row;
  981. justify-content: flex-start;
  982. height: 72px;
  983. line-height: 72px;
  984. align-items: center;
  985. .el-checkbox {
  986. margin-right: 20px;
  987. }
  988. .el-select {
  989. margin-right: 20px;
  990. }
  991. }
  992. }
  993. }
  994. .activeType {
  995. display: flex;
  996. flex-direction: row;
  997. justify-content: flex-start;
  998. .left {
  999. margin-right: 20px;
  1000. p {
  1001. height: 40px;
  1002. line-height: 40px;
  1003. }
  1004. }
  1005. .right {
  1006. > div {
  1007. display: flex;
  1008. flex-direction: row;
  1009. justify-content: flex-start;
  1010. height: 40px;
  1011. line-height: 40px;
  1012. margin-bottom: 20px;
  1013. .head {
  1014. width: 120px;
  1015. height: 40px;
  1016. line-height: 40px;
  1017. border: 1px solid #ccc;
  1018. text-align: center;
  1019. border-radius: 5px;
  1020. cursor: pointer;
  1021. margin-right: 10px;
  1022. }
  1023. > .head.active {
  1024. background-color: #13817a;
  1025. color: #fff;
  1026. border: none;
  1027. }
  1028. .title {
  1029. line-height: 40px;
  1030. height: 40px;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. .vipform {
  1036. .el-select {
  1037. width: 400px !important;
  1038. .el-input__inner {
  1039. width: 400px;
  1040. }
  1041. }
  1042. }
  1043. .ishidden {
  1044. visibility: hidden;
  1045. }
  1046. </style>