group.vue 49 KB

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