edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <view style="padding: 30rpx;">
  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.courseName }}</text>
  7. <view class="del_icon"><u-icon name="minus-circle-fill" color="#EB4D3D" size="40" @click="delItem(index)"></u-icon></view>
  8. </view>
  9. <view class="item" style="vertical-align: top;">
  10. <view class="item_add" @click="openSel"><u-icon name="plus-circle-fill" color="#32467B" size="32"></u-icon></view>
  11. </view>
  12. </view>
  13. <view class="list_box form">
  14. <u-form :model="form" ref="uForm">
  15. <u-form-item label="课程类型" :label-width="auto"><u-input v-model="form.category" :disabled="true" /></u-form-item>
  16. <u-form-item label="考试日期" prop="birth" :label-width="auto">
  17. <picker mode="date" :value="form.date" @change="bindDateChange">
  18. <view class="picker">{{ form.date }}</view>
  19. </picker>
  20. </u-form-item>
  21. <u-form-item label="学习提醒" prop="birth" :label-width="auto">
  22. <picker mode="time" :value="form.time" @change="bindTimeChange">
  23. <view class="picker">{{ form.time }}</view>
  24. </picker>
  25. </u-form-item>
  26. <u-form-item label="学习频率" :label-width="auto">
  27. <view class="picker" @click="openWeek">{{ form.week }}</view>
  28. </u-form-item>
  29. <u-form-item label="复习天数" :label-width="auto">
  30. <picker @change="bindPickerChangeReview" :value="index_review" :range="array_review">
  31. <view class="picker">{{ array_review[index_review] }}</view>
  32. </picker>
  33. </u-form-item>
  34. <u-form-item label="起止日期" :label-width="auto">
  35. <view class="picker" @click="openCalendar">{{ form.startDate }}~{{ form.endDate }}</view>
  36. </u-form-item>
  37. </u-form>
  38. </view>
  39. <u-calendar v-model="calendar_show" :mode="calendar" @change="change" :max-date="maxDate"></u-calendar>
  40. <!-- 弹框-->
  41. <u-popup v-model="week_show" mode="bottom">
  42. <view style="height: 400rpx;text-align: center">
  43. <view style="padding-top: 100rpx;padding-left: 40rpx;text-align: center;">
  44. <u-checkbox-group @change="checkboxGroupChange">
  45. <u-checkbox v-model="item.checked" v-for="(item, index) in list3" :key="index" :name="item.name">{{ item.name }}</u-checkbox>
  46. </u-checkbox-group>
  47. <view class="title_l" @click="week_submit" style="margin: 50rpx auto;">确认</view>
  48. </view>
  49. </view>
  50. </u-popup>
  51. <u-popup v-model="show" mode="bottom">
  52. <view class="popup_box">
  53. <view class="popup_title">
  54. <u-row>
  55. <u-col span="6"><view class="title_r">我的课程</view></u-col>
  56. <u-col span="3" offset="3"><view class="title_l" @click="submit">确认</view></u-col>
  57. </u-row>
  58. </view>
  59. <view class="popup_list" v-if="list2.length !== 0">
  60. <view class="popup_item" v-for="(item, index) in list2" :key="index">
  61. <view style="display: flex;align-items: center;">
  62. <u-checkbox
  63. :disabled="item.disabled"
  64. @change="checkboxChange(item)"
  65. shape="circle"
  66. active-color="#32467B"
  67. v-model="item.checked"
  68. :key="index"
  69. :name="item.id"
  70. ></u-checkbox>
  71. </view>
  72. <view style="display: flex;align-items: center;"><image :src="item.coverUrl" style="width: 278rpx;height: 134rpx;"></image></view>
  73. <view style="margin: 30rpx;">{{ item.courseName }}</view>
  74. </view>
  75. </view>
  76. <view v-else><u-empty text="请前往购买课程" mode="list"></u-empty></view>
  77. </view>
  78. </u-popup>
  79. <button @click="resultForm" class="submit_btn">提交</button>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. week_show: false,
  87. form: {
  88. category: '',
  89. date: '',
  90. time: '',
  91. startDate: '',
  92. endDate: '',
  93. week: ''
  94. },
  95. calendar: 'range',
  96. list: [],
  97. list2: [],
  98. show: false,
  99. calendar_show: false,
  100. maxDate: '2023-01-01',
  101. list3: [
  102. {
  103. name: '一',
  104. checked: false,
  105. disabled: false,
  106. id: 1
  107. },
  108. {
  109. name: '二',
  110. checked: false,
  111. disabled: false,
  112. id: 2
  113. },
  114. {
  115. name: '三',
  116. checked: false,
  117. disabled: false,
  118. id: 3
  119. },
  120. {
  121. name: '四',
  122. checked: false,
  123. disabled: false,
  124. id: 4
  125. },
  126. {
  127. name: '五',
  128. checked: false,
  129. disabled: false,
  130. id: 5
  131. },
  132. {
  133. name: '六',
  134. checked: false,
  135. disabled: false,
  136. id: 6
  137. },
  138. {
  139. name: '日',
  140. checked: false,
  141. disabled: false,
  142. id: 0
  143. }
  144. ],
  145. selWeek: '',
  146. index_review: 4,
  147. array_review: [1, 2, 3, 4, 5, 6, 7]
  148. };
  149. },
  150. onLoad(option) {
  151. this.planId = option.id;
  152. this.getMyCourse();
  153. this.getListForm(option.id);
  154. },
  155. onShow() {},
  156. methods: {
  157. resultForm() {
  158. var self = this
  159. if (this.list.length == 0) {
  160. uni.showModal({
  161. title: '提示',
  162. content: '请选择课程',
  163. showCancel: false
  164. });
  165. return;
  166. }
  167. let courseId = [];
  168. for (let i = 0; i < this.list.length; i++) {
  169. courseId.push(this.list[i].courseId);
  170. }
  171. let ss = this.form.week.split('、');
  172. let weekArray = [];
  173. for (let i = 0; i < ss.length; i++) {
  174. if (ss[i] == '日') {
  175. weekArray.push(0);
  176. }
  177. if (ss[i] == '一') {
  178. weekArray.push(1);
  179. }
  180. if (ss[i] == '二') {
  181. weekArray.push(2);
  182. }
  183. if (ss[i] == '三') {
  184. weekArray.push(3);
  185. }
  186. if (ss[i] == '四') {
  187. weekArray.push(4);
  188. }
  189. if (ss[i] == '五') {
  190. weekArray.push(5);
  191. }
  192. if (ss[i] == '六') {
  193. weekArray.push(6);
  194. }
  195. }
  196. let data = {
  197. planId: this.planId,
  198. courseId: courseId,
  199. reminderTime: this.form.time,
  200. examDate: this.$method.TimeTotimestamp(this.form.date),
  201. startTime: this.$method.TimeTotimestamp(this.form.startDate),
  202. endTime: this.$method.TimeTotimestamp(this.form.endDate),
  203. studyCount: weekArray,
  204. studyDay: this.array_review[this.index_review],
  205. status: 2
  206. };
  207. this.$api.planupdateGenerate(data).then(result => {
  208. if (result.data.code == 200) {
  209. uni.showModal({
  210. title: '提示',
  211. content: '提交成功',
  212. showCancel: false,
  213. success: function(res) {
  214. if (res.confirm) {
  215. uni.navigateBack({
  216. delta: 1
  217. });
  218. }
  219. }
  220. });
  221. }else{
  222. self.$method.showToast(result.data.msg,'error')
  223. }
  224. });
  225. },
  226. getMyCourse() {
  227. let data = {
  228. typeId: 1
  229. };
  230. let self = this;
  231. this.$api.getUserBuy(data).then(result => {
  232. if (result.data.data.courseVoList !== null) {
  233. self.form.courseId = result.data.data.courseVoList[0].courseId;
  234. if (result.data.data.courseVoList.length > 0) {
  235. for (let i = 0; i < result.data.data.courseVoList.length; i++) {
  236. let item = result.data.data.courseVoList[i];
  237. item.checked = false;
  238. item.disabled = false;
  239. item.coverUrl = self.$method.splitImgHost(item.coverUrl);
  240. }
  241. }
  242. self.list2 = result.data.data.courseVoList;
  243. }
  244. });
  245. },
  246. getListForm(int) {
  247. var self = this;
  248. this.$api
  249. .planUserPlan({
  250. planId: int
  251. })
  252. .then(res => {
  253. this.form.date = this.$method.timestampToTime(res.data.data[0].examDate);
  254. this.form.time = res.data.data[0].reminderTime;
  255. this.form.startDate = this.$method.timestampToTime(res.data.data[0].startTime);
  256. this.form.endDate = this.$method.timestampToTime(res.data.data[0].endTime);
  257. this.index_review = res.data.data[0].studyDay - 1;
  258. this.form.week = res.data.data[0].studyCount;
  259. this.form.category = res.data.data[0].coursePlanVo[0].categoryName;
  260. this.list = res.data.data[0].coursePlanVo;
  261. var numWeek = [];
  262. this.form.week.forEach((items, indexs) => {
  263. if (items === 1) {
  264. numWeek.push('一');
  265. return;
  266. }
  267. if (items === 2) {
  268. numWeek.push('二');
  269. return;
  270. }
  271. if (items === 3) {
  272. numWeek.push('三');
  273. return;
  274. }
  275. if (items === 4) {
  276. numWeek.push('四');
  277. return;
  278. }
  279. if (items === 5) {
  280. numWeek.push('五');
  281. return;
  282. }
  283. if (items === 6) {
  284. numWeek.push('六');
  285. return;
  286. }
  287. if (items === 0) {
  288. numWeek.push('日');
  289. return;
  290. }
  291. });
  292. this.form.week = numWeek.join('、');
  293. });
  294. },
  295. bindPickerChangeReview(e) {
  296. this.index_review = e.detail.value;
  297. },
  298. week_submit() {
  299. if (this.selWeek == '') {
  300. uni.showModal({
  301. title: '提示',
  302. content: '至少选择一个'
  303. });
  304. return;
  305. }
  306. this.form.week = this.selWeek;
  307. this.week_show = false;
  308. },
  309. openWeek() {
  310. this.week_show = true;
  311. this.selWeek = this.form.week;
  312. let that = this;
  313. this.list3.map(val => {
  314. val.checked = false;
  315. if (that.form.week.indexOf(val.name) != -1) {
  316. val.checked = true;
  317. }
  318. });
  319. },
  320. checkboxGroupChange(e) {
  321. this.selWeek = e.join('、');
  322. },
  323. openCalendar() {
  324. this.calendar_show = true;
  325. },
  326. change(e) {
  327. console.log(e);
  328. this.form.startDate = e.startDate;
  329. this.form.endDate = e.endDate;
  330. },
  331. bindTimeChange(e) {
  332. this.form.time = e.detail.value;
  333. },
  334. bindDateChange(e) {
  335. this.form.date = e.detail.value;
  336. },
  337. submit() {
  338. let that = this;
  339. var arrays = [];
  340. this.list2.map(val => {
  341. if (val.checked) {
  342. arrays.push(val);
  343. }
  344. });
  345. this.list = arrays;
  346. this.show = false;
  347. if (arrays.length !== 0) {
  348. this.form.category = this.list[0].categoryName;
  349. }else{
  350. this.form.category = '';
  351. }
  352. // return;
  353. // this.list2.map(val => {
  354. // if (val.checked) {
  355. // that.list.push(val);
  356. // }
  357. // });
  358. // this.checkSameItem();
  359. // this.show = false;
  360. // this.form.category = this.list[0].categoryName;
  361. },
  362. checkboxChange(item) {
  363. var self = this;
  364. this.$nextTick(function() {
  365. if (item.checked) {
  366. self.list2.forEach((items, indexs) => {
  367. if (items.categoryId !== item.categoryId) {
  368. items.disabled = true;
  369. }
  370. });
  371. } else {
  372. var astatus = false;
  373. self.list2.forEach((items, indexs) => {
  374. if (items.checked) {
  375. astatus = true;
  376. }
  377. });
  378. if (!astatus) {
  379. self.list2.map((items, indexs) => {
  380. items.disabled = false;
  381. });
  382. }
  383. }
  384. // this.list2.map(val => {
  385. // if (val.categoryId !== item.categoryId) {
  386. // val.disabled = true;
  387. // }
  388. // });
  389. });
  390. },
  391. checkSameItem() {
  392. var self = this;
  393. this.list2.map((item, index) => {
  394. self.list.map(val => {
  395. if (item.courseId === val.courseId) {
  396. item.checked = true;
  397. }
  398. if (item.categoryId !== val.categoryId) {
  399. item.disabled = true;
  400. }
  401. });
  402. });
  403. // this.list2.map(val => {
  404. // val.disabled = false;
  405. // self.list.map(val1 => {
  406. // if (val.courseId == val1.courseId || val.categoryId !== val1.categoryId) {
  407. // val.disabled = true;
  408. // }
  409. // val.checked = false;
  410. // });
  411. // });
  412. },
  413. delItem(index) {
  414. this.list.splice(index, 1);
  415. if (this.list.length === 0) {
  416. this.form.category = '';
  417. } else {
  418. this.form.category = this.list[0].categoryName;
  419. }
  420. },
  421. openSel() {
  422. this.show = true;
  423. this.list2.forEach((item, index) => {
  424. item.checked = false;
  425. item.disabled = false;
  426. });
  427. this.checkSameItem();
  428. }
  429. }
  430. };
  431. </script>
  432. <style>
  433. ::-webkit-scrollbar {
  434. width: 0;
  435. height: 0;
  436. color: transparent;
  437. }
  438. .u-drawer-content-visible {
  439. border-radius: 32rpx 32rpx 0rpx 0rpx;
  440. overflow: hidden;
  441. }
  442. </style>
  443. <style scope>
  444. .picker {
  445. text-align: right;
  446. }
  447. .form {
  448. padding: 0 16rpx !important;
  449. margin-top: 30rpx;
  450. }
  451. input {
  452. text-align: right;
  453. }
  454. .popup_item {
  455. width: 100%;
  456. height: 182rpx;
  457. background: #ffffff;
  458. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  459. border-radius: 32rpx;
  460. margin: 20rpx 0;
  461. padding: 10rpx;
  462. display: flex;
  463. }
  464. .popup_list {
  465. height: 500rpx;
  466. padding: 0 20rpx;
  467. }
  468. .title_l {
  469. width: 88rpx;
  470. height: 48rpx;
  471. background: #32467b;
  472. border-radius: 16rpx;
  473. font-size: 28rpx;
  474. color: #ffffff;
  475. text-align: center;
  476. line-height: 48rpx;
  477. }
  478. .title_r {
  479. font-size: 30rpx;
  480. font-family: PingFang SC;
  481. font-weight: bold;
  482. color: #2f4379;
  483. }
  484. .popup_title {
  485. width: 100%;
  486. margin: 40rpx;
  487. }
  488. .popup_box {
  489. height: 600rpx;
  490. }
  491. .del_icon {
  492. position: absolute;
  493. right: -15rpx;
  494. top: -15rpx;
  495. }
  496. .item_add {
  497. background: #f9f9f9;
  498. border-radius: 32rpx;
  499. width: 100%;
  500. height: 150rpx;
  501. text-align: center;
  502. line-height: 150rpx;
  503. }
  504. .item text {
  505. font-size: 24rpx;
  506. color: #0c141f;
  507. }
  508. .item image {
  509. border-radius: 32rpx;
  510. width: 100%;
  511. height: 150rpx;
  512. }
  513. .item {
  514. width: 46%;
  515. display: inline-block;
  516. margin: 1% 2%;
  517. position: relative;
  518. }
  519. .list_box {
  520. width: 100%;
  521. background: #ffffff;
  522. box-shadow: 0rpx 0rpx 1rpx 4rpx rgba(145, 156, 178, 0.1);
  523. border-radius: 32rpx;
  524. padding: 20rpx 0;
  525. }
  526. .submit_btn {
  527. background-color: #32467b !important;
  528. border-color: #32467b !important;
  529. color: #ffffff;
  530. font-size: 30rpx;
  531. padding: 5rpx;
  532. margin-top: 50rpx;
  533. }
  534. page {
  535. background: #ffffff;
  536. }
  537. </style>