selectGradeBox.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view>
  3. <u-popup v-model="isShow" @close="close" mode="bottom" border-radius="40">
  4. <view class="popup_box">
  5. <view class="check_head">
  6. <view class="grade">选择班级</view>
  7. <u-icon
  8. name="close"
  9. color="#CFCFCF"
  10. size="30"
  11. @click="close"
  12. ></u-icon>
  13. </view>
  14. <view class="check_con">
  15. <scroll-view scroll-y="true" style="height: 580rpx">
  16. <view>
  17. <u-radio-group v-model="gradeValue">
  18. <view
  19. v-for="(item, index) in gradeList"
  20. :key="index"
  21. class="items_c"
  22. >
  23. <view class="border_c">
  24. <view>
  25. <u-radio
  26. shape="circle"
  27. active-color="#FC3F3F"
  28. :name="index"
  29. :disabled="
  30. item.studentNum > 0 &&
  31. item.studentNum == item.studentUpper
  32. "
  33. >
  34. <view
  35. :class="
  36. index == gradeValue
  37. ? 'white-box blue-box'
  38. : 'white-box'
  39. "
  40. >
  41. <view>
  42. <view class="blackTxt">{{ item.className }}</view>
  43. <Class-time-tip :classInfo="item"></Class-time-tip>
  44. </view>
  45. </view>
  46. </u-radio>
  47. </view>
  48. </view>
  49. </view>
  50. </u-radio-group>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. <view class="confrim-btn">
  55. <view class="okBtn" @click="okPopup()">确定</view>
  56. </view>
  57. </view>
  58. </u-popup>
  59. </view>
  60. </template>
  61. <script>
  62. import ClassTimeTip from "@/components/common/ClassTimeTip.vue";
  63. export default {
  64. name: "SaasMiniprogramSelectGradeBox",
  65. data() {
  66. return {
  67. gradeValue: 0,
  68. gradeList: [],
  69. isShow: false,
  70. };
  71. },
  72. mounted() {},
  73. methods: {
  74. goodsGradeList(id) {
  75. return this.$api.goodsGradeList({ goodsId: id }).then((res) => {
  76. let { code, rows } = res.data;
  77. if (code == 200) {
  78. if (rows.length == 0) {
  79. let item = {
  80. className: "系统分班",
  81. gradeId: 0,
  82. };
  83. rows.push(item);
  84. } else {
  85. let isGradeFull = rows.every(
  86. (item) =>
  87. item.studentNum > 0 && item.studentNum == item.studentUpper
  88. );
  89. //所有班级都满了
  90. if (isGradeFull) {
  91. let item = {
  92. className: "系统分班",
  93. gradeId: 0,
  94. };
  95. rows.unshift(item);
  96. }
  97. }
  98. return Promise.resolve(rows);
  99. }
  100. });
  101. },
  102. async open(data, selectGradeId) {
  103. console.log(data, selectGradeId, "data, selectGradeId");
  104. this.isShow = true;
  105. this.gradeValue = 0;
  106. if (Array.isArray(data)) {
  107. this.gradeList = data;
  108. } else {
  109. this.gradeList = await this.goodsGradeList(data);
  110. }
  111. if (selectGradeId) {
  112. this.gradeValue = this.gradeList.findIndex(
  113. (e) => e.gradeId == selectGradeId
  114. );
  115. }
  116. console.log(this.gradeValue, "this.gradeValue");
  117. },
  118. okPopup() {
  119. this.isShow = false;
  120. this.$emit("submit", this.gradeList[this.gradeValue]);
  121. },
  122. close() {
  123. this.isShow = false;
  124. console.log(this.isShow, "this.isShow");
  125. // this.$emit("close");
  126. },
  127. },
  128. components: { ClassTimeTip },
  129. };
  130. </script>
  131. <style lang="scss" scoped>
  132. .popup_box {
  133. height: 824rpx;
  134. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  135. border-radius: 28rpx 28rpx 0rpx 0rpx;
  136. .check_head {
  137. padding: 0rpx 32rpx;
  138. display: flex;
  139. align-items: center;
  140. justify-content: space-between;
  141. height: 104rpx;
  142. background: #f2f2f2;
  143. }
  144. .items_c {
  145. padding: 0rpx 32rpx;
  146. }
  147. .border_c {
  148. display: flex;
  149. align-items: center;
  150. padding: 20rpx 0rpx;
  151. border-bottom: 1rpx solid #f2f2f2;
  152. }
  153. .okBtn {
  154. width: 232rpx;
  155. height: 92rpx;
  156. line-height: 92rpx;
  157. background: #fc3f3f;
  158. border-radius: 120rpx;
  159. color: #ffffff;
  160. text-align: center;
  161. font-size: 32rpx;
  162. font-weight: 500;
  163. }
  164. .confrim-btn {
  165. // border-top:1px solid #eee;
  166. height: 98rpx;
  167. width: 100%;
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. }
  172. }
  173. </style>