PaperStructure.vue 12 KB

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