TaskManage1.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div class="task-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <el-form-item label="档案:">
  6. <archives-select
  7. v-model="filter.paperArchivesId"
  8. placeholder="请选择档案"
  9. >
  10. </archives-select>
  11. </el-form-item>
  12. <el-form-item label="课程:">
  13. <course-select
  14. v-model="filter.courseCode"
  15. :filter-data="filter"
  16. placeholder="请选择课程"
  17. >
  18. </course-select>
  19. </el-form-item>
  20. <el-form-item label-width="0px">
  21. <el-button type="primary" @click="search">查询</el-button>
  22. <el-button v-if="openBarCode" type="primary" @click="toSetOrcArea"
  23. >设置条码识别区</el-button
  24. >
  25. </el-form-item>
  26. </el-form>
  27. </div>
  28. <div class="mb-4 tab-btns">
  29. <el-button
  30. v-for="tab in tabs"
  31. :key="tab.val"
  32. size="medium"
  33. :type="curTab == tab.val ? 'primary' : 'default'"
  34. @click="selectMenu(tab.val)"
  35. >{{ tab.name }}
  36. </el-button>
  37. </div>
  38. <div class="part-box part-box-pad">
  39. <el-table ref="TableList" size="medium" :data="dataList">
  40. <el-table-column
  41. prop="id"
  42. label="任务ID"
  43. min-width="160"
  44. ></el-table-column>
  45. <el-table-column
  46. prop="scanTaskName"
  47. label="任务名称"
  48. min-width="160"
  49. ></el-table-column>
  50. <el-table-column
  51. prop="archivesName"
  52. label="档案名称"
  53. min-width="160"
  54. ></el-table-column>
  55. <el-table-column prop="courseName" label="课程" min-width="200">
  56. <span slot-scope="scope">
  57. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  58. </span>
  59. </el-table-column>
  60. <el-table-column
  61. prop="studentCount"
  62. label="学生数"
  63. min-width="100"
  64. ></el-table-column>
  65. <el-table-column label="实扫/已上传(采集)" width="100" align="center">
  66. <span slot-scope="scope">
  67. {{ scope.row.clientScanCount }} / {{ scope.row.clientUploadCount }}
  68. </span>
  69. </el-table-column>
  70. <el-table-column
  71. prop="scanCount"
  72. label="已上传(后台)"
  73. width="80"
  74. align="center"
  75. ></el-table-column>
  76. <el-table-column
  77. v-if="curTab === 'my'"
  78. class-name="action-column"
  79. prop="enable"
  80. label="状态"
  81. width="80"
  82. fixed="right"
  83. >
  84. <template slot-scope="scope">
  85. <el-button
  86. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  87. type="text"
  88. @click="toEnable(scope.row)"
  89. >
  90. {{ scope.row.enable ? "已完成" : "未完成" }}
  91. </el-button>
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. class-name="action-column"
  96. label="操作"
  97. width="100"
  98. fixed="right"
  99. >
  100. <template slot-scope="scope">
  101. <el-button
  102. v-if="!scope.row.enable"
  103. class="btn-primary"
  104. type="text"
  105. @click="toScan(scope.row)"
  106. >
  107. 扫描
  108. </el-button>
  109. <el-button
  110. v-if="!scope.row.scanCount && scope.row.clientScanCount"
  111. class="btn-danger"
  112. type="text"
  113. @click="toClean(scope.row)"
  114. >
  115. 清除
  116. </el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <div class="part-page">
  121. <el-pagination
  122. background
  123. layout="total,prev, pager, next"
  124. :current-page="current"
  125. :total="total"
  126. :page-size="size"
  127. @current-change="toPage"
  128. >
  129. </el-pagination>
  130. </div>
  131. </div>
  132. <!-- ScanTaskProcessDialog -->
  133. <scan-task-process-dialog
  134. ref="ScanTaskProcessDialog"
  135. :task="curRow"
  136. @on-close="getList"
  137. ></scan-task-process-dialog>
  138. <!-- OcrAreaSetDialog -->
  139. <ocr-area-set-dialog
  140. v-if="openBarCode"
  141. ref="OcrAreaSetDialog"
  142. @modified="getOcrArea"
  143. >
  144. </ocr-area-set-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import db from "../../../plugins/db";
  149. import { taskListPage, enableScanTask } from "../api";
  150. import ScanTaskProcessDialog from "../components/ScanTaskProcessDialog.vue";
  151. import OcrAreaSetDialog from "../components/OcrAreaSetDialog.vue";
  152. import { clearTaskOriginDir } from "../../../plugins/imageOcr";
  153. // import ScanTaskProcessDialog from "../components/ScanTaskDialog.vue";
  154. export default {
  155. name: "task-manage",
  156. components: {
  157. ScanTaskProcessDialog,
  158. OcrAreaSetDialog,
  159. },
  160. data() {
  161. return {
  162. curTab: "all",
  163. tabs: [
  164. {
  165. name: "全部",
  166. val: "all",
  167. },
  168. {
  169. name: "我的",
  170. val: "my",
  171. },
  172. ],
  173. cacheData: {
  174. all: {},
  175. my: {},
  176. },
  177. filter: {
  178. paperArchivesId: "",
  179. courseCode: "",
  180. isMine: false,
  181. },
  182. current: 1,
  183. size: 10,
  184. total: 0,
  185. dataList: [],
  186. curRow: {},
  187. recordList: [],
  188. courseList: [],
  189. teachingClassList: [],
  190. ocrArea: null,
  191. };
  192. },
  193. computed: {
  194. openBarCode() {
  195. return this.$store.state.user.openBarCode;
  196. },
  197. },
  198. mounted() {
  199. this.getOcrArea();
  200. this.search();
  201. },
  202. methods: {
  203. search() {
  204. this.cacheData[this.curTab] = {};
  205. this.toPage(1);
  206. },
  207. async getOcrArea() {
  208. const ocrArea = await db.getDict("ocrArea", "").catch(() => {});
  209. this.ocrArea = ocrArea || null;
  210. this.$store.commit(
  211. "client/setOcrArea",
  212. ocrArea ? JSON.parse(ocrArea) : {}
  213. );
  214. },
  215. async getList() {
  216. let datas = {
  217. pageNumber: this.current,
  218. pageSize: this.size,
  219. };
  220. if (this.curTab === "all") {
  221. datas = { ...datas, ...this.filter };
  222. } else {
  223. datas = { ...datas, isMine: true };
  224. }
  225. const data = await taskListPage(datas);
  226. this.dataList = data.records;
  227. this.total = data.total;
  228. this.updateTaskCount();
  229. },
  230. toPage(page) {
  231. this.current = page;
  232. this.getList();
  233. },
  234. async updateTaskCount() {
  235. for (let i = 0; i < this.dataList.length; i++) {
  236. const task = this.dataList[i];
  237. const scanCount = await db.countScanList({ taskId: task.id });
  238. this.$set(task, "clientScanCount", scanCount);
  239. const uploadCount = await db.countScanList({
  240. taskId: task.id,
  241. isUpload: 1,
  242. });
  243. this.$set(task, "clientUploadCount", uploadCount);
  244. }
  245. },
  246. selectMenu(curTab) {
  247. this.cacheData[this.curTab] = {
  248. current: this.current,
  249. total: this.total,
  250. dataList: this.dataList,
  251. };
  252. this.curTab = curTab;
  253. if (this.cacheData[this.curTab].total) {
  254. const { current, total, dataList } = this.cacheData[this.curTab];
  255. this.current = current;
  256. this.total = total;
  257. this.dataList = dataList;
  258. } else {
  259. this.toPage(1);
  260. }
  261. },
  262. toScan(row) {
  263. if (row.enable) return;
  264. if (this.openBarCode && !this.ocrArea) {
  265. this.$message.error("请先设置条形码识别区!");
  266. return;
  267. }
  268. this.curRow = row;
  269. this.$refs.ScanTaskProcessDialog.open();
  270. },
  271. toSetOrcArea() {
  272. this.$refs.OcrAreaSetDialog.open();
  273. },
  274. async toEnable(row) {
  275. await enableScanTask({
  276. paperScanTaskId: row.id,
  277. enable: !row.enable,
  278. });
  279. row.enable = !row.enable;
  280. },
  281. async toClean(row) {
  282. if (!(row.clientScanCount && !row.scanCount)) return;
  283. this.$parent.$parent.stopUpload();
  284. const res = await db.deleteScanByTaskId(row.id).catch((err) => {
  285. console.error(err);
  286. });
  287. if (!res) {
  288. this.$message.error("本地数据删除错误!");
  289. this.$parent.$parent.initUploadTask();
  290. return;
  291. }
  292. try {
  293. clearTaskOriginDir(row.id);
  294. } catch (error) {
  295. console.error(error);
  296. this.$message.error("本地文件删除错误!");
  297. }
  298. this.$parent.$parent.initUploadTask();
  299. this.getList();
  300. },
  301. },
  302. };
  303. </script>