edit.vue 15 KB

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