studentList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>学员列表
  5. </h2>
  6. <div class="m-core">
  7. <div class="newBand"
  8. v-permission="'studentManage/register'"
  9. @click="addStudent">新增学员</div>
  10. <div class="newBand"
  11. @click="onCreateQRCode">学员激活列表</div>
  12. <!-- 搜索标题 -->
  13. <el-form :inline="true"
  14. class="searchForm"
  15. v-model="searchForm">
  16. <el-form-item>
  17. <el-input placeholder="学生姓名或电话"
  18. @keyup.enter.native='onSearch'
  19. v-model="searchForm.search"></el-input>
  20. </el-form-item>
  21. <el-form-item prop='organId'>
  22. <el-select class='multiple'
  23. filterable
  24. v-model="searchForm.organId"
  25. clearable
  26. placeholder="请选择分部">
  27. <el-option v-for="(item,index) in organList"
  28. :key="index"
  29. :label="item.name"
  30. :value="item.id"></el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item prop='isActive'>
  34. <el-select class='multiple'
  35. v-model="searchForm.isActive"
  36. clearable
  37. placeholder="是否激活">
  38. <el-option label="是" value="true"></el-option>
  39. <el-option label="否" value="false"></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <!-- <el-form-item>
  43. <el-input placeholder="学生姓名"
  44. @keyup.enter.native='onSearch'
  45. v-model="searchForm.studentName"></el-input>
  46. </el-form-item> -->
  47. <el-form-item>
  48. <el-button @click="onSearch"
  49. type="danger">搜索</el-button>
  50. <el-button @click="onReSet"
  51. type="primary">重置</el-button>
  52. </el-form-item>
  53. </el-form>
  54. <!-- 列表 -->
  55. <div class="tableWrap">
  56. <el-table :data='tableList'
  57. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  58. <el-table-column align='center'
  59. prop="userId"
  60. label="学员编号">
  61. </el-table-column>
  62. <el-table-column align='center'
  63. prop="username"
  64. label="学员姓名">
  65. </el-table-column>
  66. <el-table-column align='center'
  67. label="性别">
  68. <template slot-scope="scope">
  69. {{ scope.row.gender ? '男': '女' }}
  70. </template>
  71. </el-table-column>
  72. <el-table-column align='center'
  73. prop="realName"
  74. label="家长姓名">
  75. </el-table-column>
  76. <el-table-column align='center'
  77. prop="parentsPhone"
  78. label="家长联系电话">
  79. </el-table-column>
  80. <el-table-column align='center'
  81. label="是否激活">
  82. <template slot-scope="scope">
  83. {{ scope.row.isActive ? '是' : '否' }}
  84. </template>
  85. </el-table-column>
  86. <el-table-column align='center'
  87. prop="courseBalance"
  88. label="课程余额(元)">
  89. </el-table-column>
  90. <el-table-column align='center'
  91. label="操作">
  92. <template slot-scope="scope">
  93. <router-link style="color:#409EFF"
  94. v-permission="'/studentDetail'"
  95. :to="{path:`/business/studentDetail?userId=${scope.row.userId}`,query:{search:JSON.stringify(searchForm),rules:JSON.stringify(pageInfo)}}">查看</router-link>
  96. <el-button type="text"
  97. v-permission="'studentManage/studentUpdate'"
  98. @click="resetStudent(scope.row)">修改</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination :total="pageInfo.total"
  103. :page.sync="pageInfo.page"
  104. :limit.sync="pageInfo.limit"
  105. :page-sizes="pageInfo.page_size"
  106. @pagination="getList" />
  107. </div>
  108. </div>
  109. <el-dialog :title="maskName"
  110. width="700px"
  111. label-width='100px'
  112. label-position="right"
  113. :visible.sync="studentVisible">
  114. <el-divider>基本信息</el-divider>
  115. <el-form :model="studentForm"
  116. :inline='true'
  117. label-width="80px"
  118. label-position="right"
  119. ref='studentForm'
  120. :rules="studentRules">
  121. <el-form-item label="联系电话"
  122. :rules="[{ required: true, message: '请输入手机号' }, { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }]">
  123. <!-- @blur="checkPhone(studentForm.phone)" -->
  124. <el-input v-model="studentForm.phone"></el-input>
  125. </el-form-item>
  126. <el-form-item label="所属分部"
  127. v-if="isNew"
  128. prop="organId">
  129. <el-select class='multiple'
  130. v-model="studentForm.organId"
  131. filterable
  132. clearable
  133. placeholder="请选择分部">
  134. <el-option v-for="(item,index) in organList"
  135. :key="index"
  136. :label="item.name"
  137. :value="item.id"></el-option>
  138. </el-select>
  139. </el-form-item>
  140. <el-form-item label="学生姓名"
  141. prop="name">
  142. <el-input v-model="studentForm.name"></el-input>
  143. </el-form-item>
  144. <el-form-item label="学生性别"
  145. prop="sex">
  146. <el-select class='multiple'
  147. filterable
  148. v-model="studentForm.sex"
  149. clearable
  150. placeholder="请选择分部">
  151. <el-option :value="0"
  152. label="女"></el-option>
  153. <el-option :value="1"
  154. label="男"></el-option>
  155. </el-select>
  156. </el-form-item>
  157. <!-- <el-form-item label="名族"
  158. prop="nation">
  159. <el-input v-model="studentForm.nation"></el-input>
  160. </el-form-item> -->
  161. <el-form-item label="家长姓名">
  162. <el-input v-model="studentForm.parseName"></el-input>
  163. </el-form-item>
  164. <el-form-item label="出生日期">
  165. <el-date-picker v-model="studentForm.date"
  166. value-format="yyyy-MM-dd"
  167. type="date"
  168. placeholder="选择日期">
  169. </el-date-picker>
  170. </el-form-item>
  171. </el-form>
  172. <div slot="footer"
  173. class="dialog-footer">
  174. <el-button @click="studentVisible = false">取 消</el-button>
  175. <el-button type="primary"
  176. v-if="isNew"
  177. @click="submitAddStudent">确 定</el-button>
  178. <el-button type="primary"
  179. v-if="!isNew"
  180. @click="resetStudentSubmie">确 定</el-button>
  181. </div>
  182. </el-dialog>
  183. <el-dialog :visible.sync="qrcodeStatus"
  184. center
  185. width="300px">
  186. <div class="right-code">
  187. <h2 class="title">学员激活列表</h2>
  188. <div id="qrcode"
  189. class="qrcode code"
  190. ref="qrCodeUrl"></div>
  191. <!-- <p class="code-url"
  192. v-if="codeUrl2">{{ codeUrl2 }}</p> -->
  193. </div>
  194. </el-dialog>
  195. </div>
  196. </template>
  197. <script>
  198. import pagination from '@/components/Pagination/index'
  199. import { queryStudentList, getStudentInfoByPhone, registerStudent, updateStudent } from '@/api/studentManager'
  200. import { vaildStudentUrl } from '@/utils/validate'
  201. import { getEmployeeOrgan } from '@/api/buildTeam'
  202. import QRCode from 'qrcodejs2'
  203. import store from '@/store'
  204. export default {
  205. name: 'studentList',
  206. components: { pagination },
  207. data () {
  208. return {
  209. studentVisible: false,
  210. searchForm: {
  211. organId: null,
  212. search: null,
  213. studentName: null,
  214. isActive: null
  215. },
  216. searchList: [],
  217. tableList: [],
  218. organList: [],
  219. pageInfo: {
  220. // 分页规则
  221. limit: 10, // 限制显示条数
  222. page: 1, // 当前页
  223. total: 0, // 总条数
  224. page_size: [10, 20, 40, 50] // 选择限制显示条数
  225. },
  226. studentForm: {
  227. phone: '',
  228. organId: '',
  229. name: '',
  230. sex: '',
  231. parseName: '',
  232. date: '',
  233. nation: ''
  234. },
  235. studentRules: {
  236. name: [{ required: true, message: '请输入学生姓名' },],
  237. sex: [{ required: true, message: '请选择学生姓名' },],
  238. date: [{ required: true, message: '请选择出生日期' },],
  239. organId: [{ required: true, message: '请选择分部' }],
  240. nation: [{ required: true, message: '请输入名族' }]
  241. },
  242. isNew: false,
  243. active: null,
  244. maskName: '新增学员',
  245. qrcodeStatus: false,
  246. qrcodes: true,
  247. activeRow: null
  248. }
  249. },
  250. mounted () {
  251. if (this.$route.query.search) {
  252. this.$route.query.search instanceof Object ? this.searchForm = this.$route.query.search : this.searchForm = JSON.parse(this.$route.query.search);
  253. }
  254. if (this.$route.query.rules) {
  255. this.$route.query.rules instanceof Object ? this.pageInfo = this.$route.query.rules : this.pageInfo = JSON.parse(this.$route.query.rules);
  256. }
  257. getEmployeeOrgan().then(res => {
  258. if (res.code == 200) {
  259. this.organList = res.data;
  260. }
  261. })
  262. this.getList();
  263. },
  264. methods: {
  265. onSearch () {
  266. this.pageInfo.page = 1;
  267. this.getList()
  268. },
  269. onCreateQRCode () { // 生成报名二维码
  270. this.qrcodeStatus = true
  271. // let id = this.$route.query.id
  272. // let teamName = this.$route.query.name
  273. setTimeout(() => {
  274. if (this.qrcodes) {
  275. this.qrcodes = false
  276. this.qrcode = new QRCode('qrcode', {
  277. width: 250,
  278. height: 250,
  279. colorDark: '#000000',
  280. colorLight: '#ffffff',
  281. correctLevel: QRCode.CorrectLevel.H
  282. })
  283. }
  284. // vaildStudentUrl() + `/#/sporadicLogin?id=${刷刷刷}`
  285. this.qrcode.clear();
  286. this.qrcode.makeCode(vaildStudentUrl() + `/#/queryStudentPer`)
  287. // this.codeUrl = vaildStudentUrl() + '/#/login?musicGroupId=' + id
  288. }, 500)
  289. },
  290. getList () {
  291. let params = this.searchForm
  292. params.rows = this.pageInfo.limit
  293. params.page = this.pageInfo.page
  294. params.organId ? params.organId : params.organId = null;
  295. queryStudentList(params).then(res => {
  296. if (res.code == 200) {
  297. this.tableList = res.data.rows
  298. this.pageInfo.total = res.data.total
  299. }
  300. })
  301. },
  302. onReSet () {
  303. this.searchForm = {
  304. organId: null,
  305. search: null,
  306. studentName: null,
  307. isActive: null
  308. }
  309. },
  310. checkPhone (val) {
  311. var regu = /^1[3456789]\d{9}$/;
  312. var re = new RegExp(regu);
  313. if (re.test(val)) {
  314. getStudentInfoByPhone({ mobile: this.studentForm.phone }).then(res => {
  315. if (res.code == 200) {
  316. if (res.data) {
  317. this.studentForm = {
  318. name: res.data.name,
  319. sex: res.data.gender,
  320. parseName: res.data.parentsName,
  321. // sound: parseInt(res.data.subjectId),
  322. phone: val,
  323. date: res.data.birthdate
  324. }
  325. }
  326. }
  327. })
  328. }
  329. },
  330. submitAddStudent () {
  331. // 效验 然后组数据提交
  332. this.$refs['studentForm'].validate(item => {
  333. if (item) {
  334. let obj = {
  335. phone: this.studentForm.phone,
  336. username: this.studentForm.name,
  337. gender: this.studentForm.sex,
  338. realName: this.studentForm.parseName,
  339. birthdate: this.studentForm.date,
  340. organId: this.studentForm.organId,
  341. nation: this.studentForm.nation
  342. }
  343. registerStudent(obj).then(res => {
  344. if (res.code == 200) {
  345. this.$message.success('添加成功');
  346. this.studentVisible = false;
  347. this.getList()
  348. }
  349. })
  350. }
  351. })
  352. },
  353. // 修改学生信息
  354. resetStudentSubmie () {
  355. this.$refs['studentForm'].validate(item => {
  356. if (item) {
  357. let obj = {
  358. phone: this.studentForm.phone,
  359. username: this.studentForm.name,
  360. gender: this.studentForm.sex,
  361. realName: this.studentForm.parseName,
  362. birthdate: this.studentForm.date,
  363. organId: this.studentForm.organId,
  364. id: this.active.userId,
  365. nation: this.studentForm.nation
  366. }
  367. updateStudent(obj).then(res => {
  368. if (res.code == 200) {
  369. this.$message.success('修改成功');
  370. this.studentVisible = false;
  371. this.getList()
  372. }
  373. })
  374. }
  375. })
  376. },
  377. addStudent () {
  378. this.isNew = true;
  379. this.studentVisible = true;
  380. this.maskName = '新增学员'
  381. },
  382. resetStudent (row) {
  383. this.isNew = false;
  384. this.active = row;
  385. this.studentVisible = true;
  386. this.maskName = '修改学员'
  387. this.studentForm = {
  388. phone: row.parentsPhone,
  389. name: row.username,
  390. sex: row.gender,
  391. parseName: row.realName,
  392. date: row.birthdate,
  393. nation: row.nation
  394. }
  395. }
  396. },
  397. watch: {
  398. studentVisible (val) {
  399. if (!val) {
  400. this.studentForm = {
  401. phone: '',
  402. organId: '',
  403. name: '',
  404. sex: '',
  405. parseName: '',
  406. date: '',
  407. nation: ''
  408. }
  409. // this.studentForm.
  410. }
  411. }
  412. }
  413. }
  414. </script>
  415. <style lang="scss" scoped>
  416. .newBand {
  417. display: inline-block;
  418. margin-right: 10px;
  419. }
  420. .right-code {
  421. // width: 50%;
  422. // float: left;
  423. .title {
  424. font-size: 18px;
  425. text-align: center;
  426. padding-bottom: 8px;
  427. }
  428. }
  429. </style>