activeSenior.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header @back="onCancel" :content="title"></el-page-header>
  5. </h2>
  6. <div class="m-core">
  7. <el-button
  8. type="primary"
  9. style="margin-bottom: 20px"
  10. v-permission="'activityUserMapper/add'"
  11. @click="addStudent"
  12. >添加学员</el-button
  13. >
  14. <save-form
  15. :inline="true"
  16. ref="searchForm"
  17. :model="searchForm"
  18. @submit="search"
  19. @reset="onReSet"
  20. >
  21. <el-form-item prop="search">
  22. <el-input
  23. class="search"
  24. v-model.trim="searchForm.search"
  25. clearable
  26. @keyup.enter.native="
  27. (e) => {
  28. e.target.blur();
  29. $refs.searchForm.save();
  30. search();
  31. }
  32. "
  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 organList"
  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>
  54. <el-button native-type="submit" type="primary">搜索</el-button>
  55. <el-button native-type="reset" type="danger">重置</el-button>
  56. </el-form-item>
  57. </save-form>
  58. <div class="tableWrap">
  59. <el-table
  60. style="width: 100%"
  61. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  62. :data="tableList"
  63. >
  64. <el-table-column
  65. align="center"
  66. prop="organName"
  67. label="分部"
  68. ></el-table-column>
  69. <el-table-column
  70. align="center"
  71. prop="userId"
  72. label="学员编号"
  73. ></el-table-column>
  74. <el-table-column
  75. align="center"
  76. prop="username"
  77. label="学员姓名"
  78. ></el-table-column>
  79. <el-table-column
  80. align="center"
  81. prop="phone"
  82. label="手机号"
  83. ></el-table-column>
  84. <el-table-column
  85. v-if="courseType && courseType == 'VIP'"
  86. align="center"
  87. prop="studentId"
  88. label="付费课已使用/剩余资格"
  89. >
  90. <template slot-scope="scope">
  91. <div v-if="scope.row.userId">
  92. {{ scope.row.useVipNum + "" + "/" + scope.row.freeVipNum + "" }}
  93. </div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. v-else
  98. align="center"
  99. prop="studentId"
  100. label="付费课已使用/剩余资格"
  101. >
  102. <template slot-scope="scope">
  103. <div v-if="scope.row.userId">
  104. {{
  105. scope.row.usePracticeNum +
  106. "" +
  107. "/" +
  108. scope.row.freePracticeNum +
  109. ""
  110. }}
  111. </div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column
  115. v-if="giveCourseType == 'VIP'"
  116. align="center"
  117. prop="studentId"
  118. label="赠课已使用/剩余资格"
  119. >
  120. <template slot-scope="scope">
  121. <div v-if="scope.row.userId">
  122. {{
  123. scope.row.useGiveVipNum +
  124. "" +
  125. "/" +
  126. scope.row.freeGiveVipNum +
  127. ""
  128. }}
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. v-if="giveCourseType == 'PRACTICE'"
  134. align="center"
  135. prop="studentId"
  136. label="赠课已使用/剩余资格"
  137. >
  138. <template slot-scope="scope">
  139. <div v-if="scope.row.userId">
  140. {{
  141. scope.row.useGivePracticeNum +
  142. "" +
  143. "/" +
  144. scope.row.freeGivePracticeNum +
  145. ""
  146. }}
  147. </div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column
  151. v-if="giveCourseType != 'PRACTICE' && giveCourseType != 'VIP'"
  152. align="center"
  153. prop="studentId"
  154. label="赠课已使用/剩余资格"
  155. >
  156. <template slot-scope="scope">
  157. <div v-if="scope.row.userId">
  158. {{ "--" + "/" + "--" }}
  159. </div>
  160. </template>
  161. </el-table-column>
  162. <el-table-column
  163. align="center"
  164. prop="studentId"
  165. label="操作"
  166. width="260px"
  167. >
  168. <template slot-scope="scope">
  169. <div>
  170. <el-button
  171. type="text"
  172. v-permission="'activityUserMapper/add'"
  173. @click="addCount(scope.row)"
  174. >添加资格</el-button
  175. >
  176. <el-button
  177. type="text"
  178. v-permission="'activityUserMapper/cut'"
  179. @click="reduceCount(scope.row)"
  180. >减少资格</el-button
  181. >
  182. <el-button
  183. type="text"
  184. v-permission="'activityUserMapperAdjustLog/queryPage'"
  185. @click="lookInfo(scope.row)"
  186. >调整记录</el-button
  187. >
  188. </div>
  189. </template>
  190. </el-table-column>
  191. </el-table>
  192. <pagination
  193. sync
  194. :total.sync="rules.total"
  195. :page.sync="rules.page"
  196. :limit.sync="rules.limit"
  197. :page-sizes="rules.page_size"
  198. @pagination="getList"
  199. />
  200. </div>
  201. </div>
  202. <el-dialog
  203. title="添加学员"
  204. :visible.sync="addStudentVisible"
  205. width="1000px"
  206. v-if="addStudentVisible"
  207. >
  208. <addStudentSenior
  209. :organList="organList"
  210. :hasGive="hasGive"
  211. ref="addStudentSenior"
  212. @getList="getList"
  213. @close="addStudentVisible = false"
  214. />
  215. <span slot="footer" class="dialog-footer">
  216. <el-button @click="addStudentVisible = false">取 消</el-button>
  217. <el-button type="primary" @click="submitStudent">确 定</el-button>
  218. </span>
  219. </el-dialog>
  220. <el-dialog
  221. title="添加资格"
  222. :visible.sync="addSeniorVisible"
  223. width="800px"
  224. v-if="addSeniorVisible"
  225. >
  226. <addSenior
  227. :hasGive="hasGive"
  228. :activeRow="activeRow"
  229. @getList="getList"
  230. ref="addSenior"
  231. @close="addSeniorVisible = false"
  232. />
  233. <span slot="footer" class="dialog-footer">
  234. <el-button @click="addSeniorVisible = false">取 消</el-button>
  235. <el-button type="primary" @click="addSeniorSubmit">确 定</el-button>
  236. </span>
  237. </el-dialog>
  238. <el-dialog
  239. title="减少资格"
  240. :visible.sync="reduceVisible"
  241. width="1000px"
  242. v-if="reduceVisible"
  243. >
  244. <reduceSenior
  245. :activeRow="activeRow"
  246. :courseType="courseType"
  247. :giveCourseType="giveCourseType"
  248. @getList="getList"
  249. />
  250. <span slot="footer" class="dialog-footer">
  251. <!-- <el-button @click="addStudentVisible = false">取 消</el-button> -->
  252. <el-button type="primary" @click="reduceVisible = false"
  253. >确 定</el-button
  254. >
  255. </span>
  256. </el-dialog>
  257. <el-dialog
  258. title="资格记录"
  259. :visible.sync="infoVisible"
  260. width="1000px"
  261. v-if="infoVisible"
  262. >
  263. <seniorInfo :activeRow="activeRow" />
  264. <!-- <span slot="footer" class="dialog-footer">
  265. <el-button type="primary" @click="infoVisible = false">确 定</el-button>
  266. </span>-->
  267. </el-dialog>
  268. </div>
  269. </template>
  270. <script>
  271. import axios from "axios";
  272. import { getToken } from "@/utils/auth";
  273. import pagination from "@/components/Pagination/index";
  274. import load from "@/utils/loading";
  275. import {
  276. getVipGroupActivity,
  277. getActivityUserMapperList,
  278. } from "@/api/vipSeting";
  279. import addSenior from "./modals/addSenior.vue";
  280. import reduceSenior from "./modals/reduceSenior.vue";
  281. import addStudentSenior from "./modals/addStudentSenior.vue";
  282. import seniorInfo from "./modals/seniorInfo";
  283. export default {
  284. components: {
  285. pagination,
  286. addSenior,
  287. reduceSenior,
  288. addStudentSenior,
  289. seniorInfo,
  290. },
  291. data() {
  292. return {
  293. searchForm: {
  294. search: null,
  295. organId: null,
  296. },
  297. title: "",
  298. tableList: [{}],
  299. organList: [],
  300. activeRow: null,
  301. hasGive: false,
  302. addStudentVisible: false,
  303. addSeniorVisible: false,
  304. reduceVisible: false,
  305. infoVisible: false,
  306. courseType: "",
  307. giveCourseType: "",
  308. rules: {
  309. // 分页规则
  310. limit: 10, // 限制显示条数
  311. page: 1, // 当前页
  312. total: 0, // 总条数
  313. page_size: [10, 20, 40, 50], // 选择限制显示条数
  314. },
  315. };
  316. },
  317. //生命周期 - 创建完成(可以访问当前this实例)
  318. created() {},
  319. //生命周期 - 挂载完成(可以访问DOM元素)
  320. async mounted() {
  321. // 获取分部
  322. // 获取分部
  323. await this.$store.dispatch("setBranchs");
  324. this.init();
  325. },
  326. methods: {
  327. async init() {
  328. if (this.$route.query.id) {
  329. // this.baseForm.id = this.$route.query.id;
  330. try {
  331. const rusult = await getVipGroupActivity({
  332. id: this.$route.query.id,
  333. });
  334. this.formatDetail(rusult.data);
  335. } catch (e) {
  336. console.log(e);
  337. }
  338. }
  339. this.getList();
  340. },
  341. async getList() {
  342. try {
  343. const res = await getActivityUserMapperList({
  344. ...this.searchForm,
  345. page: this.rules.page,
  346. rows: this.rules.limit,
  347. activityId: this.$route.query.id,
  348. });
  349. this.tableList = res.data.rows;
  350. this.rules.total = res.data.total;
  351. } catch (e) {
  352. console.log(e);
  353. }
  354. },
  355. search() {
  356. this.rules.page = 1;
  357. this.getList();
  358. },
  359. onReSet() {
  360. this.$refs.searchForm.resetFields();
  361. this.search();
  362. },
  363. onCancel() {
  364. this.$store.dispatch("delVisitedViews", this.$route);
  365. this.$router.push({
  366. path: "/vipActiveManager/vipActiveList",
  367. query: { rules: this.rules, searchForm: this.searchForm },
  368. });
  369. },
  370. formatDetail(data) {
  371. this.title = data.name;
  372. let organIds = data.organId.split(",").map((organ) => {
  373. return Number(organ);
  374. });
  375. this.organList = [];
  376. this.selects.branchs.forEach((organ) => {
  377. if (organIds.indexOf(organ.id) != -1) {
  378. this.organList.push(organ);
  379. }
  380. });
  381. this.hasGive = Boolean(
  382. data.giveCourseType && data.giveCourseType != "MEMBER"
  383. );
  384. this.courseType = data.courseType;
  385. this.giveCourseType = data.giveCourseType;
  386. console.log(this.courseType, this.giveCourseType);
  387. // selects.branchs
  388. },
  389. addCount(row) {
  390. this.activeRow = row;
  391. this.addSeniorVisible = true;
  392. },
  393. reduceCount(row) {
  394. this.activeRow = row;
  395. this.reduceVisible = true;
  396. },
  397. addStudent() {
  398. this.addStudentVisible = true;
  399. },
  400. submitStudent() {
  401. this.$refs.addStudentSenior.submit();
  402. },
  403. addSeniorSubmit() {
  404. this.$refs.addSenior.submit();
  405. },
  406. lookInfo(row) {
  407. this.activeRow = row;
  408. this.infoVisible = true;
  409. },
  410. },
  411. };
  412. </script>
  413. <style lang='scss' scoped>
  414. .m-container {
  415. .search {
  416. /deep/.el-input__inner {
  417. width: 200px !important;
  418. }
  419. }
  420. }
  421. </style>