PublishPrintTask.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <el-dialog
  3. class="publish-print-task"
  4. :visible.sync="modalIsShow"
  5. title="发布印刷任务"
  6. fullscreen
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. @opened="visibleChange"
  11. >
  12. <div class="md-4">
  13. <el-form ref="FilterForm" label-position="left" label-width="0" inline>
  14. <el-form-item>
  15. <print-plan-select
  16. v-model.trim="filter.printPlanId"
  17. placeholder="印刷计划"
  18. clearable
  19. @change="printPlanChange"
  20. ></print-plan-select>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-date-picker
  24. v-model="createDate"
  25. type="date"
  26. :disabled="timeDisabled"
  27. value-format="timestamp"
  28. placeholder="考试日期"
  29. style="width: 150px"
  30. @change="timeChange"
  31. >
  32. </el-date-picker>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-time-picker
  36. is-range
  37. v-model="createTime"
  38. range-separator="至"
  39. start-placeholder="考试开始时间"
  40. end-placeholder="考试结束时间"
  41. placeholder="选择时间范围"
  42. value-format="timestamp"
  43. :disabled="timeDisabled"
  44. @change="timeChange"
  45. >
  46. </el-time-picker>
  47. </el-form-item>
  48. </el-form>
  49. </div>
  50. <el-button class="mb-2" type="primary" @click="toAdd"
  51. >增加考试对象</el-button
  52. >
  53. <el-table ref="TableList" :data="tableData">
  54. <el-table-column type="index" width="80" label="卷袋序号">
  55. </el-table-column>
  56. <el-table-column prop="examRoom" label="考场"> </el-table-column>
  57. <el-table-column prop="examPlace" label="考点"> </el-table-column>
  58. <el-table-column prop="invigilatorTeacher" label="监考老师">
  59. </el-table-column>
  60. <el-table-column prop="className" label="考试对象"> </el-table-column>
  61. <el-table-column prop="studentCount" label="人数"> </el-table-column>
  62. <el-table-column prop="printHouseName" label="印刷室"> </el-table-column>
  63. <el-table-column
  64. v-for="item in extendFields"
  65. :key="item.code"
  66. :label="item.name"
  67. >
  68. <div slot-scope="scope">
  69. {{ scope.row.extends[item.code] }}
  70. </div>
  71. </el-table-column>
  72. <el-table-column label="操作" width="160">
  73. <template slot-scope="scope">
  74. <el-button
  75. class="btn-primary"
  76. type="text"
  77. @click="toPreview(scope.row)"
  78. >考生明细</el-button
  79. >
  80. <el-button class="btn-primary" type="text" @click="toEdit(scope.row)"
  81. >编辑</el-button
  82. >
  83. <el-button class="btn-danger" type="text" @click="toDelete(scope.row)"
  84. >删除</el-button
  85. >
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <div class="part-page">
  90. <el-pagination
  91. background
  92. layout="total,prev, pager, next"
  93. :current-page="current"
  94. :total="total"
  95. :page-size="size"
  96. @current-change="toPage"
  97. >
  98. </el-pagination>
  99. </div>
  100. <div slot="footer"></div>
  101. <!-- CreatePrintTask -->
  102. <create-print-task
  103. ref="CreatePrintTask"
  104. :instance="curRow"
  105. :clazzs="clazzs"
  106. :extend-fields="extendFields"
  107. @modified="getList"
  108. ></create-print-task>
  109. <!-- PrintTaskStudents -->
  110. <print-task-students
  111. ref="PrintTaskStudents"
  112. :class-id="curClassId"
  113. ></print-task-students>
  114. </el-dialog>
  115. </template>
  116. <script>
  117. import { listTaskPrint, removeTaskPrint } from "../api";
  118. import { examRuleDetail } from "../../base/api";
  119. import CreatePrintTask from "./CreatePrintTask";
  120. import PrintTaskStudents from "./PrintTaskStudents";
  121. import { getTimeDatestamp } from "@/plugins/utils";
  122. export default {
  123. name: "publish-print-task",
  124. components: { CreatePrintTask, PrintTaskStudents },
  125. props: {
  126. instance: {
  127. type: Object,
  128. default() {
  129. return {};
  130. }
  131. }
  132. },
  133. data() {
  134. return {
  135. modalIsShow: false,
  136. isSubmit: false,
  137. filter: {
  138. printPlanName: "",
  139. printPlanId: "",
  140. examStartTime: "",
  141. examEndTime: "",
  142. paperNumber: "",
  143. courseName: "",
  144. courseCode: ""
  145. },
  146. current: 1,
  147. size: this.GLOBAL.pageSize,
  148. total: 0,
  149. timeDisabled: false,
  150. tableData: [],
  151. curRow: {},
  152. printRooms: [],
  153. teachers: [],
  154. clazzs: [],
  155. curClassId: "",
  156. extendFields: [],
  157. // date-picker
  158. curCreateTime: [],
  159. createDate: "",
  160. createTime: []
  161. };
  162. },
  163. created() {
  164. this.getExtendFields();
  165. const curDate = getTimeDatestamp(Date.now());
  166. const hour = 60 * 60 * 1000;
  167. this.curCreateTime = [curDate + 8 * hour, curDate + 10 * hour];
  168. this.createTime = [...this.curCreateTime];
  169. },
  170. methods: {
  171. visibleChange() {
  172. this.filter = this.$objAssign(this.filter, this.instance);
  173. this.tableData = [];
  174. this.curRow = {};
  175. },
  176. async getExtendFields() {
  177. const examRule = await examRuleDetail();
  178. this.extendFields = examRule.extendFields
  179. ? JSON.parse(examRule.extendFields)
  180. : [];
  181. },
  182. async getList() {
  183. const datas = {
  184. printPlanId: this.filter.printPlanId,
  185. courseCode: this.instance.courseCode,
  186. paperNumber: this.instance.paperNumber,
  187. pageNumber: this.current,
  188. pageSize: this.size
  189. };
  190. const data = await listTaskPrint(datas);
  191. if (data.iPage) {
  192. this.tableData = data.iPage.records.map(item => {
  193. item.extends = {};
  194. const extendFields = item.extendFields
  195. ? JSON.parse(item.extendFields)
  196. : [];
  197. extendFields.forEach(field => {
  198. item.extends[field.code] = field.value;
  199. });
  200. return item;
  201. });
  202. this.total = data.iPage.total;
  203. } else {
  204. this.tableData = [];
  205. }
  206. if (data.examStartTime && data.examEndTime) {
  207. this.createTime = [data.examStartTime, data.examEndTime];
  208. this.createDate = getTimeDatestamp(data.examStartTime);
  209. this.filter.examStartTime = this.createTime[0];
  210. this.filter.examEndTime = this.createTime[1];
  211. this.timeDisabled = true;
  212. } else {
  213. this.createTime = [...this.curCreateTime];
  214. this.createDate = null;
  215. this.filter.examStartTime = "";
  216. this.filter.examEndTime = "";
  217. this.timeDisabled = false;
  218. }
  219. },
  220. toPage(page) {
  221. this.current = page;
  222. this.getList();
  223. },
  224. printPlanChange(val) {
  225. if (!val) return;
  226. this.filter.printPlanName = val && val.name;
  227. this.getList();
  228. },
  229. timeChange() {
  230. if (!this.createDate || !this.createTime) {
  231. this.filter.examStartTime = null;
  232. this.filter.examEndTime = null;
  233. return;
  234. }
  235. const curDate = getTimeDatestamp(this.createDate);
  236. const timeDate = getTimeDatestamp(this.createTime[0]);
  237. this.filter.examStartTime = curDate + this.createTime[0] - timeDate;
  238. this.filter.examEndTime = curDate + this.createTime[1] - timeDate;
  239. },
  240. cancel() {
  241. this.modalIsShow = false;
  242. },
  243. open() {
  244. this.modalIsShow = true;
  245. },
  246. toAdd() {
  247. if (
  248. !this.filter.printPlanId ||
  249. !this.filter.examStartTime ||
  250. !this.filter.examEndTime
  251. ) {
  252. this.$message.error("请选择印刷计划和考试时间!");
  253. return;
  254. }
  255. if (this.filter.examStartTime === this.filter.examEndTime) {
  256. this.$message.error("考试开始时间不能等于考试结束时间!");
  257. return;
  258. }
  259. this.curRow = {
  260. examPlace: "",
  261. examRoom: "",
  262. invigilatorTeacher: "",
  263. classId: "",
  264. className: "",
  265. studentCount: null,
  266. printHouseId: null,
  267. printHouseName: null,
  268. ...this.filter
  269. };
  270. this.$refs.CreatePrintTask.open();
  271. },
  272. toEdit(row) {
  273. this.curRow = { ...row, ...this.filter };
  274. this.$refs.CreatePrintTask.open();
  275. },
  276. toPreview(row) {
  277. this.curClassId = row.classId;
  278. this.$refs.PrintTaskStudents.open();
  279. },
  280. async toDelete(row) {
  281. const result = await this.$confirm(`确定要删除当前卷袋吗?`, "提示", {
  282. type: "warning"
  283. }).catch(() => {});
  284. if (result !== "confirm") return;
  285. await removeTaskPrint(row.id);
  286. this.$message.success("删除成功!");
  287. this.deletePageLastItem();
  288. }
  289. }
  290. };
  291. </script>