edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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="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">
  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"
  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>
  77. </u-popup>
  78. <button @click="resultForm" class="submit_btn">提交</button>
  79. </view>
  80. </template>
  81. <script>
  82. export default {
  83. data() {
  84. return {
  85. week_show: false,
  86. form: {
  87. category: '',
  88. date: '',
  89. time: '',
  90. startDate: '',
  91. endDate: '',
  92. week: ''
  93. },
  94. calendar: 'range',
  95. list: [],
  96. list2: [],
  97. show: false,
  98. calendar_show: false,
  99. maxDate: '2023-01-01',
  100. list3: [
  101. {
  102. name: '一',
  103. checked: false,
  104. disabled: false,
  105. id: 1
  106. },
  107. {
  108. name: '二',
  109. checked: false,
  110. disabled: false,
  111. id: 2
  112. },
  113. {
  114. name: '三',
  115. checked: false,
  116. disabled: false,
  117. id: 3
  118. },
  119. {
  120. name: '四',
  121. checked: false,
  122. disabled: false,
  123. id: 4
  124. },
  125. {
  126. name: '五',
  127. checked: false,
  128. disabled: false,
  129. id: 5
  130. },
  131. {
  132. name: '六',
  133. checked: false,
  134. disabled: false,
  135. id: 6
  136. },
  137. {
  138. name: '日',
  139. checked: false,
  140. disabled: false,
  141. id: 0
  142. }
  143. ],
  144. selWeek: '',
  145. index_review: 4,
  146. array_review: [1, 2, 3, 4, 5, 6, 7]
  147. };
  148. },
  149. onLoad(option) {
  150. this.planId = option.id
  151. this.getMyCourse()
  152. this.getListForm(option.id);
  153. },
  154. onShow() {},
  155. methods: {
  156. resultForm(){
  157. if (this.list.length == 0) {
  158. uni.showModal({
  159. title: '提示',
  160. content: '请选择课程',
  161. showCancel: false
  162. });
  163. return;
  164. }
  165. let courseId = [];
  166. for (let i = 0; i < this.list.length; i++) {
  167. courseId.push(this.list[i].courseId);
  168. }
  169. let ss = this.form.week.split('、');
  170. let weekArray = [];
  171. for (let i = 0; i < ss.length; i++) {
  172. if (ss[i] == '日') {
  173. weekArray.push(0);
  174. }
  175. if (ss[i] == '一') {
  176. weekArray.push(1);
  177. }
  178. if (ss[i] == '二') {
  179. weekArray.push(2);
  180. }
  181. if (ss[i] == '三') {
  182. weekArray.push(3);
  183. }
  184. if (ss[i] == '四') {
  185. weekArray.push(4);
  186. }
  187. if (ss[i] == '五') {
  188. weekArray.push(5);
  189. }
  190. if (ss[i] == '六') {
  191. weekArray.push(6);
  192. }
  193. }
  194. let data = {
  195. planId: this.planId,
  196. courseId: courseId,
  197. reminderTime: this.form.time,
  198. examDate: this.$method.TimeTotimestamp(this.form.date),
  199. startTime: this.$method.TimeTotimestamp(this.form.startDate),
  200. endTime: this.$method.TimeTotimestamp(this.form.endDate),
  201. studyCount: weekArray,
  202. studyDay: this.array_review[this.index_review],
  203. status: 2
  204. };
  205. this.$api.planupdateGenerate(data).then(result => {
  206. if (result.data.code == 200) {
  207. uni.showModal({
  208. title: '提示',
  209. content: '提交成功',
  210. showCancel: false,
  211. success: function (res) {
  212. if (res.confirm) {
  213. uni.navigateBack({
  214. delta: 1
  215. });
  216. }
  217. }
  218. });
  219. }
  220. console.log(result);
  221. });
  222. },
  223. getMyCourse() {
  224. let data = {
  225. typeId: 0
  226. };
  227. let self = this;
  228. this.$api.getUserBuy(data).then(result => {
  229. self.form.courseId = result.data.data.courseVoList[0].courseId
  230. if (result.data.data.courseVoList.length > 0) {
  231. for (let i = 0; i < result.data.data.courseVoList.length; i++) {
  232. let item = result.data.data.courseVoList[i];
  233. item.checked = false;
  234. item.disabled = false;
  235. item.coverUrl = self.$method.splitImgHost(item.coverUrl);
  236. }
  237. }
  238. self.list2 = result.data.data.courseVoList;
  239. });
  240. },
  241. getListForm(int) {
  242. var self = this
  243. this.$api.planUserPlan({
  244. planId: int
  245. }).then(res => {
  246. this.form.date = this.$method.timestampToTime(res.data.data[0].examDate);
  247. this.form.time = res.data.data[0].reminderTime;
  248. this.form.startDate = this.$method.timestampToTime(res.data.data[0].startTime);
  249. this.form.endDate = this.$method.timestampToTime(res.data.data[0].endTime);
  250. this.index_review = res.data.data[0].studyDay;
  251. this.form.week = res.data.data[0].studyCount;
  252. this.form.category = res.data.data[0].coursePlanVo[0].categoryName
  253. this.list = res.data.data[0].coursePlanVo;
  254. var numWeek = []
  255. this.form.week.forEach((items,indexs) => {
  256. if(items === 1){
  257. numWeek.push('一')
  258. return
  259. }
  260. if(items === 2){
  261. numWeek.push('二')
  262. return
  263. }
  264. if(items === 3){
  265. numWeek.push('三')
  266. return
  267. }
  268. if(items === 4){
  269. numWeek.push('四')
  270. return
  271. }
  272. if(items === 5){
  273. numWeek.push('五')
  274. return
  275. }
  276. if(items === 6){
  277. numWeek.push('六')
  278. return
  279. }
  280. if(items === 0){
  281. numWeek.push('日')
  282. return
  283. }
  284. })
  285. this.form.week = numWeek.join('、')
  286. });
  287. },
  288. bindPickerChangeReview(e) {
  289. this.index_review = e.detail.value;
  290. },
  291. week_submit() {
  292. if (this.selWeek == '') {
  293. uni.showModal({
  294. title: '提示',
  295. content: '至少选择一个'
  296. });
  297. return;
  298. }
  299. this.form.week = this.selWeek;
  300. this.week_show = false;
  301. },
  302. openWeek() {
  303. this.week_show = true;
  304. this.selWeek = this.form.week;
  305. let that = this;
  306. this.list3.map(val => {
  307. val.checked = false;
  308. if (that.form.week.indexOf(val.name) != -1) {
  309. val.checked = true;
  310. }
  311. });
  312. },
  313. checkboxGroupChange(e) {
  314. this.selWeek = e.join('、');
  315. },
  316. openCalendar() {
  317. this.calendar_show = true;
  318. },
  319. change(e) {
  320. console.log(e);
  321. this.form.startDate = e.startDate;
  322. this.form.endDate = e.endDate;
  323. },
  324. bindTimeChange(e) {
  325. this.form.time = e.detail.value;
  326. },
  327. bindDateChange(e) {
  328. this.form.date = e.detail.value;
  329. },
  330. submit() {
  331. let that = this;
  332. this.list2.map(val => {
  333. if (val.checked) {
  334. that.list.push(val);
  335. }
  336. });
  337. this.checkSameItem();
  338. this.show = false;
  339. this.form.category = this.list[0].categoryName
  340. },
  341. checkboxChange(e) {},
  342. checkSameItem() {
  343. this.list2.map(val => {
  344. val.disabled = false;
  345. this.list.map(val1 => {
  346. if (val.id == val1.id) {
  347. val.disabled = true;
  348. }
  349. val.checked = false;
  350. });
  351. });
  352. },
  353. delItem(index) {
  354. this.list.splice(index, 1);
  355. if(this.list.length === 0){
  356. this.form.category = ''
  357. }else{
  358. this.form.category = this.list[0].categoryName
  359. }
  360. },
  361. openSel() {
  362. this.show = true;
  363. this.checkSameItem();
  364. }
  365. }
  366. };
  367. </script>
  368. <style>
  369. ::-webkit-scrollbar {
  370. width: 0;
  371. height: 0;
  372. color: transparent;
  373. }
  374. .u-drawer-content-visible {
  375. border-radius: 32rpx 32rpx 0rpx 0rpx;
  376. overflow: hidden;
  377. }
  378. </style>
  379. <style scope>
  380. .picker {
  381. text-align: right;
  382. }
  383. .form {
  384. padding: 0 16rpx !important;
  385. margin-top: 30rpx;
  386. }
  387. input {
  388. text-align: right;
  389. }
  390. .popup_item {
  391. width: 100%;
  392. height: 182rpx;
  393. background: #ffffff;
  394. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  395. border-radius: 32rpx;
  396. margin: 20rpx 0;
  397. padding: 10rpx;
  398. display: flex;
  399. }
  400. .popup_list {
  401. height: 500rpx;
  402. padding: 0 20rpx;
  403. }
  404. .title_l {
  405. width: 88rpx;
  406. height: 48rpx;
  407. background: #32467b;
  408. border-radius: 16rpx;
  409. font-size: 28rpx;
  410. color: #ffffff;
  411. text-align: center;
  412. line-height: 48rpx;
  413. }
  414. .title_r {
  415. font-size: 30rpx;
  416. font-family: PingFang SC;
  417. font-weight: bold;
  418. color: #2f4379;
  419. }
  420. .popup_title {
  421. width: 100%;
  422. margin: 40rpx;
  423. }
  424. .popup_box {
  425. height: 600rpx;
  426. }
  427. .del_icon {
  428. position: absolute;
  429. right: -15rpx;
  430. top: -15rpx;
  431. }
  432. .item_add {
  433. background: #f9f9f9;
  434. border-radius: 32rpx;
  435. width: 100%;
  436. height: 150rpx;
  437. text-align: center;
  438. line-height: 150rpx;
  439. }
  440. .item text {
  441. font-size: 24rpx;
  442. color: #0c141f;
  443. }
  444. .item image {
  445. border-radius: 32rpx;
  446. width: 100%;
  447. height: 150rpx;
  448. }
  449. .item {
  450. width: 46%;
  451. display: inline-block;
  452. margin: 1% 2%;
  453. position: relative;
  454. }
  455. .list_box {
  456. width: 100%;
  457. background: #ffffff;
  458. box-shadow: 0rpx 0rpx 1rpx 4rpx rgba(145, 156, 178, 0.1);
  459. border-radius: 32rpx;
  460. padding: 20rpx 0;
  461. }
  462. .submit_btn {
  463. background-color: #32467b !important;
  464. border-color: #32467b !important;
  465. color: #ffffff;
  466. font-size: 30rpx;
  467. padding: 5rpx;
  468. margin-top: 50rpx;
  469. }
  470. page {
  471. background: #ffffff;
  472. }
  473. </style>