ExamStructure.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <section class="content" style="margin-top: -18px;">
  3. <div class="box box-info">
  4. <!-- 头信息 -->
  5. <div
  6. class="box-header with-border"
  7. style="background-color:#d3dce6;margin-bottom:20px;"
  8. >
  9. <h3 class="box-title">考试结构</h3>
  10. <div class="box-tools pull-right">
  11. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  12. <i class="fa fa-minus"></i>
  13. </button>
  14. </div>
  15. </div>
  16. <!-- 正文信息 -->
  17. <div class="box-body">
  18. <el-form
  19. :model="formSearch"
  20. :inline="true"
  21. label-position="right"
  22. label-width="100px"
  23. >
  24. <el-form-item label="学校">
  25. <el-select
  26. v-model="formSearch.orgId"
  27. placeholder="请选择"
  28. filterable
  29. clearable
  30. @change="searchExamList(formSearch.orgId);"
  31. >
  32. <el-option
  33. v-for="item in orgList"
  34. :label="item.orgName"
  35. :value="item.orgId"
  36. :key="item.orgId"
  37. ></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="考试">
  41. <el-select v-model="formSearch.examId" placeholder="请选择">
  42. <el-option
  43. v-for="item in examList"
  44. :label="item.examName"
  45. :value="item.examId"
  46. :key="item.examId"
  47. ></el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item class="pull-right">
  51. <el-button
  52. size="small"
  53. type="primary"
  54. icon="el-icon-search"
  55. @click="searchRecords"
  56. >查询
  57. </el-button>
  58. <el-button
  59. size="small"
  60. type="primary"
  61. icon="el-icon-plus"
  62. :disabled="!hasPermit"
  63. @click="addStructure"
  64. >新增
  65. </el-button>
  66. </el-form-item>
  67. </el-form>
  68. <!-- 数据列表 -->
  69. <el-table
  70. v-loading="loading"
  71. :data="tableData"
  72. element-loading-text="数据加载中"
  73. style="width:100%;"
  74. border
  75. >
  76. <el-table-column label="学校名称" prop="orgName" />
  77. <el-table-column label="考试名称" prop="examName" />
  78. <el-table-column width="220" label="题数">
  79. <template slot-scope="scope">
  80. 单选:{{ scope.row.questionStructure.singleChoiceTotal }}<br />
  81. 多选:{{ scope.row.questionStructure.multipleChoiceTotal }}<br />
  82. 判断:{{ scope.row.questionStructure.boolQuestionTotal }}
  83. </template>
  84. </el-table-column>
  85. <el-table-column width="200" label="操作" :context="_self">
  86. <template slot-scope="scope">
  87. <el-button
  88. size="mini"
  89. type="primary"
  90. icon="el-icon-menu"
  91. @click="cloneStructure(scope.row);"
  92. :disabled="!hasPermit"
  93. >复用
  94. </el-button>
  95. <el-button
  96. size="mini"
  97. type="danger"
  98. icon="el-icon-delete"
  99. @click="removeStructure(scope.row);"
  100. :disabled="!hasPermit"
  101. >删除
  102. </el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <!-- 分页 -->
  107. <div class="page pull-right">
  108. <el-pagination
  109. @current-change="handlePager"
  110. :current-page="formSearch.pageNo"
  111. :page-size="formSearch.pageSize"
  112. :total="totalElements"
  113. layout="total, prev, pager, next, jumper"
  114. ></el-pagination>
  115. </div>
  116. </div>
  117. </div>
  118. </section>
  119. </template>
  120. <script>
  121. import { print_api, userRole } from "../constants/constants.js";
  122. import { mapState } from "vuex";
  123. export default {
  124. data() {
  125. return {
  126. formSearch: {
  127. orgId: "",
  128. examId: "",
  129. pageNo: 1,
  130. pageSize: 10
  131. },
  132. curUserRole: userRole,
  133. hasPermit: false,
  134. totalElements: 0,
  135. loading: false,
  136. tableData: [],
  137. orgList: [],
  138. examList: [],
  139. rules: {}
  140. };
  141. },
  142. methods: {
  143. handlePager(current) {
  144. /* 处理分页 */
  145. this.formSearch.pageNo = current;
  146. this.searchRecords();
  147. },
  148. searchRecords() {
  149. /* 查询记录列表 */
  150. let orgId = this.formSearch.orgId;
  151. if (this.isEmptyNumber(orgId)) {
  152. this.$notify({
  153. message: "请选择学校!",
  154. type: "warning"
  155. });
  156. return;
  157. }
  158. let examId = this.formSearch.examId;
  159. if (this.isEmptyNumber(examId)) {
  160. this.$notify({
  161. message: "请选择考试!",
  162. type: "warning"
  163. });
  164. return;
  165. }
  166. this.loading = true;
  167. let url = print_api + "/examStructure/list";
  168. this.$http.post(url, this.formSearch).then(
  169. response => {
  170. this.tableData = response.data.content;
  171. this.totalElements = response.data.totalElements;
  172. this.loading = false;
  173. },
  174. error => {
  175. console.log(error);
  176. this.loading = false;
  177. }
  178. );
  179. },
  180. searchExamList(orgId) {
  181. /* 查询考试列表 */
  182. this.formSearch.examId = "";
  183. this.examList = [];
  184. if (!this.isEmptyNumber(orgId)) {
  185. let url = print_api + "/printing/project/exam/list?orgId=" + orgId;
  186. this.$http.post(url).then(response => {
  187. this.examList = response.data;
  188. });
  189. }
  190. },
  191. addStructure() {
  192. /* 新增考试结构 */
  193. this.$notify({
  194. message: "Todo...",
  195. type: "warning"
  196. });
  197. },
  198. cloneStructure(row) {
  199. /* 复用考试结构 */
  200. console.log(row);
  201. this.$notify({
  202. message: "Todo...",
  203. type: "warning"
  204. });
  205. },
  206. removeStructure(row) {
  207. /* 删除考试结构 */
  208. console.log(row);
  209. this.$notify({
  210. message: "Todo...",
  211. type: "warning"
  212. });
  213. }
  214. },
  215. computed: {
  216. ...mapState({ user: state => state.user })
  217. },
  218. created() {
  219. this.loadOrgList();
  220. this.loadUserRole(this.user);
  221. if (this.curUserRole.isSuperLeader || this.curUserRole.isPM) {
  222. this.hasPermit = true;
  223. } else {
  224. this.hasPermit = false;
  225. }
  226. }
  227. };
  228. </script>
  229. <style scoped>
  230. .page {
  231. margin-top: 10px;
  232. }
  233. .pull-right {
  234. float: right;
  235. }
  236. .pull-left {
  237. float: left;
  238. }
  239. </style>