toStudent.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <script setup>
  2. import { userInfo } from "~/store/user";
  3. const router = useRouter();
  4. const { uo_type, uo_name } = userInfo;
  5. const { currentRoute } = useRouter()
  6. const route = currentRoute.value
  7. const grade_id = route.query.grade_id
  8. const isBureau = ref(false); // 当前用户是否局端
  9. isBureau.value = uo_type === "1";
  10. const list = ref([]);
  11. const loading = ref(false);
  12. const finished = ref(false);
  13. const classList = ref([]);
  14. const classOption = $ref([{ text: "班级", value: "" }]);
  15. let page = 1;
  16. const firstForm = $ref({
  17. class: "",
  18. type: "",
  19. time: "",
  20. });
  21. function getTimeFormat() {
  22. var date = new Date();
  23. var month = date.getMonth() + 1;
  24. var strDate = date.getDate();
  25. if (month >= 1 && month <= 9) {
  26. month = "0" + month;
  27. }
  28. if (strDate >= 0 && strDate <= 9) {
  29. strDate = "0" + strDate;
  30. }
  31. let time = [
  32. date.getFullYear() + "-" + month + "-" + strDate,
  33. date.getFullYear() + "-" + month + "-" + strDate,
  34. ];
  35. firstForm.time = time[0] + " - " + time[1];
  36. console.log((firstForm.time));
  37. }
  38. getTimeFormat()
  39. function onLoad() {
  40. loading.value = true;
  41. request({
  42. url: "/xddy/dygl_cjxt_bj/index",
  43. data: {
  44. page,
  45. limit: 20,
  46. class_id: firstForm.class,
  47. xdcbj_tjlx: firstForm.type,
  48. xdcbj_tjrq:firstForm.time
  49. },
  50. }).then((res) => {
  51. const data = res.data;
  52. list.value = [...list.value, ...data.page_data];
  53. finished.value = data.total_page === page;
  54. page++;
  55. loading.value = false;
  56. });
  57. }
  58. function getClassData() {
  59. loading.value = true;
  60. request({
  61. url: "/jcxx/class/index",
  62. data: {
  63. page: 1,
  64. limit: 999,
  65. grade_id: grade_id,
  66. },
  67. }).then((res) => {
  68. if (res.code == 1) {
  69. classList.value = res.data.page_data;
  70. loading.value = false;
  71. classList.value.map((item) => {
  72. classOption.push({ text: item.class_name, value: item.class_num });
  73. });
  74. }
  75. });
  76. }
  77. getClassData();
  78. const resultOption = $ref([
  79. { text: "结果", value: "" },
  80. {
  81. text: "良好",
  82. value: 1,
  83. },
  84. {
  85. text: "及格",
  86. value: 2,
  87. },
  88. {
  89. text: "异常",
  90. value: 3,
  91. },
  92. ]);
  93. const typeOption = $ref([
  94. { text: "类别", value: "" },
  95. {
  96. text: "晨检",
  97. value: 1,
  98. },
  99. {
  100. text: "午检",
  101. value: 2,
  102. },
  103. ]);
  104. const date = ref("");
  105. const show = ref(false);
  106. const formatDate = (date) =>
  107. `${date.getFullYear()}-${((date.getMonth() + 1)>=1&&(date.getMonth() + 1)<=9)?'0'+(date.getMonth() + 1):date.getMonth() + 1}-${(date.getDate()>=0&&date.getDate()<=9)?'0'+date.getDate():date.getDate()}`;
  108. const onConfirm = (values) => {
  109. const [start, end] = values;
  110. show.value = false;
  111. firstForm.time = `${formatDate(start)} - ${formatDate(end)}`;
  112. console.log(firstForm.time,typeof(firstForm.time), " firstForm.time ");
  113. dropItemChange()
  114. };
  115. const minDate = new Date(2010, 0, 1);
  116. const maxDate = new Date(2010, 0, 31);
  117. function dropItemChange() {
  118. page = 1;
  119. list.value = [];
  120. finished.value = false;
  121. onLoad();
  122. }
  123. </script>
  124. <template>
  125. <div class="index">
  126. <div class="flex">
  127. <van-dropdown-menu>
  128. <van-dropdown-item
  129. v-model="firstForm.class"
  130. :options="classOption"
  131. @change="dropItemChange"
  132. />
  133. <van-dropdown-item
  134. v-model="firstForm.type"
  135. :options="typeOption"
  136. @change="dropItemChange"
  137. />
  138. </van-dropdown-menu>
  139. <van-cell
  140. class="dateSearch"
  141. title="日期:"
  142. :value="firstForm.time"
  143. @click="show = true"
  144. /><van-calendar
  145. v-model:show="show"
  146. type="range"
  147. :min-date="new Date('1970/01/01')"
  148. :max-date="new Date('2099/01/31')"
  149. @confirm="onConfirm"
  150. allow-same-day
  151. />
  152. </div>
  153. <van-list
  154. v-model:loading="loading"
  155. :finished="finished"
  156. finished-text="没有更多了"
  157. @load="onLoad"
  158. >
  159. <van-cell v-for="item in list" :key="item" >
  160. <template #title>
  161. <div
  162. style="display: flex; justify-content: space-between; color: black"
  163. >
  164. <span>{{
  165. `${item.xdcbj_tjlx}\u00A0\u00A0\u00A0\u00A0\u00A0${item.class_name}`
  166. }}</span>
  167. <span style="color: black">{{ item.xdcbj_tjrq }}</span>
  168. </div>
  169. </template>
  170. <template #label>
  171. <div>
  172. <span class="mr-50px">应到:{{ item.xdcbj_ydrs }}人</span>
  173. <span>实到:{{ item.xdcbj_sdrs }}人 </span>
  174. <span></span>
  175. </div>
  176. <div
  177. style="display: flex; justify-content: space-between; color: black"
  178. >
  179. <div>
  180. <span>因病缺勤:{{ item.xdcbj_ybqqrs }}人 </span>
  181. </div>
  182. <div>
  183. <span>因事缺勤:{{ item.xdcbj_ysqqrs }}人 </span>
  184. </div>
  185. <div>
  186. <span>异常学生:{{ item.xdcbj_ysqqrs }}人 </span>
  187. </div>
  188. </div>
  189. </template>
  190. </van-cell>
  191. </van-list>
  192. </div>
  193. </template>
  194. <style lang="scss" scoped>
  195. .search {
  196. box-shadow: 0 0.05333rem 0.32rem rgba(100, 101, 102, 0.12);
  197. }
  198. :deep(.van-dropdown-menu) {
  199. // width: 50%;
  200. }
  201. :deep(.van-dropdown-menu__item) {
  202. flex: none;
  203. padding: 0 10px;
  204. }
  205. ::v-deep .dateSearch {
  206. font-size: 15.4px;
  207. padding: 10.4px 5px;
  208. }
  209. ::v-deep .dateSearch .van-cell__title {
  210. width: 20%;
  211. flex: auto;
  212. }
  213. ::v-deep .dateSearch .van-cell__value {
  214. width: 80%;
  215. font-size: 12px;
  216. flex: auto;
  217. }
  218. </style>