table.vue 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009
  1. <template>
  2. <div class="tabbox">
  3. <div class="topbox">
  4. <template>
  5. <div class="topbox_area" v-if="boxType == 0">
  6. <span v-if="!ClaEditvisible">{{ activeinfo.name }}</span>
  7. <input v-if="ClaEditvisible" ref="claEditInput" class="claInp" type="text"
  8. placeholder="请输入班级名称..."
  9. v-model.trim="ClaEditInfo.name"
  10. @blur="confirmClaEdit"
  11. @keyup.enter="confirmClaEdit">
  12. <span>学生列表</span>
  13. <el-tooltip content="编辑" placement="top">
  14. <img
  15. :src="editBtnHovered || ClaEditvisible ? eidl : eidh"
  16. alt=""
  17. @click="editCla(activeinfo)"
  18. @mouseover="editBtnHovered = true"
  19. @mouseout="editBtnHovered = false"
  20. class="xk_img"
  21. :class="ClaEditvisible || editBtnHovered ? 'bacl' : ''"
  22. />
  23. </el-tooltip>
  24. <el-tooltip content="删除" placement="top">
  25. <img
  26. :src="deleteBtnHovered ? delh : dell"
  27. alt=""
  28. @click="deleteCla(activeId,1)"
  29. @mouseover="deleteBtnHovered = true"
  30. @mouseout="deleteBtnHovered = false"
  31. class="xk_img xk_img2"
  32. />
  33. </el-tooltip>
  34. </div>
  35. <div class="topbox_area" v-if="boxType == 1">
  36. <span
  37. v-if="interestType == 0"
  38. >兴趣班列表</span
  39. >
  40. <template v-if="interestType == 1">
  41. <span
  42. style="cursor: pointer"
  43. @click="
  44. interestType = 0;
  45. refresh();
  46. "
  47. >兴趣班列表</span
  48. >
  49. <i class="el-icon-arrow-right"></i>
  50. <span>学生列表</span>
  51. </template>
  52. </div>
  53. <div class="topbox_area" v-if="boxType == 2">
  54. <span>学生列表</span>
  55. <span>{{ total }}人</span>
  56. </div>
  57. </template>
  58. <!-- 右边区域 -->
  59. <div class="topbox_area">
  60. <el-input
  61. :placeholder="boxType == 1 ? '搜索兴趣班...' : '搜索学生...'"
  62. v-model="inp"
  63. @keyup.enter.native="refresh"
  64. v-if="boxType == 0 || boxType == 2 || (boxType == 1 && interestType == 1)"
  65. >
  66. <i slot="prefix" @click="refresh" class="el-input__icon el-icon-search"></i>
  67. </el-input>
  68. <template v-if="(boxType == 1 && interestType == 0) || boxType == 2">
  69. <el-popover
  70. placement="bottom"
  71. trigger="hover"
  72. popper-class="topbox_area_popover"
  73. >
  74. <div class="topbox_areaCon">
  75. <div :class="insort == 1 ? 'topbox_areaConBck' : ''">
  76. 按最早创建排序
  77. </div>
  78. <div :class="insort == 0 ? 'topbox_areaConBck' : ''">
  79. 按最晚创建排序
  80. </div>
  81. </div>
  82. <img slot="reference" class="sortImg" v-if="insort == 0" @click="intSort('1')" src="../../../../assets/stuImg/jiang.svg" alt="">
  83. <img slot="reference" class="sortImg" v-if="insort == 1" @click="intSort('0')" src="../../../../assets/stuImg/sheng.svg" alt="">
  84. </el-popover>
  85. </template>
  86. <div @click="refresh" v-if="!selectedData.length" class="action_btn">
  87. <img
  88. src="../../../../assets/stuImg/cz.svg"
  89. alt="刷新"
  90. class="action_img"
  91. />
  92. 刷新
  93. </div>
  94. <!-- 处理学生相关操作 -->
  95. <div
  96. @click="exportStudent"
  97. class="action_btn"
  98. v-if="boxType == 0 || (boxType == 1 && interestType == 1)"
  99. >
  100. <img
  101. src="../../../../assets/stuImg/share.svg"
  102. alt="导出"
  103. class="action_img"
  104. />
  105. 导出
  106. </div>
  107. <template v-if="boxType == 0">
  108. <template v-if="selectedData.length">
  109. <div class="action_btn action_btn2" @click="resetPassword">
  110. <i class="el-icon-lock"></i>
  111. 重置密码
  112. </div>
  113. <div class="action_btn action_btn2" @click="moveSelStu">
  114. <i class="el-icon-rank"></i>
  115. 移动
  116. </div>
  117. <div
  118. class="action_btn"
  119. style="background: #ff4d4f; color: #fff"
  120. @click="removeSelStu"
  121. >
  122. <i class="el-icon-remove-outline"></i>
  123. 移除
  124. </div>
  125. </template>
  126. </template>
  127. <div
  128. @click="addStudent"
  129. v-if="!selectedData.length && (boxType == 0 || boxType == 2)"
  130. class="action_btn"
  131. >
  132. <i class="el-icon-plus"></i>
  133. 添加学生
  134. </div>
  135. <!-- 处理兴趣班相关操作 -->
  136. <div
  137. @click="addInterestCla()"
  138. v-if="boxType == 1 && interestType == 0"
  139. class="action_btn"
  140. >
  141. <i class="el-icon-plus"></i>
  142. 添加兴趣班
  143. </div>
  144. <div
  145. @click="addStudent"
  146. v-if="boxType == 1 && interestType == 1 && activeinfo.createuserid == userid"
  147. class="action_btn"
  148. >
  149. <i class="el-icon-plus"></i>
  150. 添加学生
  151. </div>
  152. </div>
  153. </div>
  154. <div class="tabList" v-loading="isLoading">
  155. <el-table
  156. :data="tableData"
  157. ref="tableData"
  158. :header-cell-style="{ background: '#E7EAF0' }"
  159. :key="boxType"
  160. height="100%"
  161. class="tableList"
  162. @selection-change="handleSelectionChange"
  163. @row-click="viewStudent"
  164. >
  165. <el-table-column
  166. type="selection"
  167. v-if="boxType == 0 || (boxType == 1 && interestType == 1)"
  168. width="55px"
  169. >
  170. </el-table-column>
  171. <el-table-column
  172. v-for="(item, index) in tableColumns"
  173. :key="index"
  174. :width="item.wid"
  175. show-overflow-tooltip
  176. :label="item.label"
  177. >
  178. <template slot-scope="scope">
  179. <div
  180. class="cla_box"
  181. v-if="item.label == '班级'"
  182. >
  183. <span
  184. class="cla_span"
  185. v-for="(cla, ind) in stuClalist(scope.row.classname,1)"
  186. :key="ind + 'cla123'"
  187. >
  188. {{ cla }}
  189. </span>
  190. <span
  191. v-if="stuClalist(scope.row.classname,2).length > 0"
  192. >
  193. <el-popover
  194. placement="bottom"
  195. min-width="80"
  196. trigger="hover"
  197. :visible-arrow="false"
  198. >
  199. <div class="action_box" style="display: flex;flex-direction: column;gap: 5px;justify-content: center;align-items: center;">
  200. <div v-for="(cla, ind) in stuClalist(scope.row.classname,2)" :key="ind + 'cla'">
  201. {{ cla }}
  202. </div>
  203. </div>
  204. <div slot="reference" style="display: flex;align-items: center;">
  205. <img
  206. src="../../../../assets/stuImg/act.svg"
  207. style="width: 20px; cursor: pointer;"
  208. />
  209. </div>
  210. </el-popover>
  211. </span>
  212. </div>
  213. <div v-else-if="item.label == '账号'">
  214. <span>{{ scope.row.acc.split("@")[0] }}</span>
  215. </div>
  216. <div v-else>
  217. <span>{{ scope.row[item.prop] }}</span>
  218. </div>
  219. </template>
  220. </el-table-column>
  221. <!-- 操作列 -->
  222. <el-table-column width="200" align="right" label="">
  223. <template slot-scope="scope">
  224. <div>
  225. <el-popover
  226. placement="bottom-end"
  227. width="60"
  228. trigger="hover"
  229. popper-class="student-manage-action-popover"
  230. >
  231. <div class="action_box">
  232. <template
  233. v-if="
  234. boxType == 0 ||
  235. boxType == 2 ||
  236. (boxType == 1 && interestType == 1)
  237. "
  238. >
  239. <div @click="editStudent(scope.row)">编辑</div>
  240. <div v-if="boxType == 1 && interestType == 1" @click="deleteClassStudent(scope.row.userid)">
  241. 移除
  242. </div>
  243. <div v-else @click="deleteStudentL(scope.row)">
  244. 删除
  245. </div>
  246. </template>
  247. <template v-if="boxType == 1 && interestType == 0 && scope.row.createuserid == userid">
  248. <!-- <div @click="viewStudent(scope.row)">查看</div> -->
  249. <div @click="editInterestCla(scope.row)">编辑</div>
  250. <div @click="deleteCla(scope.row.id,0,scope.row.createuserid)">删除</div>
  251. </template>
  252. </div>
  253. <img
  254. src="../../../../assets/stuImg/act.svg"
  255. slot="reference"
  256. alt="编辑"
  257. class="action_img"
  258. style="cursor: pointer"
  259. />
  260. </el-popover>
  261. </div>
  262. </template>
  263. </el-table-column>
  264. </el-table>
  265. <div
  266. class="page_box"
  267. v-if="boxType == 2 || (boxType == 1 && interestType == 0)"
  268. >
  269. <el-pagination
  270. background
  271. @size-change="handleSizeChange"
  272. @current-change="handlePageChange"
  273. :current-page.sync="page"
  274. :page-sizes="[10, 15, 20, 25]"
  275. :page-size="pageSize"
  276. layout="sizes, prev, pager, next"
  277. :total="total"
  278. >
  279. </el-pagination>
  280. </div>
  281. <div
  282. class="page_box"
  283. v-if="
  284. (boxType == 0 || (boxType == 1 && interestType == 1)) &&
  285. selectedData.length
  286. "
  287. >
  288. <div class="page_box_area" v-if="boxType == 0">
  289. <div style="display: flex; align-items: center; gap: 10px">
  290. <!-- <el-checkbox
  291. @change="handleCheckedAllSelection"
  292. v-model="checkedAllSelection"
  293. ></el-checkbox> -->
  294. <div class="action_btn" @click="cancelAllSelection" v-if="selectedData.length != 0 && selectedData.length == tableData.length">
  295. 取消全选
  296. </div>
  297. <div class="action_btn" @click="allSel" v-else>全选</div>
  298. </div>
  299. <div
  300. @click="deleteSelectionStudent"
  301. class="action_btn"
  302. style="background: #ff4d4f; color: #fff"
  303. >
  304. 删除
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <!-- 添加兴趣班弹框 -->
  310. <el-dialog :visible.sync="addInterestClaVisible" height="400px" width="442px">
  311. <template slot="title">
  312. <div class="dia_title_box">
  313. <span>添加兴趣班</span>
  314. </div>
  315. </template>
  316. <div class="dia_box_item2">
  317. <div class="addcla_box_item">
  318. <span>兴趣班名称:</span>
  319. <el-input
  320. v-model="interestName"
  321. placeholder="请输入兴趣班名称"
  322. ></el-input>
  323. </div>
  324. </div>
  325. <div slot="footer" class="dialog-footer" style="display: flex;justify-content: flex-end;gap: 10px;">
  326. <div @click="addInterestClaVisible = false">取消</div>
  327. <div @click="addInterestClaConfirm" style="background: #3681FC; color: #E6FFFFFF;">确认</div>
  328. </div>
  329. </el-dialog>
  330. <!-- 移动班级学生弹框 -->
  331. <el-dialog :visible.sync="moveClaVisible" width="440px">
  332. <template slot="title">
  333. <div class="dia_title_box">
  334. <span>移动学生</span>
  335. </div>
  336. </template>
  337. <div style="width: 100%;height: 300px;padding-top: 20px;box-sizing: border-box;">
  338. <el-cascader
  339. :options="cascaderData"
  340. v-model="moveClaCascaderDataPath"
  341. @change="handlemoveChangecascader"
  342. popper-class="myCascader2"
  343. style="width: 100%;"
  344. :props="{
  345. label: 'name',
  346. value: 'id',
  347. children: 'children',
  348. }"
  349. >
  350. <template slot-scope="{ data, node }">
  351. <!-- 一级选项(年级) -->
  352. <span v-if="node.level === 1">{{ data.name }}</span>
  353. <!-- 二级选项(班级)- 可以自定义显示 -->
  354. <span v-else-if="node.level === 2" class="cascader-class-item">
  355. <span>{{ data.name }}</span>
  356. </span>
  357. <!-- 其他级别(兜底) -->
  358. <span v-else>{{ data.name }}</span>
  359. </template>
  360. </el-cascader>
  361. </div>
  362. <div slot="footer" class="dialog-footer">
  363. <!-- <el-button @click="moveClaVisible = false">取消</el-button> -->
  364. <div class="kbtn" @click="moveClaVisible = false">取消</div>
  365. <div class="kbtn" @click="confirmMoveClaEdit" style="background: #3681FC; color: #E3EDFF;">确定</div>
  366. <!-- <el-button type="primary" @click="confirmMoveClaEdit">确定</el-button> -->
  367. </div>
  368. </el-dialog>
  369. <!-- 编辑信息 -->
  370. <el-dialog :visible.sync="stuEditvisible" width="500px">
  371. <template slot="title">
  372. <div class="dia_title_box">
  373. <span>编辑信息</span>
  374. <span @click="inPassword">重置密码</span>
  375. </div>
  376. </template>
  377. <div class="dia_box_item">
  378. <div class="addcla_box_item">
  379. <span>姓名:</span>
  380. <el-input
  381. v-model="stuEditInfo.username"
  382. placeholder="请输入姓名"
  383. ></el-input>
  384. </div>
  385. <div class="addcla_box_item">
  386. <span>账号:</span>
  387. <div>{{ stuEditInfo.acc }}</div>
  388. </div>
  389. <div class="addcla_box_item">
  390. <span>班级:</span>
  391. <el-cascader
  392. :options="cascaderData"
  393. v-model="cascaderDataPath"
  394. @change="handleChangecascader"
  395. popper-class="myCascader"
  396. :props="{
  397. label: 'name',
  398. value: 'id',
  399. children: 'children',
  400. multiple: true,
  401. }"
  402. >
  403. <template slot-scope="{ data, node }">
  404. <!-- 一级选项(年级) -->
  405. <span v-if="node.level === 1">{{ data.name }}</span>
  406. <!-- 二级选项(班级)- 可以自定义显示 -->
  407. <span v-else-if="node.level === 2" class="cascader-class-item">
  408. <span>{{ data.name }}</span>
  409. </span>
  410. <!-- 其他级别(兜底) -->
  411. <span v-else>{{ data.name }}</span>
  412. </template>
  413. </el-cascader>
  414. </div>
  415. </div>
  416. <div slot="footer" class="dialog-footer">
  417. <!-- <el-button @click="closeEditStu">取消</el-button> -->
  418. <div class="kbtn" @click="closeEditStu">取消</div>
  419. <div class="kbtn" @click="confirmEditStu" style="background: #3681FC; color: #E3EDFF;">确认</div>
  420. <!-- <el-button type="primary" @click="confirmEditStu">确定</el-button> -->
  421. </div>
  422. </el-dialog>
  423. <!-- 编辑兴趣班 -->
  424. <editInterstcla ref="editInterstcla" @getCascaderData="getCascaderData" :cascaderData="cascaderData" :interestClaEditInfo="InterestClaEditInfo" />
  425. <!-- 添加学生 -->
  426. <addStu ref="addStu" :boxType="boxType" :cascaderData="cascaderData" @getStudent="getStudent" @getCascaderData="getCascaderData" />
  427. <!-- 重置密码弹框 -->
  428. <!-- <msgbox ref="msgboxref" infomMsg="infomMsg"></msgbox> -->
  429. <div class="pop-upBox">
  430. <el-dialog
  431. :visible.sync="popBoxdia"
  432. width="480px"
  433. :show-close="false"
  434. >
  435. <div class="msgCon">
  436. <img style="width: 20px;" v-if="deltypy == 7 || deltypy == 8" src="../../../../assets/stuImg/duil.svg" alt="">
  437. <img style="width: 20px;" v-else src="../../../../assets/stuImg/tishi.svg" alt="">
  438. <div class="msgContxt">
  439. <div v-if="deltypy == 1">确认删除“{{delStuinfo.username}}”学生? </div>
  440. <div v-if="deltypy == 2">确认删除这 {{selectedData.length}} 位学生? </div>
  441. <div v-if="deltypy == 3">此操作将删除该班级,及班级所有已产生的授课数据, 是否继续? </div>
  442. <div v-if="deltypy == 4">确定从当前班级移除{{ selectedData.length }}名学生吗? </div>
  443. <div v-if="deltypy == 5">确定要重置 {{selectedData.length}} 个学生的密码吗? </div>
  444. <div v-if="deltypy == 6">确定要重置 {{this.stuEditInfo.username}} 的密码吗? </div>
  445. <div v-if="deltypy == 9">确定要移动到该班级吗? </div>
  446. <div v-if="deltypy == 10">确定要修改 {{this.stuEditInfo.username}} 的学生信息吗? </div>
  447. </div>
  448. <div class="msgContxt" v-if="deltypy == 7 || deltypy == 8">
  449. <div v-if="deltypy == 7">对{{selectedData.length}}个账户重置密码成功! </div>
  450. <div v-if="deltypy == 8">重置密码成功! </div>
  451. <div>
  452. <span>默认密码为:Coco1234</span>
  453. <el-tooltip class="item" effect="dark" content="复制" placement="top">
  454. <img @click="copyText"
  455. class="copyMg"
  456. :src="deleteBtnHovered ? copy1 : copy"
  457. @mouseover="deleteBtnHovered = true"
  458. @mouseout="deleteBtnHovered = false"
  459. alt="">
  460. </el-tooltip>
  461. </div>
  462. </div>
  463. </div>
  464. <span slot="footer" class="dialog-footer">
  465. <!-- <el-button @click="closeDia"
  466. v-if="deltypy != 7 && deltypy != 8"
  467. >取 消</el-button
  468. > -->
  469. <div @click="closeDia" v-if="deltypy != 7 && deltypy != 8">取消</div>
  470. <div @click="confirmDelStu" style="background: #3681FC; color: #E3EDFF;">确认</div>
  471. <!-- <el-button type="primary" @click="confirmDelStu"
  472. >确 认</el-button
  473. > -->
  474. </span>
  475. </el-dialog>
  476. </div>
  477. </div>
  478. </template>
  479. <script>
  480. import editInterstcla from "./editInterstcla.vue";
  481. import addStu from "./addstu.vue";
  482. // import msgbox from "./msgbox.vue";
  483. export default {
  484. components: {
  485. editInterstcla,
  486. addStu,
  487. },
  488. props: {
  489. GrapTableData: {
  490. type: Array,
  491. default: () => [],
  492. },
  493. activeIdL: {
  494. type: String,
  495. default: "",
  496. },
  497. activeinfoData: {
  498. type: Object,
  499. default: () => {},
  500. },
  501. boxType: {
  502. type: Number,
  503. default: 0,
  504. },
  505. },
  506. data() {
  507. return {
  508. userid: this.$route.query.userid,
  509. org: this.$route.query.org,
  510. oid: this.$route.query.oid,
  511. role: this.$route.query.role,
  512. activeId: "", // 当前选中的班级id
  513. activeinfo: {}, // 当前选中的班级信息
  514. eidl:require('../../../../assets/stuImg/eidl.svg'),
  515. eidh:require('../../../../assets/stuImg/eidh.svg'),
  516. dell:require('../../../../assets/stuImg/dell.svg'),
  517. delh:require('../../../../assets/stuImg/delh.svg'),
  518. copy1:require('../../../../assets/stuImg/copymsg1.svg'),
  519. copy:require('../../../../assets/stuImg/copymsg.svg'),
  520. popBoxdia:false,
  521. insort:0,
  522. EditStubox:'',
  523. delClaid:'',
  524. delClaidtype:'',
  525. infomMsg:{}, //消息提示
  526. delStuinfo:{},
  527. deltypy: 1, //1单个删除学生 2批量删除学生 3删除班级
  528. interestName: "", // 兴趣班名称
  529. interestType: 0, // 0 班级 1 班级内学生
  530. InterestClaAddInfo: {}, // 兴趣班添加信息
  531. addInterestClaVisible: false, // 兴趣班添加弹框
  532. InterestClaEditInfo: {}, // 兴趣班编辑信息
  533. cascaderData: [], // 班级级联数据
  534. cascaderDataPath: [], // 班级级联选中数据路径
  535. checkedAllSelection: false, // 全选
  536. stuEditvisible: false,
  537. stuEditInfo: {}, // 学生编辑信息
  538. ClaEditvisible: false, // 班级编辑信息
  539. ClaEditInfo: {}, // 班级编辑信息
  540. editBtnHovered: false, // 编辑按钮hover状态
  541. deleteBtnHovered: false, // 删除按钮hover状态
  542. moveClaVisible: false, // 移动班级学生弹框
  543. moveClaInfo: {}, // 移动班级学生信息
  544. moveClaCascaderDataPath: [], // 移动班级学生级联选中数据路径
  545. tableData: [], //表格数据
  546. selectedData: [], //选中数据
  547. page: 1,
  548. total: 0,
  549. pageSize: 10,
  550. isLoading: false,
  551. inp: "",
  552. tableColumns: [
  553. {
  554. label: "学生姓名",
  555. prop: "username",
  556. },
  557. {
  558. label: "账号",
  559. prop: "acc",
  560. },
  561. {
  562. label: "班级",
  563. prop: "classname",
  564. wid: "300",
  565. },
  566. ],
  567. studentColumns: [
  568. {
  569. label: "学生姓名",
  570. prop: "username",
  571. },
  572. {
  573. label: "账号",
  574. prop: "acc",
  575. },
  576. {
  577. label: "班级",
  578. prop: "classname",
  579. wid:"360"
  580. },
  581. ],
  582. // 兴趣班表格列
  583. tableInterestClaColumns: [
  584. {
  585. label: "班级信息",
  586. prop: "name",
  587. },
  588. {
  589. label: "学生人数",
  590. prop: "pnum",
  591. },
  592. {
  593. label: "时间",
  594. prop: "create_at",
  595. },
  596. ],
  597. };
  598. },
  599. watch: {
  600. GrapTableData: {
  601. handler(newVal) {
  602. this.cascaderData = newVal;
  603. },
  604. immediate: true,
  605. },
  606. activeinfoData:{
  607. handler(newVal) {
  608. this.activeinfo = newVal;
  609. },
  610. immediate: true,
  611. },
  612. activeIdL: {
  613. handler(newVal) {
  614. this.activeId = newVal;
  615. this.inp = "";
  616. this.interestType = 0;
  617. this.refresh();
  618. },
  619. immediate: true,
  620. },
  621. },
  622. computed: {
  623. stuClalist() {
  624. return function(data,val){
  625. // console.log(data, "data");
  626. if(data.length == 0){
  627. return [];
  628. }
  629. let list = JSON.parse(JSON.stringify(data)).split('/');
  630. // console.log(list, "list");
  631. if(list.length > 0 && val == 1){
  632. // console.log(list.slice(0, 2), "list.slice(0, 2)");
  633. return list.slice(0, 2);
  634. }else if(list.length > 0 && val == 2){
  635. // console.log(list.slice(2), "list.slice(2)");
  636. return list.slice(2);
  637. }
  638. return [];
  639. };
  640. },
  641. },
  642. methods: {
  643. copyText(){
  644. const text = 'Coco1234';
  645. if (navigator.clipboard && navigator.clipboard.writeText) {
  646. navigator.clipboard.writeText(text).then(() => {
  647. this.$message.success('已复制到剪贴板');
  648. }).catch(() => {
  649. this.fallbackCopy(text);
  650. });
  651. } else {
  652. this.fallbackCopy(text);
  653. }
  654. },
  655. fallbackCopy(text) {
  656. const textarea = document.createElement('textarea');
  657. textarea.value = text;
  658. textarea.style.position = 'fixed';
  659. textarea.style.opacity = '0';
  660. document.body.appendChild(textarea);
  661. textarea.select();
  662. try {
  663. document.execCommand('copy');
  664. this.$message.success('已复制到剪贴板');
  665. } catch (err) {
  666. this.$message.error('复制失败');
  667. }
  668. document.body.removeChild(textarea);
  669. },
  670. // 年级方法区域
  671. // 打开删除班级弹框
  672. deleteCla(cid,val,uid) {
  673. if (val == 0 && uid != this.userid) return this.$message.error('仅限创建者删除')
  674. this.delClaidtype = val;
  675. this.delClaid = cid
  676. this.popBoxdia =true
  677. this.deltypy = 3;
  678. },
  679. confirmdeleteCla(){
  680. let params = {
  681. id: this.delClaid,
  682. };
  683. if (this.time()) {
  684. this.ajax
  685. .get(this.$store.state.api + "deleteClass", params)
  686. .then((res) => {
  687. this.$message({
  688. message: "删除成功",
  689. type: "success",
  690. });
  691. this.popBoxdia =false;
  692. this.$emit("getGrade", this.delClaidtype);
  693. this.refresh()
  694. this.delClaid = '';
  695. this.deltypy = 0;
  696. })
  697. .catch((err) => {
  698. this.$message.error("删除失败");
  699. console.error(err);
  700. });
  701. }
  702. },
  703. // 修改班级名称弹框
  704. editCla(row) {
  705. this.ClaEditvisible = !this.ClaEditvisible;
  706. this.ClaEditInfo = JSON.parse(JSON.stringify(row));
  707. this.ClaEditInfo.name = '';
  708. if (this.ClaEditvisible) {
  709. this.$nextTick(() => {
  710. this.$refs.claEditInput.focus();
  711. });
  712. }
  713. },
  714. // 全选
  715. allSel(){
  716. this.tableData.forEach((row) => {
  717. this.$refs.tableData.toggleRowSelection(row, true);
  718. });
  719. },
  720. // 导出学生
  721. exportStudent() {
  722. if (this.selectedData.length == 0) {
  723. this.$message({
  724. message: "请先选中要导出的学生",
  725. type: "error",
  726. });
  727. return;
  728. }
  729. var res = this.selectedData;
  730. //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
  731. //将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
  732. var array = [];
  733. for (var i = 0; i < res.length; i++) {
  734. var _json = {};
  735. _json["学生信息"] = res[i].username;
  736. _json["账号"] = res[i].acc;
  737. _json["班级"] = res[i].classname;
  738. array.push(_json);
  739. }
  740. var XLSX = require("xlsx");
  741. const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
  742. let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
  743. ws["!cols"] = [
  744. //设置每一列的宽度
  745. { wch: 20 },
  746. { wch: 20 },
  747. { wch: 20 },
  748. ];
  749. XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
  750. XLSX.writeFile(workbook, this.activeinfo.name + "学生列表.xlsx");
  751. // const wopts = { bookType: "xlsx", bookSST: false, type: "array" };//写入的样式bookType:输出的文件类型,type:输出的数据类型,bookSST: 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
  752. // const wbout = XLSX.write(workbook, wopts);// 浏览器端和node共有的API,实际上node可以直接使用xlsx.writeFile来写入文件,但是浏览器没有该API
  753. // FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }), `${title} demo.xlsx`);//保存文件
  754. this.$message({
  755. message: "导出成功",
  756. type: "success",
  757. });
  758. this.cancelAllSelection();
  759. },
  760. // 移动班级学生
  761. moveSelStu() {
  762. console.log("this.selectedData", this.selectedData);
  763. // 先移除班级
  764. let box = this.cascaderData
  765. .flatMap((item) => item.children)
  766. .find((item) => item.id == this.activeId);
  767. this.moveClaCascaderDataPath = [box.pid, this.activeId];
  768. console.log(this.moveClaCascaderDataPath, "this.moveClaCascaderDataPath");
  769. this.moveClaVisible = true;
  770. },
  771. // 确定移动
  772. confirmMoveClaEdit() {
  773. if (this.moveClaCascaderDataPath.length === 0) {
  774. this.$message({
  775. message: "请选择班级",
  776. type: "error",
  777. });
  778. return;
  779. }
  780. this.deltypy = 9;
  781. this.popBoxdia = true;
  782. },
  783. confirmMoveClaEditStu(){
  784. // this.$confirm("确定要移动到该班级吗?", "提示", {
  785. // confirmButtonText: "确定",
  786. // cancelButtonText: "取消",
  787. // type: "warning",
  788. // })
  789. // .then(() => {
  790. // 先移出班级
  791. const promises = this.selectedData.map((item) => {
  792. item.classid = item.classid
  793. .split(",")
  794. .filter((item) => item != this.activeId)
  795. .join(",");
  796. return this.deleteClassStudent(item.userid);
  797. });
  798. Promise.all(promises)
  799. .then(() => {
  800. // 再移入班级
  801. const promises2 = this.selectedData.map((item) => {
  802. let box = [
  803. ...item.classid.split(","),
  804. this.moveClaCascaderDataPath[1],
  805. ];
  806. box = box.filter((item) => item != '');
  807. console.log("box", box);
  808. return this.moveClassStudentPromise(item, box.join(","));
  809. });
  810. Promise.all(promises2)
  811. .then(() => {
  812. this.$message({
  813. message: "移动成功",
  814. type: "success",
  815. });
  816. this.moveClaVisible = false;
  817. this.moveClaCascaderDataPath = [];
  818. this.popBoxdia = false;
  819. this.$emit("getGrade");
  820. this.refresh();
  821. })
  822. .catch((err) => {
  823. console.error(err);
  824. this.$message({
  825. message: "移动失败",
  826. type: "error",
  827. });
  828. });
  829. })
  830. .catch(() => {});
  831. // })
  832. // .catch(() => {});
  833. },
  834. moveClassStudentPromise(item, cid) {
  835. return new Promise((resolve, reject) => {
  836. let params = [
  837. {
  838. userid: item.userid,
  839. username: item.acc,
  840. alias: item.username,
  841. ph: item.phonenumber,
  842. sid: item.studentid,
  843. cid: cid,
  844. },
  845. ];
  846. console.log(params);
  847. this.ajax
  848. .post(this.$store.state.api + "updateStudentInfo", params)
  849. .then((res) => {
  850. resolve(res);
  851. })
  852. .catch((err) => {
  853. console.error(err);
  854. reject(err);
  855. });
  856. });
  857. },
  858. // 批量移除班级学生
  859. removeSelStu() {
  860. this.deltypy = 4;
  861. this.popBoxdia = true;
  862. },
  863. confirmRemove(){
  864. const promises = this.selectedData.map((item) => {
  865. return this.deleteClassStudent(item.userid);
  866. });
  867. Promise.all(promises)
  868. .then(() => {
  869. this.$message({
  870. message: "移除成功",
  871. type: "success",
  872. });
  873. this.popBoxdia = false;
  874. this.refresh();
  875. this.$emit("getGrade");
  876. })
  877. .catch((err) => {
  878. console.error(err);
  879. this.$message({
  880. message: "移除失败",
  881. type: "error",
  882. });
  883. this.refresh();
  884. });
  885. },
  886. // 移除班级学生Promise
  887. deleteClassStudent(id) {
  888. return new Promise((resolve, reject) => {
  889. let params = [{ uid: id, cid: this.activeId }];
  890. this.ajax
  891. .post(this.$store.state.api + "deleteClassStudent", params)
  892. .then((res) => {
  893. console.log("res", res);
  894. resolve(res);
  895. })
  896. .catch((err) => {
  897. console.error(err);
  898. resolve(err);
  899. });
  900. });
  901. },
  902. // 批量重置密码
  903. resetPassword() {
  904. this.deltypy = 5;
  905. this.popBoxdia = true;
  906. // return this.msgbox();
  907. // this.$confirm(
  908. // `确定要重置 ${this.selectedData.length} 个学生的密码吗?`,
  909. // "提示",
  910. // {
  911. // confirmButtonText: "确定",
  912. // cancelButtonText: "取消",
  913. // type: "warning",
  914. // }
  915. // )
  916. // .then(() => {
  917. // })
  918. // .catch(() => {});
  919. },
  920. confirmrestpsd(){
  921. const promises = this.selectedData.map((item) => {
  922. return this.doResetPassword(item.userid);
  923. });
  924. Promise.all(promises)
  925. .then(() => {
  926. this.popBoxdia = false;
  927. this.deltypy = 7;
  928. this.popBoxdia = true;
  929. })
  930. .catch((err) => {
  931. console.error(err);
  932. this.$message({
  933. message: "部分密码重置失败,请重试",
  934. type: "error",
  935. });
  936. });
  937. },
  938. // 执行重置密码操作(返回Promise)
  939. doResetPassword(id) {
  940. return new Promise((resolve, reject) => {
  941. let params = [
  942. {
  943. uid: id,
  944. pa: "Coco1234",
  945. },
  946. ];
  947. this.ajax
  948. .post(this.$store.state.api + "iniPassword", params)
  949. .then((res) => {
  950. resolve(res);
  951. })
  952. .catch((err) => {
  953. console.error(err);
  954. reject(err);
  955. });
  956. });
  957. },
  958. inPassword() {
  959. this.deltypy = 6;
  960. this.popBoxdia = true;
  961. // this.$confirm(
  962. // `确定要重置 ${this.stuEditInfo.username} 的密码吗?`,
  963. // "提示",
  964. // {
  965. // confirmButtonText: "确定",
  966. // cancelButtonText: "取消",
  967. // type: "warning",
  968. // }
  969. // )
  970. // .then(() => {
  971. // })
  972. // .catch(() => {});
  973. },
  974. confirminPassword(){
  975. let params = [
  976. {
  977. uid: this.stuEditInfo.userid,
  978. pa: "Coco1234",
  979. },
  980. ];
  981. this.ajax
  982. .post(this.$store.state.api + "iniPassword", params)
  983. .then((res) => {
  984. // this.$message({
  985. // message: "密码重置成功",
  986. // type: "success",
  987. // });
  988. this.popBoxdia = false;
  989. this.deltypy = 8
  990. this.popBoxdia = true;
  991. // this.$refs.msgboxref.dialogVisible = true;
  992. })
  993. .catch((err) => {
  994. this.popBoxdia = false;
  995. this.$message({
  996. message: "密码重置失败",
  997. type: "error",
  998. });
  999. });
  1000. },
  1001. // 打开批量删除弹框
  1002. deleteSelectionStudent() {
  1003. this.deltypy = 2
  1004. this.popBoxdia = true
  1005. },
  1006. // 打开单删删除学生弹框
  1007. deleteStudentL(row) {
  1008. this.deltypy = 1;
  1009. this.delStuinfo = row;
  1010. this.popBoxdia = true;
  1011. },
  1012. // 判断使用单删onedelstu ,twodelstu批量删除
  1013. confirmDelStu(){
  1014. if (this.deltypy == 1) {
  1015. this.onedelstu()
  1016. }else if (this.deltypy == 2) {
  1017. this.twodelstu()
  1018. }else if (this.deltypy == 3) {
  1019. this.confirmdeleteCla()
  1020. }else if(this.deltypy == 4){
  1021. this.confirmRemove()
  1022. }else if(this.deltypy == 5){
  1023. this.confirmrestpsd()
  1024. }else if(this.deltypy == 6){
  1025. this.confirminPassword()
  1026. }else if(this.deltypy == 7){
  1027. this.cancelAllSelection();
  1028. this.popBoxdia = false;
  1029. }else if(this.deltypy == 8){
  1030. this.popBoxdia = false;
  1031. }else if(this.deltypy == 9){
  1032. this.confirmMoveClaEditStu();
  1033. }else if(this.deltypy == 10){
  1034. this.update_Student(this.EditStubox);
  1035. }
  1036. },
  1037. onedelstu(){
  1038. let params = [{ uid: this.delStuinfo.userid, state: 0 }];
  1039. this.ajax
  1040. .post(this.$store.state.api + "deleteStudent", params)
  1041. .then(() => {
  1042. // this.getAllStudent();
  1043. this.delStuinfo = {};
  1044. this.popBoxdia = false;
  1045. this.$emit("getGrade");
  1046. this.refresh()
  1047. this.$message({
  1048. message: "删除成功",
  1049. type: "success",
  1050. });
  1051. })
  1052. .catch((err) => {
  1053. console.error(err);
  1054. this.popBoxdia = false;
  1055. this.$message({
  1056. message: "删除失败",
  1057. type: "error",
  1058. });
  1059. });
  1060. },
  1061. twodelstu(){
  1062. const promises = this.selectedData.map((item) => {
  1063. return this.deleteStudentPromise(item.userid, item.state);
  1064. });
  1065. Promise.all(promises)
  1066. .then(() => {
  1067. this.refresh();
  1068. this.popBoxdia = false;
  1069. this.cancelAllSelection();
  1070. this.$emit("getGrade");
  1071. this.$message({
  1072. message: "删除成功",
  1073. type: "error",
  1074. });
  1075. })
  1076. .catch((err) => {
  1077. console.error(err);
  1078. this.$message({
  1079. message: "部分删除失败,请重试",
  1080. type: "error",
  1081. });
  1082. });
  1083. },
  1084. // 删除学生Promise
  1085. deleteStudentPromise(id, state) {
  1086. return new Promise((resolve, reject) => {
  1087. state = 0;
  1088. let params = [{ uid: id, state: state }];
  1089. this.ajax
  1090. .post(this.$store.state.api + "deleteStudent", params)
  1091. .then((res) => {
  1092. resolve(res);
  1093. })
  1094. .catch((err) => {
  1095. console.error(err);
  1096. reject(err);
  1097. });
  1098. });
  1099. },
  1100. // 取消删除
  1101. closeDia(){
  1102. this.delStuinfo = {};
  1103. this.popBoxdia = false;
  1104. },
  1105. // 移动班级学生级联选中数据路径改变
  1106. handlemoveChangecascader(val) {
  1107. console.log(val);
  1108. },
  1109. // 公共方法区域
  1110. // 更新年级列表 (添加,删除学生,编辑兴趣班后需要)
  1111. getCascaderData() {
  1112. this.$emit("getGrade");
  1113. this.refresh();
  1114. },
  1115. // 添加学生
  1116. addStudent() {
  1117. this.$refs.addStu.stardop()
  1118. this.$refs.addStu.classInfo = this.activeinfo;
  1119. },
  1120. // 兴趣班方法区域
  1121. // 兴趣班排序
  1122. intSort(val){
  1123. this.insort = val;
  1124. if (this.boxType == 1) {
  1125. this.getInterestClass()
  1126. }else if (this.boxType == 2) {
  1127. this.getAllStudent()
  1128. }
  1129. },
  1130. // 编辑兴趣班
  1131. editInterestCla(row) {
  1132. if (row.createuserid != this.userid) {
  1133. return this.$message.error('仅限创建者编辑')
  1134. }
  1135. this.$refs.editInterstcla.InterestClaEditvisible = true;
  1136. this.InterestClaEditInfo = JSON.parse(JSON.stringify(row));
  1137. // this.$refs.editInterstcla.getdata();
  1138. },
  1139. // 查看兴趣班学生
  1140. viewStudent(row, column, event) {
  1141. // console.log('111');
  1142. console.log(row, column, event);
  1143. // if (row.createuserid != this.userid) return
  1144. if (this.boxType == 1 && this.interestType == 0) {
  1145. this.interestType = 1;
  1146. this.tableColumns = this.studentColumns;
  1147. this.activeId = row.id;
  1148. this.refresh();
  1149. this.activeinfo = row;
  1150. }
  1151. },
  1152. // 新增班级
  1153. addInterestClaConfirm() {
  1154. if (!this.interestName) {
  1155. this.$message({
  1156. message: "请输入兴趣班名称",
  1157. type: "error",
  1158. });
  1159. return;
  1160. }
  1161. //新增班级
  1162. let params = [
  1163. {
  1164. claName: this.interestName,
  1165. gid: "",
  1166. oid: this.oid,
  1167. uid: this.userid,
  1168. },
  1169. ];
  1170. console.log(params);
  1171. this.ajax
  1172. .post(this.$store.state.api + "addClassgra", params)
  1173. .then((res) => {
  1174. if (res.data[0] && res.data[0][0].classname == 1) {
  1175. this.$message({
  1176. message: this.lang.Cannotsameothercla,
  1177. type: "error",
  1178. });
  1179. } else {
  1180. this.$message({
  1181. message: this.lang.AddSuccessful,
  1182. type: "success",
  1183. });
  1184. this.addInterestClaVisible = false;
  1185. this.interestName = "";
  1186. this.refresh();
  1187. this.$emit("getGrade");
  1188. }
  1189. })
  1190. .catch((err) => {
  1191. this.$message({
  1192. message: this.lang.Additionfailed,
  1193. type: "error",
  1194. });
  1195. console.error(err);
  1196. });
  1197. },
  1198. // 添加兴趣班
  1199. addInterestCla(row) {
  1200. this.addInterestClaVisible = true;
  1201. this.InterestClaAddInfo = row;
  1202. },
  1203. // 移除单个学生
  1204. deleteClassStudent(id) {
  1205. let params = [{ uid: id, cid: this.activeId }];
  1206. this.ajax
  1207. .post(this.$store.state.api + "deleteClassStudent", params)
  1208. .then((res) => {
  1209. console.log("res", res);
  1210. this.refresh()
  1211. })
  1212. .catch((err) => {
  1213. console.error(err);
  1214. });
  1215. },
  1216. // 修改学生信息
  1217. confirmEditStu() {
  1218. // console.log(this.cascaderDataPath);
  1219. if (this.stuEditInfo.username === "") {
  1220. this.$message({
  1221. message: "请输入姓名",
  1222. type: "error",
  1223. });
  1224. return;
  1225. }
  1226. if (this.cascaderDataPath.length === 0) {
  1227. this.$message({
  1228. message: "请选择班级",
  1229. type: "error",
  1230. });
  1231. return;
  1232. }
  1233. this.EditStubox = this.cascaderDataPath.map((item) => item[1]).join(",");
  1234. // console.log(box);
  1235. // console.log("this.stuEditInfo", this.stuEditInfo);
  1236. this.deltypy = 10;
  1237. this.popBoxdia = true;
  1238. // this.$confirm(
  1239. // `确定要修改 ${this.stuEditInfo.username} 的学生信息吗?`,
  1240. // "提示",
  1241. // {
  1242. // confirmButtonText: "确定",
  1243. // cancelButtonText: "取消",
  1244. // type: "warning",
  1245. // }
  1246. // )
  1247. // .then(() => {
  1248. // this.update_Student(box);
  1249. // })
  1250. // .catch(() => {
  1251. // return;
  1252. // });
  1253. },
  1254. // 修改学生信息
  1255. update_Student(cid) {
  1256. let params = [
  1257. {
  1258. userid: this.stuEditInfo.userid,
  1259. username: this.stuEditInfo.acc,
  1260. alias: this.stuEditInfo.username,
  1261. ph: this.stuEditInfo.phonenumber,
  1262. sid: this.stuEditInfo.studentid,
  1263. cid: cid,
  1264. },
  1265. ];
  1266. // return console.log(params);
  1267. this.ajax
  1268. .post(this.$store.state.api + "updateStudentInfo", params)
  1269. .then((res) => {
  1270. this.$message({
  1271. message: this.lang.Editsuccessful,
  1272. type: "success",
  1273. });
  1274. this.stuEditvisible = false;
  1275. this.refresh();
  1276. this.popBoxdia = false;
  1277. this.EditStubox = '';
  1278. this.stuEditInfo = {};
  1279. this.cascaderDataPath = [];
  1280. })
  1281. .catch((err) => {
  1282. this.isLoading = false;
  1283. this.$message({
  1284. message: this.lang.Modificationfailed,
  1285. type: "error",
  1286. });
  1287. console.error(err);
  1288. });
  1289. },
  1290. // 编辑学生
  1291. editStudent(row) {
  1292. this.stuEditvisible = true;
  1293. this.stuEditInfo = { ...row };
  1294. // 根据 classid 找到对应的路径数组(多选模式需要二维数组)
  1295. this.cascaderDataPath = row.classid
  1296. ? this.findCascaderPath(row.classid, this.cascaderData)
  1297. : [];
  1298. },
  1299. handleChangecascader(val) {
  1300. console.log(val);
  1301. // 更新级联选择器的选中数据路径
  1302. this.cascaderDataPath = val || [];
  1303. },
  1304. findCascaderPath(classid, cascaderData) {
  1305. if (!classid || !cascaderData || cascaderData.length === 0) {
  1306. return [];
  1307. }
  1308. // 解析逗号分隔的 classid 字符串(班级字符串数组)
  1309. const classIds = classid
  1310. .split(",")
  1311. .map((id) => id.trim())
  1312. .filter((id) => id);
  1313. console.log('classIds',classIds);
  1314. let result = [];
  1315. let box = cascaderData.flatMap((item) => item.children).filter((item) => classIds.includes(item.id));
  1316. console.log(box, "box");
  1317. result = box.map((item) => {
  1318. return [!item.pid ? 0 : item.pid, item.id];
  1319. });
  1320. return result;
  1321. },
  1322. // 刷新
  1323. refresh() {
  1324. this.page = 1;
  1325. this.pageSize = 10;
  1326. this.total = 0;
  1327. this.tableData = [];
  1328. if (this.boxType == 0) {
  1329. // 清除选中数据
  1330. if (this.selectedData.length > 0) {
  1331. this.cancelAllSelection();
  1332. }
  1333. this.getStudent();
  1334. } else if (this.boxType == 1) {
  1335. if (this.interestType == 0) {
  1336. this.getInterestClass();
  1337. } else if (this.interestType == 1) {
  1338. this.getStudent();
  1339. }
  1340. } else if (this.boxType == 2) {
  1341. this.getAllStudent();
  1342. }
  1343. },
  1344. // 全选
  1345. handleSelectionChange(val) {
  1346. this.selectedData = val;
  1347. // 同步全选复选框状态:当选中数量等于表格数据数量时,全选复选框应该被选中
  1348. this.checkedAllSelection =
  1349. val.length > 0 && val.length === this.tableData.length;
  1350. },
  1351. // 清除多选table数据
  1352. cancelAllSelection() {
  1353. this.$refs.tableData.clearSelection();
  1354. this.selectedData = [];
  1355. this.checkedAllSelection = false;
  1356. },
  1357. closeEditStu() {
  1358. this.stuEditvisible = false;
  1359. this.stuEditInfo = {};
  1360. },
  1361. handlePageChange(val) {
  1362. console.log(`当前页: ${val}`);
  1363. this.page = val;
  1364. if (this.boxType == 0) {
  1365. this.getStudent();
  1366. } else if (this.boxType == 1) {
  1367. this.getInterestClass();
  1368. } else if (this.boxType == 2) {
  1369. this.getAllStudent();
  1370. }
  1371. },
  1372. handleSizeChange(val) {
  1373. console.log(`每页条数: ${val}`);
  1374. this.pageSize = val;
  1375. this.page = 1;
  1376. if (this.boxType == 0) {
  1377. this.getStudent();
  1378. } else if (this.boxType == 1) {
  1379. this.getInterestClass();
  1380. } else if (this.boxType == 2) {
  1381. this.getAllStudent();
  1382. }
  1383. },
  1384. getStudent() {
  1385. this.isLoading = true;
  1386. this.tableColumns = [];
  1387. this.tableColumns = this.studentColumns;
  1388. let params = {
  1389. oid: this.oid,
  1390. claid: this.activeId,
  1391. inp: this.inp,
  1392. };
  1393. this.ajax
  1394. .get(this.$store.state.api + "selectclaStu", params)
  1395. .then((res) => {
  1396. this.isLoading = false;
  1397. let box1 = res.data[0];
  1398. box1.forEach((e) => {
  1399. let kk = [];
  1400. this.cascaderData.forEach(item => {
  1401. item.children.forEach(item2 => {
  1402. if (e.classid && e.classid.indexOf(item2.id) != -1) {
  1403. kk.push(item.name + item2.name);
  1404. }else{
  1405. }
  1406. });
  1407. });
  1408. e.classname = kk.join("/");
  1409. });
  1410. this.tableData = res.data[0];
  1411. console.log(JSON.parse(JSON.stringify(this.tableData)),'this.tableData');
  1412. })
  1413. .catch((err) => {
  1414. this.isLoading = false;
  1415. console.error(err);
  1416. });
  1417. },
  1418. // 获取兴趣班
  1419. getInterestClass() {
  1420. this.isLoading = true;
  1421. this.tableColumns = this.tableInterestClaColumns;
  1422. let params = {
  1423. oid: this.oid,
  1424. inp: this.inp,
  1425. srt: this.insort,
  1426. page: this.page,
  1427. pageSize: this.pageSize,
  1428. };
  1429. console.log('params',params);
  1430. this.ajax
  1431. .get(this.$store.state.api + "selectInterestcla", params)
  1432. .then((res) => {
  1433. this.isLoading = false;
  1434. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  1435. this.tableData = res.data[0];
  1436. })
  1437. .catch((err) => {
  1438. this.isLoading = false;
  1439. console.error(err);
  1440. });
  1441. },
  1442. // 学生管理全部学生
  1443. getAllStudent() {
  1444. this.isLoading = true;
  1445. this.cancelAllSelection();
  1446. this.tableColumns = this.studentColumns;
  1447. let params = {
  1448. oid: this.oid,
  1449. cid: "",
  1450. inp: this.inp,
  1451. srt:this.insort,
  1452. page: this.page,
  1453. num: this.pageSize,
  1454. };
  1455. this.ajax
  1456. .get(this.$store.state.api + "selectStudentManagesrt", params)
  1457. .then((res) => {
  1458. this.isLoading = false;
  1459. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  1460. let box1 = res.data[0];
  1461. box1.forEach((e) => {
  1462. let kk = [];
  1463. this.cascaderData.forEach(item => {
  1464. item.children.forEach(item2 => {
  1465. if (e.classid && e.classid.indexOf(item2.id) != -1) {
  1466. kk.push(item.name + item2.name);
  1467. }else{
  1468. }
  1469. });
  1470. });
  1471. e.classname = kk.join("/");
  1472. });
  1473. this.tableData = res.data[0];
  1474. })
  1475. .catch((err) => {
  1476. this.isLoading = false;
  1477. console.error(err);
  1478. });
  1479. },
  1480. time() {
  1481. if (!this.now) {
  1482. this.now = new Date().getTime();
  1483. return true;
  1484. } else {
  1485. let time = new Date().getTime();
  1486. if (time - this.now > 3000) {
  1487. this.now = time;
  1488. return true;
  1489. } else {
  1490. return false;
  1491. }
  1492. }
  1493. },
  1494. // 修改班级名称
  1495. confirmClaEdit() {
  1496. if (this.ClaEditInfo.name == '' || this.ClaEditInfo.name == this.activeinfo.name) {
  1497. this.ClaEditvisible = false
  1498. return
  1499. }
  1500. let params = {
  1501. id: this.ClaEditInfo.id,
  1502. n: this.ClaEditInfo.name,
  1503. oid: this.oid,
  1504. };
  1505. this.ajax
  1506. .get(this.$store.state.api + "updateClass", params)
  1507. .then((res) => {
  1508. if (res.data[0] && res.data[0][0].classname == 1) {
  1509. this.$message({
  1510. message: this.lang.Cannotsameothercla,
  1511. type: "error",
  1512. });
  1513. } else {
  1514. this.$message({
  1515. message: this.lang.Editsuccessful,
  1516. type: "success",
  1517. });
  1518. this.$emit("getGrade");
  1519. this.ClaEditvisible = false;
  1520. this.ClaEditInfo = {};
  1521. }
  1522. })
  1523. .catch((err) => {
  1524. this.$message({
  1525. message: this.lang.Modificationfailed,
  1526. type: "error",
  1527. });
  1528. console.error(err);
  1529. });
  1530. }
  1531. },
  1532. };
  1533. </script>
  1534. <style>
  1535. /* 学生管理表格操作弹窗样式 - 全局样式(Element UI popover 挂载到 body,需要全局样式) */
  1536. .student-manage-action-popover {
  1537. width: 70px !important;
  1538. min-width: 60px !important;
  1539. padding: 0 !important;
  1540. }
  1541. .student-manage-action-popover .action_box > div {
  1542. padding: 8px 15px;
  1543. cursor: pointer;
  1544. font-size: 14px;
  1545. text-align: center;
  1546. }
  1547. .student-manage-action-popover .action_box > div:hover {
  1548. background: #e8f3ff;
  1549. color: #0052d9;
  1550. }
  1551. .topbox_area_popover{
  1552. width: 152px !important;
  1553. min-width: 60px !important;
  1554. padding: 0 !important;
  1555. }
  1556. /* 学生管理重置密码消息框样式 - 全局样式(Element UI msgbox 挂载到 body,需要全局样式) */
  1557. .student-manage-reset-password-msgbox .el-message-box__status {
  1558. top: 0 !important;
  1559. transform: none !important;
  1560. align-self: flex-start !important;
  1561. }
  1562. .student-manage-reset-password-msgbox .el-message-box__message {
  1563. padding-left: 0 !important;
  1564. display: flex !important;
  1565. align-items: flex-start !important;
  1566. }
  1567. .student-manage-reset-password-msgbox .el-message-box__message > p {
  1568. margin-top: 0 !important;
  1569. }
  1570. .student-manage-reset-password-msgbox .el-message-box__btns {
  1571. text-align: right !important;
  1572. }
  1573. .student-manage-reset-password-msgbox
  1574. .el-message-box__btns
  1575. .el-button--primary {
  1576. background-color: #409eff !important;
  1577. border-color: #409eff !important;
  1578. color: #fff !important;
  1579. }
  1580. .student-manage-reset-password-msgbox
  1581. .el-message-box__btns
  1582. .el-button--primary:hover {
  1583. background-color: #66b1ff !important;
  1584. border-color: #66b1ff !important;
  1585. }
  1586. /* 学生管理删除确认对话框样式 - 按钮右对齐 */
  1587. .student-manage-delete-msgbox .el-message-box__btns {
  1588. text-align: right !important;
  1589. }
  1590. .myCascader
  1591. .el-cascader-panel
  1592. .el-cascader-menu:first-child
  1593. .el-scrollbar__wrap
  1594. ul
  1595. li
  1596. label,
  1597. .myCascader
  1598. .el-cascader-panel
  1599. .el-cascader-menu:first-child
  1600. .el-scrollbar__wrap
  1601. ul
  1602. li
  1603. .el-checkbox {
  1604. display: none !important;
  1605. }
  1606. .myCascader2 .el-cascader{
  1607. /* width: 100% !important; */
  1608. display: block !important;
  1609. }
  1610. .myCascader2 .el-cascader-panel{
  1611. width: 400px !important;
  1612. }
  1613. .myCascader2 .el-cascader-menu__list{
  1614. width: 200px;
  1615. }
  1616. </style>
  1617. <style scoped>
  1618. .sortImg{
  1619. width: 30px;
  1620. background: #F4F4F4;
  1621. padding: 5px;
  1622. box-sizing: border-box;
  1623. border-radius: 8px;
  1624. cursor: pointer;
  1625. }
  1626. .tabbox {
  1627. width: 100%;
  1628. height: 100%;
  1629. display: flex;
  1630. flex-direction: column;
  1631. }
  1632. .topbox {
  1633. background: #fff;
  1634. height: 60px;
  1635. width: 100%;
  1636. background: #ffffff;
  1637. border-radius: 8px 8px 8px 8px;
  1638. padding: 5px 10px;
  1639. box-sizing: border-box;
  1640. display: flex;
  1641. align-items: center;
  1642. justify-content: space-between;
  1643. }
  1644. .topbox_area {
  1645. display: flex;
  1646. align-items: center;
  1647. gap: 10px;
  1648. }
  1649. .topbox_areaCon{
  1650. width: 100%;padding: 8px;
  1651. box-sizing: border-box;display: flex;
  1652. flex-direction: column;gap: 5px;
  1653. align-content: center;
  1654. }
  1655. .topbox_areaCon div{
  1656. padding: 5px 10px;
  1657. box-sizing: border-box;
  1658. text-align: center;
  1659. border-radius: 2px;
  1660. }
  1661. .topbox_areaConBck{
  1662. background: #E8F3FF;
  1663. color: #498DFC;
  1664. }
  1665. .xk_img {
  1666. width: 20px;
  1667. height: 20px;
  1668. padding: 3px;
  1669. cursor: pointer;
  1670. }
  1671. .xk_img2:hover{
  1672. background: #FFDFD5;
  1673. border-radius: 4px;
  1674. }
  1675. .topbox_area >>> .el-input {
  1676. width: 150px;
  1677. }
  1678. .topbox_area >>> .el-input__inner {
  1679. height: 30px;
  1680. line-height: 30px;
  1681. width: 150px;
  1682. }
  1683. .topbox_area >>> .el-input__icon {
  1684. line-height: 30px;
  1685. }
  1686. .tabList {
  1687. flex: 1;
  1688. overflow: auto;
  1689. border-radius: 0 0 8px 8px;
  1690. display: grid;
  1691. flex-direction: column;
  1692. background: #fff;
  1693. }
  1694. .tableList >>> .has-gutter .gutter {
  1695. background: #e7eaf0 !important;
  1696. }
  1697. .tableList >>> .el-table__header-wrapper .el-checkbox {
  1698. display: none;
  1699. }
  1700. .cla_box {
  1701. display: flex;
  1702. flex-wrap: wrap;
  1703. align-items: center;
  1704. gap: 10px;
  1705. height: 30px;
  1706. line-height: 30px;
  1707. }
  1708. .cla_span {
  1709. background: #e8f3ff;
  1710. color: #0052d9;
  1711. padding: 0px 25px;
  1712. border-radius: 5px;
  1713. box-sizing: border-box;
  1714. }
  1715. .cla_span:nth-child(1) {
  1716. background: #e8f3ff;
  1717. color: #0052d9;
  1718. }
  1719. .cla_span:nth-child(2) {
  1720. background: #fff1d5;
  1721. color: #df8a00;
  1722. }
  1723. .action_btn {
  1724. display: flex;
  1725. align-items: center;
  1726. justify-content: center;
  1727. gap: 5px;
  1728. cursor: pointer;
  1729. background: #f6f6f6;
  1730. padding: 7px 15px;
  1731. box-sizing: border-box;
  1732. font-size: 14px;
  1733. border-radius: 5px;
  1734. }
  1735. .action_btn2 {
  1736. background: #0052d9;
  1737. color: #fff;
  1738. }
  1739. .page_box {
  1740. display: flex;
  1741. justify-content: flex-end;
  1742. align-items: center;
  1743. padding: 10px;
  1744. box-sizing: border-box;
  1745. }
  1746. .page_box_area {
  1747. display: flex;
  1748. align-items: center;
  1749. justify-content: space-between;
  1750. width: 100%;
  1751. /* padding: 0 10px; */
  1752. box-sizing: border-box;
  1753. }
  1754. .dia_box_item {
  1755. display: flex;
  1756. flex-direction: column;
  1757. gap: 15px;
  1758. height: 400px;
  1759. padding-left: 4px;
  1760. padding-right: 12px;
  1761. box-sizing: border-box;
  1762. }
  1763. .dia_box_item2{
  1764. display: flex;
  1765. flex-direction: column;
  1766. gap: 15px;
  1767. /* height: 400px; */
  1768. padding-left: 4px;
  1769. padding-right: 12px;
  1770. box-sizing: border-box;
  1771. }
  1772. .addcla_box_item {
  1773. min-height: 35px;
  1774. /* line-height: 30px; */
  1775. display: flex;
  1776. align-items: center;
  1777. gap: 10px;
  1778. }
  1779. .addcla_box_item >>> .el-cascader {
  1780. width: 100%;
  1781. }
  1782. .addcla_box_item >>> .el-select {
  1783. width: 100%;
  1784. }
  1785. .addcla_box_item >>> .el-input__inner {
  1786. width: 100%;
  1787. }
  1788. .addcla_box_item >>> .el-input__icon {
  1789. width: 100%;
  1790. }
  1791. .addcla_box_item span {
  1792. /* width: 80px; */
  1793. flex-shrink: 0;
  1794. text-align: right;
  1795. }
  1796. .tabbox >>> .el-dialog {
  1797. border-radius: 10px !important;
  1798. }
  1799. .dia_title_box {
  1800. display: flex;
  1801. align-items: center;
  1802. gap: 10px;
  1803. padding-left: 4px;
  1804. align-items: baseline;
  1805. box-sizing: border-box;
  1806. }
  1807. .dia_title_box span:nth-child(1) {
  1808. font-size: 16px;
  1809. }
  1810. .dia_title_box span:nth-child(2) {
  1811. font-size: 12px;
  1812. color: #689ce9;
  1813. cursor: pointer;
  1814. border-bottom: 1px solid #689ce9;
  1815. }
  1816. .cascader-class-item {
  1817. display: flex;
  1818. align-items: center;
  1819. gap: 5px;
  1820. }
  1821. .class-student-count {
  1822. color: #86909c;
  1823. font-size: 12px;
  1824. }
  1825. /* 隐藏一级选项(年级)的多选按钮 */
  1826. .addcla_box_item
  1827. >>> .el-cascader-panel
  1828. .el-cascader-menu
  1829. .el-cascader-menu__wrap
  1830. .el-checkbox {
  1831. display: none !important;
  1832. }
  1833. .addcla_box_item >>> .el-cascader-menu:first-child .el-cascader-menu__item {
  1834. padding-left: 20px !important;
  1835. }
  1836. .selected_stu_box {
  1837. display: flex;
  1838. align-items: center;
  1839. gap: 10px;
  1840. }
  1841. .selected_stu_box_item {
  1842. background: #e8f3ff;
  1843. padding: 5px 10px;
  1844. }
  1845. .tabbox >>> .el-table--enable-row-transition .el-table__body td{
  1846. padding: 12px 30px;
  1847. }
  1848. .tabbox >>> .el-table th{
  1849. /* padding: 12px 20px; */
  1850. padding-left: 30px;
  1851. box-sizing: border-box;
  1852. }
  1853. .claInp{
  1854. border: none;
  1855. outline: none;
  1856. height: 30px;
  1857. line-height: 30px;
  1858. width: 130px;
  1859. font-size: 16px;
  1860. }
  1861. .bacl{
  1862. background: #E8F3FF;
  1863. border-radius: 4px;
  1864. }
  1865. .pop-upBox >>> .el-dialog{
  1866. border-radius: 8px !important;
  1867. margin-top: 30vh !important;
  1868. }
  1869. .pop-upBox >>> .el-dialog__body{
  1870. padding: 12px 23px;
  1871. }
  1872. .msgCon{
  1873. display: flex;
  1874. gap: 10px;
  1875. align-items: flex-start;
  1876. box-sizing: border-box;
  1877. }
  1878. .msgContxt{
  1879. display: flex;
  1880. flex-direction: column;
  1881. gap: 10px;
  1882. font-size: 16px;
  1883. color: #000000;
  1884. }
  1885. .copyMg{
  1886. width: 22px;
  1887. cursor: pointer;
  1888. padding: 2px;
  1889. }
  1890. .copyMg:hover{
  1891. background: #E8F3FF;
  1892. border-radius: 2px;
  1893. }
  1894. .dialog-footer div{
  1895. /* width: 100px; */
  1896. text-align: center;
  1897. padding: 8px 14px;
  1898. cursor: pointer;
  1899. border-radius: 5px;
  1900. box-sizing: border-box;
  1901. font-size: 14px;
  1902. }
  1903. .kbtn{
  1904. text-align: center;
  1905. padding: 8px 14px;
  1906. cursor: pointer;
  1907. border-radius: 3px;
  1908. box-sizing: border-box;
  1909. font-size: 14px;
  1910. }
  1911. .dialog-footer {
  1912. display: flex;
  1913. justify-content: flex-end;
  1914. gap: 10px;
  1915. }
  1916. </style>