vipActiveList.vue 33 KB

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