TaskManage.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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
  66. prop="studentCount"
  67. label="实扫/已上传(采集)"
  68. min-width="100"
  69. >
  70. <span slot-scope="scope">
  71. {{ scope.row.scanCount }} / {{ scope.row.uploadCount }}
  72. </span>
  73. </el-table-column>
  74. <el-table-column
  75. prop="scanCount"
  76. label="已上传(后台)"
  77. min-width="100"
  78. ></el-table-column>
  79. <el-table-column
  80. v-if="curTab === 'my'"
  81. class-name="action-column"
  82. prop="enable"
  83. label="状态"
  84. width="80"
  85. fixed="right"
  86. >
  87. <template slot-scope="scope">
  88. <el-button
  89. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  90. type="text"
  91. @click="toEnable(scope.row)"
  92. >
  93. {{ scope.row.enable ? "已完成" : "未完成" }}
  94. </el-button>
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. class-name="action-column"
  99. label="操作"
  100. width="80"
  101. fixed="right"
  102. >
  103. <template slot-scope="scope">
  104. <el-button
  105. v-if="!scope.row.enable"
  106. class="btn-primary"
  107. type="text"
  108. @click="toScan(scope.row)"
  109. >
  110. 扫描
  111. </el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <div class="part-page">
  116. <el-pagination
  117. background
  118. layout="total,prev, pager, next"
  119. :current-page="current"
  120. :total="total"
  121. :page-size="size"
  122. @current-change="toPage"
  123. >
  124. </el-pagination>
  125. </div>
  126. </div>
  127. <!-- ScanTaskProcessDialog -->
  128. <scan-task-process-dialog
  129. ref="ScanTaskProcessDialog"
  130. :task="curRow"
  131. @on-close="getList"
  132. ></scan-task-process-dialog>
  133. <!-- OcrAreaSetDialog -->
  134. <ocr-area-set-dialog
  135. v-if="openBarCode"
  136. ref="OcrAreaSetDialog"
  137. @modified="getOcrArea"
  138. >
  139. </ocr-area-set-dialog>
  140. </div>
  141. </template>
  142. <script>
  143. import db from "../../../plugins/db";
  144. import { taskListPage, enableScanTask } from "../api";
  145. import ScanTaskProcessDialog from "../components/ScanTaskProcessDialog.vue";
  146. import OcrAreaSetDialog from "../components/OcrAreaSetDialog.vue";
  147. // import ScanTaskProcessDialog from "../components/ScanTaskDialog.vue";
  148. export default {
  149. name: "task-manage",
  150. components: {
  151. ScanTaskProcessDialog,
  152. OcrAreaSetDialog
  153. },
  154. data() {
  155. return {
  156. curTab: "all",
  157. tabs: [
  158. {
  159. name: "全部",
  160. val: "all"
  161. },
  162. {
  163. name: "我的",
  164. val: "my"
  165. }
  166. ],
  167. cacheData: {
  168. all: {},
  169. my: {}
  170. },
  171. filter: {
  172. paperArchivesId: "",
  173. courseCode: "",
  174. isMine: false
  175. },
  176. current: 1,
  177. size: 10,
  178. total: 0,
  179. dataList: [],
  180. curRow: {},
  181. recordList: [],
  182. courseList: [],
  183. teachingClassList: [],
  184. ocrArea: null
  185. };
  186. },
  187. computed: {
  188. openBarCode() {
  189. return this.$store.state.user.openBarCode;
  190. }
  191. },
  192. mounted() {
  193. this.getOcrArea();
  194. this.search();
  195. },
  196. methods: {
  197. search() {
  198. this.cacheData[this.curTab] = {};
  199. this.toPage(1);
  200. },
  201. async getOcrArea() {
  202. const ocrArea = await db.getDict("ocrArea", "").catch(() => {});
  203. this.ocrArea = ocrArea || null;
  204. this.$store.commit(
  205. "client/setOcrArea",
  206. ocrArea ? JSON.parse(ocrArea) : {}
  207. );
  208. },
  209. async getList() {
  210. let datas = {
  211. pageNumber: this.current,
  212. pageSize: this.size
  213. };
  214. if (this.curTab === "all") {
  215. datas = { ...datas, ...this.filter };
  216. } else {
  217. datas = { ...datas, isMine: true };
  218. }
  219. const data = await taskListPage(datas);
  220. this.dataList = data.records;
  221. this.total = data.total;
  222. this.updateTaskCount();
  223. },
  224. toPage(page) {
  225. this.current = page;
  226. this.getList();
  227. },
  228. async updateTaskCount() {
  229. for (let i = 0; i < this.dataList.length; i++) {
  230. const task = this.dataList[i];
  231. const scanCount = await db.countScanList({ taskId: task.id });
  232. this.$set(task, "scanCount", scanCount);
  233. const uploadCount = await db.countScanList({
  234. taskId: task.id,
  235. isUpload: 1
  236. });
  237. this.$set(task, "uploadCount", uploadCount);
  238. }
  239. },
  240. selectMenu(curTab) {
  241. this.cacheData[this.curTab] = {
  242. current: this.current,
  243. total: this.total,
  244. dataList: this.dataList
  245. };
  246. this.curTab = curTab;
  247. if (this.cacheData[this.curTab].total) {
  248. const { current, total, dataList } = this.cacheData[this.curTab];
  249. this.current = current;
  250. this.total = total;
  251. this.dataList = dataList;
  252. } else {
  253. this.toPage(1);
  254. }
  255. },
  256. toScan(row) {
  257. if (row.enable) return;
  258. if (this.openBarCode && !this.ocrArea) {
  259. this.$message.error("请先设置条形码识别区!");
  260. return;
  261. }
  262. this.curRow = row;
  263. this.$refs.ScanTaskProcessDialog.open();
  264. },
  265. toSetOrcArea() {
  266. this.$refs.OcrAreaSetDialog.open();
  267. },
  268. async toEnable(row) {
  269. await enableScanTask({
  270. paperScanTaskId: row.id,
  271. enable: !row.enable
  272. });
  273. row.enable = !row.enable;
  274. }
  275. }
  276. };
  277. </script>