group.vue 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. <template>
  2. <div>
  3. <el-dialog title="分组设置" :visible.sync="dialogVisibleGroup" :append-to-body="true" width="95%"
  4. :before-close="handleClose2" class="dialog_diy">
  5. <div v-if="dialogVisibleGroup">
  6. <div class="g_d_btnBox">
  7. <div class="btn_left" v-if="type == 1 || type == 4">
  8. <div @click="setClassid('1')" :class="{ active: classid == '1' }" v-if="!classList.length">全部</div>
  9. <div @click="setClassid(item.id)" :class="{ active: classid == item.id }"
  10. v-for="(item, index) in classList" :key="index">{{ item.name }}</div>
  11. </div>
  12. <div class="btn_left" v-if="type == 2">
  13. <div @click="setClassid('1')" :class="{ active: classid == '1' }" v-if="!classList.length">全部</div>
  14. <div @click="setClassid(item.id)" :class="{ active: classid == item.id }"
  15. v-for="(item, index) in classList" :key="index">{{ item.name }}</div>
  16. </div>
  17. <div class="btn_right"
  18. v-if="courseDetail.userid == userid || (courseDetail.course_teacher && courseDetail.course_teacher.indexOf(userid) != -1)">
  19. <div style="color: rgb(171 171 171); margin: 0 10px 0 0">
  20. 提示:开启【开放选座】,学生能够自由加入和退出小组。
  21. </div>
  22. <!-- 开放选座 -->
  23. <!-- <div type="primary" v-if="groupJson.islock == 1 && groupJson.group.length" class="returnBtn"
  24. style="background-color: #225bc7" @click="lockChair">
  25. 锁定位置
  26. </div>
  27. <div type="primary" v-else-if="groupJson.group.length" class="returnBtn"
  28. style="background-color: #225bc7" @click="lockChair">
  29. 解锁位置
  30. </div> -->
  31. <div class="group_switch">
  32. <span>开放选座</span>
  33. <el-switch v-model="islock" active-text="" class="switchCss" @change="lockChair"></el-switch>
  34. </div>
  35. <div class="group_switch">
  36. <span>开启分组</span>
  37. <el-switch v-model="isopen" class="switchCss" @change="openChair"></el-switch>
  38. </div>
  39. <div type="primary" @click="updateGroup" class="returnBtn" style="background-color: #225bc7">
  40. 分组设置
  41. </div>
  42. <div type="primary" @click="deleteCourseGroup" class="returnBtn" style="background-color: #225bc7">
  43. 删除分组
  44. </div>
  45. </div>
  46. </div>
  47. <div>
  48. <div class="g_d_box" v-if="groupJson.group.length && isopen">
  49. <div class="g_d_group" v-for="(g, gindex) in groupJson.group" :key="gindex">
  50. <div class="g_d_group_chair">
  51. <div v-if="groupJson.number > 1">
  52. <span :class="{
  53. isChair:
  54. groupStudent[g.id] &&
  55. groupStudent[g.id][0],
  56. updateChair:
  57. courseDetail.userid == userid &&
  58. groupStudent[g.id] &&
  59. groupStudent[g.id][0] &&
  60. groupJson.islock == 2,
  61. }"><span class="updateChairBtn"
  62. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][0])">修改</span></span><span>{{
  63. groupStudent[g.id] &&
  64. groupStudent[g.id][0]
  65. ? groupStudent[g.id] &&
  66. groupStudent[g.id][0].name
  67. : "空位置" }}</span>
  68. </div>
  69. <div v-if="groupJson.number > 4">
  70. <span :class="{
  71. isChair:
  72. groupStudent[g.id] &&
  73. groupStudent[g.id][4],
  74. updateChair:
  75. courseDetail.userid == userid &&
  76. groupStudent[g.id] &&
  77. groupStudent[g.id][4] &&
  78. groupJson.islock == 2,
  79. }"><span class="updateChairBtn"
  80. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][4])">修改</span></span><span>{{
  81. groupStudent[g.id] &&
  82. groupStudent[g.id][4]
  83. ? groupStudent[g.id] &&
  84. groupStudent[g.id][4].name
  85. : "空位置" }}</span>
  86. </div>
  87. <div v-if="groupJson.number > 8">
  88. <span :class="{
  89. isChair:
  90. groupStudent[g.id] &&
  91. groupStudent[g.id][8],
  92. updateChair:
  93. courseDetail.userid == userid &&
  94. groupStudent[g.id] &&
  95. groupStudent[g.id][8] &&
  96. groupJson.islock == 2,
  97. }"><span class="updateChairBtn"
  98. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][8])">修改</span></span><span>{{
  99. groupStudent[g.id] &&
  100. groupStudent[g.id][8]
  101. ? groupStudent[g.id] &&
  102. groupStudent[g.id][8].name
  103. : "空位置" }}</span>
  104. </div>
  105. </div>
  106. <div class="g_d_group_tableBox">
  107. <div class="g_d_group_chair2">
  108. <div v-if="groupJson.number > 2">
  109. <span :class="{
  110. isChair:
  111. groupStudent[g.id] &&
  112. groupStudent[g.id][2],
  113. updateChair:
  114. courseDetail.userid == userid &&
  115. groupStudent[g.id] &&
  116. groupStudent[g.id][2] &&
  117. groupJson.islock == 2,
  118. }"><span class="updateChairBtn"
  119. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][2])">修改</span></span><span>{{
  120. groupStudent[g.id] &&
  121. groupStudent[g.id][2]
  122. ? groupStudent[g.id] &&
  123. groupStudent[g.id][2].name
  124. : "空位置" }}</span>
  125. </div>
  126. <div v-if="groupJson.number > 6">
  127. <span :class="{
  128. isChair:
  129. groupStudent[g.id] &&
  130. groupStudent[g.id][6],
  131. updateChair:
  132. courseDetail.userid == userid &&
  133. groupStudent[g.id] &&
  134. groupStudent[g.id][6] &&
  135. groupJson.islock == 2,
  136. }"><span class="updateChairBtn"
  137. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][6])">修改</span></span><span>{{
  138. groupStudent[g.id] &&
  139. groupStudent[g.id][6]
  140. ? groupStudent[g.id] &&
  141. groupStudent[g.id][6].name
  142. : "空位置" }}</span>
  143. </div>
  144. </div>
  145. <div class="g_d_group_table">
  146. <div>
  147. {{ g.name }}
  148. </div>
  149. <div>
  150. <div v-if="courseDetail.userid == userid && groupJson.islock == 2"
  151. @click="deleteGroupChair(g.id, gindex)">
  152. 移除组员
  153. </div>
  154. <div @click="selectGroup(g.id)"
  155. v-else-if="groupStudentUid && groupStudentUid[g.id].indexOf(userid) == -1">
  156. 加入分组
  157. </div>
  158. <div @click="
  159. exitGroup(groupStudent[g.id] &&
  160. groupStudent[g.id][
  161. groupStudentUid[g.id].indexOf(userid)
  162. ].id)
  163. "
  164. v-else-if="groupStudentUid && groupStudentUid[g.id].indexOf(userid) != -1">
  165. 退出分组
  166. </div>
  167. <div style="margin-top:10px"
  168. v-if="(courseDetail.userid == userid || (courseDetail.course_teacher && courseDetail.course_teacher.indexOf(userid) != -1)) && groupStudent[g.id].length < groupJson.number"
  169. @click="addGroupStudent(g.id)">
  170. 添加组员
  171. </div>
  172. </div>
  173. </div>
  174. <div class="g_d_group_chair2">
  175. <div v-if="groupJson.number > 3">
  176. <span :class="{
  177. isChair:
  178. groupStudent[g.id] &&
  179. groupStudent[g.id][3],
  180. updateChair:
  181. courseDetail.userid == userid &&
  182. groupStudent[g.id] &&
  183. groupStudent[g.id][3] &&
  184. groupJson.islock == 2,
  185. }"><span class="updateChairBtn"
  186. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][3])">修改</span></span><span>{{
  187. groupStudent[g.id] &&
  188. groupStudent[g.id][3]
  189. ? groupStudent[g.id] &&
  190. groupStudent[g.id][3].name
  191. : "空位置" }}</span>
  192. </div>
  193. <div v-if="groupJson.number > 7">
  194. <span :class="{
  195. isChair:
  196. groupStudent[g.id] &&
  197. groupStudent[g.id][7],
  198. updateChair:
  199. courseDetail.userid == userid &&
  200. groupStudent[g.id] &&
  201. groupStudent[g.id][7] &&
  202. groupJson.islock == 2,
  203. }"><span class="updateChairBtn"
  204. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][7])">修改</span></span><span>{{
  205. groupStudent[g.id] &&
  206. groupStudent[g.id][7]
  207. ? groupStudent[g.id] &&
  208. groupStudent[g.id][7].name
  209. : "空位置" }}</span>
  210. </div>
  211. </div>
  212. </div>
  213. <div class="g_d_group_chair">
  214. <div v-if="groupJson.number > 1">
  215. <span :class="{
  216. isChair:
  217. groupStudent[g.id] &&
  218. groupStudent[g.id][1],
  219. updateChair:
  220. courseDetail.userid == userid &&
  221. groupStudent[g.id] &&
  222. groupStudent[g.id][1] &&
  223. groupJson.islock == 2,
  224. }"><span class="updateChairBtn"
  225. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][1])">修改</span></span><span>{{
  226. groupStudent[g.id] &&
  227. groupStudent[g.id][1]
  228. ? groupStudent[g.id] &&
  229. groupStudent[g.id][1].name
  230. : "空位置" }}</span>
  231. </div>
  232. <div v-if="groupJson.number > 5">
  233. <span :class="{
  234. isChair:
  235. groupStudent[g.id] &&
  236. groupStudent[g.id][5],
  237. updateChair:
  238. courseDetail.userid == userid &&
  239. groupStudent[g.id] &&
  240. groupStudent[g.id][5] &&
  241. groupJson.islock == 2,
  242. }"><span class="updateChairBtn"
  243. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][5])">修改</span></span><span>{{
  244. groupStudent[g.id] &&
  245. groupStudent[g.id][5]
  246. ? groupStudent[g.id] &&
  247. groupStudent[g.id][5].name
  248. : "空位置" }}</span>
  249. </div>
  250. <div v-if="groupJson.number > 9">
  251. <span :class="{
  252. isChair:
  253. groupStudent[g.id] &&
  254. groupStudent[g.id][9],
  255. updateChair:
  256. courseDetail.userid == userid &&
  257. groupStudent[g.id] &&
  258. groupStudent[g.id][9] &&
  259. groupJson.islock == 2,
  260. }"><span class="updateChairBtn"
  261. @click="updateGroupChair(groupStudent[g.id] && groupStudent[g.id][9])">修改</span></span><span>{{
  262. groupStudent[g.id] &&
  263. groupStudent[g.id][9]
  264. ? groupStudent[g.id] &&
  265. groupStudent[g.id][9].name
  266. : "空位置" }}</span>
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. <div v-else-if="!groupJson.group.length" style="text-align: center;">{{ courseDetail.userid == userid ? "暂无分组,请点击右上角设置分组" :
  272. "老师暂未添加分组" }}</div>
  273. <div v-else-if="!isopen" style="text-align: center;">{{ "已关闭分组" }}</div>
  274. </div>
  275. </div>
  276. <span slot="footer" class="dialog-footer">
  277. </span>
  278. </el-dialog>
  279. <el-dialog title="分组设置" :visible.sync="dialogVisibleGroup2" :append-to-body="true" width="650px"
  280. :before-close="handleClose" class="dialog_diy">
  281. <div class="groupBox">
  282. <div v-if="groupJson2.group" class="groupContent">
  283. <div class="groupTitle">请设置小组数量及名称</div>
  284. <div v-for="(item, index) in groupJson2.group" :key="index" class="groupName">
  285. <span class="groupn">第{{ index + 1 }}组名称:</span>
  286. <el-input v-model="item.name" placeholder="请输入名称..." style="width: 250px"></el-input>
  287. <div class="groupBtn">
  288. <el-button type="primary" size="small" @click="addGroup(index)" v-if="(groupJson2.group.length - 1) == index">
  289. 添加</el-button>
  290. <el-button type="primary" size="small" @click="deleteGroup(index)"
  291. v-if="groupJson2.group && groupJson2.group.length > 1">删除</el-button>
  292. </div>
  293. </div>
  294. </div>
  295. <div class="groupContent">
  296. <div class="groupTitle">请设置每组人数</div>
  297. <el-input-number v-model="groupJson2.number" :controls="false" :min="2" :max="10"
  298. placeholder="请输入2-10的数字"></el-input-number>
  299. </div>
  300. </div>
  301. <span slot="footer" class="dialog-footer">
  302. <el-button @click="dialogVisibleGroup2 = false">取 消</el-button>
  303. <el-button type="primary" @click="updateGroupJson">确定</el-button>
  304. </span>
  305. </el-dialog>
  306. <el-dialog title="移除组员" :visible.sync="dialogVisibleDeleteGroup" :append-to-body="true" width="350px"
  307. :before-close="handleClose" class="dialog_diy">
  308. <div>
  309. <h2>
  310. {{ this.deleteGroupArray.name }}
  311. </h2>
  312. <div style="color: rgb(171 171 171); margin-top: 10px">
  313. 请选择要删除的组员
  314. </div>
  315. <el-checkbox-group v-model="checkDeleteGroup">
  316. <el-checkbox style="display: block; margin-top: 20px" v-for="(item, index) in deleteGroupUser"
  317. :label="item.userid" :key="index">{{ item.name }}</el-checkbox>
  318. </el-checkbox-group>
  319. </div>
  320. <span slot="footer" class="dialog-footer">
  321. <el-button @click="dialogVisibleDeleteGroup = false">取 消</el-button>
  322. <el-button type="primary" @click="deleteChair">确定</el-button>
  323. </span>
  324. </el-dialog>
  325. <el-dialog title="修改分组" :visible.sync="dialogVisibleUpdateGroup" :append-to-body="true" width="350px"
  326. :before-close="handleClose" class="dialog_diy">
  327. <div>
  328. <h2>
  329. {{ this.updateGroupUser.name }}
  330. </h2>
  331. <div style="color: rgb(171 171 171); margin-top: 10px">
  332. 请选择要进入的分组
  333. </div>
  334. <el-radio-group v-model="checkChair">
  335. <el-radio style="display: block; margin-top: 20px" v-for="(item, index) in updateGroupArray"
  336. :label="item.id" :key="index">{{ item.name }}</el-radio>
  337. </el-radio-group>
  338. </div>
  339. <span slot="footer" class="dialog-footer">
  340. <el-button @click="dialogVisibleUpdateGroup = false">取 消</el-button>
  341. <el-button type="primary" @click="updateChair">确定</el-button>
  342. </span>
  343. </el-dialog>
  344. <el-dialog title="添加学生" :visible.sync="dialogVisibleMember" :append-to-body="true" width="540px" height="80%"
  345. :before-close="handleClose" class="addNewPP">
  346. <div class="people">
  347. <div class="people_top">
  348. <div class="people_top_right">
  349. <div class="people_search">
  350. <el-input placeholder="搜索学生的姓名" v-model="searchTN" @keyup.enter.native="getStudent"></el-input>
  351. <div class="search_img" @click="getStudent">
  352. <img src="../../assets/icon/search.png" alt />
  353. </div>
  354. </div>
  355. </div>
  356. <div class="people_nav">选择成员</div>
  357. </div>
  358. <!-- <div class="t_j_box" style="
  359. padding: 20px 0 0 25px;
  360. width: calc(100% - 55px);
  361. margin-left: 25px;
  362. ">
  363. <span>姓名</span>
  364. <span>账号</span>
  365. </div> -->
  366. <!-- <el-checkbox-group v-model="checkboxList3" class="people_name" v-if="classJuri.length">
  367. <el-checkbox v-for="item in classJuri" :key="item.userid" :label="item.userid">
  368. <div class="t_j_box">
  369. <el-tooltip placement="top" :content="item.name ? item.name : '暂无姓名'">
  370. <span>{{ item.name ? item.name : "暂无姓名" }}</span>
  371. </el-tooltip>
  372. <el-tooltip placement="top" :content="item.username">
  373. <span>{{ item.username }}</span>
  374. </el-tooltip>
  375. </div>
  376. </el-checkbox>
  377. </el-checkbox-group> -->
  378. <div class="i_box_login2" v-if="classJuri.length">
  379. <div :class="{ active: checkboxList3.indexOf(item.userid) != -1 }" v-for="item in classJuri"
  380. :key="item.userid" :label="item.userid" @click="addGroupUser(item.userid)">
  381. <el-tooltip placement="top" :content="item.name ? item.name : '暂无姓名'">
  382. <span>{{ item.name ? item.name : "暂无姓名" }}</span>
  383. </el-tooltip>
  384. </div>
  385. </div>
  386. <div style="text-align: center; margin-top: 10px" v-else>暂无数据</div>
  387. </div>
  388. <!-- <div style="margin-top: 10px;">
  389. <el-pagination background layout="prev, pager, next" :page-size="pageSize" :total="total"
  390. v-if="page && classJuri.length" style="padding-bottom: 20px"
  391. @current-change="handleCurrentChange"></el-pagination>
  392. </div> -->
  393. <span slot="footer" class="dialog-footer">
  394. <el-button @click="dialogVisibleMember = false">取 消</el-button>
  395. <el-button type="primary" @click="joinGroup2">确定</el-button>
  396. </span>
  397. </el-dialog>
  398. </div>
  399. </template>
  400. <script>
  401. export default {
  402. props: ['cid', 'dialogVisibleGroup', 'classList', 'courseDetail', 'userid', "type", "classId", "oid"],
  403. data() {
  404. return {
  405. groupJson2: {},
  406. classid: "1",
  407. groupid: "",
  408. gid: "",
  409. groupJson: {
  410. group: [],
  411. number: undefined,
  412. islock: 1,
  413. },
  414. islock: false,
  415. isopen:true,
  416. timer: null,
  417. groupStudent: {},
  418. groupStudentUid: {},
  419. allGroupStudentUid: [],
  420. dialogVisibleGroup2: false,
  421. checkDeleteGroup: [],
  422. deleteGroupUser: [],
  423. deleteGroupArray: [],
  424. dialogVisibleDeleteGroup: false,
  425. checkChair: "",
  426. updateGroupArray: [],
  427. updateGroupUser: {},
  428. dialogVisibleUpdateGroup: false,
  429. classJuri: [],
  430. checkboxList3: [],
  431. pageSize: 20,
  432. total: 0,
  433. page: 1,
  434. dialogVisibleMember: false,
  435. searchTN: "",
  436. }
  437. },
  438. methods: {
  439. handleClose2(done) {
  440. this.$emit('update:dialogVisibleGroup', false)
  441. done();
  442. },
  443. handleClose(done) {
  444. done();
  445. },
  446. getStudent() {
  447. this.page = 1
  448. this.selectCStudent();
  449. },
  450. handleCurrentChange(val) {
  451. this.page = val;
  452. this.selectCStudent();
  453. },
  454. selectCStudent() {
  455. let params = {
  456. cid: this.classid,
  457. oid: this.oid,
  458. cn: this.searchTN,
  459. };
  460. this.ajax
  461. .get(this.$store.state.api + "selectSnameByCidGroup", params)
  462. .then((res) => {
  463. if (res.data && res.data[0].length) {
  464. this.classJuri = res.data[0].filter((el) => {
  465. return this.allGroupStudentUid.indexOf(el.userid) == -1
  466. });
  467. }
  468. })
  469. .catch((err) => {
  470. console.error(err);
  471. });
  472. },
  473. setClassid(cid) {
  474. this.classid = cid
  475. this.groupid = ''
  476. this.groupJson = {
  477. group: [],
  478. number: undefined,
  479. islock: 1,
  480. }
  481. this.islock = false
  482. this.isopen = true
  483. this.getCourseGroup();
  484. },
  485. guid() {
  486. var _num,
  487. i,
  488. _guid = "";
  489. for (i = 0; i < 32; i++) {
  490. _guid += Math.floor(Math.random() * 16).toString(16); //随机0 - 16 的数字 转变为16进制的字符串
  491. _num = Math.floor((i - 7) / 4); //计算 (i-7)除4
  492. if (_num > -1 && _num < 4 && i == 7 + 4 * _num) {
  493. //会使guid中间加 "-" 形式为xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  494. _guid += "-";
  495. }
  496. }
  497. return _guid;
  498. },
  499. updateGroup() {
  500. this.groupJson2 = JSON.parse(JSON.stringify(this.groupJson));
  501. if (!this.groupJson2.group.length) {
  502. this.groupJson2.group.push({
  503. name: "第" + (this.groupJson2.group.length + 1) + "组",
  504. id: this.guid()
  505. });
  506. }
  507. this.dialogVisibleGroup2 = true;
  508. },
  509. deleteCourseGroup() {
  510. this.$confirm(
  511. // "您确定要删除该分组吗? 分组删除后将被清空并且无法恢复。",
  512. "是否确定删除已有分组?删除后分组数据将被清空!",
  513. "提示",
  514. {
  515. confirmButtonText: "确定",
  516. cancelButtonText: "取消",
  517. type: "warning",
  518. }
  519. )
  520. .then(() => {
  521. let params = [{
  522. gid: this.groupid,
  523. }];
  524. this.ajax
  525. .post(this.$store.state.api + "deleteCourseGroup", params)
  526. .then((res) => {
  527. this.groupJson = {
  528. group: [],
  529. number: undefined,
  530. islock: 1,
  531. }
  532. this.islock = false
  533. this.isopen = true
  534. this.$message.success("操作成功");
  535. this.getCourseGroup();
  536. this.$forceUpdate()
  537. })
  538. .catch((err) => {
  539. console.error(err);
  540. });
  541. })
  542. .catch(() => { });
  543. },
  544. addGroup() {
  545. this.groupJson2.group.push({
  546. name: "第" + (this.groupJson2.group.length + 1) + "组",
  547. id: this.guid()
  548. });
  549. },
  550. deleteGroup(i) {
  551. this.groupJson2.group.splice(i, 1);
  552. },
  553. lockChair() {
  554. this.groupJson2 = JSON.parse(JSON.stringify(this.groupJson));
  555. if(this.groupJson2.isopen == 2){
  556. this.$message.error("请开启分组后才能开放选座")
  557. this.islock = false
  558. return
  559. }else{
  560. this.groupJson2.islock = this.groupJson2.islock == 1 ? 2 : 1;
  561. }
  562. this.updateGroupJson();
  563. },
  564. openChair() {
  565. this.groupJson2 = JSON.parse(JSON.stringify(this.groupJson));
  566. if(!this.groupJson2.isopen){
  567. this.groupJson2.isopen = 2;
  568. }else{
  569. this.groupJson2.isopen = this.groupJson2.isopen == 1 ? 2 : 1;
  570. }
  571. if(this.groupJson2.isopen == 2){
  572. this.groupJson2.islock = 2
  573. }else{
  574. this.groupJson2.islock = 1
  575. }
  576. this.updateGroupJson();
  577. },
  578. updateGroupJson() {
  579. for (var i = 0; i < this.groupJson2.group.length; i++) {
  580. if (!this.groupJson2.group[i].name) {
  581. this.$message.error("请将信息填写完整!");
  582. return;
  583. }
  584. }
  585. if (!this.groupJson2.number) {
  586. this.$message.error("请将信息填写完整!");
  587. return;
  588. }
  589. for (var i = 0; i < this.groupJson2.group.length; i++) {
  590. if (
  591. this.groupStudentUid[this.groupJson2.group[i].id] && this.groupStudentUid[this.groupJson2.group[i].id].length >
  592. this.groupJson2.number
  593. ) {
  594. this.$message.error("已经有小组比你设置的人数多,请重新设置");
  595. return;
  596. }
  597. }
  598. let params = [
  599. {
  600. cid: this.cid,
  601. group: JSON.stringify(this.groupJson2).replaceAll(/%/g, "%25"),
  602. classid: this.classid,
  603. },
  604. ];
  605. this.ajax
  606. .post(this.$store.state.api + "setCourseGroup", params)
  607. .then((res) => {
  608. if(this.groupJson2.isopen == 1){
  609. this.$message.success("开启分组成功");
  610. }else{
  611. this.$message.success("关闭分组成功");
  612. }
  613. // 开启分组成功/关闭分组成功
  614. this.dialogVisibleGroup2 = false;
  615. this.groupJson2 = {};
  616. this.getCourseGroup();
  617. this.$forceUpdate();
  618. })
  619. .catch((err) => {
  620. this.$message.error("网络不佳");
  621. console.error(err);
  622. });
  623. },
  624. getCourseGroup(gid) {
  625. let params = {
  626. cid: this.cid,
  627. classid: this.classid,
  628. };
  629. this.ajax
  630. .get(this.$store.state.api + "getCourseGroup", params)
  631. .then((res) => {
  632. if (res.data && res.data[0].length) {
  633. this.groupJson = JSON.parse(res.data[0][0].group);
  634. this.islock = this.groupJson.islock == 1 ? true : false;
  635. if(!this.groupJson.isopen){
  636. this.isopen = true
  637. }else{
  638. this.isopen = this.groupJson.isopen == 1 ? true : false;
  639. }
  640. this.groupid = res.data[0][0].id;
  641. let groupPerson = res.data[1]
  642. let group = JSON.parse(res.data[0][0].group).group
  643. let groupStudent = {}
  644. let groupStudentUid = {}
  645. for (var i = 0; i < group.length; i++) {
  646. groupStudent[group[i].id] = []
  647. groupStudentUid[group[i].id] = []
  648. for (var j = 0; j < groupPerson.length; j++) {
  649. if (groupPerson[j].groupCid == group[i].id) {
  650. groupStudent[group[i].id].push(groupPerson[j])
  651. groupStudentUid[group[i].id].push(groupPerson[j].userid)
  652. }
  653. }
  654. }
  655. this.allGroupStudentUid = []
  656. for (var j = 0; j < groupPerson.length; j++) {
  657. this.allGroupStudentUid.push(groupPerson[j].userid)
  658. }
  659. this.groupStudent = groupStudent
  660. this.groupStudentUid = groupStudentUid
  661. this.$forceUpdate();
  662. if (gid) {
  663. this.joinGroup(gid)
  664. }
  665. }
  666. })
  667. .catch((err) => {
  668. this.$message.error("网络不佳");
  669. console.error(err);
  670. });
  671. },
  672. updateGroupChair(user) {
  673. this.updateGroupArray = this.groupJson.group.filter((el, index) => {
  674. el.label = index;
  675. return el.id != user.groupCid;
  676. });
  677. this.updateGroupUser = user;
  678. this.dialogVisibleUpdateGroup = true;
  679. },
  680. updateChair() {
  681. if (
  682. this.groupStudent[this.checkChair].length >
  683. this.groupJson.number ||
  684. this.groupStudent[this.checkChair].length ==
  685. this.groupJson.number
  686. ) {
  687. this.$message.error("位置已满,无法加入");
  688. return;
  689. }
  690. let params = [
  691. {
  692. gid: this.groupid,
  693. g: this.checkChair,
  694. uid: this.updateGroupUser.userid,
  695. },
  696. ];
  697. this.ajax
  698. .post(this.$store.state.api + "joinCourseGroup", params)
  699. .then((res) => {
  700. this.$message.success("修改成功");
  701. this.updateGroupUser = {};
  702. this.checkChair = "";
  703. this.updateGroupArray = {};
  704. this.dialogVisibleUpdateGroup = false;
  705. this.getCourseGroup();
  706. })
  707. .catch((err) => {
  708. this.$message.error("网络不佳");
  709. console.error(err);
  710. });
  711. },
  712. deleteGroupChair(gid, gindex) {
  713. this.checkDeleteGroup = [];
  714. this.deleteGroupUser = JSON.parse(
  715. JSON.stringify(this.groupStudent[gid])
  716. );
  717. this.deleteGroupArray = this.groupJson.group[gindex];
  718. this.gid = gid;
  719. this.dialogVisibleDeleteGroup = true;
  720. },
  721. async deleteChair() {
  722. for (let i = 0; i < this.checkDeleteGroup.length; i++) {
  723. const gid =
  724. this.groupStudent[this.gid][
  725. this.groupStudentUid[this.gid].indexOf(
  726. this.checkDeleteGroup[i]
  727. )
  728. ];
  729. let params = [
  730. {
  731. gid: gid.id,
  732. },
  733. ];
  734. var a = await this.deleteChairA(params);
  735. if (i == this.checkDeleteGroup.length - 1) {
  736. this.$message.success("退出成功");
  737. this.dialogVisibleDeleteGroup = false;
  738. this.deleteGroupUser = [];
  739. this.deleteGroupArray = {};
  740. this.gid = "";
  741. this.checkDeleteGroup = [];
  742. this.getCourseGroup();
  743. }
  744. }
  745. },
  746. deleteChairA(params) {
  747. return new Promise((resolve, reject) => {
  748. this.ajax
  749. .post(this.$store.state.api + "exitCourseGroup", params)
  750. .then((res) => {
  751. resolve(1);
  752. })
  753. .catch((err) => {
  754. this.$message.error("网络不佳");
  755. console.error(err);
  756. });
  757. });
  758. },
  759. selectGroup(gid) {
  760. this.getCourseGroup(gid)
  761. },
  762. joinGroup(gid) {
  763. if (this.groupJson.islock == 2) {
  764. this.$message.error("位置已被锁定,无法加入");
  765. return;
  766. }
  767. if (
  768. this.groupStudent[gid].length >
  769. this.groupJson.number ||
  770. this.groupStudent[gid].length == this.groupJson.number
  771. ) {
  772. this.$message.error("位置已满,无法加入");
  773. return;
  774. }
  775. let params = [
  776. {
  777. gid: this.groupid,
  778. g: gid,
  779. uid: this.userid,
  780. },
  781. ];
  782. this.ajax
  783. .post(this.$store.state.api + "joinCourseGroup", params)
  784. .then((res) => {
  785. this.$message.success("加入成功");
  786. this.$emit('getGroup')
  787. this.getCourseGroup();
  788. })
  789. .catch((err) => {
  790. this.$message.error("网络不佳");
  791. console.error(err);
  792. });
  793. },
  794. addGroupUser(uid) {
  795. if (this.checkboxList3.indexOf(uid) == -1) {
  796. this.checkboxList3.push(uid)
  797. } else {
  798. this.checkboxList3.splice(this.checkboxList3.indexOf(uid), 1)
  799. }
  800. },
  801. async joinGroup2() {
  802. if (
  803. this.groupStudent[this.gid].length + this.checkboxList3.length >
  804. this.groupJson.number
  805. ) {
  806. this.$message.error("位置已满,无法加入");
  807. return;
  808. }
  809. for (let i = 0; i < this.checkboxList3.length; i++) {
  810. let params = [
  811. {
  812. gid: this.groupid,
  813. g: this.gid,
  814. uid: this.checkboxList3[i],
  815. },
  816. ];
  817. const res = await this.ajax.post(this.$store.state.api + "joinCourseGroup", params)
  818. if (i == this.checkboxList3.length - 1) {
  819. this.$message.success("加入成功");
  820. this.dialogVisibleMember = false
  821. this.getCourseGroup();
  822. }
  823. }
  824. },
  825. exitGroup(id) {
  826. if (this.groupJson.islock == 2) {
  827. this.$message.error("位置已被锁定,无法退出");
  828. return;
  829. }
  830. let params = [
  831. {
  832. gid: id,
  833. },
  834. ];
  835. this.ajax
  836. .post(this.$store.state.api + "exitCourseGroup", params)
  837. .then((res) => {
  838. this.$message.success("退出成功");
  839. this.$emit('getGroup')
  840. this.getCourseGroup();
  841. })
  842. .catch((err) => {
  843. this.$message.error("网络不佳"); s
  844. console.error(err);
  845. });
  846. },
  847. addGroupStudent(groupid) {
  848. this.gid = groupid
  849. this.page = 1
  850. this.searchTN = ""
  851. this.checkboxList3 = []
  852. this.selectCStudent()
  853. this.getCourseGroup();
  854. this.dialogVisibleMember = true
  855. }
  856. },
  857. watch: {
  858. dialogVisibleGroup(newValue, oldValue) {
  859. if (this.classList.length) {
  860. if (this.type == 2) {
  861. this.classList = this.classList.filter(el => {
  862. return this.classId.indexOf(el.id) != -1
  863. })
  864. this.classid = this.classList[0].id
  865. } else {
  866. this.classid = this.classList[0].id
  867. }
  868. } else {
  869. this.classid = '1'
  870. }
  871. this.setClassid(this.classid)
  872. this.getCourseGroup();
  873. if (this.dialogVisibleGroup) {
  874. this.getCourseGroup();
  875. this.timer = setInterval(() => {
  876. this.getCourseGroup();
  877. }, 5000)
  878. } else {
  879. clearInterval(this.timer)
  880. this.timer = null
  881. }
  882. }
  883. },
  884. beforeDestory() {
  885. clearInterval(this.timer)
  886. this.timer = null
  887. },
  888. mounted() {
  889. }
  890. }
  891. </script>
  892. <style scoped>
  893. .dialog_diy>>>.el-dialog {
  894. margin-top: 10vh !important;
  895. }
  896. .dialog_diy>>>.el-dialog__header {
  897. background: #454545 !important;
  898. padding: 15px 20px;
  899. }
  900. .dialog_diy>>>.el-dialog__title {
  901. color: #fff;
  902. }
  903. .dialog_diy>>>.el-dialog__headerbtn {
  904. top: 19px;
  905. }
  906. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  907. color: #fff;
  908. }
  909. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  910. color: #fff;
  911. }
  912. .dialog_diy>>>.el-dialog__body,
  913. .dialog_diy>>>.el-dialog__footer {
  914. background: #fafafa;
  915. }
  916. .group_workBox {}
  917. .group_workBox+.group_workBox {
  918. margin-top: 20px;
  919. }
  920. .group_box {
  921. padding-bottom: 20px;
  922. border-bottom: 2px solid #f0f0f0;
  923. }
  924. .group_title {
  925. display: flex;
  926. align-items: center;
  927. justify-content: space-between;
  928. }
  929. .group_name {
  930. background-image: url(../../assets/icon/groupN.png);
  931. width: 220px;
  932. background-size: 100% 100%;
  933. height: 67px;
  934. padding: 0 20px 0 43px;
  935. box-sizing: border-box;
  936. line-height: 63px;
  937. color: #fff;
  938. overflow: hidden;
  939. white-space: nowrap;
  940. text-overflow: ellipsis;
  941. }
  942. .group_work {
  943. width: 100%;
  944. padding: 0 10px;
  945. box-sizing: border-box;
  946. display: flex;
  947. flex-wrap: wrap;
  948. }
  949. .g_d_box {
  950. display: flex;
  951. flex-flow: wrap;
  952. justify-content: space-around;
  953. }
  954. .g_d_box .isChair {
  955. background-image: url(../../assets/avatar.png) !important;
  956. }
  957. .g_d_group {
  958. width: 500px;
  959. margin-bottom: 80px;
  960. }
  961. .g_d_group_chair {
  962. display: flex;
  963. align-items: center;
  964. justify-content: center;
  965. }
  966. .g_d_group_chair>div+div {
  967. margin-left: 30px;
  968. }
  969. .g_d_group_chair>div,
  970. .g_d_group_chair2>div {
  971. display: flex;
  972. flex-direction: column;
  973. align-items: center;
  974. }
  975. .g_d_group_chair>div>span:nth-child(1),
  976. .g_d_group_chair2>div>span:nth-child(1) {
  977. background-image: url(../../assets/icon/chair.png);
  978. width: 50px;
  979. height: 50px;
  980. display: block;
  981. background-size: 100% 100%;
  982. }
  983. .g_d_group_tableBox {
  984. display: flex;
  985. align-items: center;
  986. justify-content: center;
  987. }
  988. .g_d_group_chair2 {
  989. display: flex;
  990. flex-direction: column;
  991. align-items: center;
  992. justify-content: center;
  993. }
  994. .g_d_group_chair2>div+div {
  995. margin-top: 10px;
  996. }
  997. .g_d_group_table {
  998. background-image: url(../../assets/icon/groupBg.png);
  999. width: 354px;
  1000. height: 196px;
  1001. background-size: 100% 100%;
  1002. display: flex;
  1003. align-items: center;
  1004. justify-content: center;
  1005. flex-direction: column;
  1006. color: #fff;
  1007. }
  1008. .g_d_group_table>div:nth-child(1) {
  1009. font-size: 24px;
  1010. margin-bottom: 5px;
  1011. }
  1012. .g_d_group_table>div:nth-child(2) div {
  1013. cursor: pointer;
  1014. background: #2e77bf;
  1015. padding: 4px 10px;
  1016. border-radius: 5px;
  1017. }
  1018. .groupBox {}
  1019. .groupContent+.groupContent {
  1020. margin-top: 30px;
  1021. }
  1022. .groupTitle {
  1023. font-size: 24px;
  1024. color: rgb(80, 80, 80);
  1025. margin-bottom: 20px;
  1026. }
  1027. .groupName {
  1028. display: flex;
  1029. align-items: center;
  1030. }
  1031. .groupn {
  1032. font-size: 15px;
  1033. margin-right: 10px;
  1034. }
  1035. .groupName+.groupName {
  1036. margin-top: 15px;
  1037. }
  1038. .groupBtn {
  1039. margin-left: 10px;
  1040. }
  1041. .groupContent>>>.el-input-number.is-without-controls .el-input__inner {
  1042. text-align: left;
  1043. }
  1044. .g_d_btnBox {
  1045. display: flex;
  1046. justify-content: space-between;
  1047. align-items: flex-end;
  1048. margin-bottom: 20px;
  1049. }
  1050. .btn_left {
  1051. display: flex;
  1052. margin-top: 20px;
  1053. padding: 0px 0 0 30px;
  1054. }
  1055. .btn_left>div {
  1056. cursor: pointer;
  1057. }
  1058. .btn_left>div+div {
  1059. margin-left: 10px;
  1060. }
  1061. .btn_left .active {
  1062. color: #3e88f4;
  1063. border-bottom: 2px solid #2f80f3;
  1064. padding: 0 0 5px;
  1065. }
  1066. .btn_right {
  1067. display: flex;
  1068. align-items: center;
  1069. }
  1070. .updateChair {
  1071. position: relative;
  1072. }
  1073. .updateChairBtn {
  1074. position: absolute;
  1075. width: 50px;
  1076. height: 50px;
  1077. overflow: hidden;
  1078. /* display: flex; */
  1079. align-items: center;
  1080. justify-content: center;
  1081. background: #00000087;
  1082. color: #fff;
  1083. border-radius: 50px;
  1084. display: none;
  1085. cursor: pointer;
  1086. }
  1087. .updateChair:hover .updateChairBtn {
  1088. display: flex;
  1089. }
  1090. .returnBtn {
  1091. background: #499eef;
  1092. width: 65px;
  1093. height: 30px;
  1094. color: #fff;
  1095. text-align: center;
  1096. line-height: 32px;
  1097. margin-right: 20px;
  1098. cursor: pointer;
  1099. border-radius: 5px;
  1100. font-size: 14px;
  1101. }
  1102. .addNewPP>>>.el-dialog__body {
  1103. padding: 5px 20px;
  1104. }
  1105. .people {
  1106. border: 1px solid rgb(229 229 229);
  1107. height: 495px;
  1108. border-radius: 5px;
  1109. width: 100%;
  1110. overflow: auto;
  1111. }
  1112. .people_top {
  1113. display: flex;
  1114. width: 100%;
  1115. /* justify-content: space-between; */
  1116. /* align-items: center; */
  1117. flex-direction: column;
  1118. padding: 10px 25px 0;
  1119. box-sizing: border-box;
  1120. }
  1121. .people_nav,
  1122. .people_top_right {
  1123. /* padding: 20px 0 0 20px; */
  1124. }
  1125. .people_top_right {
  1126. height: 40px;
  1127. margin-bottom: 10px;
  1128. }
  1129. .people_search {
  1130. display: flex;
  1131. position: relative;
  1132. }
  1133. .people_search>>>.el-input__inner {
  1134. /* height: 25px; */
  1135. width: 100%;
  1136. }
  1137. .search_img {
  1138. width: 20px;
  1139. height: 20px;
  1140. position: absolute;
  1141. right: 10px;
  1142. top: 50%;
  1143. transform: translateY(-50%);
  1144. }
  1145. .search_img>img {
  1146. width: 100%;
  1147. height: 100%;
  1148. }
  1149. .people_name {
  1150. display: flex;
  1151. justify-content: flex-start;
  1152. padding: 10px 0 0 25px;
  1153. flex-direction: column;
  1154. flex-wrap: nowrap;
  1155. height: calc(100% - 140px);
  1156. overflow-y: auto;
  1157. overflow-x: hidden;
  1158. flex-direction: column;
  1159. }
  1160. .people_name>>>.el-checkbox {
  1161. width: 100%;
  1162. display: flex;
  1163. align-items: center;
  1164. margin-bottom: 10px;
  1165. }
  1166. .people_name>>>.el-checkbox__label {
  1167. text-overflow: ellipsis;
  1168. overflow: hidden;
  1169. width: 100%;
  1170. }
  1171. .t_j_box {
  1172. display: flex;
  1173. }
  1174. .t_j_box span:nth-child(1) {
  1175. width: 50%;
  1176. overflow: hidden;
  1177. margin-right: 10px;
  1178. text-overflow: ellipsis;
  1179. white-space: nowrap;
  1180. }
  1181. .t_j_box span:nth-child(2) {
  1182. width: 50%;
  1183. overflow: hidden;
  1184. margin-right: 10px;
  1185. text-overflow: ellipsis;
  1186. white-space: nowrap;
  1187. }
  1188. .i_box_login2 {
  1189. height: calc(100% - 80px);
  1190. width: 100%;
  1191. display: flex;
  1192. flex-wrap: wrap;
  1193. overflow: auto;
  1194. padding-bottom: 10px;
  1195. box-sizing: border-box;
  1196. align-content: flex-start;
  1197. padding: 10px 25px 0;
  1198. }
  1199. .i_box_login2>div {
  1200. cursor: pointer;
  1201. width: 80px;
  1202. text-align: center;
  1203. height: 30px;
  1204. line-height: 30px;
  1205. padding: 0 5px;
  1206. overflow: hidden;
  1207. background: rgb(225, 237, 255);
  1208. margin: 10px calc((100% - (80px*5)) / 4) 0 0;
  1209. color: rgb(37 124 255);
  1210. border-radius: 5px;
  1211. box-sizing: border-box;
  1212. }
  1213. .i_box_login2>div:nth-child(5n) {
  1214. margin: 10px 0 0 0;
  1215. }
  1216. .i_box_login2>.active {
  1217. background: rgb(92, 157, 255);
  1218. color: #fff;
  1219. }
  1220. .i_box_login2>div>span {
  1221. width: 100%;
  1222. overflow: hidden;
  1223. white-space: nowrap;
  1224. text-overflow: ellipsis;
  1225. display: block;
  1226. }
  1227. .group_switch {
  1228. margin-right: 10px;
  1229. height: 30px;
  1230. display: flex;
  1231. align-items: center;
  1232. }
  1233. .group_switch>span {
  1234. margin-right: 5px;
  1235. }
  1236. </style>