activeSenior.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. align="center"
  86. prop="studentId"
  87. label="付费剩余课时数/总课时数"
  88. >
  89. <template slot-scope="scope">
  90. <div v-if="scope.row.userId">
  91. {{ scope.row.subCourseNum + "" + "/" + scope.row.totalCourseNum + "" }}
  92. </div>
  93. </template>
  94. </el-table-column>
  95. <el-table-column
  96. align="center"
  97. prop="studentId"
  98. label="赠送剩余课时数/总课时数"
  99. >
  100. <template slot-scope="scope">
  101. <div v-if="scope.row.userId">
  102. {{
  103. scope.row.subGiveCourseNum +
  104. "" +
  105. "/" +
  106. scope.row.totalGiveCourseNum +
  107. ""
  108. }}
  109. </div>
  110. </template>
  111. </el-table-column>
  112. <el-table-column
  113. align="center"
  114. prop="studentId"
  115. label="操作"
  116. width="260px"
  117. >
  118. <template slot-scope="scope">
  119. <div>
  120. <el-button
  121. type="text"
  122. v-permission="'activityUserMapper/add'"
  123. @click="addCount(scope.row)"
  124. >添加资格</el-button
  125. >
  126. <el-button
  127. type="text"
  128. v-permission="'activityUserMapper/cut'"
  129. @click="reduceCount(scope.row)"
  130. >减少资格</el-button
  131. >
  132. <el-button
  133. type="text"
  134. v-permission="'activityUserMapperAdjustLog/queryPage'"
  135. @click="lookInfo(scope.row)"
  136. >调整记录</el-button
  137. >
  138. </div>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <pagination
  143. sync
  144. :total.sync="rules.total"
  145. :page.sync="rules.page"
  146. :limit.sync="rules.limit"
  147. :page-sizes="rules.page_size"
  148. @pagination="getList"
  149. />
  150. </div>
  151. </div>
  152. <el-dialog
  153. title="添加学员"
  154. :visible.sync="addStudentVisible"
  155. width="1000px"
  156. v-if="addStudentVisible"
  157. >
  158. <addStudentSenior
  159. :organList="organList"
  160. :hasGive="hasGive"
  161. ref="addStudentSenior"
  162. @getList="getList"
  163. @close="addStudentVisible = false"
  164. />
  165. <span slot="footer" class="dialog-footer">
  166. <el-button @click="addStudentVisible = false">取 消</el-button>
  167. <el-button type="primary" @click="submitStudent">确 定</el-button>
  168. </span>
  169. </el-dialog>
  170. <el-dialog
  171. title="添加资格"
  172. :visible.sync="addSeniorVisible"
  173. width="800px"
  174. v-if="addSeniorVisible"
  175. >
  176. <addSenior
  177. :hasGive="hasGive"
  178. :activeRow="activeRow"
  179. @getList="getList"
  180. ref="addSenior"
  181. @close="addSeniorVisible = false"
  182. />
  183. <span slot="footer" class="dialog-footer">
  184. <el-button @click="addSeniorVisible = false">取 消</el-button>
  185. <el-button type="primary" @click="addSeniorSubmit">确 定</el-button>
  186. </span>
  187. </el-dialog>
  188. <el-dialog
  189. title="减少资格"
  190. :visible.sync="reduceVisible"
  191. width="1000px"
  192. v-if="reduceVisible"
  193. >
  194. <reduceSenior
  195. :activeRow="activeRow"
  196. :courseType="courseType"
  197. :giveCourseType="giveCourseType"
  198. @getList="getList"
  199. />
  200. <span slot="footer" class="dialog-footer">
  201. <!-- <el-button @click="addStudentVisible = false">取 消</el-button> -->
  202. <el-button type="primary" @click="reduceVisible = false"
  203. >确 定</el-button
  204. >
  205. </span>
  206. </el-dialog>
  207. <el-dialog
  208. title="资格记录"
  209. :visible.sync="infoVisible"
  210. width="1000px"
  211. v-if="infoVisible"
  212. >
  213. <seniorInfo :activeRow="activeRow" />
  214. <!-- <span slot="footer" class="dialog-footer">
  215. <el-button type="primary" @click="infoVisible = false">确 定</el-button>
  216. </span>-->
  217. </el-dialog>
  218. </div>
  219. </template>
  220. <script>
  221. import axios from "axios";
  222. import { getToken } from "@/utils/auth";
  223. import pagination from "@/components/Pagination/index";
  224. import load from "@/utils/loading";
  225. import {
  226. getVipGroupActivity,
  227. getActivityUserMapperList,
  228. } from "@/api/vipSeting";
  229. import addSenior from "./modals/addSenior.vue";
  230. import reduceSenior from "./modals/reduceSenior.vue";
  231. import addStudentSenior from "./modals/addStudentSenior.vue";
  232. import seniorInfo from "./modals/seniorInfo";
  233. export default {
  234. components: {
  235. pagination,
  236. addSenior,
  237. reduceSenior,
  238. addStudentSenior,
  239. seniorInfo,
  240. },
  241. data() {
  242. return {
  243. searchForm: {
  244. search: null,
  245. organId: null,
  246. },
  247. title: "",
  248. tableList: [{}],
  249. organList: [],
  250. activeRow: null,
  251. hasGive: false,
  252. addStudentVisible: false,
  253. addSeniorVisible: false,
  254. reduceVisible: false,
  255. infoVisible: false,
  256. courseType: "",
  257. giveCourseType: "",
  258. rules: {
  259. // 分页规则
  260. limit: 10, // 限制显示条数
  261. page: 1, // 当前页
  262. total: 0, // 总条数
  263. page_size: [10, 20, 40, 50], // 选择限制显示条数
  264. },
  265. };
  266. },
  267. //生命周期 - 创建完成(可以访问当前this实例)
  268. created() {},
  269. //生命周期 - 挂载完成(可以访问DOM元素)
  270. async mounted() {
  271. // 获取分部
  272. // 获取分部
  273. await this.$store.dispatch("setBranchs");
  274. this.init();
  275. },
  276. methods: {
  277. async init() {
  278. if (this.$route.query.id) {
  279. // this.baseForm.id = this.$route.query.id;
  280. try {
  281. const rusult = await getVipGroupActivity({
  282. id: this.$route.query.id,
  283. });
  284. this.formatDetail(rusult.data);
  285. } catch (e) {
  286. console.log(e);
  287. }
  288. }
  289. this.getList();
  290. },
  291. async getList() {
  292. try {
  293. const res = await getActivityUserMapperList({
  294. ...this.searchForm,
  295. page: this.rules.page,
  296. rows: this.rules.limit,
  297. activityId: this.$route.query.id,
  298. });
  299. this.tableList = res.data.rows;
  300. this.rules.total = res.data.total;
  301. } catch (e) {
  302. console.log(e);
  303. }
  304. },
  305. search() {
  306. this.rules.page = 1;
  307. this.getList();
  308. },
  309. onReSet() {
  310. this.$refs.searchForm.resetFields();
  311. this.search();
  312. },
  313. onCancel() {
  314. this.$store.dispatch("delVisitedViews", this.$route);
  315. this.$router.push({
  316. path: "/vipActiveManager/vipActiveList",
  317. query: { rules: this.rules, searchForm: this.searchForm },
  318. });
  319. },
  320. formatDetail(data) {
  321. this.title = data.name;
  322. let organIds = data.organId.split(",").map((organ) => {
  323. return Number(organ);
  324. });
  325. this.organList = [];
  326. this.selects.branchs.forEach((organ) => {
  327. if (organIds.indexOf(organ.id) != -1) {
  328. this.organList.push(organ);
  329. }
  330. });
  331. this.hasGive = Boolean(
  332. data.giveCourseType && data.giveCourseType != "MEMBER"
  333. );
  334. this.courseType = data.courseType;
  335. this.giveCourseType = data.giveCourseType;
  336. console.log(this.courseType, this.giveCourseType);
  337. // selects.branchs
  338. },
  339. addCount(row) {
  340. this.activeRow = row;
  341. this.addSeniorVisible = true;
  342. },
  343. reduceCount(row) {
  344. this.activeRow = row;
  345. this.reduceVisible = true;
  346. },
  347. addStudent() {
  348. this.addStudentVisible = true;
  349. },
  350. submitStudent() {
  351. this.$refs.addStudentSenior.submit();
  352. },
  353. addSeniorSubmit() {
  354. this.$refs.addSenior.submit();
  355. },
  356. lookInfo(row) {
  357. this.activeRow = row;
  358. this.infoVisible = true;
  359. },
  360. },
  361. };
  362. </script>
  363. <style lang='scss' scoped>
  364. .m-container {
  365. .search {
  366. ::v-deep .el-input__inner {
  367. width: 200px !important;
  368. }
  369. }
  370. }
  371. </style>