settrainingcamp.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. {extend name="public/layout"/} {block name="title"}设置训练营{/block} {block name="body"}
  2. <style type="text/css">
  3. html,
  4. body {
  5. display: block;
  6. min-width: 1100px;
  7. }
  8. .layui-layer .layui-layer-iframe .layui-layer-title {
  9. background-color: #D8E6F1;
  10. }
  11. .layui-fluid {
  12. display: block;
  13. box-shadow: 0 0 4px 0 #B6CADE;
  14. border-radius: 5px;
  15. margin: 15px;
  16. background-color: #ffffff;
  17. }
  18. .layui-form-label {
  19. width: auto;
  20. }
  21. .layui-btn-primary {
  22. color: #249EFB;
  23. border: 1px solid #249EFB;
  24. }
  25. .layui-btn-primary:hover {
  26. background-color: #E3F7FF;
  27. color: #249EFB;
  28. }
  29. .layui-form-item .layui-input-inline {
  30. width: auto;
  31. margin-right: 0px;
  32. }
  33. .layui-table-cell {
  34. padding: 0px 20px;
  35. }
  36. .plr10 {
  37. padding: 0px 10px;
  38. }
  39. .goback {
  40. float: left;
  41. margin-right: 20px;
  42. }
  43. .goback a {
  44. color: #269efb;
  45. }
  46. .goback i {
  47. position: relative !important;
  48. left: 0px;
  49. }
  50. .addPlan {
  51. width: 100%;
  52. height: 60px;
  53. display: flex;
  54. align-items: center;
  55. background-color: #F5F7FA;
  56. box-sizing: border-box;
  57. padding: 0px 20px;
  58. color: #269efb;
  59. cursor: pointer;
  60. }
  61. .additemPlan {
  62. width: 100%;
  63. height: 60px;
  64. display: flex;
  65. align-items: center;
  66. background-color: #f2f2f2;
  67. box-sizing: border-box;
  68. padding: 0px 20px 0px 60px;
  69. color: #269efb;
  70. cursor: pointer;
  71. }
  72. .itemPlanTitle {
  73. width: 100%;
  74. height: 60px;
  75. display: flex;
  76. align-items: center;
  77. justify-content: space-between;
  78. background-color: #F5F7FA;
  79. box-sizing: border-box;
  80. padding: 0px 20px;
  81. margin-bottom: 10px;
  82. cursor: pointer;
  83. }
  84. .itemPlan {
  85. width: 100%;
  86. height: 60px;
  87. display: flex;
  88. align-items: center;
  89. justify-content: space-between;
  90. background-color: #f2f2f2;
  91. box-sizing: border-box;
  92. padding: 0px 20px 0px 60px;
  93. margin-bottom: 10px;
  94. cursor: pointer;
  95. }
  96. .mb10 {
  97. margin-bottom: 10px;
  98. }
  99. .ml5 {
  100. margin-left: 5px;
  101. }
  102. .ml10 {
  103. margin-left: 10px;
  104. }
  105. .mr10 {
  106. margin-right: 10px;
  107. }
  108. .flex {
  109. display: flex;
  110. }
  111. .align-center {
  112. align-items: center;
  113. }
  114. .flex-sub {
  115. flex: 1;
  116. }
  117. .justify-end {
  118. justify-content: flex-end;
  119. }
  120. .justify-center {
  121. justify-content: center;
  122. }
  123. .justify-around {
  124. justify-content: space-around;
  125. }
  126. .mask {
  127. width: 100%;
  128. height: 100%;
  129. position: fixed;
  130. top: 0px;
  131. left: 0px;
  132. bottom: 0px;
  133. right: 0px;
  134. background-color: rgba(0, 0, 0, 0.5);
  135. z-index: 99;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. }
  140. .mask-content {
  141. width: 600px;
  142. height: 350px;
  143. background-color: #fff;
  144. display: flex;
  145. flex-direction: column;
  146. }
  147. .mask-title {
  148. height: 45px;
  149. width: 100%;
  150. display: flex;
  151. justify-content: space-between;
  152. background-color: #D8E6F1;
  153. align-items: center;
  154. box-sizing: border-box;
  155. padding: 0px 20px;
  156. color: #333;
  157. }
  158. .item-box {
  159. width: 150px;
  160. height: 130px;
  161. border: 1px solid #333333;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. font-size: 15px;
  166. cursor: pointer;
  167. }
  168. .planTitle {
  169. width: 100%;
  170. height: 40px;
  171. color: #333;
  172. font-weight: 600;
  173. box-sizing: border-box;
  174. padding: 0px 20px;
  175. border-left: 4px solid #249EFB;
  176. display: flex;
  177. align-items: center;
  178. margin-bottom: 10px;
  179. background-color: #f6f6f6;
  180. }
  181. .width100 {
  182. width: 100%;
  183. }
  184. .active {
  185. border: 2px solid #249EFB;
  186. color: #249EFB;
  187. font-weight: 600;
  188. }
  189. .p20 {
  190. padding: 20px;
  191. }
  192. .reopen {
  193. color: #249EFB;
  194. }
  195. .cDelStyle {
  196. font-size: 18px;
  197. margin-left: 10px;
  198. }
  199. .link {
  200. cursor: pointer;
  201. }
  202. .rotate90 {
  203. transform: rotate(180deg);
  204. transition: .5s;
  205. }
  206. </style>
  207. <div class="layui-fluid">
  208. <div class="layui-card">
  209. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  210. <div class="layui-form-item">
  211. <div class="layui-inline" style="float: left;">
  212. <div class="goback">
  213. <a class="link">
  214. 新增训练计划
  215. </a>
  216. <span>>></span>
  217. <span>设置训练营</span>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. <div class="layui-card-body">
  223. <div class="planTitle">训练计划目录</div>
  224. <div class="planContent">
  225. </div>
  226. <div class="addPlan">
  227. <i class="layui-icon layui-icon-addition"></i>
  228. <span>添加计划</span>
  229. </div>
  230. </div>
  231. <div class="flex justify-center p20">
  232. <button type="button" class="layui-btn layui-btn-normal submitMsg">保存</button>
  233. </div>
  234. </div>
  235. <!-- 弹窗 -->
  236. <div class="mask layui-hide">
  237. <div class="mask-content">
  238. <div class="mask-title">
  239. <span>选择任务类型</span>
  240. <i class="layui-icon layui-icon-close"></i>
  241. </div>
  242. <div class="width100 flex-sub flex justify-around align-center">
  243. <div class="item-box" data-index="0">
  244. 课程类
  245. </div>
  246. <div class="item-box" data-index="1">
  247. 考试类
  248. </div>
  249. </div>
  250. <!-- <div class="flex justify-end p20">
  251. <button type="button" class="layui-btn layui-btn-primary cancel">取消</button>
  252. <button type="button" class="layui-btn sure">确定</button>
  253. </div> -->
  254. </div>
  255. </div>
  256. <input type="hidden" name="course_id" id="course_id" />
  257. </div>
  258. {/block} {block name="js"}
  259. <script>
  260. layui.config({
  261. base: '__LAYUI__/',
  262. urlbase: '/sys'
  263. }).extend({
  264. index: 'lib/index'
  265. }).use(['index', 'table', 'layedit', 'element'], function () {
  266. var $ = layui.$,
  267. table = layui.table,
  268. element = layui.element,
  269. form = layui.form,
  270. arrPlan = [],
  271. addType = null,
  272. planId = null,
  273. isEdit = false,
  274. trainCampId = null,
  275. plan_index = null,
  276. task_index = null,
  277. loading = false,
  278. isChange = false;
  279. var field = {};
  280. form.on('submit(LAY-app-contlist-search)', function (data) {
  281. var type_id = $('.type_id').val();
  282. var keyword = $('.keyword').val();
  283. field['type_id'] = type_id;
  284. field['keyword'] = keyword;
  285. //执行重载
  286. table.reload('datalist', {
  287. where: field,
  288. page: {
  289. curr: 1
  290. }
  291. });
  292. });
  293. //获取已设置的训练计划
  294. getTrainCampList();
  295. function getTrainCampList(index) {
  296. arrPlan = [];
  297. $.ajax({
  298. url: "{:url('camp/read')}",
  299. data: {
  300. id: "{$id}"
  301. },
  302. dataType: 'json',
  303. type: 'post',
  304. success: function (res) {
  305. if (res.code == 0) {
  306. arrPlan = res.data;
  307. setTimeout(() => {
  308. setHtml(arrPlan, index);
  309. }, 50)
  310. } else {
  311. layer.msg(res.msg, {
  312. anim: 6
  313. , time: 2000
  314. });
  315. }
  316. }
  317. })
  318. }
  319. // 编辑计划名称
  320. function editPlanName(plan_name, id) {
  321. $.ajax({
  322. url: "{:url('camp/edit')}",
  323. data: {
  324. camp_id: "{$id}",
  325. plan_name: plan_name,
  326. id: id
  327. },
  328. dataType: 'json',
  329. type: 'post',
  330. success: function (res) {
  331. if (res.code == 0) {
  332. getTrainCampList();
  333. isChange = true;
  334. layer.msg('编辑成功', {
  335. time: 2000
  336. });
  337. } else {
  338. layer.msg(res.msg, {
  339. anim: 6
  340. , time: 2000
  341. });
  342. }
  343. }
  344. })
  345. }
  346. //编辑训练任务
  347. function editTrainCamp(id, plan_id, type, con_name, con_id) {
  348. $.ajax({
  349. url: "{:url('camp/edit_plan')}",
  350. data: {
  351. id: id,
  352. plan_id: plan_id,
  353. type: type,
  354. con_name: con_name,
  355. con_id: con_id
  356. },
  357. dataType: 'json',
  358. type: 'post',
  359. success: function (res) {
  360. if (res.code == 0) {
  361. // getTrainCampList();
  362. isChange = true;
  363. layer.msg('编辑成功', {
  364. time: 2000
  365. });
  366. setHtml(arrPlan);
  367. } else {
  368. layer.msg(res.msg, {
  369. anim: 6
  370. , time: 2000
  371. });
  372. }
  373. }
  374. })
  375. }
  376. function setHtml(arr, index) {
  377. $('.planContent')[0].innerHTML = arr.map((v, i) => {
  378. return `<div class="mb10">
  379. <div class="itemPlanTitle">
  380. <div class="flex-sub flex align-center">
  381. <i class="layui-icon layui-icon-up" data-index="${i}"></i>
  382. <span class="ml5 ${index != i ? 'layui-show' : 'layui-hide'}">${v.title}</span>
  383. <span class="${index == i ? 'layui-show' : 'layui-hide'}">
  384. <div class="flex align-center">
  385. <input type="text" name="" id="plan${i}" value="${v.title}" placeholder="请输入计划名称" class="layui-input ml5 flex-sub" style="width: 200px;">
  386. <i class="layui-icon layui-icon-ok ml10" data-index=${i} data-id="${v.id}"></i>
  387. </div>
  388. </span>
  389. </div>
  390. <div class="flex-sub flex justify-end">
  391. <i class="layui-icon layui-icon-edit mr10" style="font-size: 18px;" data-index="${i}"></i>
  392. <i class="layui-icon layui-icon-delete delElement" style="font-size: 18px;" data-id="${v.id}" data-index="${i}"></i>
  393. </div>
  394. </div>
  395. <div class="planItemBox${i}">
  396. ${v.plan.map((o, x) => {
  397. return `<div class="itemPlan">
  398. <div>
  399. <span>${o.type == 0 ? '课程类' : '考试类'}:${o.title}</span>
  400. </div>
  401. <div class="flex align-center">
  402. <span class="reopen" data-index="${i}" data-oindex="${x}" data-planid="${o.plan_id}" data-id="${o.id}" data-type="${o.type}">重新选择</span>
  403. <i class="layui-icon layui-icon-delete cDelStyle" data-conid="${o.con_id}" data-id="${o.id}" data-index="${i}" data-oindex="${x}"></i>
  404. </div>
  405. </div>`;
  406. }).join('')}
  407. <div class="additemPlan" data-index="${i}" data-planid="${v.id}">
  408. <i class="layui-icon layui-icon-addition" data-index="${i}" data-planid="${v.id}"></i>
  409. <span data-index="${i}" data-planid="${v.id}">添加训练任务</span>
  410. </div>
  411. </div>
  412. </div>`
  413. }).join('');
  414. setTimeout(() => {
  415. $(".layui-icon-up").click(function() {
  416. let index = $(this).prop('dataset').index;
  417. $(`.planItemBox${index}`).toggleClass('layui-hide');
  418. $(this).toggleClass('rotate90');
  419. })
  420. //删除计划
  421. $('.delElement').click((e) => {
  422. let plan_id = parseInt(e.target.dataset.id);
  423. let delIndex = parseInt(e.target.dataset.index);
  424. layer.confirm('确定删除当前训练计划吗?', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'], }, function (index) {
  425. if (plan_id && plan_id != 'undefined') {
  426. $.ajax({
  427. url: "{:url('camp/del_plan')}",
  428. type: 'post',
  429. data: {
  430. id: plan_id
  431. },
  432. success: function (res) {
  433. if (res.code == 0) {
  434. // getTrainCampList();
  435. isChange = true;
  436. arrPlan.splice(delIndex,1);
  437. setHtml(arrPlan);
  438. layer.msg('删除成功', {
  439. time: 2000
  440. });
  441. } else {
  442. layer.msg(res.msg, {
  443. anim: 6
  444. , time: 2000
  445. });
  446. }
  447. }
  448. });
  449. } else {
  450. arrPlan.splice(delIndex, 1);
  451. setHtml(arrPlan)
  452. }
  453. layer.close(index);
  454. });
  455. })
  456. // 删除训练任务
  457. $('.cDelStyle').click((e) => {
  458. let conid = e.target.dataset.conid;
  459. let task_id = e.target.dataset.id;
  460. let p_index = parseInt(e.target.dataset.index);
  461. let c_index = parseInt(e.target.dataset.oindex);
  462. layer.confirm('确定删除当前训练任务?', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'], }, function (index) {
  463. if (conid && conid != 'undefined') {
  464. $.ajax({
  465. url: "{:url('camp/del_plan')}",
  466. type: 'post',
  467. data: {
  468. id: task_id
  469. },
  470. success: function (res) {
  471. if (res.code == 0) {
  472. // getTrainCampList();
  473. isChange = true;
  474. arrPlan[p_index].plan.splice(c_index,1);
  475. setHtml(arrPlan);
  476. layer.msg('删除成功', {
  477. time: 2000
  478. });
  479. } else {
  480. layer.msg(res.msg, {
  481. anim: 6
  482. , time: 2000
  483. });
  484. }
  485. }
  486. });
  487. } else {
  488. arrPlan[p_index].plan.splice(c_index, 1);
  489. setHtml(arrPlan);
  490. }
  491. layer.close(index);
  492. });
  493. })
  494. // 编辑计划名称
  495. $('.layui-icon-ok').click((e) => {
  496. let index = parseInt(e.target.dataset.index);
  497. let val = $(`#plan${index}`).val();
  498. let id = e.target.dataset.id;
  499. if (id && id != 'undefined') {
  500. editPlanName(val, id);
  501. } else {
  502. arrPlan[index].title = val;
  503. setHtml(arrPlan)
  504. }
  505. })
  506. $('.layui-icon-edit').click((e) => {
  507. let index = parseInt(e.target.dataset.index);
  508. setHtml(arrPlan, index);
  509. })
  510. $('.reopen').click((e) => {
  511. let type = parseInt(e.target.dataset.type);
  512. planId = e.target.dataset.planid;
  513. trainCampId = e.target.dataset.id;
  514. plan_index = parseInt(e.target.dataset.index);
  515. task_index = parseInt(e.target.dataset.oindex);
  516. if (planId && planId != 'undefined') {
  517. isEdit = true;
  518. } else {
  519. isEdit = false;
  520. }
  521. $('.mask')[0].className = 'mask';
  522. $('.item-box')[type].className = 'item-box active';
  523. if (type == 0) {
  524. $('.item-box')[1].className = 'item-box';
  525. } else {
  526. $('.item-box')[0].className = 'item-box';
  527. }
  528. })
  529. $('.additemPlan').click((e) => {
  530. if (arrPlan.length && arrPlan[arrPlan.length - 1].title == '') {
  531. layer.msg('请完善计划名称', {
  532. anim: 6
  533. , time: 2000
  534. });
  535. return;
  536. }
  537. plan_index = parseInt(e.target.dataset.index);
  538. task_index = null;
  539. isEdit = false;
  540. planId = e.target.dataset.planid;
  541. $('.mask')[0].className = 'mask';
  542. })
  543. }, 100)
  544. }
  545. $('.layui-icon-close,.cancel').click(() => {
  546. $('.mask')[0].className = 'mask layui-hide';
  547. })
  548. function handleParams() {
  549. let arrayTrainPlan = JSON.parse(JSON.stringify(arrPlan));
  550. let arr = arrayTrainPlan.filter(v => {
  551. if (!v.id) {
  552. return v;
  553. } else {
  554. v.plan = v.plan.filter(o => !o.con_id);
  555. return v;
  556. }
  557. }).filter(x => {
  558. if (x.plan.length) {
  559. return { title: x.title, plan: x.plan };
  560. }
  561. });
  562. return arr;
  563. }
  564. // 返回上一级
  565. $('.link').click(() => {
  566. let data = handleParams();
  567. if (data.length) {
  568. layer.confirm('您还有数据未保存,确定离开吗', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'], }, function (index) {
  569. window.history.back(-1);
  570. layer.close(index);
  571. });
  572. } else {
  573. window.history.back(-1);
  574. }
  575. })
  576. $('.submitMsg').click(() => {
  577. if (arrPlan.length && arrPlan[arrPlan.length - 1].title == '') {
  578. layer.msg('请完善计划名称', {
  579. anim: 6
  580. , time: 2000
  581. });
  582. return;
  583. }
  584. let data = handleParams();
  585. if (isChange && !data.length) {
  586. layer.msg('保存成功', {
  587. time: 2000
  588. });
  589. setTimeout(() => {
  590. isChange = false;
  591. window.history.back(-1);
  592. sessionStorage.setItem('Dialog',true);
  593. }, 1000)
  594. return;
  595. }
  596. if (!data.length) {
  597. layer.msg('保存成功', {
  598. time: 2000
  599. });
  600. setTimeout(() => {
  601. isChange = false;
  602. window.history.back(-1);
  603. sessionStorage.setItem('Dialog',true);
  604. }, 1000)
  605. return;
  606. }
  607. if (!loading) {
  608. loading = true;
  609. $.ajax({
  610. url: "{:url('camp/save')}",
  611. data: {
  612. camp_id: "{$id}",
  613. arr: data
  614. },
  615. dataType: 'json',
  616. type: 'post',
  617. success: function (res) {
  618. if (res.code == 0) {
  619. getTrainCampList();
  620. layer.msg('保存成功', {
  621. time: 2000
  622. });
  623. setTimeout(() => {
  624. window.history.back(-1);
  625. sessionStorage.setItem('Dialog',true);
  626. }, 1000)
  627. } else {
  628. layer.msg(res.msg, {
  629. anim: 6
  630. , time: 2000
  631. });
  632. }
  633. loading = false;
  634. }
  635. })
  636. } else {
  637. layer.msg('正在保存数据', {
  638. anim: 6
  639. , time: 2000
  640. });
  641. }
  642. })
  643. //获取已选中的课程数据
  644. function getAllCourseTaskIds() {
  645. let arrTask = JSON.parse(JSON.stringify(arrPlan));
  646. let arr = [];
  647. arrTask.forEach(v => {
  648. let ids = v.plan.filter(w => !w.con_id && w.type == '0');
  649. if (ids.length) {
  650. arr.push(...ids)
  651. }
  652. })
  653. return arr;
  654. }
  655. //获取已选中的试卷数据
  656. function getAllTestPaperTaskIds() {
  657. let arrTask = JSON.parse(JSON.stringify(arrPlan));
  658. let arr = [];
  659. arrTask.forEach(v => {
  660. let ids = v.plan.filter(w => !w.con_id && w.type == '1');
  661. if (ids.length) {
  662. arr.push(...ids)
  663. }
  664. })
  665. return arr;
  666. }
  667. $('.item-box').click((e) => {
  668. if (e.target.dataset.index == 0) {
  669. e.target.className = 'item-box active';
  670. $('.item-box')[1].className = 'item-box';
  671. } else {
  672. e.target.className = 'item-box active';
  673. $('.item-box')[0].className = 'item-box';
  674. }
  675. let p = $('.active').prop('dataset');
  676. addType = p.index;
  677. if (addType == '0') {
  678. var task_ids = getAllCourseTaskIds().map(v => v.id).join(',');
  679. layer.open({
  680. type: 2,
  681. title: ['选择课程', 'color:#333333;background-color:#D8E6F1;'],
  682. content: '{:url("camp/class_choice_course")}?camp_id=' + "{$id}" + "&taskIds=" + task_ids,
  683. area: ['80%', '80%'],
  684. btn: ['确定', '取消'],
  685. yes: function (index, layero) {
  686. //点击确认触发 iframe 内容中的按钮提交
  687. var classCourse = JSON.parse(layero.find('iframe').contents().find("#hiddentext").val()); //获取选中的课程
  688. if (!isEdit) {
  689. if (task_index || task_index == 0) {
  690. arrPlan[plan_index].plan[task_index] = { type: '0', title: classCourse[0].title, id: classCourse[0].id };
  691. } else {
  692. classCourse.forEach(v => {
  693. let arr = arrPlan[plan_index].plan.filter(w => w.id == v.id || v.id == w.con_id);
  694. if (!arr.length) {
  695. arrPlan[plan_index].plan.push({ type: '0', title: v.title, id: v.id });
  696. }
  697. });
  698. }
  699. setHtml(arrPlan);
  700. } else {
  701. arrPlan[plan_index].plan[task_index] = { type: '0', title: classCourse[0].title, id: classCourse[0].id };
  702. editTrainCamp(trainCampId, planId, addType, classCourse[0].title, classCourse[0].id);
  703. }
  704. layer.close(index);
  705. }
  706. });
  707. } else {
  708. var task_ids = getAllTestPaperTaskIds().map(v => v.id).join(',');
  709. layer.open({
  710. type: 2,
  711. title: ['选择试卷', 'color:#333333;background-color:#D8E6F1;'],
  712. content: '{:url("camp/choice_test_paper")}?camp_id=' + "{$id}" + "&taskIds=" + task_ids,
  713. area: ['80%', '80%'],
  714. btn: ['确定', '取消'],
  715. yes: function (index, layero) {
  716. //点击确认触发 iframe 内容中的按钮提交
  717. var testPaper = JSON.parse(layero.find('iframe').contents().find("#hiddentext").val()); //获取选中的课程
  718. if (!isEdit) {
  719. if (task_index || task_index == 0) {
  720. arrPlan[plan_index].plan[task_index] = { type: '1', title: testPaper[0].name, id: testPaper[0].id };
  721. } else {
  722. testPaper.forEach(v => {
  723. let arr = arrPlan[plan_index].plan.filter(w => w.id == v.id || v.id == w.con_id);
  724. if (!arr.length) {
  725. arrPlan[plan_index].plan.push({ type: '1', title: v.name, id: v.id });
  726. }
  727. });
  728. }
  729. setHtml(arrPlan);
  730. } else {
  731. arrPlan[plan_index].plan[task_index] = { type: '1', title: testPaper[0].name, id: testPaper[0].id };
  732. editTrainCamp(trainCampId, planId, addType, testPaper[0].name, testPaper[0].id);
  733. }
  734. layer.close(index);
  735. }
  736. });
  737. }
  738. $('.mask')[0].className = 'mask layui-hide';
  739. })
  740. $('.addPlan').click(() => {
  741. if (arrPlan.length && arrPlan[arrPlan.length - 1].title == '') {
  742. layer.msg('请完善计划名称', {
  743. anim: 6
  744. , time: 2000
  745. });
  746. return;
  747. }
  748. arrPlan.push({ title: '', plan: [] });
  749. setHtml(arrPlan, (arrPlan.length - 1))
  750. })
  751. $('.layui-btn.layuiadmin-btn').on('click', function () {
  752. var type = $(this).data('type');
  753. active[type] ? active[type].call(this) : '';
  754. });
  755. });
  756. </script>
  757. {/block}