PaperStructure.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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="65">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.detailCount }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="小题数" width="65">
  125. <template slot-scope="scope">
  126. <span>{{ scope.row.detailUnitCount }}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="总分" width="55">
  130. <template slot-scope="scope">
  131. <span>{{ scope.row.totalScore }}</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="创建人" width="100">
  135. <template slot-scope="scope">
  136. <span>{{ scope.row.creator }}</span>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="操作" width="175">
  140. <template slot-scope="scope">
  141. <div class="operate_left">
  142. <el-button
  143. size="mini"
  144. type="primary"
  145. plain
  146. @click="editPaperStruct(scope.row)"
  147. ><i class="el-icon-edit"></i>编辑</el-button
  148. >
  149. <el-button
  150. size="mini"
  151. type="danger"
  152. @click="deletePaper(scope.$index, scope.row)"
  153. ><i class="el-icon-delete"></i> 删除</el-button
  154. >
  155. </div>
  156. </template>
  157. </el-table-column>
  158. </el-table>
  159. <div class="page pull-right">
  160. <el-pagination
  161. @current-change="handleCurrentChange"
  162. :current-page="currentPage"
  163. :page-size="pageSize"
  164. :page-sizes="[10, 20, 50, 100]"
  165. @size-change="handleSizeChange"
  166. layout="total, prev, pager, next, jumper"
  167. :total="total"
  168. ></el-pagination>
  169. </div>
  170. </div>
  171. </section>
  172. </template>
  173. <script>
  174. import { CORE_API, QUESTION_API } from "@/constants/constants";
  175. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  176. export default {
  177. components: { LinkTitlesCustom },
  178. data() {
  179. return {
  180. courseLoading: false,
  181. formSearch: {
  182. name: "",
  183. creator: "",
  184. courseNo: "ALL",
  185. type: "EXACT",
  186. courseName: ""
  187. },
  188. paperStructId: "",
  189. loading: false,
  190. tableData: [],
  191. selectedList: [],
  192. currentPage: 1,
  193. pageSize: 10,
  194. total: 10,
  195. courseList: [],
  196. isClear: 0
  197. };
  198. },
  199. methods: {
  200. //重置
  201. resetForm() {
  202. this.formSearch = {
  203. name: "",
  204. creator: "",
  205. courseNo: "ALL",
  206. type: "EXACT"
  207. };
  208. },
  209. //查询
  210. searchFrom() {
  211. this.currentPage = 1;
  212. this.searchPaperStructs();
  213. },
  214. searchPaperStructs() {
  215. this.loading = true;
  216. var url =
  217. QUESTION_API + "/paperStruct/" + this.currentPage + "/" + this.pageSize;
  218. this.$http.get(url, { params: this.formSearch }).then(response => {
  219. this.tableData = response.data.content;
  220. this.total = response.data.totalElements;
  221. });
  222. this.loading = false;
  223. },
  224. //全选
  225. selectionChange(val) {
  226. this.selectedList = [];
  227. var selectedList = this.selectedList;
  228. val.forEach(element => {
  229. selectedList.push(element.id);
  230. });
  231. this.selectedList = selectedList;
  232. },
  233. getCourseName(courseNo) {
  234. for (let course of this.courseList) {
  235. if (course.code == courseNo) {
  236. this.formSearch.courseName = course.name;
  237. }
  238. }
  239. },
  240. editPaperStruct(row) {
  241. this.getCourseName(this.formSearch.courseNo);
  242. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  243. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  244. sessionStorage.setItem("paperStruct", JSON.stringify(row));
  245. this.$router.push({
  246. path: "/questions/insert_paper_structure/" + row.id
  247. });
  248. },
  249. //删除单条数据
  250. deletePaper(index, row) {
  251. this.$confirm("是否删除试卷结构?", "提示", {
  252. confirmButtonText: "确定",
  253. cancelButtonText: "取消",
  254. type: "warning"
  255. }).then(() => {
  256. var url = QUESTION_API + "/paperStruct/" + row.id;
  257. this.loading = true;
  258. this.$http.delete(url).then(
  259. () => {
  260. this.$notify({
  261. type: "success",
  262. message: "删除成功!"
  263. });
  264. this.searchPaperStructs();
  265. },
  266. () => {
  267. this.$notify({
  268. type: "error",
  269. message: "删除失败!"
  270. });
  271. }
  272. );
  273. });
  274. this.loading = false;
  275. },
  276. //删除多条数据
  277. deletePapers() {
  278. this.$confirm("是否删除试卷结构?", "提示", {
  279. confirmButtonText: "确定",
  280. cancelButtonText: "取消",
  281. type: "error"
  282. }).then(() => {
  283. this.loading = true;
  284. var url = QUESTION_API + "/paperStruct/" + this.selectedIds;
  285. this.$http
  286. .delete(url)
  287. .then(() => {
  288. this.$notify({
  289. type: "success",
  290. message: "删除成功!"
  291. });
  292. this.searchPaperStructs();
  293. this.selectedList = [];
  294. })
  295. .catch(() => {
  296. this.$notify({
  297. type: "error",
  298. message: "删除失败!"
  299. });
  300. this.selectedList = [];
  301. });
  302. });
  303. this.loading = false;
  304. },
  305. //新增
  306. addPaperStruct() {
  307. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  308. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  309. this.$router.push({
  310. path: "/questions/insert_paper_structure/add"
  311. });
  312. },
  313. //分页跳转
  314. handleCurrentChange(val) {
  315. this.currentPage = val;
  316. this.searchPaperStructs();
  317. },
  318. handleSizeChange(val) {
  319. this.pageSize = val;
  320. this.currentPage = 1;
  321. this.searchPaperStructs();
  322. },
  323. //查询所有课程
  324. getCourses(query) {
  325. query = query.trim();
  326. if (query) {
  327. if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
  328. this.courseLoading = true;
  329. this.$http
  330. .get(CORE_API + "/course/query?name=" + query + "&enable=true")
  331. .then(response => {
  332. this.courseList = response.data;
  333. this.courseLoading = false;
  334. });
  335. }
  336. } else {
  337. this.courseList = [];
  338. }
  339. },
  340. getType(val) {
  341. if (val == "ENSEMBLE") {
  342. return "宏观结构";
  343. }
  344. return "微观结构";
  345. },
  346. removeItem() {
  347. sessionStorage.removeItem("paperStruct");
  348. },
  349. initVue() {
  350. this.isClear = this.$route.params.isClear;
  351. if (this.isClear == 0 || !this.isClear) {
  352. sessionStorage.removeItem("paper_stucture");
  353. sessionStorage.removeItem("paper_stucture_currentPage");
  354. this.formSearch = {
  355. name: "",
  356. creator: "",
  357. courseNo: "ALL",
  358. type: "EXACT",
  359. courseName: ""
  360. };
  361. this.currentPage = 1;
  362. } else {
  363. this.formSearch = JSON.parse(sessionStorage.getItem("paper_stucture"));
  364. this.currentPage = parseInt(
  365. sessionStorage.getItem("paper_stucture_currentPage")
  366. );
  367. }
  368. if (this.formSearch.courseName) {
  369. this.getCourses(this.formSearch.courseName);
  370. }
  371. this.searchPaperStructs();
  372. }
  373. },
  374. computed: {
  375. selectedIds() {
  376. var selectedIdsStr = "";
  377. for (let id of this.selectedList) {
  378. if (!selectedIdsStr) {
  379. selectedIdsStr += id;
  380. } else {
  381. selectedIdsStr += "," + id;
  382. }
  383. }
  384. return selectedIdsStr;
  385. },
  386. courseInfoSelect() {
  387. var courseList = [];
  388. for (let course of this.courseList) {
  389. var courseInfo = course.name + "(" + course.code + ")";
  390. var courseNo = course.code;
  391. courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
  392. }
  393. return courseList;
  394. },
  395. noBatchSelected() {
  396. return this.selectedList.length === 0;
  397. }
  398. },
  399. watch: {
  400. $route: "initVue"
  401. },
  402. created() {
  403. this.initVue();
  404. this.removeItem();
  405. }
  406. };
  407. </script>
  408. <style scoped src="../styles/Common.css"></style>