edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <view>
  3. <nav-bar title="修改计划"></nav-bar>
  4. <view class="list_box">
  5. <view class="item" v-for="(item, index) in list" :key="index">
  6. <image :src="item.coverUrl"></image>
  7. <view style="height: 80rpx;overflow: hidden;">
  8. <text >{{ item.goodsName }}</text>
  9. <text style="color:#999;margin-left:12rpx;">{{ item.secAllNum }}节</text>
  10. </view>
  11. <view class="del_icon"><u-icon name="close" color="#fff" size="20" @click="delItem(index)"></u-icon></view>
  12. </view>
  13. <view class="item" style="vertical-align: top;">
  14. <view class="item_add" @click="openSel"><u-icon name="plus-circle-fill" color="#007AFF" size="32"></u-icon></view>
  15. <view style="color:#999;text-align: center;">添加网课</view>
  16. </view>
  17. </view>
  18. <view class="list_box form">
  19. <u-form :model="form" ref="uForm">
  20. <u-form-item label="课程类型" :label-width="auto">
  21. <view style="line-height: 40rpx;text-align: right;" v-if="form.category">{{ form.category }}</view>
  22. <view v-else style="text-align: right;">请添加网课</view>
  23. </u-form-item>
  24. <!-- <u-form-item label="考试日期" prop="birth" :label-width="auto">
  25. <picker mode="date" :value="form.date" @change="bindDateChange">
  26. <view class="picker">{{ form.date }}</view>
  27. </picker>
  28. </u-form-item> -->
  29. <u-form-item label="学习提醒" prop="birth" :label-width="auto">
  30. <picker mode="time" :value="form.time" @change="bindTimeChange">
  31. <view class="picker">{{ form.time }}</view>
  32. </picker>
  33. </u-form-item>
  34. <u-form-item label="学习频率" :label-width="auto">
  35. <view class="picker" @click="openWeek">{{ form.week }}</view>
  36. </u-form-item>
  37. <u-form-item label="复习天数" :label-width="auto">
  38. <picker @change="bindPickerChangeReview" :value="index_review" :range="array_review">
  39. <view class="picker">{{ array_review[index_review] }}</view>
  40. </picker>
  41. </u-form-item>
  42. <u-form-item label="起止日期" :label-width="auto">
  43. <view class="picker" @click="openCalendar">{{ form.startDate }}~{{ form.endDate }}</view>
  44. </u-form-item>
  45. </u-form>
  46. </view>
  47. <view class="list_box form">
  48. <view class="dis_ss">
  49. <image src="@/static/icon/computeIcon.png" style="width:32rpx;height:32rpx;" mode=""></image>
  50. <text class="getNums" @click="resultForm(1)">点击计算</text>
  51. </view>
  52. <view style="padding: 25rpx 0rpx; color: #999;text-align: center;font-size: 30rpx;">
  53. 根据当前计划每个学习日需完成
  54. <text style="color: #FF9500;margin: 0rpx 10rpx;font-size: 30rpx;font-weight: bold;">{{ studyNums }}</text>
  55. 个学时
  56. </view>
  57. </view>
  58. <u-calendar v-model="calendar_show" :min-date="minDate" :mode="calendar" @change="change" :max-date="maxDate"></u-calendar>
  59. <!-- 弹框-->
  60. <u-popup v-model="week_show" mode="bottom" @close="weekPopClose">
  61. <view style="height: 450rpx;">
  62. <view style="padding-top: 20rpx;padding-left: 40rpx;padding-right:40rpx;">
  63. <u-checkbox-group @change="checkboxGroupChange" width="100%">
  64. <u-checkbox v-model="item.checked" v-for="(item, index) in list3" :key="index" :name="item.name">
  65. <view style="width:660rpx;">{{ item.name }}</view>
  66. </u-checkbox>
  67. </u-checkbox-group>
  68. <!-- <view class="title_l" @click="week_submit" style="margin: 50rpx auto;">确认</view> -->
  69. </view>
  70. </view>
  71. </u-popup>
  72. <u-popup v-model="show" mode="bottom">
  73. <view class="popup_box">
  74. <view>
  75. <view class="line1"></view>
  76. <view class="grade">选择课程</view>
  77. <u-line></u-line>
  78. </view>
  79. <view class="popup_list" v-if="list2.length !== 0">
  80. <scroll-view @scrolltolower="scrolltolower" class="list_in" scroll-y="true">
  81. <view class="popup_item" v-for="(item, index) in list2" :key="index" @click="selectToast(item)" v-if="index < indexRange">
  82. <u-checkbox
  83. :disabled="item.disabled"
  84. @change="checkboxChange"
  85. shape="circle"
  86. active-color="#007AFF"
  87. v-model="item.checked"
  88. :key="index"
  89. :name="item.goodsId"
  90. >
  91. <view class="course_item" :class="{selected:item.checked}">
  92. <view style="display: flex;align-items: center;"><image :src="item.coverUrl" style="width: 278rpx;height: 134rpx;"></image></view>
  93. <view style="margin: 16rpx;">
  94. <view>{{ item.goodsName }}</view>
  95. <view style="color:#999;">{{ item.secAllNum }}节</view>
  96. </view>
  97. </view>
  98. </u-checkbox>
  99. </view>
  100. </scroll-view>
  101. </view>
  102. <view class="popup_list" v-else><u-empty text="请前往购买课程" mode="list"></u-empty></view>
  103. <view class="submit_wrap">
  104. <view class="title_l" @click="submit">确认</view>
  105. </view>
  106. </view>
  107. </u-popup>
  108. <view @click="resultForm" class="submit_btn">确认计划</view>
  109. </view>
  110. </template>
  111. <script>
  112. export default {
  113. data() {
  114. return {
  115. week_show: false,
  116. form: {
  117. category: '',
  118. // date: '2021-01-01',
  119. time: '20:30',
  120. startDate: '2021-05-07',
  121. endDate: '2021-05-31',
  122. week: '每周一、每周三、每周五'
  123. },
  124. businessId:'',
  125. calendar: 'range',
  126. list: [],
  127. list2: [],
  128. param:{
  129. pageSize:10,
  130. pageNum:0,
  131. },
  132. indexRange:10,
  133. show: false,
  134. calendar_show: false,
  135. maxDate: '2023-01-01',
  136. minDate: '',
  137. list3: [
  138. {
  139. name: '每周日',
  140. checked: false,
  141. disabled: false,
  142. id: 0
  143. },
  144. {
  145. name: '每周一',
  146. checked: false,
  147. disabled: false,
  148. id: 1
  149. },
  150. {
  151. name: '每周二',
  152. checked: false,
  153. disabled: false,
  154. id: 2
  155. },
  156. {
  157. name: '每周三',
  158. checked: false,
  159. disabled: false,
  160. id: 3
  161. },
  162. {
  163. name: '每周四',
  164. checked: false,
  165. disabled: false,
  166. id: 4
  167. },
  168. {
  169. name: '每周五',
  170. checked: false,
  171. disabled: false,
  172. id: 5
  173. },
  174. {
  175. name: '每周六',
  176. checked: false,
  177. disabled: false,
  178. id: 6
  179. }
  180. ],
  181. selWeek: '',
  182. index_review: 4,
  183. array_review: [0,1, 2, 3, 4, 5, 6, 7],
  184. planId: null,
  185. studyNums: '?'
  186. };
  187. },
  188. onLoad(option) {
  189. this.planId = Number(option.id);
  190. this.minDate = this.$method.timestampToTime(new Date().getTime() / 1000).replace(/-/g,'/');
  191. this.form.startDate = this.minDate;
  192. this.form.endDate = this.$method.timestampToTime(new Date().getTime() / 1000 + 24 * 3600 * 30).replace(/-/g,'/');
  193. this.getGoods();
  194. this.getInfo();
  195. },
  196. onShow() {},
  197. methods: {
  198. scrolltolower(e) {
  199. this.indexRange += 10;
  200. },
  201. getGoods() {
  202. var self = this;
  203. self.$api.courseGoodsList().then(res => {
  204. if (res.data.code === 200) {
  205. if (res.data.rows.length) {
  206. for (let i = 0; i < res.data.rows.length; i++) {
  207. res.data.rows[i].checked = false;
  208. res.data.rows[i].disabled = false;
  209. res.data.rows[i].coverUrl = self.$method.splitImgHost(res.data.rows[i].coverUrl);
  210. }
  211. }
  212. self.list2 = res.data.rows;
  213. }
  214. });
  215. },
  216. resultForm(int) {
  217. if (this.list.length == 0) {
  218. uni.showModal({
  219. title: '提示',
  220. content: '请选择课程',
  221. showCancel: false
  222. });
  223. return;
  224. }
  225. // if (this.form.week == '请选择') {
  226. // uni.showModal({
  227. // title: '提示',
  228. // content: '请选择学习频率',
  229. // showCancel: false
  230. // });
  231. // return;
  232. // }
  233. let goodsId = [];
  234. for (let i = 0; i < this.list.length; i++) {
  235. goodsId.push(this.list[i].goodsId);
  236. }
  237. let ss = this.form.week.split('、');
  238. let weekArray = [];
  239. for (let i = 0; i < ss.length; i++) {
  240. if (ss[i] == '每周日') {
  241. weekArray.push(0);
  242. }
  243. if (ss[i] == '每周一') {
  244. weekArray.push(1);
  245. }
  246. if (ss[i] == '每周二') {
  247. weekArray.push(2);
  248. }
  249. if (ss[i] == '每周三') {
  250. weekArray.push(3);
  251. }
  252. if (ss[i] == '每周四') {
  253. weekArray.push(4);
  254. }
  255. if (ss[i] == '每周五') {
  256. weekArray.push(5);
  257. }
  258. if (ss[i] == '每周六') {
  259. weekArray.push(6);
  260. }
  261. }
  262. let data = {
  263. goodsId: goodsId,
  264. reminderTime: this.form.time,
  265. // examDate: this.$method.TimeTotimestamp(this.form.date),
  266. startTime: this.$method.TimeTotimestamp(this.form.startDate),
  267. endTime: this.$method.TimeTotimestamp(this.form.endDate),
  268. studyCount: weekArray,
  269. studyDay: this.array_review[this.index_review],
  270. status: 1
  271. };
  272. console.log(data);
  273. if (int === 1) {
  274. this.$api.getsystemplanlistPlan(data).then(result => {
  275. if (result.data.code == 200) {
  276. this.studyNums = result.data.data.studyCourseKnob;
  277. } else {
  278. uni.showToast({
  279. title: result.data.msg,
  280. icon: 'none',
  281. duration: 2000
  282. });
  283. }
  284. });
  285. } else {
  286. data.planId = this.planId;
  287. this.$api.editsystemplan(data).then(result => {
  288. if (result.data.code == 200) {
  289. uni.showModal({
  290. title: '提示',
  291. content: '提交成功',
  292. showCancel: false,
  293. success: function (res) {
  294. if (res.confirm) {
  295. uni.navigateBack();
  296. }
  297. }
  298. });
  299. } else {
  300. uni.showToast({
  301. title: result.data.msg,
  302. icon: 'none',
  303. duration: 2000
  304. });
  305. }
  306. });
  307. }
  308. },
  309. selItem(item) {
  310. console.log(34);
  311. item.checked = !item.checked;
  312. },
  313. selectToast(item) {
  314. if(item.disabled) {
  315. uni.showToast({
  316. icon:'none',
  317. title:'选择网课(只能选同类课程)',
  318. duration:3000
  319. })
  320. }
  321. },
  322. getInfo(int) {
  323. var self = this;
  324. this.$api.systemplanInfo({planId:this.planId}).then(res => {
  325. this.form.date = this.$method.timestampToTime(res.data.data.examDate).replace(/-/g,'/');
  326. this.form.time = res.data.data.reminderTime;
  327. this.form.startDate = this.$method.timestampToTime(res.data.data.startTime).replace(/-/g,'/');
  328. this.form.endDate = this.$method.timestampToTime(res.data.data.endTime).replace(/-/g,'/');
  329. this.index_review = res.data.data.studyDay;
  330. this.form.week = res.data.data.studyCount;
  331. res.data.data.goodsVos.forEach(item => {
  332. item.coverUrl = this.$method.splitImgHost(item.coverUrl)
  333. })
  334. this.list = res.data.data.goodsVos;
  335. this.businessId = res.data.data.goodsVos[0].businessId;
  336. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  337. var numWeek = [];
  338. this.form.week.forEach((items, indexs) => {
  339. if (items === 1) {
  340. numWeek.push('每周一');
  341. return;
  342. }
  343. if (items === 2) {
  344. numWeek.push('每周二');
  345. return;
  346. }
  347. if (items === 3) {
  348. numWeek.push('每周三');
  349. return;
  350. }
  351. if (items === 4) {
  352. numWeek.push('每周四');
  353. return;
  354. }
  355. if (items === 5) {
  356. numWeek.push('每周五');
  357. return;
  358. }
  359. if (items === 6) {
  360. numWeek.push('每周六');
  361. return;
  362. }
  363. if (items === 0) {
  364. numWeek.push('每周日');
  365. return;
  366. }
  367. });
  368. this.form.week = numWeek.join('、');
  369. this.resultForm(1);
  370. });
  371. },
  372. bindPickerChangeReview(e) {
  373. this.index_review = e.detail.value;
  374. },
  375. week_submit() {
  376. if (this.selWeek == '') {
  377. uni.showModal({
  378. title: '提示',
  379. content: '至少选择一个'
  380. });
  381. return;
  382. }
  383. this.form.week = this.selWeek;
  384. this.week_show = false;
  385. },
  386. weekPopClose() {
  387. this.form.week = this.selWeek;
  388. },
  389. openWeek() {
  390. this.week_show = true;
  391. this.selWeek = this.form.week;
  392. let that = this;
  393. this.list3.map(val => {
  394. val.checked = false;
  395. if (that.form.week.indexOf(val.name) != -1) {
  396. val.checked = true;
  397. }
  398. });
  399. },
  400. checkboxGroupChange(e) {
  401. this.selWeek = e.join('、');
  402. },
  403. openCalendar() {
  404. this.calendar_show = true;
  405. },
  406. change(e) {
  407. console.log(e);
  408. this.form.startDate = e.startDate;
  409. this.form.endDate = e.endDate;
  410. },
  411. bindTimeChange(e) {
  412. this.form.time = e.detail.value;
  413. },
  414. bindDateChange(e) {
  415. this.form.date = e.detail.value;
  416. },
  417. submit() {
  418. let that = this;
  419. this.list2.map(val => {
  420. if (val.checked) {
  421. that.list.push(val);
  422. }
  423. });
  424. this.checkSameItem();
  425. this.show = false;
  426. if (this.list.length) {
  427. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  428. }
  429. },
  430. checkboxChange(e) {
  431. let goodsId = e.name;
  432. if(e.value) { //勾选
  433. this.businessId = this.list2.find(listItem => listItem.goodsId == goodsId).businessId;
  434. this.list2.forEach(listItem => {
  435. if(listItem.businessId != this.businessId) {
  436. listItem.disabled = true;
  437. }
  438. })
  439. } else { //取消
  440. this.$nextTick(() => {
  441. let checkedNum = this.list2.filter(listItem => {
  442. if(listItem.checked) {
  443. return true;
  444. } else {
  445. if(this.list.length) {
  446. return true;
  447. } else {
  448. return false;
  449. }
  450. }
  451. }).length;
  452. if(checkedNum == 0) { //全部取消,且没有已选择的
  453. this.businessId = '';
  454. this.list2.forEach(listItem => {
  455. console.log(listItem)
  456. listItem.disabled = false;
  457. })
  458. }
  459. })
  460. }
  461. },
  462. checkSameItem() {
  463. this.list2.map(val => {
  464. val.disabled = false;
  465. if(this.businessId) {
  466. if(val.businessId != this.businessId) {
  467. val.disabled = true;
  468. }
  469. }
  470. this.list.map(val1 => {
  471. if (val.goodsId == val1.goodsId) {
  472. val.disabled = true;
  473. }
  474. val.checked = false;
  475. });
  476. });
  477. },
  478. delItem(index, ids) {
  479. this.list.splice(index, 1);
  480. if (this.list.length === 0) {
  481. this.businessId = '';
  482. this.form.category = '';
  483. } else {
  484. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  485. }
  486. },
  487. openSel() {
  488. this.show = true;
  489. this.checkSameItem();
  490. }
  491. }
  492. };
  493. </script>
  494. <style>
  495. ::-webkit-scrollbar {
  496. width: 0;
  497. height: 0;
  498. color: transparent;
  499. }
  500. .u-drawer-content-visible {
  501. border-radius: 32rpx 32rpx 0rpx 0rpx;
  502. overflow: hidden;
  503. }
  504. </style>
  505. <style scope lang="scss">
  506. .dis_ss {
  507. display: flex;
  508. align-items: center;
  509. justify-content: center;
  510. width: 100%;
  511. padding: 22rpx 0rpx;
  512. border-bottom: 1rpx solid #eee;
  513. }
  514. .getNums {
  515. margin-left: 14rpx;
  516. color: #007aff;
  517. font-size: 30rpx;
  518. font-weight: bold;
  519. display: inline-block;
  520. text-decoration: underline;
  521. }
  522. .submit_btn {
  523. width: 526rpx;
  524. height: 80rpx;
  525. background: #007aff;
  526. border-radius: 40rpx;
  527. text-align: center;
  528. line-height: 80rpx;
  529. color: #ffffff;
  530. margin: 30rpx auto;
  531. }
  532. .picker {
  533. text-align: right;
  534. }
  535. .form {
  536. padding: 0 16rpx !important;
  537. margin-top: 16rpx;
  538. }
  539. input {
  540. text-align: right;
  541. }
  542. .popup_item {
  543. width: 100%;
  544. border-radius: 32rpx;
  545. margin: 10rpx 0;
  546. padding: 0 20rpx;
  547. display: flex;
  548. .course_item {
  549. display: flex;
  550. align-items: center;
  551. width:660rpx;
  552. padding:26rpx;
  553. &.selected {
  554. background:#EBF5FF;
  555. border-radius: 24rpx;
  556. }
  557. }
  558. }
  559. .popup_list {
  560. position:relative;
  561. flex:1;
  562. padding: 0 20rpx;
  563. .list_in {
  564. position: absolute;
  565. left:0;
  566. top:0;
  567. width:100%;
  568. height:100%;
  569. overflow: scroll;
  570. }
  571. }
  572. .submit_wrap {
  573. border-top:1px solid #eee;
  574. background:#fff;
  575. padding:18rpx 0;
  576. .title_l {
  577. margin:0 auto;
  578. text-align: center;
  579. line-height: 64rpx;
  580. width: 200rpx;
  581. height: 64rpx;
  582. background: linear-gradient(0deg, #015EEA, #00C0FA);
  583. border-radius: 32rpx;
  584. color:#fff;
  585. font-size: 30rpx;
  586. }
  587. }
  588. .title_r {
  589. font-size: 30rpx;
  590. font-family: PingFang SC;
  591. font-weight: bold;
  592. color: #2f4379;
  593. }
  594. .grade {
  595. font-size: 24rpx;
  596. color: #999999;
  597. margin: 0 auto;
  598. margin: 10rpx 0;
  599. text-align: center;
  600. }
  601. .line1 {
  602. width: 80rpx;
  603. height: 8rpx;
  604. background: #999999;
  605. border-radius: 4rpx;
  606. margin: 0 auto;
  607. margin-top: 15rpx;
  608. }
  609. .popup_box {
  610. height: 680rpx;
  611. display: flex;
  612. flex-direction: column;
  613. }
  614. .del_icon {
  615. border-radius:50%;
  616. overflow: hidden;
  617. background:rgba(255,54,87,1);
  618. width: 30rpx;
  619. height: 30rpx;
  620. position: absolute;
  621. right: -15rpx;
  622. top: -15rpx;
  623. display: flex;
  624. align-items: center;
  625. justify-content: center;
  626. }
  627. .item_add {
  628. background: #f9f9f9;
  629. border-radius: 14rpx;
  630. width: 100%;
  631. height: 134rpx;
  632. text-align: center;
  633. line-height: 134rpx;
  634. }
  635. .item text {
  636. font-size: 24rpx;
  637. color: #0c141f;
  638. }
  639. .item image {
  640. border-radius: 14rpx;
  641. width: 100%;
  642. height: 134rpx;
  643. }
  644. .item {
  645. width:278rpx;
  646. display: inline-block;
  647. position: relative;
  648. margin-right:16rpx;
  649. }
  650. .list_box {
  651. width: 100%;
  652. background: #ffffff;
  653. border-radius: 16rpx;
  654. padding: 24rpx;
  655. }
  656. page {
  657. background:rgba(234,238,241,1)
  658. }
  659. </style>