activeSenior.vue 12 KB

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