ExamStructure.vue 6.5 KB

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