edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  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 class="list_in" scroll-y="true">
  81. <view class="popup_item" v-for="(item, index) in list2" :key="index">
  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. show: false,
  129. calendar_show: false,
  130. maxDate: '2023-01-01',
  131. minDate: '',
  132. list3: [
  133. {
  134. name: '每周日',
  135. checked: false,
  136. disabled: false,
  137. id: 0
  138. },
  139. {
  140. name: '每周一',
  141. checked: false,
  142. disabled: false,
  143. id: 1
  144. },
  145. {
  146. name: '每周二',
  147. checked: false,
  148. disabled: false,
  149. id: 2
  150. },
  151. {
  152. name: '每周三',
  153. checked: false,
  154. disabled: false,
  155. id: 3
  156. },
  157. {
  158. name: '每周四',
  159. checked: false,
  160. disabled: false,
  161. id: 4
  162. },
  163. {
  164. name: '每周五',
  165. checked: false,
  166. disabled: false,
  167. id: 5
  168. },
  169. {
  170. name: '每周六',
  171. checked: false,
  172. disabled: false,
  173. id: 6
  174. }
  175. ],
  176. selWeek: '',
  177. index_review: 4,
  178. array_review: [0,1, 2, 3, 4, 5, 6, 7],
  179. planId: null,
  180. studyNums: '?'
  181. };
  182. },
  183. onLoad(option) {
  184. this.planId = Number(option.id);
  185. this.minDate = this.$method.timestampToTime(new Date().getTime() / 1000);
  186. this.form.startDate = this.minDate;
  187. this.form.endDate = this.$method.timestampToTime(new Date().getTime() / 1000 + 24 * 3600 * 30);
  188. this.getGoods();
  189. this.getInfo();
  190. },
  191. onShow() {},
  192. methods: {
  193. getGoods() {
  194. var self = this;
  195. self.$api.courseGoodsList().then(res => {
  196. if (res.data.code === 200) {
  197. if (res.data.rows.length) {
  198. for (let i = 0; i < res.data.rows.length; i++) {
  199. res.data.rows[i].checked = false;
  200. res.data.rows[i].disabled = false;
  201. res.data.rows[i].coverUrl = self.$method.splitImgHost(res.data.rows[i].coverUrl);
  202. }
  203. }
  204. self.list2 = res.data.rows;
  205. }
  206. });
  207. },
  208. resultForm(int) {
  209. if (this.list.length == 0) {
  210. uni.showModal({
  211. title: '提示',
  212. content: '请选择课程',
  213. showCancel: false
  214. });
  215. return;
  216. }
  217. // if (this.form.week == '请选择') {
  218. // uni.showModal({
  219. // title: '提示',
  220. // content: '请选择学习频率',
  221. // showCancel: false
  222. // });
  223. // return;
  224. // }
  225. let goodsId = [];
  226. for (let i = 0; i < this.list.length; i++) {
  227. goodsId.push(this.list[i].goodsId);
  228. }
  229. let ss = this.form.week.split('、');
  230. let weekArray = [];
  231. for (let i = 0; i < ss.length; i++) {
  232. if (ss[i] == '每周日') {
  233. weekArray.push(0);
  234. }
  235. if (ss[i] == '每周一') {
  236. weekArray.push(1);
  237. }
  238. if (ss[i] == '每周二') {
  239. weekArray.push(2);
  240. }
  241. if (ss[i] == '每周三') {
  242. weekArray.push(3);
  243. }
  244. if (ss[i] == '每周四') {
  245. weekArray.push(4);
  246. }
  247. if (ss[i] == '每周五') {
  248. weekArray.push(5);
  249. }
  250. if (ss[i] == '每周六') {
  251. weekArray.push(6);
  252. }
  253. }
  254. let data = {
  255. goodsId: goodsId,
  256. reminderTime: this.form.time,
  257. examDate: this.$method.TimeTotimestamp(this.form.date),
  258. startTime: this.$method.TimeTotimestamp(this.form.startDate),
  259. endTime: this.$method.TimeTotimestamp(this.form.endDate),
  260. studyCount: weekArray,
  261. studyDay: this.array_review[this.index_review],
  262. status: 1
  263. };
  264. console.log(data);
  265. if (int === 1) {
  266. this.$api.getsystemplanlistPlan(data).then(result => {
  267. if (result.data.code == 200) {
  268. this.studyNums = result.data.data.studyCourseKnob;
  269. } else {
  270. uni.showToast({
  271. title: result.data.msg,
  272. icon: 'none',
  273. duration: 2000
  274. });
  275. }
  276. });
  277. } else {
  278. data.planId = this.planId;
  279. this.$api.editsystemplan(data).then(result => {
  280. if (result.data.code == 200) {
  281. uni.showModal({
  282. title: '提示',
  283. content: '提交成功',
  284. showCancel: false,
  285. success: function (res) {
  286. if (res.confirm) {
  287. uni.navigateBack();
  288. }
  289. }
  290. });
  291. } else {
  292. uni.showToast({
  293. title: result.data.msg,
  294. icon: 'none',
  295. duration: 2000
  296. });
  297. }
  298. });
  299. }
  300. },
  301. selItem(item) {
  302. console.log(34);
  303. item.checked = !item.checked;
  304. },
  305. getInfo(int) {
  306. var self = this;
  307. this.$api.systemplanInfo({planId:this.planId}).then(res => {
  308. this.form.date = this.$method.timestampToTime(res.data.data.examDate);
  309. this.form.time = res.data.data.reminderTime;
  310. this.form.startDate = this.$method.timestampToTime(res.data.data.startTime);
  311. this.form.endDate = this.$method.timestampToTime(res.data.data.endTime);
  312. this.index_review = res.data.data.studyDay - 1;
  313. this.form.week = res.data.data.studyCount;
  314. res.data.data.goodsVos.forEach(item => {
  315. item.coverUrl = this.$method.splitImgHost(item.coverUrl)
  316. })
  317. this.list = res.data.data.goodsVos;
  318. this.businessId = res.data.data.goodsVos[0].businessId;
  319. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  320. var numWeek = [];
  321. this.form.week.forEach((items, indexs) => {
  322. if (items === 1) {
  323. numWeek.push('每周一');
  324. return;
  325. }
  326. if (items === 2) {
  327. numWeek.push('每周二');
  328. return;
  329. }
  330. if (items === 3) {
  331. numWeek.push('每周三');
  332. return;
  333. }
  334. if (items === 4) {
  335. numWeek.push('每周四');
  336. return;
  337. }
  338. if (items === 5) {
  339. numWeek.push('每周五');
  340. return;
  341. }
  342. if (items === 6) {
  343. numWeek.push('每周六');
  344. return;
  345. }
  346. if (items === 0) {
  347. numWeek.push('每周日');
  348. return;
  349. }
  350. });
  351. this.form.week = numWeek.join('、');
  352. this.resultForm(1);
  353. });
  354. },
  355. bindPickerChangeReview(e) {
  356. this.index_review = e.detail.value;
  357. },
  358. week_submit() {
  359. if (this.selWeek == '') {
  360. uni.showModal({
  361. title: '提示',
  362. content: '至少选择一个'
  363. });
  364. return;
  365. }
  366. this.form.week = this.selWeek;
  367. this.week_show = false;
  368. },
  369. weekPopClose() {
  370. this.form.week = this.selWeek;
  371. },
  372. openWeek() {
  373. this.week_show = true;
  374. this.selWeek = this.form.week;
  375. let that = this;
  376. this.list3.map(val => {
  377. val.checked = false;
  378. if (that.form.week.indexOf(val.name) != -1) {
  379. val.checked = true;
  380. }
  381. });
  382. },
  383. checkboxGroupChange(e) {
  384. this.selWeek = e.join('、');
  385. },
  386. openCalendar() {
  387. this.calendar_show = true;
  388. },
  389. change(e) {
  390. console.log(e);
  391. this.form.startDate = e.startDate;
  392. this.form.endDate = e.endDate;
  393. },
  394. bindTimeChange(e) {
  395. this.form.time = e.detail.value;
  396. },
  397. bindDateChange(e) {
  398. this.form.date = e.detail.value;
  399. },
  400. submit() {
  401. let that = this;
  402. this.list2.map(val => {
  403. if (val.checked) {
  404. that.list.push(val);
  405. }
  406. });
  407. this.checkSameItem();
  408. this.show = false;
  409. if (this.list.length) {
  410. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  411. }
  412. },
  413. checkboxChange(e) {
  414. let goodsId = e.name;
  415. if(e.value) { //勾选
  416. this.businessId = this.list2.find(listItem => listItem.goodsId == goodsId).businessId;
  417. this.list2.forEach(listItem => {
  418. if(listItem.businessId != this.businessId) {
  419. listItem.disabled = true;
  420. }
  421. })
  422. } else { //取消
  423. this.$nextTick(() => {
  424. let checkedNum = this.list2.filter(listItem => {
  425. if(listItem.checked) {
  426. return true;
  427. } else {
  428. if(this.list.length) {
  429. return true;
  430. } else {
  431. return false;
  432. }
  433. }
  434. }).length;
  435. if(checkedNum == 0) { //全部取消,且没有已选择的
  436. this.businessId = '';
  437. this.list2.forEach(listItem => {
  438. console.log(listItem)
  439. listItem.disabled = false;
  440. })
  441. }
  442. })
  443. }
  444. },
  445. checkSameItem() {
  446. this.list2.map(val => {
  447. val.disabled = false;
  448. if(this.businessId) {
  449. if(val.businessId != this.businessId) {
  450. val.disabled = true;
  451. }
  452. }
  453. this.list.map(val1 => {
  454. if (val.goodsId == val1.goodsId) {
  455. val.disabled = true;
  456. }
  457. val.checked = false;
  458. });
  459. });
  460. },
  461. delItem(index, ids) {
  462. this.list.splice(index, 1);
  463. if (this.list.length === 0) {
  464. this.businessId = '';
  465. this.form.category = '';
  466. } else {
  467. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  468. }
  469. },
  470. openSel() {
  471. this.show = true;
  472. this.checkSameItem();
  473. }
  474. }
  475. };
  476. </script>
  477. <style>
  478. ::-webkit-scrollbar {
  479. width: 0;
  480. height: 0;
  481. color: transparent;
  482. }
  483. .u-drawer-content-visible {
  484. border-radius: 32rpx 32rpx 0rpx 0rpx;
  485. overflow: hidden;
  486. }
  487. </style>
  488. <style scope lang="scss">
  489. .dis_ss {
  490. display: flex;
  491. align-items: center;
  492. justify-content: center;
  493. width: 100%;
  494. padding: 22rpx 0rpx;
  495. border-bottom: 1rpx solid #eee;
  496. }
  497. .getNums {
  498. margin-left: 14rpx;
  499. color: #007aff;
  500. font-size: 30rpx;
  501. font-weight: bold;
  502. display: inline-block;
  503. text-decoration: underline;
  504. }
  505. .submit_btn {
  506. width: 526rpx;
  507. height: 80rpx;
  508. background: #007aff;
  509. border-radius: 40rpx;
  510. text-align: center;
  511. line-height: 80rpx;
  512. color: #ffffff;
  513. margin: 30rpx auto;
  514. }
  515. .picker {
  516. text-align: right;
  517. }
  518. .form {
  519. padding: 0 16rpx !important;
  520. margin-top: 16rpx;
  521. }
  522. input {
  523. text-align: right;
  524. }
  525. .popup_item {
  526. width: 100%;
  527. border-radius: 32rpx;
  528. margin: 10rpx 0;
  529. padding: 0 20rpx;
  530. display: flex;
  531. .course_item {
  532. display: flex;
  533. align-items: center;
  534. width:660rpx;
  535. padding:26rpx;
  536. &.selected {
  537. background:#EBF5FF;
  538. border-radius: 24rpx;
  539. }
  540. }
  541. }
  542. .popup_list {
  543. position:relative;
  544. flex:1;
  545. padding: 0 20rpx;
  546. .list_in {
  547. position: absolute;
  548. left:0;
  549. top:0;
  550. width:100%;
  551. height:100%;
  552. overflow: scroll;
  553. }
  554. }
  555. .submit_wrap {
  556. border-top:1px solid #eee;
  557. background:#fff;
  558. padding:18rpx 0;
  559. .title_l {
  560. margin:0 auto;
  561. text-align: center;
  562. line-height: 64rpx;
  563. width: 200rpx;
  564. height: 64rpx;
  565. background: linear-gradient(0deg, #015EEA, #00C0FA);
  566. border-radius: 32rpx;
  567. color:#fff;
  568. font-size: 30rpx;
  569. }
  570. }
  571. .title_r {
  572. font-size: 30rpx;
  573. font-family: PingFang SC;
  574. font-weight: bold;
  575. color: #2f4379;
  576. }
  577. .grade {
  578. font-size: 24rpx;
  579. color: #999999;
  580. margin: 0 auto;
  581. margin: 10rpx 0;
  582. text-align: center;
  583. }
  584. .line1 {
  585. width: 80rpx;
  586. height: 8rpx;
  587. background: #999999;
  588. border-radius: 4rpx;
  589. margin: 0 auto;
  590. margin-top: 15rpx;
  591. }
  592. .popup_box {
  593. height: 680rpx;
  594. display: flex;
  595. flex-direction: column;
  596. }
  597. .del_icon {
  598. border-radius:50%;
  599. overflow: hidden;
  600. background:rgba(255,54,87,1);
  601. width: 30rpx;
  602. height: 30rpx;
  603. position: absolute;
  604. right: -15rpx;
  605. top: -15rpx;
  606. display: flex;
  607. align-items: center;
  608. justify-content: center;
  609. }
  610. .item_add {
  611. background: #f9f9f9;
  612. border-radius: 14rpx;
  613. width: 100%;
  614. height: 134rpx;
  615. text-align: center;
  616. line-height: 134rpx;
  617. }
  618. .item text {
  619. font-size: 24rpx;
  620. color: #0c141f;
  621. }
  622. .item image {
  623. border-radius: 14rpx;
  624. width: 100%;
  625. height: 134rpx;
  626. }
  627. .item {
  628. width:278rpx;
  629. display: inline-block;
  630. position: relative;
  631. margin-right:16rpx;
  632. }
  633. .list_box {
  634. width: 100%;
  635. background: #ffffff;
  636. border-radius: 16rpx;
  637. padding: 24rpx;
  638. }
  639. page {
  640. background:rgba(234,238,241,1)
  641. }
  642. </style>