group.vue 48 KB

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