PaperStructure.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <section class="content">
  3. <!-- 正文信息 -->
  4. <div class="part-box">
  5. <h2 class="part-box-title">精确结构预设</h2>
  6. <el-form class="part-filter-form" :inline="true" :model="formSearch">
  7. <el-form-item label="结构名称">
  8. <el-input
  9. v-model="formSearch.name"
  10. placeholder="请输入结构名称"
  11. ></el-input>
  12. </el-form-item>
  13. <el-form-item label="创建人">
  14. <el-input
  15. v-model="formSearch.creator"
  16. placeholder="请输入创建人"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item label="制定课程">
  20. <el-select
  21. v-model="formSearch.courseId"
  22. filterable
  23. :remote-method="getCourses"
  24. remote
  25. clearable
  26. placeholder="请选择"
  27. @clear="getCourses('')"
  28. >
  29. <el-option label="公用" value="-1"></el-option>
  30. <el-option
  31. v-for="item in courseInfoSelect"
  32. :key="item.courseId"
  33. :label="item.courseInfo"
  34. :value="item.courseId"
  35. ></el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button type="danger" @click="searchFrom">查询</el-button>
  40. <el-button type="danger" plain @click="resetForm">重置</el-button>
  41. </el-form-item>
  42. </el-form>
  43. <div class="part-box-action">
  44. <el-button
  45. type="danger"
  46. plain
  47. icon="icon icon-delete"
  48. :disabled="noBatchSelected"
  49. @click="deletePapers"
  50. >删除
  51. </el-button>
  52. <el-button
  53. type="primary"
  54. icon="icon icon-plus-white"
  55. @click="addPaperStruct"
  56. >新增</el-button
  57. >
  58. </div>
  59. </div>
  60. <div class="part-box">
  61. <!-- 页面列表 -->
  62. <el-table
  63. v-loading="loading"
  64. :data="tableData"
  65. element-loading-text="拼命加载中"
  66. @selection-change="selectionChange"
  67. >
  68. <el-table-column
  69. type="selection"
  70. width="50"
  71. align="center"
  72. ></el-table-column>
  73. <el-table-column label="预设精确结构名称">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.name }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="关联课程" width="180">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.courseName }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="课程代码" width="90">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.courseNo }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="类型" width="80">
  89. <template slot-scope="scope">
  90. <span>{{ getType(scope.row.courseNo) }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="大题数" width="88" sortable prop="detailCount">
  94. </el-table-column>
  95. <el-table-column
  96. label="小题数"
  97. width="88"
  98. sortable
  99. prop="detailUnitCount"
  100. >
  101. </el-table-column>
  102. <el-table-column label="总分" width="78" sortable prop="totalScore">
  103. </el-table-column>
  104. <el-table-column label="创建人" width="100">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.creator }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="操作" width="175" fixed="right">
  110. <template slot-scope="scope">
  111. <div class="operate_left">
  112. <el-button
  113. size="mini"
  114. type="primary"
  115. plain
  116. @click="editPaperStruct(scope.row)"
  117. >编辑</el-button
  118. >
  119. <el-button
  120. size="mini"
  121. type="danger"
  122. plain
  123. @click="deletePaper(scope.$index, scope.row)"
  124. >删除</el-button
  125. >
  126. </div>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <div class="part-page">
  131. <el-pagination
  132. :current-page="currentPage"
  133. :page-size="pageSize"
  134. :page-sizes="[10, 20, 50, 100, 200, 300]"
  135. layout="total, sizes, prev, pager, next, jumper"
  136. :total="total"
  137. @current-change="handleCurrentChange"
  138. @size-change="handleSizeChange"
  139. ></el-pagination>
  140. </div>
  141. </div>
  142. </section>
  143. </template>
  144. <script>
  145. import { QUESTION_API } from "@/constants/constants";
  146. export default {
  147. data() {
  148. return {
  149. courseLoading: false,
  150. formSearch: {
  151. name: "",
  152. creator: "",
  153. courseId: null,
  154. type: "EXACT",
  155. courseName: "",
  156. },
  157. paperStructId: "",
  158. loading: false,
  159. tableData: [],
  160. selectedList: [],
  161. currentPage: 1,
  162. pageSize: 10,
  163. total: 10,
  164. courseList: [],
  165. isClear: 0,
  166. };
  167. },
  168. computed: {
  169. selectedIds() {
  170. var selectedIdsStr = "";
  171. for (let id of this.selectedList) {
  172. if (!selectedIdsStr) {
  173. selectedIdsStr += id;
  174. } else {
  175. selectedIdsStr += "," + id;
  176. }
  177. }
  178. return selectedIdsStr;
  179. },
  180. courseInfoSelect() {
  181. var courseList = [];
  182. for (let course of this.courseList) {
  183. var courseInfo = course.name + "(" + course.code + ")";
  184. var courseId = course.id;
  185. courseList.push({ courseId: courseId, courseInfo: courseInfo });
  186. }
  187. return courseList;
  188. },
  189. noBatchSelected() {
  190. return this.selectedList.length === 0;
  191. },
  192. },
  193. watch: {
  194. $route: "initVue",
  195. },
  196. created() {
  197. this.initVue();
  198. this.removeItem();
  199. },
  200. methods: {
  201. //重置
  202. resetForm() {
  203. this.formSearch = {
  204. name: "",
  205. creator: "",
  206. courseId: null,
  207. type: "EXACT",
  208. };
  209. },
  210. //查询
  211. searchFrom() {
  212. this.currentPage = 1;
  213. this.searchPaperStructs();
  214. },
  215. searchPaperStructs() {
  216. var pageNo = Number(this.currentPage);
  217. this.currentPage = 1;
  218. this.loading = true;
  219. var url = QUESTION_API + "/paperStruct/" + pageNo + "/" + this.pageSize;
  220. this.$http.get(url, { params: this.formSearch }).then((response) => {
  221. this.tableData = response.data.content;
  222. this.total = response.data.totalElements;
  223. this.currentPage = pageNo;
  224. });
  225. this.loading = false;
  226. },
  227. //全选
  228. selectionChange(val) {
  229. this.selectedList = [];
  230. var selectedList = this.selectedList;
  231. val.forEach((element) => {
  232. selectedList.push(element.id);
  233. });
  234. this.selectedList = selectedList;
  235. },
  236. getCourseName(courseId) {
  237. for (let course of this.courseList) {
  238. if (course.courseId == courseId) {
  239. this.formSearch.courseName = course.name;
  240. }
  241. }
  242. },
  243. editPaperStruct(row) {
  244. this.getCourseName(this.formSearch.courseId);
  245. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  246. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  247. sessionStorage.setItem("paperStruct", JSON.stringify(row));
  248. this.$router.push({
  249. path: "/questions/insert_paper_structure/" + row.id,
  250. });
  251. },
  252. //删除单条数据
  253. deletePaper(index, row) {
  254. this.$confirm("是否删除试卷结构?", "提示", {
  255. confirmButtonText: "确定",
  256. cancelButtonText: "取消",
  257. type: "warning",
  258. }).then(() => {
  259. var url = QUESTION_API + "/paperStruct/" + row.id;
  260. this.loading = true;
  261. this.$http.delete(url).then(
  262. () => {
  263. this.$notify({
  264. type: "success",
  265. message: "删除成功!",
  266. });
  267. this.searchPaperStructs();
  268. },
  269. () => {
  270. this.$notify({
  271. type: "error",
  272. message: "删除失败!",
  273. });
  274. }
  275. );
  276. });
  277. this.loading = false;
  278. },
  279. //删除多条数据
  280. deletePapers() {
  281. this.$confirm("是否删除试卷结构?", "提示", {
  282. confirmButtonText: "确定",
  283. cancelButtonText: "取消",
  284. type: "error",
  285. }).then(() => {
  286. this.loading = true;
  287. var url = QUESTION_API + "/paperStruct/" + this.selectedIds;
  288. this.$http
  289. .delete(url)
  290. .then(() => {
  291. this.$notify({
  292. type: "success",
  293. message: "删除成功!",
  294. });
  295. this.searchPaperStructs();
  296. this.selectedList = [];
  297. })
  298. .catch(() => {
  299. this.$notify({
  300. type: "error",
  301. message: "删除失败!",
  302. });
  303. this.selectedList = [];
  304. });
  305. });
  306. this.loading = false;
  307. },
  308. //新增
  309. addPaperStruct() {
  310. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  311. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  312. this.$router.push({
  313. path: "/questions/insert_paper_structure/add",
  314. });
  315. },
  316. //分页跳转
  317. handleCurrentChange(val) {
  318. this.currentPage = val;
  319. this.searchPaperStructs();
  320. },
  321. handleSizeChange(val) {
  322. this.pageSize = val;
  323. this.currentPage = 1;
  324. this.searchPaperStructs();
  325. },
  326. //查询所有课程
  327. getCourses(query) {
  328. this.courseLoading = true;
  329. this.$http
  330. .get(QUESTION_API + "/course/query?name=" + query + "&enable=true")
  331. .then((response) => {
  332. this.courseList = response.data;
  333. this.courseLoading = false;
  334. });
  335. },
  336. getType(val) {
  337. if (val == "ENSEMBLE") {
  338. return "宏观结构";
  339. }
  340. return "微观结构";
  341. },
  342. removeItem() {
  343. sessionStorage.removeItem("paperStruct");
  344. },
  345. initVue() {
  346. this.isClear = this.$route.params.isClear;
  347. if (this.isClear == 0 || !this.isClear) {
  348. sessionStorage.removeItem("paper_stucture");
  349. sessionStorage.removeItem("paper_stucture_currentPage");
  350. this.formSearch = {
  351. name: "",
  352. creator: "",
  353. courseId: null,
  354. type: "EXACT",
  355. courseName: "",
  356. };
  357. this.currentPage = 1;
  358. this.getCourses("");
  359. } else {
  360. this.formSearch = JSON.parse(sessionStorage.getItem("paper_stucture"));
  361. this.currentPage = parseInt(
  362. sessionStorage.getItem("paper_stucture_currentPage")
  363. );
  364. }
  365. if (this.formSearch.courseName) {
  366. this.getCourses(this.formSearch.courseName);
  367. } else {
  368. this.getCourses("");
  369. }
  370. this.searchPaperStructs();
  371. },
  372. },
  373. };
  374. </script>