studentAfterWork.tsx 8.2 KB

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