studentAfterWork.tsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. import { defineComponent, onMounted, reactive, ref } from 'vue';
  2. import styles from '../index.module.less';
  3. import {
  4. NButton,
  5. NDataTable,
  6. NForm,
  7. NFormItem,
  8. NModal,
  9. NSpace
  10. } from 'naive-ui';
  11. import CSelect from '@/components/CSelect';
  12. import Pagination from '@/components/pagination';
  13. import { getStudentAfterWork } from '../api';
  14. import { useRoute } from 'vue-router';
  15. import CDatePicker from '/src/components/CDatePicker';
  16. import {
  17. getNowDateAndMonday,
  18. getNowDateAndSunday,
  19. getTimes
  20. } from '/src/utils/dateFormat';
  21. import { trainingStatusArray } from '@/utils/searchArray';
  22. import StudentTraomomhDetails from '../modals/studentTraomomhDetails';
  23. import dayjs from 'dayjs';
  24. import TheEmpty from '/src/components/TheEmpty';
  25. export default defineComponent({
  26. name: 'student-studentList',
  27. setup() {
  28. const state = reactive({
  29. searchForm: { keyword: '', trainingStatus: null as any },
  30. loading: false,
  31. pagination: {
  32. page: 1,
  33. rows: 10,
  34. pageTotal: 4
  35. },
  36. tableList: [] as any,
  37. workInfo: {
  38. createTime: '',
  39. expireDate: '',
  40. teacherAvatar: '',
  41. teacherName: ''
  42. },
  43. detailVisiable: false,
  44. activeRow: null as any,
  45. index: 0
  46. });
  47. const timer = ref<[number, number]>([
  48. new Date('2023-01-01').getTime(),
  49. // getNowDateAndMonday(new Date().getTime()),
  50. getNowDateAndSunday(new Date().getTime())
  51. ]);
  52. const TrainingDetailsRef = ref();
  53. const route = useRoute();
  54. // const routerList = ref([
  55. // { name: '班级管理', path: '/classList' },
  56. // { name: route.query.name, path: '/classDetail' },
  57. // { name: route.query.teacherName, path: '/afterWorkDetail' }
  58. // ] as any);
  59. const search = () => {
  60. state.pagination.page = 1;
  61. getList();
  62. console.log('search', state);
  63. };
  64. const onReset = () => {
  65. state.searchForm = { keyword: '', trainingStatus: null as any };
  66. timer.value = [
  67. getNowDateAndMonday(new Date().getTime()),
  68. getNowDateAndSunday(new Date().getTime())
  69. ];
  70. search();
  71. };
  72. const getList = async () => {
  73. state.loading = true;
  74. try {
  75. const res = await getStudentAfterWork({
  76. studentId: route.query.studentId,
  77. ...state.searchForm,
  78. ...state.pagination,
  79. ...getTimes(timer.value, ['startTime', 'endTime'], 'YYYY-MM-DD')
  80. });
  81. state.tableList = res.data.rows;
  82. state.pagination.pageTotal = res.data.total;
  83. state.loading = false;
  84. } catch (e) {
  85. state.loading = false;
  86. console.log(e);
  87. }
  88. };
  89. // const getWorkInfo = async () => {
  90. // console.log(route.query);
  91. // try {
  92. // const res = await getWorkDetail({ trainingId: route.query.trainingId });
  93. // state.workInfo = { ...res.data };
  94. // } catch (e) {
  95. // console.log(e);
  96. // }
  97. // };
  98. const lookDetail = (row: any, index: number) => {
  99. console.log(index, 'index');
  100. state.index = index + 1;
  101. state.activeRow = row;
  102. state.detailVisiable = true;
  103. };
  104. onMounted(() => {
  105. // getWorkInfo();
  106. getList();
  107. });
  108. const columns = () => {
  109. return [
  110. {
  111. title: '布置老师',
  112. key: 'teacherName'
  113. },
  114. {
  115. title: '布置时间',
  116. key: 'createTime',
  117. render(row: any) {
  118. return row.createTime
  119. ? dayjs(row.createTime).format('YYYY-MM-DD')
  120. : '--';
  121. }
  122. },
  123. {
  124. title: '截止时间',
  125. key: 'expireDate',
  126. render(row: any) {
  127. return row.expireDate
  128. ? dayjs(row.expireDate).format('YYYY-MM-DD')
  129. : '--';
  130. }
  131. },
  132. {
  133. title: '最后提交时间',
  134. key: 'submitTime',
  135. render(row: any) {
  136. return row.submitTime
  137. ? dayjs(row.submitTime).format('YYYY-MM-DD')
  138. : '--';
  139. }
  140. },
  141. {
  142. title: '提交状态',
  143. key: 'sex',
  144. render(row: any) {
  145. return (
  146. <div>
  147. {row.trainingStatus == 'UNSUBMITTED' ? (
  148. <p class={styles.nosub} style={{ color: '#aaa' }}>
  149. 未提交
  150. </p>
  151. ) : null}
  152. {row.trainingStatus == 'SUBMITTED' ? (
  153. <p style={{ color: '#EA4132' }} class={styles.ison}>
  154. 不合格
  155. </p>
  156. ) : null}
  157. {row.trainingStatus == 'TARGET' ? (
  158. <p class={styles.isok}>合格</p>
  159. ) : null}
  160. </div>
  161. );
  162. }
  163. },
  164. {
  165. title: '操作',
  166. key: 'id',
  167. render(row: any, index: number) {
  168. return (
  169. <NButton
  170. text
  171. type="primary"
  172. onClick={() => {
  173. lookDetail(row, index);
  174. }}>
  175. 详情
  176. </NButton>
  177. );
  178. }
  179. }
  180. ];
  181. };
  182. // const goToNext = () => {
  183. // ++state.index;
  184. // state.activeRow = state.tableList[state.index - 1];
  185. // TrainingDetailsRef.value.getTrainingDetail(
  186. // state.activeRow.studentLessonTrainingId
  187. // );
  188. // };
  189. // const gotoPre = () => {
  190. // --state.index;
  191. // state.activeRow = state.tableList[state.index - 1];
  192. // TrainingDetailsRef.value.getTrainingDetail(
  193. // state.activeRow.studentLessonTrainingId
  194. // );
  195. // };
  196. return () => (
  197. <div>
  198. <div>
  199. <div class={styles.searchList}>
  200. <NForm label-placement="left" inline>
  201. <NFormItem>
  202. <CDatePicker
  203. v-model:value={timer.value}
  204. separator={'至'}
  205. type="daterange"
  206. timerValue={timer.value}></CDatePicker>
  207. </NFormItem>
  208. <NFormItem>
  209. <CSelect
  210. {...({
  211. options: [
  212. {
  213. label: '提交状态',
  214. value: null
  215. },
  216. ...trainingStatusArray
  217. ],
  218. placeholder: '提交状态',
  219. clearable: true,
  220. inline: true
  221. } as any)}
  222. v-model:value={state.searchForm.trainingStatus}></CSelect>
  223. </NFormItem>
  224. <NFormItem>
  225. <NSpace justify="end">
  226. <NButton type="primary" class="searchBtn" onClick={search}>
  227. 搜索
  228. </NButton>
  229. <NButton
  230. type="primary"
  231. ghost
  232. class="resetBtn"
  233. onClick={onReset}>
  234. 重置
  235. </NButton>
  236. </NSpace>
  237. </NFormItem>
  238. </NForm>
  239. </div>
  240. <div>
  241. <NDataTable
  242. v-slots={{
  243. empty: () => <TheEmpty></TheEmpty>
  244. }}
  245. class={styles.classTable}
  246. loading={state.loading}
  247. columns={columns()}
  248. data={state.tableList}></NDataTable>
  249. <Pagination
  250. v-model:page={state.pagination.page}
  251. v-model:pageSize={state.pagination.rows}
  252. v-model:pageTotal={state.pagination.pageTotal}
  253. onList={getList}
  254. sync
  255. />
  256. </div>
  257. </div>
  258. <NModal
  259. v-model:show={state.detailVisiable}
  260. preset="card"
  261. class={['modalTitle background', styles.wordDetailModel]}
  262. title={'作业详情'}>
  263. <StudentTraomomhDetails
  264. // onNext={() => goToNext()}
  265. // onPre={() => gotoPre()}
  266. ref={TrainingDetailsRef}
  267. onClose={() => (state.detailVisiable = false)}
  268. total={state.tableList.length}
  269. current={state.index}
  270. activeRow={state.activeRow}></StudentTraomomhDetails>
  271. </NModal>
  272. </div>
  273. );
  274. }
  275. });