vipActiveList.vue 38 KB

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