edit.vue 15 KB

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