edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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: 1
  226. };
  227. let self = this;
  228. this.$api.getUserBuy(data).then(result => {
  229. console.log(result)
  230. self.form.courseId = result.data.data.courseVoList[0].courseId
  231. if (result.data.data.courseVoList.length > 0) {
  232. for (let i = 0; i < result.data.data.courseVoList.length; i++) {
  233. let item = result.data.data.courseVoList[i];
  234. item.checked = false;
  235. item.disabled = false;
  236. item.coverUrl = self.$method.splitImgHost(item.coverUrl);
  237. }
  238. }
  239. self.list2 = result.data.data.courseVoList;
  240. });
  241. },
  242. getListForm(int) {
  243. var self = this
  244. this.$api.planUserPlan({
  245. planId: int
  246. }).then(res => {
  247. this.form.date = this.$method.timestampToTime(res.data.data[0].examDate);
  248. this.form.time = res.data.data[0].reminderTime;
  249. this.form.startDate = this.$method.timestampToTime(res.data.data[0].startTime);
  250. this.form.endDate = this.$method.timestampToTime(res.data.data[0].endTime);
  251. this.index_review = res.data.data[0].studyDay;
  252. this.form.week = res.data.data[0].studyCount;
  253. this.form.category = res.data.data[0].coursePlanVo[0].categoryName
  254. this.list = res.data.data[0].coursePlanVo;
  255. var numWeek = []
  256. this.form.week.forEach((items,indexs) => {
  257. if(items === 1){
  258. numWeek.push('一')
  259. return
  260. }
  261. if(items === 2){
  262. numWeek.push('二')
  263. return
  264. }
  265. if(items === 3){
  266. numWeek.push('三')
  267. return
  268. }
  269. if(items === 4){
  270. numWeek.push('四')
  271. return
  272. }
  273. if(items === 5){
  274. numWeek.push('五')
  275. return
  276. }
  277. if(items === 6){
  278. numWeek.push('六')
  279. return
  280. }
  281. if(items === 0){
  282. numWeek.push('日')
  283. return
  284. }
  285. })
  286. this.form.week = numWeek.join('、')
  287. });
  288. },
  289. bindPickerChangeReview(e) {
  290. this.index_review = e.detail.value;
  291. },
  292. week_submit() {
  293. if (this.selWeek == '') {
  294. uni.showModal({
  295. title: '提示',
  296. content: '至少选择一个'
  297. });
  298. return;
  299. }
  300. this.form.week = this.selWeek;
  301. this.week_show = false;
  302. },
  303. openWeek() {
  304. this.week_show = true;
  305. this.selWeek = this.form.week;
  306. let that = this;
  307. this.list3.map(val => {
  308. val.checked = false;
  309. if (that.form.week.indexOf(val.name) != -1) {
  310. val.checked = true;
  311. }
  312. });
  313. },
  314. checkboxGroupChange(e) {
  315. this.selWeek = e.join('、');
  316. },
  317. openCalendar() {
  318. this.calendar_show = true;
  319. },
  320. change(e) {
  321. console.log(e);
  322. this.form.startDate = e.startDate;
  323. this.form.endDate = e.endDate;
  324. },
  325. bindTimeChange(e) {
  326. this.form.time = e.detail.value;
  327. },
  328. bindDateChange(e) {
  329. this.form.date = e.detail.value;
  330. },
  331. submit() {
  332. let that = this;
  333. this.list2.map(val => {
  334. if (val.checked) {
  335. that.list.push(val);
  336. }
  337. });
  338. this.checkSameItem();
  339. this.show = false;
  340. this.form.category = this.list[0].categoryName
  341. },
  342. checkboxChange(e) {},
  343. checkSameItem() {
  344. this.list2.map(val => {
  345. val.disabled = false;
  346. this.list.map(val1 => {
  347. if (val.id == val1.id) {
  348. val.disabled = true;
  349. }
  350. val.checked = false;
  351. });
  352. });
  353. },
  354. delItem(index) {
  355. this.list.splice(index, 1);
  356. if(this.list.length === 0){
  357. this.form.category = ''
  358. }else{
  359. this.form.category = this.list[0].categoryName
  360. }
  361. },
  362. openSel() {
  363. this.show = true;
  364. this.checkSameItem();
  365. }
  366. }
  367. };
  368. </script>
  369. <style>
  370. ::-webkit-scrollbar {
  371. width: 0;
  372. height: 0;
  373. color: transparent;
  374. }
  375. .u-drawer-content-visible {
  376. border-radius: 32rpx 32rpx 0rpx 0rpx;
  377. overflow: hidden;
  378. }
  379. </style>
  380. <style scope>
  381. .picker {
  382. text-align: right;
  383. }
  384. .form {
  385. padding: 0 16rpx !important;
  386. margin-top: 30rpx;
  387. }
  388. input {
  389. text-align: right;
  390. }
  391. .popup_item {
  392. width: 100%;
  393. height: 182rpx;
  394. background: #ffffff;
  395. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  396. border-radius: 32rpx;
  397. margin: 20rpx 0;
  398. padding: 10rpx;
  399. display: flex;
  400. }
  401. .popup_list {
  402. height: 500rpx;
  403. padding: 0 20rpx;
  404. }
  405. .title_l {
  406. width: 88rpx;
  407. height: 48rpx;
  408. background: #32467b;
  409. border-radius: 16rpx;
  410. font-size: 28rpx;
  411. color: #ffffff;
  412. text-align: center;
  413. line-height: 48rpx;
  414. }
  415. .title_r {
  416. font-size: 30rpx;
  417. font-family: PingFang SC;
  418. font-weight: bold;
  419. color: #2f4379;
  420. }
  421. .popup_title {
  422. width: 100%;
  423. margin: 40rpx;
  424. }
  425. .popup_box {
  426. height: 600rpx;
  427. }
  428. .del_icon {
  429. position: absolute;
  430. right: -15rpx;
  431. top: -15rpx;
  432. }
  433. .item_add {
  434. background: #f9f9f9;
  435. border-radius: 32rpx;
  436. width: 100%;
  437. height: 150rpx;
  438. text-align: center;
  439. line-height: 150rpx;
  440. }
  441. .item text {
  442. font-size: 24rpx;
  443. color: #0c141f;
  444. }
  445. .item image {
  446. border-radius: 32rpx;
  447. width: 100%;
  448. height: 150rpx;
  449. }
  450. .item {
  451. width: 46%;
  452. display: inline-block;
  453. margin: 1% 2%;
  454. position: relative;
  455. }
  456. .list_box {
  457. width: 100%;
  458. background: #ffffff;
  459. box-shadow: 0rpx 0rpx 1rpx 4rpx rgba(145, 156, 178, 0.1);
  460. border-radius: 32rpx;
  461. padding: 20rpx 0;
  462. }
  463. .submit_btn {
  464. background-color: #32467b !important;
  465. border-color: #32467b !important;
  466. color: #ffffff;
  467. font-size: 30rpx;
  468. padding: 5rpx;
  469. margin-top: 50rpx;
  470. }
  471. page {
  472. background: #ffffff;
  473. }
  474. </style>