PaperStructure.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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="结构名称" class="pull-left">
  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="创建人" class="pull-left">
  27. <el-input
  28. v-model="formSearch.creator"
  29. class="search_width"
  30. placeholder="请输入创建人"
  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. v-model="formSearch.courseNo"
  39. class="search_width"
  40. filterable
  41. :remote-method="getCourses"
  42. remote
  43. placeholder="请选择"
  44. size="small"
  45. >
  46. <el-option key="ALL" label="请选择" value="ALL"></el-option>
  47. <el-option key label="公用" value></el-option>
  48. <el-option
  49. v-for="item in courseInfoSelect"
  50. :key="item.courseNo"
  51. :label="item.courseInfo"
  52. :value="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. :disabled="noBatchSelected"
  81. @click="deletePapers"
  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. v-loading="loading"
  92. :data="tableData"
  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="40"></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-page="currentPage"
  158. :page-size="pageSize"
  159. :page-sizes="[10, 20, 50, 100, 200, 300]"
  160. layout="total, sizes, prev, pager, next, jumper"
  161. :total="total"
  162. @current-change="handleCurrentChange"
  163. @size-change="handleSizeChange"
  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. computed: {
  196. selectedIds() {
  197. var selectedIdsStr = "";
  198. for (let id of this.selectedList) {
  199. if (!selectedIdsStr) {
  200. selectedIdsStr += id;
  201. } else {
  202. selectedIdsStr += "," + id;
  203. }
  204. }
  205. return selectedIdsStr;
  206. },
  207. courseInfoSelect() {
  208. var courseList = [];
  209. for (let course of this.courseList) {
  210. var courseInfo = course.name + "(" + course.code + ")";
  211. var courseNo = course.code;
  212. courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
  213. }
  214. return courseList;
  215. },
  216. noBatchSelected() {
  217. return this.selectedList.length === 0;
  218. },
  219. },
  220. watch: {
  221. $route: "initVue",
  222. },
  223. created() {
  224. this.initVue();
  225. this.removeItem();
  226. },
  227. methods: {
  228. //重置
  229. resetForm() {
  230. this.formSearch = {
  231. name: "",
  232. creator: "",
  233. courseNo: "ALL",
  234. type: "EXACT",
  235. };
  236. },
  237. //查询
  238. searchFrom() {
  239. this.currentPage = 1;
  240. this.searchPaperStructs();
  241. },
  242. searchPaperStructs() {
  243. var pageNo = Number(this.currentPage);
  244. this.currentPage = 1;
  245. this.loading = true;
  246. var url = QUESTION_API + "/paperStruct/" + pageNo + "/" + this.pageSize;
  247. this.$http.get(url, { params: this.formSearch }).then((response) => {
  248. this.tableData = response.data.content;
  249. this.total = response.data.totalElements;
  250. this.currentPage = pageNo;
  251. });
  252. this.loading = false;
  253. },
  254. //全选
  255. selectionChange(val) {
  256. this.selectedList = [];
  257. var selectedList = this.selectedList;
  258. val.forEach((element) => {
  259. selectedList.push(element.id);
  260. });
  261. this.selectedList = selectedList;
  262. },
  263. getCourseName(courseNo) {
  264. for (let course of this.courseList) {
  265. if (course.code == courseNo) {
  266. this.formSearch.courseName = course.name;
  267. }
  268. }
  269. },
  270. editPaperStruct(row) {
  271. this.getCourseName(this.formSearch.courseNo);
  272. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  273. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  274. sessionStorage.setItem("paperStruct", JSON.stringify(row));
  275. this.$router.push({
  276. path: "/questions/insert_paper_structure/" + row.id,
  277. });
  278. },
  279. //删除单条数据
  280. deletePaper(index, row) {
  281. this.$confirm("是否删除试卷结构?", "提示", {
  282. confirmButtonText: "确定",
  283. cancelButtonText: "取消",
  284. type: "warning",
  285. })
  286. .then(() => {
  287. var url = QUESTION_API + "/paperStruct/" + row.id;
  288. this.loading = true;
  289. this.$httpWithMsg.delete(url).then(() => {
  290. this.$notify({
  291. type: "success",
  292. message: "删除成功!",
  293. });
  294. this.searchPaperStructs();
  295. });
  296. })
  297. .finally(() => (this.loading = false));
  298. },
  299. //删除多条数据
  300. deletePapers() {
  301. this.$confirm("是否删除试卷结构?", "提示", {
  302. confirmButtonText: "确定",
  303. cancelButtonText: "取消",
  304. type: "error",
  305. })
  306. .then(() => {
  307. this.loading = true;
  308. var url = QUESTION_API + "/paperStruct/" + this.selectedIds;
  309. this.$httpWithMsg.delete(url).then(() => {
  310. this.$notify({
  311. type: "success",
  312. message: "删除成功!",
  313. });
  314. this.searchPaperStructs();
  315. this.selectedList = [];
  316. });
  317. })
  318. .finally(() => (this.loading = false));
  319. },
  320. //新增
  321. addPaperStruct() {
  322. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  323. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  324. this.$router.push({
  325. path: "/questions/insert_paper_structure/add",
  326. });
  327. },
  328. //分页跳转
  329. handleCurrentChange(val) {
  330. this.currentPage = val;
  331. this.searchPaperStructs();
  332. },
  333. handleSizeChange(val) {
  334. this.pageSize = val;
  335. this.currentPage = 1;
  336. this.searchPaperStructs();
  337. },
  338. //查询所有课程
  339. getCourses(query) {
  340. query = query.trim();
  341. if (query) {
  342. if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
  343. this.courseLoading = true;
  344. this.$http
  345. .get(CORE_API + "/course/query?name=" + query + "&enable=true")
  346. .then((response) => {
  347. this.courseList = response.data;
  348. this.courseLoading = false;
  349. });
  350. }
  351. } else {
  352. this.courseList = [];
  353. }
  354. },
  355. getType(val) {
  356. if (val == "ENSEMBLE") {
  357. return "宏观结构";
  358. }
  359. return "微观结构";
  360. },
  361. removeItem() {
  362. sessionStorage.removeItem("paperStruct");
  363. },
  364. initVue() {
  365. this.isClear = this.$route.params.isClear;
  366. if (this.isClear == 0 || !this.isClear) {
  367. sessionStorage.removeItem("paper_stucture");
  368. sessionStorage.removeItem("paper_stucture_currentPage");
  369. this.formSearch = {
  370. name: "",
  371. creator: "",
  372. courseNo: "ALL",
  373. type: "EXACT",
  374. courseName: "",
  375. };
  376. this.currentPage = 1;
  377. } else {
  378. this.formSearch = JSON.parse(sessionStorage.getItem("paper_stucture"));
  379. this.currentPage = parseInt(
  380. sessionStorage.getItem("paper_stucture_currentPage")
  381. );
  382. }
  383. if (this.formSearch.courseName) {
  384. this.getCourses(this.formSearch.courseName);
  385. }
  386. this.searchPaperStructs();
  387. },
  388. },
  389. };
  390. </script>
  391. <style scoped src="../styles/Common.css"></style>