PaperStructure.vue 11 KB

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