index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="flex direction-column full training-monitoring-view">
  3. <div class="p-l-base p-r-base p-t-medium-base fill-blank filter-form" style="padding-bottom: 10px">
  4. <base-form
  5. ref="formRef"
  6. :key="formKey"
  7. size="small"
  8. :label-width="'100px'"
  9. :disabled="loading"
  10. :model="model"
  11. :rules="rules"
  12. :items="items"
  13. >
  14. <template #form-item-operation>
  15. <el-button type="primary" @click="onSearch">查询</el-button>
  16. </template>
  17. </base-form>
  18. </div>
  19. <div class="flex-1 p-base">
  20. <div class="radius-base p-base fill-blank">
  21. <div class="flex items m-b-base">
  22. <el-button
  23. size="small"
  24. :disabled="!hasSelected"
  25. :loading="putSampleIng || putAssessIng"
  26. type="primary"
  27. @click="onAssessPass(true)"
  28. >
  29. 考核通过
  30. </el-button>
  31. <el-button
  32. size="small"
  33. :disabled="!hasSelected"
  34. :loading="putSampleIng || putAssessIng"
  35. type="primary"
  36. plain
  37. @click="onAssessPass(false)"
  38. >
  39. 考核不通过
  40. </el-button>
  41. <!-- <el-button size="small" type="primary" custom-1 @click="viewPaper(false)">查看试卷</el-button> -->
  42. </div>
  43. <base-table
  44. :max-height="tableMaxHeight"
  45. border
  46. stripe
  47. size="small"
  48. :columns="columns"
  49. :data="trainingMonitor?.data"
  50. :row-class-name="rowClassName"
  51. @selection-change="onSectionChange"
  52. @row-dblclick="onDbClick"
  53. >
  54. </base-table>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script setup lang="tsx" name="TrainingMonitoring">
  60. /** 培训监控 */
  61. import { computed, onBeforeUnmount, onBeforeMount, ref, watch } from 'vue'
  62. import { useRouter } from 'vue-router'
  63. import { ElButton, ElMessage } from 'element-plus'
  64. import { minus, isDefine } from '@/utils/common'
  65. import BaseForm from '@/components/element/BaseForm.vue'
  66. import BaseTable from '@/components/element/BaseTable.vue'
  67. import useVW from '@/hooks/useVW'
  68. import useFetch from '@/hooks/useFetch'
  69. import useSection from '@/hooks/useSection'
  70. import useFormFilter from './hooks/useFormFilter'
  71. import ImgWaitingCheck from '../../../assets/images/daishen.png'
  72. import type { ExtractApiResponse } from '@/api/api'
  73. import type { EpTableColumn } from 'global-type'
  74. type TableDataType = ExtractArrayValue<ExtractApiResponse<'getTrainingMonitor'>['data']>
  75. const tableMaxHeight = ref(400)
  76. onBeforeMount(() => {
  77. tableMaxHeight.value = window.innerHeight - 210
  78. })
  79. const { push } = useRouter()
  80. const { diffShow, model, items, rules, formRef, elFormRef, onOptionInit } = useFormFilter()
  81. const formKey = ref(Date.now() + '')
  82. watch(rules, () => {
  83. formKey.value = Date.now() + ''
  84. })
  85. /** 培训监控列表 */
  86. const { fetch: getTrainingMonitor, result: trainingMonitor, loading } = useFetch('getTrainingMonitor')
  87. /** 培训卷审核 */
  88. const { fetch: putSampleMonitorPass, loading: putSampleIng } = useFetch('putSampleMonitorPass')
  89. /** 强制考核卷审核 */
  90. const { fetch: putAssessMonitorPass, loading: putAssessIng } = useFetch('putAssessMonitorPass')
  91. const { hasSelected, selectedList, onSectionChange } = useSection<TableDataType>()
  92. const rowClassName = (obj: any) => {
  93. if (!obj.row.markerId) {
  94. return 'fixed-row'
  95. }
  96. }
  97. const columns = computed<EpTableColumn<TableDataType>[]>(() => {
  98. const standardScores = trainingMonitor?.value?.data?.[0]?.scoreList
  99. const cols: EpTableColumn<TableDataType>[] =
  100. trainingMonitor?.value?.header?.map((h, i) => {
  101. // console.log('hhhh', h, typeof h)
  102. return {
  103. label: `${h}`,
  104. // width: 12 * (h + '' || '').length + 25,
  105. minWidth: 50,
  106. formatter(row) {
  107. if (!row.markerId) {
  108. return `${row.scoreList[i]}`
  109. }
  110. const score = row.scoreList[i]
  111. const standardScore = standardScores[i]
  112. const diff = isDefine(score) ? minus(score, standardScore) : ''
  113. return <span style={{ color: diff ? '#f00' : 'inherit' }}>{diffShow.value ? diff : score}</span>
  114. },
  115. }
  116. }) || []
  117. return [
  118. {
  119. type: 'selection',
  120. selectable(row) {
  121. return !!row.markerId
  122. },
  123. width: 60,
  124. fixed: 'left',
  125. },
  126. { label: '评卷员', prop: 'markerName', minWidth: 110, fixed: 'left' },
  127. {
  128. label: '状态',
  129. prop: 'status',
  130. width: 120,
  131. fixed: 'left',
  132. formatter(row: any) {
  133. let cls =
  134. row.status == 'Sample A'
  135. ? 'sample-a'
  136. : row.status == 'Sample B'
  137. ? 'sample-b'
  138. : row.status == 'Pass A'
  139. ? 'pass-a'
  140. : row.status == 'Pass B'
  141. ? 'pass-b'
  142. : row.status == '强制考核'
  143. ? 'qzkh'
  144. : row.status === '正评'
  145. ? 'zp'
  146. : 'normal'
  147. return (
  148. <div class={cls + ' status-box'}>
  149. {row.status}
  150. {row.needAudit ? <img class="wait-check" src={ImgWaitingCheck} /> : null}
  151. </div>
  152. )
  153. },
  154. },
  155. { label: '平均分', prop: 'avg', minWidth: 80 },
  156. { label: '标准差', prop: 'std', minWidth: 80 },
  157. { label: '相关系数', prop: 'xyRelate', minWidth: 80 },
  158. { label: '差异份数', prop: 'diffCount', minWidth: 80 },
  159. ...cols,
  160. ]
  161. })
  162. let currentDataType: TableDataType['stage'] = 'SAMPLE_A'
  163. /** 刷新按钮 */
  164. async function onSearch() {
  165. try {
  166. const valid = await elFormRef?.value?.validate()
  167. if (valid) {
  168. const { diffShow, ...params } = model || {}
  169. const dataType = model.markStage
  170. getTrainingMonitor(params).then(() => {
  171. currentDataType = dataType
  172. })
  173. }
  174. } catch (error) {
  175. console.error(error)
  176. }
  177. }
  178. /** 通过/不通过 */
  179. const onAssessPass = async (pass: boolean) => {
  180. if (!hasSelected.value) {
  181. return ElMessage.warning('未勾选考核人员')
  182. }
  183. if (currentDataType === 'FORCE') {
  184. const forceGroupMarkerIds: number[] = selectedList.map((d) => d.forceGroupMarkerId)
  185. await putAssessMonitorPass({ forceGroupMarkerIds, pass })
  186. } else {
  187. const markerIds = selectedList.map((d) => d.markerId)
  188. await putSampleMonitorPass({ markerIds, markStage: currentDataType, pass })
  189. }
  190. onSearch()
  191. }
  192. /** 双击跳转详情 */
  193. const onDbClick = (row: TableDataType) => {
  194. if (row.markerId) {
  195. push({
  196. name: 'TrainingDetail',
  197. query: {
  198. // stage: row.stage,
  199. stage: row.queryStage,
  200. markerId: row.markerId,
  201. forceGroupMarkerId: row.forceGroupMarkerId,
  202. },
  203. })
  204. }
  205. }
  206. onOptionInit(onSearch)
  207. // let timer: any = setInterval(() => {
  208. // onSearch()
  209. // }, 30000)
  210. // onBeforeUnmount(() => {
  211. // clearInterval(timer)
  212. // timer = null
  213. // })
  214. </script>
  215. <style scoped lang="scss">
  216. .training-monitoring-view {
  217. :deep(.el-form-item--small) {
  218. margin-bottom: 10px;
  219. }
  220. :deep(.el-table) {
  221. .cell {
  222. overflow: visible;
  223. }
  224. .fixed-row {
  225. display: table-row;
  226. position: sticky;
  227. position: '-webkit-sticky';
  228. top: 0;
  229. width: 100%;
  230. z-index: 3;
  231. }
  232. .status-box {
  233. height: 24px;
  234. padding: 6px 10px;
  235. text-align: center;
  236. border-radius: 12px;
  237. // background: #eee;
  238. line-height: 1 !important;
  239. font-size: 12px;
  240. font-weight: bold;
  241. position: relative;
  242. .wait-check {
  243. position: absolute;
  244. right: -1px;
  245. top: -5px;
  246. width: 10px;
  247. height: 10px;
  248. z-index: 1;
  249. }
  250. &.sample-a {
  251. background: #d6f3ff;
  252. color: #0086d9;
  253. }
  254. &.sample-b {
  255. background: #e8e4ff;
  256. color: #605ca2;
  257. }
  258. &.pass-a {
  259. background: #fdf0cc;
  260. color: #e26100;
  261. }
  262. &.pass-b {
  263. background: #ffe0cc;
  264. color: #9f4f26;
  265. }
  266. &.qzkh {
  267. background: #ffd8d8;
  268. color: #844141;
  269. }
  270. &.zp {
  271. background: #ccf1ea;
  272. color: #307864;
  273. }
  274. }
  275. }
  276. }
  277. </style>