PaperStructure.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. layout="total, prev, pager, next, jumper"
  165. :total="total"
  166. ></el-pagination>
  167. </div>
  168. </div>
  169. </section>
  170. </template>
  171. <script>
  172. import { CORE_API, QUESTION_API } from "@/constants/constants";
  173. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  174. export default {
  175. components: { LinkTitlesCustom },
  176. data() {
  177. return {
  178. courseLoading: false,
  179. formSearch: {
  180. name: "",
  181. creator: "",
  182. courseNo: "ALL",
  183. type: "EXACT"
  184. },
  185. paperStructId: "",
  186. loading: false,
  187. tableData: [],
  188. selectedList: [],
  189. currentPage: 1,
  190. pageSize: 10,
  191. total: 10,
  192. courseList: [],
  193. isClear: 0
  194. };
  195. },
  196. methods: {
  197. //重置
  198. resetForm() {
  199. this.formSearch = {
  200. name: "",
  201. creator: "",
  202. courseNo: "ALL",
  203. type: "EXACT"
  204. };
  205. },
  206. //查询
  207. searchFrom() {
  208. this.currentPage = 1;
  209. this.searchPaperStructs();
  210. },
  211. searchPaperStructs() {
  212. this.loading = true;
  213. var url =
  214. QUESTION_API + "/paperStruct/" + this.currentPage + "/" + this.pageSize;
  215. this.$http.get(url, { params: this.formSearch }).then(response => {
  216. this.tableData = response.data.content;
  217. this.total = response.data.totalElements;
  218. });
  219. this.loading = false;
  220. },
  221. //全选
  222. selectionChange(val) {
  223. this.selectedList = [];
  224. var selectedList = this.selectedList;
  225. val.forEach(element => {
  226. selectedList.push(element.id);
  227. });
  228. this.selectedList = selectedList;
  229. },
  230. editPaperStruct(row) {
  231. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  232. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  233. sessionStorage.setItem("paperStruct", JSON.stringify(row));
  234. this.$router.push({
  235. path: "/questions/insert_paper_structure/" + row.id
  236. });
  237. },
  238. //删除单条数据
  239. deletePaper(index, row) {
  240. this.$confirm("是否删除试卷结构?", "提示", {
  241. confirmButtonText: "确定",
  242. cancelButtonText: "取消",
  243. type: "warning"
  244. }).then(() => {
  245. var url = QUESTION_API + "/paperStruct/" + row.id;
  246. this.loading = true;
  247. this.$http.delete(url).then(
  248. () => {
  249. this.$notify({
  250. type: "success",
  251. message: "删除成功!"
  252. });
  253. this.searchPaperStructs();
  254. },
  255. () => {
  256. this.$notify({
  257. type: "error",
  258. message: "删除失败!"
  259. });
  260. }
  261. );
  262. });
  263. this.loading = false;
  264. },
  265. //删除多条数据
  266. deletePapers() {
  267. this.$confirm("是否删除试卷结构?", "提示", {
  268. confirmButtonText: "确定",
  269. cancelButtonText: "取消",
  270. type: "error"
  271. }).then(() => {
  272. this.loading = true;
  273. var url = QUESTION_API + "/paperStruct/" + this.selectedIds;
  274. this.$http
  275. .delete(url)
  276. .then(() => {
  277. this.$notify({
  278. type: "success",
  279. message: "删除成功!"
  280. });
  281. this.searchPaperStructs();
  282. this.selectedList = [];
  283. })
  284. .catch(() => {
  285. this.$notify({
  286. type: "error",
  287. message: "删除失败!"
  288. });
  289. this.selectedList = [];
  290. });
  291. });
  292. this.loading = false;
  293. },
  294. //新增
  295. addPaperStruct() {
  296. sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
  297. sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
  298. this.$router.push({
  299. path: "/questions/insert_paper_structure/add"
  300. });
  301. },
  302. //分页跳转
  303. handleCurrentChange(val) {
  304. this.currentPage = val;
  305. this.searchPaperStructs();
  306. },
  307. //查询所有课程
  308. getCourses(query) {
  309. query = query.trim();
  310. if (query) {
  311. if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
  312. this.courseLoading = true;
  313. this.$http
  314. .get(CORE_API + "/course/query?name=" + query + "&enable=true")
  315. .then(response => {
  316. this.courseList = response.data;
  317. this.courseLoading = false;
  318. });
  319. }
  320. } else {
  321. this.courseList = [];
  322. }
  323. },
  324. getType(val) {
  325. if (val == "ENSEMBLE") {
  326. return "宏观结构";
  327. }
  328. return "微观结构";
  329. },
  330. removeItem() {
  331. sessionStorage.removeItem("paperStruct");
  332. },
  333. initVue() {
  334. this.isClear = this.$route.params.isClear;
  335. if (this.isClear == 0 || !this.isClear) {
  336. sessionStorage.removeItem("paper_stucture");
  337. sessionStorage.removeItem("paper_stucture_currentPage");
  338. this.formSearch = {
  339. name: "",
  340. creator: "",
  341. courseNo: "ALL",
  342. type: "EXACT"
  343. };
  344. this.currentPage = 1;
  345. } else {
  346. this.formSearch = JSON.parse(sessionStorage.getItem("paper_stucture"));
  347. this.currentPage = parseInt(
  348. sessionStorage.getItem("paper_stucture_currentPage")
  349. );
  350. }
  351. this.searchPaperStructs();
  352. }
  353. },
  354. computed: {
  355. selectedIds() {
  356. var selectedIdsStr = "";
  357. for (let id of this.selectedList) {
  358. if (!selectedIdsStr) {
  359. selectedIdsStr += id;
  360. } else {
  361. selectedIdsStr += "," + id;
  362. }
  363. }
  364. return selectedIdsStr;
  365. },
  366. courseInfoSelect() {
  367. var courseList = [];
  368. for (let course of this.courseList) {
  369. var courseInfo = course.name + "(" + course.code + ")";
  370. var courseNo = course.code;
  371. courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
  372. }
  373. return courseList;
  374. },
  375. noBatchSelected() {
  376. return this.selectedList.length === 0;
  377. }
  378. },
  379. watch: {
  380. $route: "initVue"
  381. },
  382. created() {
  383. this.initVue();
  384. this.removeItem();
  385. }
  386. };
  387. </script>
  388. <style scoped src="../styles/Common.css"></style>