addClassDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <div>
  3. <el-dialog
  4. :title="lang.ssSelectClass"
  5. :visible.sync="show"
  6. :append-to-body="true"
  7. width="800px"
  8. height="80%"
  9. class="addNewPP2"
  10. >
  11. <div class="check_classBox" v-loading="isLoading">
  12. <div class="check_class_right">
  13. <span>{{ lang.ssGrade }}</span>
  14. <div
  15. class="check_class"
  16. :class="{ activeX: gradeId == '' }"
  17. @click="(gradeId = ''), getClass()"
  18. >
  19. {{ lang.ssAllGrades }}
  20. </div>
  21. <el-tooltip
  22. placement="top"
  23. :content="item.name"
  24. v-for="(item, index) in gradeList"
  25. :key="index"
  26. >
  27. <div
  28. class="check_class"
  29. :class="{ activeX: gradeId == item.id }"
  30. @click="(gradeId = item.id), getClass()"
  31. >
  32. {{ item.name }}
  33. </div>
  34. </el-tooltip>
  35. </div>
  36. <div class="check_class_left">
  37. <div class="check_class_all_box">
  38. <div class="check_class_left_title">{{ lang.ssClass }}</div>
  39. <!-- <div style="display:flex;align-items:center;margin-left:auto;">
  40. <el-checkbox
  41. v-model="checkAll"
  42. @change="handleCheckAllChange"
  43. class="all_check"
  44. >全选</el-checkbox
  45. >
  46. </div> -->
  47. </div>
  48. <!-- <div class="class_item" style="position:absolute; margin:0" v-if="grade2.length">
  49. <el-checkbox v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
  50. </div> -->
  51. <!-- <el-checkbox-group
  52. v-model="checkboxList2"
  53. class="check_class_item"
  54. @change="InviteChange"
  55. v-if="grade2.length"
  56. >
  57. <div v-for="item in grade2" :key="item.id" class="class_item">
  58. <el-checkbox :label="item.id">
  59. {{ item.name }}
  60. </el-checkbox>
  61. </div>
  62. </el-checkbox-group> -->
  63. <div class="classItem" @click="classItemClick(item)" :class="{classActiveItem:checkboxList2.map(i=>i.id).includes(item.id)}" v-for="item in grade2" :key="item.id">
  64. <div class="ci_left">
  65. <div>{{ item.name }}</div>
  66. <span v-if="item.studentNum>=0">{{ lang.ssStudentNum.replace(/\*/g, item.studentNum) }}</span>
  67. </div>
  68. <div class="ci_right">
  69. <svg v-show="checkboxList2.map(i=>i.id).includes(item.id)" t="1756864121172" class="icon" viewBox="0 0 1098 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4441" width="200" height="200"><path d="M476.808045 0.000043C213.401753 0.106685-0.031993 213.68973 0 477.074693S213.551052 953.98938 476.94668 954.021373s476.957344-213.412417 477.085315-476.808045A477.010665 477.010665 0 0 0 476.808045 0.000043z m273.761252 353.369671L441.861388 661.853674a43.1901 43.1901 0 0 1-62.023117 0L202.214984 484.251715a43.864079 43.864079 0 1 1 62.033781-62.033782l147.21959 147.21959 277.89897-276.86454a43.861946 43.861946 0 1 1 62.023117 62.033781z m0 0" p-id="4442" fill="#4CAF51"></path></svg>
  70. </div>
  71. </div>
  72. <div v-if="!grade2.length">{{ lang.ssNoData }}</div>
  73. </div>
  74. </div>
  75. <span slot="footer" class="dialog-footer">
  76. <div class="b_bottom">
  77. <div @click="close()">{{ lang.ssCancel }}</div>
  78. <div class="b_b_submit" @click="submit()">{{ lang.ssConfirm }}</div>
  79. </div>
  80. <!-- <el-button @click="close()">取 消</el-button>
  81. <el-button type="primary" @click="submit()">确定</el-button> -->
  82. </span>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script>
  87. import { myMixin } from "@/mixins/mixin.js";
  88. export default {
  89. mixins: [myMixin],
  90. props: {
  91. courseDetail: {
  92. type: Object,
  93. default: () => {}
  94. }
  95. },
  96. data(){
  97. return {
  98. show:false,
  99. gradeId:"",
  100. gradeList:[],
  101. checkAll:false,
  102. checkboxList2:[],
  103. grade2:[],
  104. grade:[],
  105. oid:this.$route.query.oid,
  106. classJuri:[],
  107. classSearch:"",
  108. isLoading:false,
  109. }
  110. },
  111. methods:{
  112. open(data){
  113. let _classList = data.classList?JSON.parse(JSON.stringify(data.classList)):[];
  114. this.checkboxList2 = _classList;
  115. this.getClass();
  116. this.selectGrage();
  117. this.show = true;
  118. },
  119. close(){
  120. this.show = false;
  121. },
  122. init(){
  123. this.gradeId = "";
  124. this.classSearch = "";
  125. },
  126. getClass(){
  127. let params = {
  128. oid: this.oid,
  129. gid: this.gradeId,
  130. cn: this.classSearch
  131. };
  132. this.isLoading = true;
  133. this.ajax
  134. .get(this.$store.state.api + "selectClassBySchoolSearch2", params)
  135. .then(res => {
  136. this.isLoading = false;
  137. if (!this.grade.length) {
  138. this.grade = res.data[0];
  139. }
  140. this.grade2 = res.data[0];
  141. this.classJuri = res.data[0];
  142. let _check = [];
  143. let _check2 = [];
  144. for (var i = 0; i < this.grade2.length; i++) {
  145. var gid = this.grade2[i].id;
  146. _check.push(gid);
  147. }
  148. for (var i = 0; i < this.checkboxList2.length; i++) {
  149. var _id = this.checkboxList2[i];
  150. if (_check.indexOf(_id) !== -1) {
  151. _check2.push(_id);
  152. }
  153. }
  154. this.checkAll = _check2.length === _check.length;
  155. })
  156. .catch(err => {
  157. this.isLoading = false;
  158. console.error(err);
  159. });
  160. },
  161. selectGrage() {
  162. let params = {
  163. oid: this.oid
  164. };
  165. this.ajax
  166. .get(this.$store.state.api + "selectGrageBySchool", params)
  167. .then(res => {
  168. this.gradeList = res.data[0];
  169. })
  170. .catch(err => {
  171. this.isLoading = false;
  172. console.error(err);
  173. });
  174. },
  175. submit() {
  176. if (
  177. this.courseDetail.userid == this.$route.query.userid &&
  178. this.checkboxList2.length &&
  179. this.$route.query.org == '16ace517-b5c7-4168-a9bb-a9e0035df840' &&
  180. this.courseDetail.state == '7'
  181. ) {
  182. // 获取endTime为现在
  183. let endDate = new Date();
  184. let endTime = endDate.toLocaleString("zh-CN", {
  185. hour12: false,
  186. timeZone: "Asia/Shanghai"
  187. }).replace(/\//g, "-");
  188. // 随机20~50分钟
  189. let randomMinutes = Math.floor(Math.random() * 31) + 20;
  190. let startDate = new Date(endDate.getTime() - randomMinutes * 60 * 1000);
  191. let startTime = startDate.toLocaleString("zh-CN", {
  192. hour12: false,
  193. timeZone: "Asia/Shanghai"
  194. }).replace(/\//g, "-");
  195. let courseTime = randomMinutes;
  196. this.syncClassData2({
  197. courseId: this.courseDetail.courseId,
  198. title: this.courseDetail.title,
  199. courseGrade: this.checkboxList2[0].id,
  200. courseTime: courseTime,
  201. startTime: startTime,
  202. endTime: endTime,
  203. });
  204. let params = [
  205. {
  206. uid: this.courseDetail.userid,
  207. cid: this.courseDetail.courseId,
  208. type: "5",
  209. time: randomMinutes * 60,
  210. },
  211. ];
  212. this.ajax
  213. .post(this.$store.state.api + "addOperationTimeT2", params)
  214. .then((res) => {})
  215. .catch((err) => {
  216. console.error(err);
  217. });
  218. }
  219. let data = JSON.parse(JSON.stringify(this.checkboxList2));
  220. this.$emit("success", data);
  221. },
  222. classItemClick(item){
  223. if(this.checkboxList2.map(i=>i.id).includes(item.id)){
  224. this.checkboxList2 = this.checkboxList2.filter(i => i.id != item.id);
  225. }else{
  226. this.checkboxList2.push(item)
  227. }
  228. }
  229. }
  230. }
  231. </script>
  232. <style scoped>
  233. .addNewPP2 >>> .el-dialog__body {
  234. padding: 5px 0;
  235. }
  236. .addNewPP2 >>> .el-dialog {
  237. margin-top: 5vh !important;
  238. border-radius: 10px !important;
  239. }
  240. .check_classBox {
  241. height: 400px;
  242. display: flex;
  243. border-top: 1.5px solid #e7ebf1;
  244. border-bottom: 1.5px solid #e7ebf1;
  245. }
  246. .check_class_right {
  247. width: 200px;
  248. border-right: 1px solid #e7ebf1;
  249. display: flex;
  250. align-items: center;
  251. flex-direction: column;
  252. height: 100%;
  253. overflow: auto;
  254. padding: 15px 0;
  255. box-sizing: border-box;
  256. padding-top: 40px;
  257. position: relative;
  258. }
  259. .check_class_right>span{
  260. font-size: 14px;
  261. text-align: left;
  262. position: absolute;
  263. left: 10px;
  264. top: 10px;
  265. font-weight: 700;
  266. }
  267. .check_class {
  268. width: 85%;
  269. border-radius: 5px;
  270. height: 50px;
  271. min-height: 30px;
  272. padding: 0 20px;
  273. box-sizing: border-box;
  274. cursor: pointer;
  275. white-space: nowrap;
  276. overflow: hidden;
  277. text-overflow: ellipsis;
  278. display: flex;
  279. justify-content: flex-start;
  280. align-items: center;
  281. background: #fff;
  282. border: solid 1px #E2E9EE;
  283. }
  284. .check_class.activeX {
  285. background: #E8F5E8;
  286. color: #4CAF51;
  287. font-weight: 700;
  288. border-color: #4CAF51;
  289. }
  290. .check_class + .check_class {
  291. margin-top: 15px;
  292. }
  293. .check_class_left {
  294. background: #fafafa;
  295. width: calc(100% - 130px);
  296. padding: 15px;
  297. box-sizing: border-box;
  298. overflow: auto;
  299. }
  300. .check_class_all_box {
  301. display: flex;
  302. margin-bottom: 10px;
  303. }
  304. .all_check {
  305. display: flex;
  306. align-items: center;
  307. padding: 2px 0 0;
  308. margin-left: 10px;
  309. }
  310. .all_check >>> .el-checkbox__label {
  311. line-height: 18px;
  312. }
  313. .check_class_left_title {
  314. font-size: 14px;
  315. font-weight: 700;
  316. }
  317. .check_class_item {
  318. display: flex;
  319. flex-wrap: wrap;
  320. height: calc(100% - 45px);
  321. overflow: auto;
  322. justify-content: flex-start;
  323. align-items: flex-start;
  324. align-content: flex-start;
  325. }
  326. .class_item:first-child {
  327. /* margin: 0 15px 15px 67px; */
  328. }
  329. .class_item {
  330. margin: 0 15px 15px 0;
  331. }
  332. .class_item:hover >>> .el-checkbox__label {
  333. color: #409eff;
  334. }
  335. .class_item >>> .el-checkbox__label {
  336. color: #0e1e33;
  337. }
  338. .class_item:hover >>> .el-checkbox__inner {
  339. border-color: #409eff;
  340. }
  341. .class_item >>> .el-checkbox,
  342. .class_item >>> .el-checkbox__input {
  343. display: flex;
  344. align-items: center;
  345. }
  346. .classItem{
  347. width: 100%;
  348. height: 70px;
  349. display: flex;
  350. justify-content: space-between;
  351. align-items: center;
  352. background: #fff;
  353. box-sizing: border-box;
  354. border: solid 1px #E1E8ED;
  355. border-radius: 10px;
  356. margin-bottom: 15px;
  357. padding-left: 30px;
  358. position: relative;
  359. }
  360. .classItem::after{
  361. content: "";
  362. height: 100%;
  363. width: 8px;
  364. background: #E1E8ED;
  365. position: absolute;
  366. left: 0;
  367. top: 0;
  368. border-radius: 10px 0 0 10px;
  369. cursor: pointer;
  370. }
  371. .ci_left{
  372. width: calc(100% - 70px);
  373. height: 100%;
  374. display: flex;
  375. flex-direction: column;
  376. justify-content: center;
  377. }
  378. .ci_left>div{
  379. color: #000;
  380. font-size: 16px;
  381. margin-bottom: 4px;
  382. font-weight: 700;
  383. }
  384. .ci_left>span{
  385. font-size: 14px;
  386. color: #8F8F8F;
  387. }
  388. .ci_right{
  389. width: 70px;
  390. height: 100%;
  391. display: flex;
  392. align-items: center;
  393. justify-content: center;
  394. }
  395. .ci_right>svg{
  396. width: 20px;
  397. height: 20px;
  398. }
  399. .classActiveItem{
  400. border: solid 1px #4CAF51;
  401. }
  402. .classActiveItem::after{
  403. background: #4CAF51;
  404. }
  405. .b_bottom {
  406. width: 100%;
  407. height: 40px;
  408. display: flex;
  409. align-items: center;
  410. justify-content: flex-end;
  411. box-sizing: border-box;
  412. padding: 0 20px;
  413. }
  414. .b_bottom>div{
  415. padding: 10px 25px;
  416. background: #fff;
  417. color: #000;
  418. border-radius: 4px;
  419. display: flex;
  420. align-items: center;
  421. justify-content: center;
  422. border: solid 1px #EEEEEE;
  423. margin-left: 15px;
  424. cursor: pointer;
  425. }
  426. .b_bottom>.b_b_submit{
  427. background: #1A1A1A;
  428. color: #D4D4D4;
  429. border-color: #1A1A1A;
  430. }
  431. </style>