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