edit.vue 15 KB

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