index.vue 8.6 KB

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