PaperStructure.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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="预设精确结构名称" width="190">
  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. this.loading = true;
  212. var url =
  213. QUESTION_API + "/paperStruct/" + this.currentPage + "/" + this.pageSize;
  214. this.$http.get(url, { params: this.formSearch }).then(response => {
  215. this.tableData = response.data.content;
  216. this.total = response.data.totalElements;
  217. });
  218. this.loading = false;
  219. },
  220. //全选
  221. selectionChange(val) {
  222. this.selectedList = [];
  223. var selectedList = this.selectedList;
  224. val.forEach(element => {
  225. selectedList.push(element.id);
  226. });
  227. this.selectedList = selectedList;
  228. },
  229. getCourseName(courseNo) {
  230. for (let course of this.courseList) {
  231. if (course.code == courseNo) {
  232. this.formSearch.courseName = course.name;
  233. }
  234. }
  235. },
  236. editPaperStruct(row) {
  237. this.getCourseName(this.formSearch.courseNo);
  238. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  239. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  240. sessionStorage.setItem("paperStruct", JSON.stringify(row));
  241. this.$router.push({
  242. path: "/questions/insert_paper_structure/" + row.id
  243. });
  244. },
  245. //删除单条数据
  246. deletePaper(index, row) {
  247. this.$confirm("是否删除试卷结构?", "提示", {
  248. confirmButtonText: "确定",
  249. cancelButtonText: "取消",
  250. type: "warning"
  251. }).then(() => {
  252. var url = QUESTION_API + "/paperStruct/" + row.id;
  253. this.loading = true;
  254. this.$http.delete(url).then(
  255. () => {
  256. this.$notify({
  257. type: "success",
  258. message: "删除成功!"
  259. });
  260. this.searchPaperStructs();
  261. },
  262. () => {
  263. this.$notify({
  264. type: "error",
  265. message: "删除失败!"
  266. });
  267. }
  268. );
  269. });
  270. this.loading = false;
  271. },
  272. //删除多条数据
  273. deletePapers() {
  274. this.$confirm("是否删除试卷结构?", "提示", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "error"
  278. }).then(() => {
  279. this.loading = true;
  280. var url = QUESTION_API + "/paperStruct/" + this.selectedIds;
  281. this.$http
  282. .delete(url)
  283. .then(() => {
  284. this.$notify({
  285. type: "success",
  286. message: "删除成功!"
  287. });
  288. this.searchPaperStructs();
  289. this.selectedList = [];
  290. })
  291. .catch(() => {
  292. this.$notify({
  293. type: "error",
  294. message: "删除失败!"
  295. });
  296. this.selectedList = [];
  297. });
  298. });
  299. this.loading = false;
  300. },
  301. //新增
  302. addPaperStruct() {
  303. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  304. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  305. this.$router.push({
  306. path: "/questions/insert_paper_structure/add"
  307. });
  308. },
  309. //分页跳转
  310. handleCurrentChange(val) {
  311. this.currentPage = val;
  312. this.searchPaperStructs();
  313. },
  314. handleSizeChange(val) {
  315. this.pageSize = val;
  316. this.currentPage = 1;
  317. this.searchPaperStructs();
  318. },
  319. //查询所有课程
  320. getCourses(query) {
  321. query = query.trim();
  322. if (query) {
  323. if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
  324. this.courseLoading = true;
  325. this.$http
  326. .get(CORE_API + "/course/query?name=" + query + "&enable=true")
  327. .then(response => {
  328. this.courseList = response.data;
  329. this.courseLoading = false;
  330. });
  331. }
  332. } else {
  333. this.courseList = [];
  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. courseNo: "ALL",
  354. type: "EXACT",
  355. courseName: ""
  356. };
  357. this.currentPage = 1;
  358. } else {
  359. this.formSearch = JSON.parse(sessionStorage.getItem("paper_stucture"));
  360. this.currentPage = parseInt(
  361. sessionStorage.getItem("paper_stucture_currentPage")
  362. );
  363. }
  364. if (this.formSearch.courseName) {
  365. this.getCourses(this.formSearch.courseName);
  366. }
  367. this.searchPaperStructs();
  368. }
  369. },
  370. computed: {
  371. selectedIds() {
  372. var selectedIdsStr = "";
  373. for (let id of this.selectedList) {
  374. if (!selectedIdsStr) {
  375. selectedIdsStr += id;
  376. } else {
  377. selectedIdsStr += "," + id;
  378. }
  379. }
  380. return selectedIdsStr;
  381. },
  382. courseInfoSelect() {
  383. var courseList = [];
  384. for (let course of this.courseList) {
  385. var courseInfo = course.name + "(" + course.code + ")";
  386. var courseNo = course.code;
  387. courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
  388. }
  389. return courseList;
  390. },
  391. noBatchSelected() {
  392. return this.selectedList.length === 0;
  393. }
  394. },
  395. watch: {
  396. $route: "initVue"
  397. },
  398. created() {
  399. this.initVue();
  400. this.removeItem();
  401. }
  402. };
  403. </script>
  404. <style scoped src="../styles/Common.css"></style>