edit.vue 13 KB

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