index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. :condition-list="conditionList"
  87. @modified="getList"
  88. />
  89. </div>
  90. <router-view />
  91. </template>
  92. <script setup lang="ts">
  93. import { ref, reactive, onMounted } from "vue";
  94. import { useRoute, useRouter } from "vue-router";
  95. import { PlusCircleOutlined } from "@ant-design/icons-vue";
  96. import { message } from "ant-design-vue";
  97. import type { TableProps } from "ant-design-vue";
  98. import useTable from "@/hooks/useTable";
  99. import {
  100. RecognizeCheckListItem,
  101. RecognizeConditionItem,
  102. } from "@/ap/types/recognizeCheck";
  103. import {
  104. recognizeCheckListPage,
  105. recognizeCheckTaskDelete,
  106. recognizeCheckResetTask,
  107. recognizeCheckBuildTask,
  108. recognizeCheckTaskStatusSave,
  109. recognizeConditionsList,
  110. } from "@/ap/recognizeCheck";
  111. import { showConfirm } from "@/utils/uiUtils";
  112. import { useUserStore } from "@/store";
  113. import ModifyRecognizeCheckTask from "./ModifyRecognizeCheckTask.vue";
  114. defineOptions({
  115. name: "RecognizeCheck",
  116. });
  117. const userStore = useUserStore();
  118. const router = useRouter();
  119. const route = useRoute();
  120. // condition action
  121. const conditionList = ref<RecognizeConditionItem[]>([]);
  122. const conditionMap = ref<Record<string, string>>({});
  123. async function getConditionList() {
  124. const res = await recognizeConditionsList();
  125. conditionList.value = res || [];
  126. conditionList.value.forEach((item) => {
  127. conditionMap.value[item.code] = item.name;
  128. });
  129. }
  130. // datalist
  131. const searchModel = reactive({
  132. examId: userStore.curExam.id,
  133. subjectCode: "",
  134. });
  135. const columns: TableProps["columns"] = [
  136. {
  137. title: "任务条件",
  138. dataIndex: "condition",
  139. minWidth: 200,
  140. },
  141. {
  142. title: "科目",
  143. dataIndex: "subjectName",
  144. minWidth: 120,
  145. },
  146. {
  147. title: "状态",
  148. dataIndex: "stage",
  149. width: "120px",
  150. },
  151. {
  152. title: "任务总数",
  153. dataIndex: "totalCount",
  154. width: "90px",
  155. },
  156. {
  157. title: "完成进度",
  158. dataIndex: "finishCount",
  159. width: "90px",
  160. },
  161. {
  162. title: "已仲裁数量",
  163. dataIndex: "arbitratedCount",
  164. width: "110px",
  165. },
  166. {
  167. title: "待仲裁数量",
  168. dataIndex: "unarbitrateCount",
  169. width: "110px",
  170. },
  171. {
  172. title: "操作",
  173. dataIndex: "operation",
  174. width: "240px",
  175. customCell: () => {
  176. return {
  177. class: "operation-cell",
  178. };
  179. },
  180. },
  181. ];
  182. const curRow = ref<RecognizeCheckListItem | null>(null);
  183. const { dataList, pagination, loading, getList, toPage, deletePageLastItem } =
  184. useTable<RecognizeCheckListItem>(recognizeCheckListPage, searchModel, false);
  185. type ActionType =
  186. | "arbitrate"
  187. | "edit"
  188. | "reset"
  189. | "recheck"
  190. | "buildTask"
  191. | "delete";
  192. function checkActionValid(index: number, type: ActionType): boolean {
  193. const record = dataList.value[index];
  194. if (type === "arbitrate") {
  195. return record.stage === "SECOND" && record.unarbitrateCount > 0;
  196. }
  197. if (type === "edit") {
  198. return record.totalCount === 0;
  199. }
  200. if (type === "reset") {
  201. return true;
  202. }
  203. if (type === "recheck") {
  204. return (
  205. record.stage === "FIRST" &&
  206. record.finishCount === record.totalCount &&
  207. record.finishCount > 0
  208. );
  209. }
  210. if (type === "buildTask") {
  211. return !record.fixed;
  212. }
  213. if (type === "delete") {
  214. return !record.fixed;
  215. }
  216. return true;
  217. }
  218. function checkDangerActionRunning(index: number) {
  219. const record = dataList.value[index];
  220. return record.building || record.deleting || record.reseting;
  221. }
  222. function getConditionContent(index: number): string {
  223. const record = dataList.value[index];
  224. return record.conditions
  225. .map((item) => `${conditionMap.value[item.code]}${item.value || ""}`)
  226. .join(";");
  227. }
  228. function getConditionProgress(index: number): string {
  229. const record = dataList.value[index];
  230. if (!record.totalCount) return "0.00%";
  231. const progress = ((100 * record.finishCount) / record.totalCount).toFixed(2);
  232. return `${progress}%`;
  233. }
  234. const modifyRecognizeCheckTaskRef = ref();
  235. function onAdd() {
  236. curRow.value = null;
  237. modifyRecognizeCheckTaskRef.value?.open();
  238. }
  239. function onEdit(index: number) {
  240. curRow.value = dataList.value[index];
  241. modifyRecognizeCheckTaskRef.value?.open();
  242. }
  243. function onArbitrate(index: number) {
  244. const record = dataList.value[index];
  245. router.push({ name: "RecognizeArbitrate", params: { groupId: record.id } });
  246. }
  247. async function onReset(index: number) {
  248. const confirm = await showConfirm({
  249. content: "确定要重置任务吗?",
  250. }).catch(() => false);
  251. if (confirm !== "confirm") return;
  252. const record = dataList.value[index];
  253. const res = await recognizeCheckResetTask(record.id).catch(() => false);
  254. if (!res) return;
  255. message.success("操作成功");
  256. await getList();
  257. }
  258. async function onRecheck(index: number) {
  259. const confirm = await showConfirm({
  260. content: "确定要复查任务吗?",
  261. }).catch(() => false);
  262. if (confirm !== "confirm") return;
  263. const record = dataList.value[index];
  264. const res = await recognizeCheckTaskStatusSave(record.id).catch(() => false);
  265. if (!res) return;
  266. message.success("操作成功");
  267. await getList();
  268. }
  269. async function onBuildTask(index: number) {
  270. const record = dataList.value[index];
  271. const res = await recognizeCheckBuildTask(record.id).catch(() => false);
  272. if (!res) return;
  273. message.success("操作成功");
  274. await getList();
  275. }
  276. async function onDelete(index: number) {
  277. const confirm = await showConfirm({
  278. content: "确定要删除任务吗?",
  279. }).catch(() => false);
  280. if (confirm !== "confirm") return;
  281. const record = dataList.value[index];
  282. const res = await recognizeCheckTaskDelete(record.id).catch(() => false);
  283. if (!res) return;
  284. deletePageLastItem();
  285. message.success("操作成功");
  286. }
  287. onMounted(async () => {
  288. if (route.name !== "RecognizeCheck") return;
  289. await getConditionList();
  290. await toPage(1);
  291. });
  292. </script>