index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div v-if="route.name === 'RecognizeCheck'" class="page-box">
  3. <a-space class="m-b-16px" :size="8">
  4. <div>
  5. <span>科目:</span>
  6. <select-course
  7. v-model:value="searchModel.subjectCode"
  8. :exam-id="userStore.curExam.id"
  9. allow-clear
  10. ></select-course>
  11. </div>
  12. <a-button @click="toPage(1)">查询</a-button>
  13. <a-divider type="vertical" style="margin: 0" />
  14. <a-button type="primary" @click="onAdd">
  15. <template #icon> <PlusCircleOutlined /> </template>
  16. 新增评卷点信息</a-button
  17. >
  18. </a-space>
  19. <a-table
  20. :columns="columns"
  21. :row-key="(record) => record.id"
  22. :data-source="dataList"
  23. :pagination="pagination"
  24. :loading="loading"
  25. bordered
  26. >
  27. <template #bodyCell="{ column, index, text }">
  28. <template v-if="column.dataIndex === 'condition'">
  29. {{ getConditionContent(index) }}
  30. </template>
  31. <template v-if="column.dataIndex === 'stage'">
  32. {{ text === "SECOND" ? "第二次复查" : "第一次复查" }}
  33. </template>
  34. <template v-if="column.dataIndex === 'finishCount'">
  35. {{ getConditionProgress(index) }}
  36. </template>
  37. <template v-if="column.dataIndex === 'operation'">
  38. <a-button
  39. v-if="checkActionValid(index, 'arbitrate')"
  40. type="link"
  41. :diabled="checkDangerActionRunning(index)"
  42. @click="onArbitrate(index)"
  43. >仲裁</a-button
  44. >
  45. <a-button
  46. v-if="checkActionValid(index, 'edit')"
  47. type="link"
  48. :diabled="checkDangerActionRunning(index)"
  49. @click="onEdit(index)"
  50. >修改</a-button
  51. >
  52. <a-button
  53. v-if="checkActionValid(index, 'reset')"
  54. type="link"
  55. :diabled="checkDangerActionRunning(index)"
  56. @click="onReset(index)"
  57. >重置</a-button
  58. >
  59. <a-button
  60. v-if="checkActionValid(index, 'recheck')"
  61. type="link"
  62. :diabled="checkDangerActionRunning(index)"
  63. @click="onRecheck(index)"
  64. >复查</a-button
  65. >
  66. <a-button
  67. v-if="checkActionValid(index, 'buildTask')"
  68. type="link"
  69. :diabled="checkDangerActionRunning(index)"
  70. @click="onBuildTask(index)"
  71. >生成任务</a-button
  72. >
  73. <a-button
  74. v-if="checkActionValid(index, 'delete')"
  75. type="link"
  76. :diabled="checkDangerActionRunning(index)"
  77. @click="onDelete(index)"
  78. >删除</a-button
  79. >
  80. </template>
  81. </template>
  82. </a-table>
  83. <ModifyRecognizeCheckTask
  84. ref="modifyRecognizeCheckTaskRef"
  85. :row-data="curRow"
  86. @modified="getList"
  87. />
  88. </div>
  89. <router-view />
  90. </template>
  91. <script setup lang="ts">
  92. import { ref, reactive, onMounted } from "vue";
  93. import { useRoute, useRouter } from "vue-router";
  94. import { PlusCircleOutlined } from "@ant-design/icons-vue";
  95. import { message } from "ant-design-vue";
  96. import type { TableProps } from "ant-design-vue";
  97. import useTable from "@/hooks/useTable";
  98. import { RecognizeCheckListItem } from "@/ap/types/recognizeCheck";
  99. import {
  100. recognizeCheckListPage,
  101. recognizeCheckTaskDelete,
  102. recognizeCheckResetTask,
  103. recognizeCheckBuildTask,
  104. recognizeCheckTaskStatusSave,
  105. } from "@/ap/recognizeCheck";
  106. import { showConfirm } from "@/utils/uiUtils";
  107. import { useUserStore } from "@/store";
  108. import ModifyRecognizeCheckTask from "./ModifyRecognizeCheckTask.vue";
  109. defineOptions({
  110. name: "RecognizeCheck",
  111. });
  112. const userStore = useUserStore();
  113. const router = useRouter();
  114. const route = useRoute();
  115. const searchModel = reactive({
  116. examId: userStore.curExam.id,
  117. subjectCode: "",
  118. });
  119. const columns: TableProps["columns"] = [
  120. {
  121. title: "任务条件",
  122. dataIndex: "condition",
  123. minWidth: "200px",
  124. },
  125. {
  126. title: "科目",
  127. dataIndex: "subjectName",
  128. minWidth: "120px",
  129. },
  130. {
  131. title: "状态",
  132. dataIndex: "stage",
  133. width: "120px",
  134. },
  135. {
  136. title: "任务总数",
  137. dataIndex: "totalCount",
  138. width: "90px",
  139. },
  140. {
  141. title: "完成进度",
  142. dataIndex: "finishCount",
  143. width: "90px",
  144. },
  145. {
  146. title: "已仲裁数量",
  147. dataIndex: "arbitratedCount",
  148. width: "110px",
  149. },
  150. {
  151. title: "待仲裁数量",
  152. dataIndex: "unarbitrateCount",
  153. width: "110px",
  154. },
  155. {
  156. title: "操作",
  157. dataIndex: "operation",
  158. width: "240px",
  159. customCell: () => {
  160. return {
  161. class: "operation-cell",
  162. };
  163. },
  164. },
  165. ];
  166. const curRow = ref(null as RecognizeCheckTaskSaveParams | null);
  167. const { dataList, pagination, loading, getList, toPage, deletePageLastItem } =
  168. useTable<RecognizeCheckListItem>(recognizeCheckListPage, searchModel, false);
  169. type ActionType =
  170. | "arbitrate"
  171. | "edit"
  172. | "reset"
  173. | "recheck"
  174. | "buildTask"
  175. | "delete";
  176. function checkActionValid(index: number, type: ActionType): boolean {
  177. const record = dataList.value[index];
  178. if (type === "arbitrate") {
  179. return record.stage === "SECOND" && record.unarbitrateCount > 0;
  180. }
  181. if (type === "edit") {
  182. return record.totalCount === 0;
  183. }
  184. if (type === "reset") {
  185. return true;
  186. }
  187. if (type === "recheck") {
  188. return (
  189. record.stage === "FIRST" &&
  190. record.finishCount === record.totalCount &&
  191. record.finishCount > 0
  192. );
  193. }
  194. if (type === "buildTask") {
  195. return !record.fixed;
  196. }
  197. if (type === "delete") {
  198. return !record.fixed;
  199. }
  200. return true;
  201. }
  202. function checkDangerActionRunning(index: number) {
  203. const record = dataList.value[index];
  204. return record.building || record.deleting || record.reseting;
  205. }
  206. function getConditionContent(index: number): string {
  207. const record = dataList.value[index];
  208. return record.conditions
  209. .map((item) => `${item.name}${item.value || ""}`)
  210. .join(";");
  211. }
  212. function getConditionProgress(index: number): string {
  213. const record = dataList.value[index];
  214. if (!record.totalCount) return "0.00%";
  215. const progress = ((100 * record.finishCount) / record.totalCount).toFixed(2);
  216. return `${progress}%`;
  217. }
  218. const modifyRecognizeCheckTaskRef = ref();
  219. function onAdd() {
  220. curRow.value = null;
  221. modifyRecognizeCheckTaskRef.value?.open();
  222. }
  223. function onEdit(index: number) {
  224. curRow.value = dataList.value[index];
  225. modifyRecognizeCheckTaskRef.value?.open();
  226. }
  227. function onArbitrate(index) {
  228. const record = dataList.value[index];
  229. router.push({ name: "RecognizeArbitrate", params: { groupId: record.id } });
  230. }
  231. async function onReset(index: number) {
  232. const confirm = await showConfirm({
  233. content: "确定要重置任务吗?",
  234. }).catch(() => false);
  235. if (confirm !== "confirm") return;
  236. const record = dataList.value[index];
  237. const res = await recognizeCheckResetTask(record.id).catch(() => false);
  238. if (!res) return;
  239. message.success("操作成功");
  240. await getList();
  241. }
  242. async function onRecheck(index: number) {
  243. const confirm = await showConfirm({
  244. content: "确定要复查任务吗?",
  245. }).catch(() => false);
  246. if (confirm !== "confirm") return;
  247. const record = dataList.value[index];
  248. const res = await recognizeCheckTaskStatusSave(record.id).catch(() => false);
  249. if (!res) return;
  250. message.success("操作成功");
  251. await getList();
  252. }
  253. async function onBuildTask(index: number) {
  254. const record = dataList.value[index];
  255. const res = await recognizeCheckBuildTask(record.id).catch(() => false);
  256. if (!res) return;
  257. message.success("操作成功");
  258. await getList();
  259. }
  260. async function onDelete(index: number) {
  261. const confirm = await showConfirm({
  262. content: "确定要删除任务吗?",
  263. }).catch(() => false);
  264. if (confirm !== "confirm") return;
  265. const record = dataList.value[index];
  266. const res = await recognizeCheckTaskDelete(record.id).catch(() => false);
  267. if (!res) return;
  268. deletePageLastItem();
  269. message.success("操作成功");
  270. }
  271. onMounted(() => {
  272. if (route.name !== "RecognizeCheck") return;
  273. toPage(1);
  274. });
  275. </script>