BluePaperStructure.vue 11 KB

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