vipActiveList.vue 34 KB

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