index2.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="pb_content" style="background: #fff" v-loading="loading">
  3. <div class="pb_content_body" style="position: relative; margin: 0">
  4. <div class="right">
  5. <div class="courseTop">
  6. <div class="stepsNav">
  7. <el-breadcrumb separator-class="el-icon-arrow-right">
  8. <el-breadcrumb-item v-if="!back"
  9. :to="{
  10. path:
  11. '/test?userid=' +
  12. userid +
  13. '&oid=' +
  14. oid +
  15. '&org=' +
  16. org +
  17. '&role=' +
  18. role,
  19. }"
  20. >表单管理</el-breadcrumb-item
  21. >
  22. <el-breadcrumb-item v-if="back=='sass'"
  23. :to="{
  24. path:
  25. '/sassPlatform?userid=' +
  26. userid +
  27. '&oid=' +
  28. oid +
  29. '&org=' +
  30. org +
  31. '&role=' +
  32. role,
  33. }"
  34. >sass平台</el-breadcrumb-item
  35. >
  36. <el-breadcrumb-item>
  37. <span style="color: rgb(15, 126, 255)">查看表单</span>
  38. </el-breadcrumb-item>
  39. </el-breadcrumb>
  40. </div>
  41. <div class="r_pub_button_retrun" @click="retrunCourse">返回</div>
  42. </div>
  43. <div class="step_box" ref="stepBox">
  44. <div class="pb_content_body">
  45. <div class="student_table">
  46. <el-table
  47. ref="table"
  48. :data="tableData"
  49. border
  50. :height="tableHeight"
  51. :fit="true"
  52. v-loading="isLoading"
  53. style="width: 100%"
  54. :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
  55. :row-class-name="tableRowClassName"
  56. >
  57. <el-table-column
  58. prop="username"
  59. label="提交人"
  60. min-width="15"
  61. align="center"
  62. >
  63. </el-table-column>
  64. <el-table-column
  65. prop="title"
  66. label="表单名称"
  67. min-width="15"
  68. align="center"
  69. >
  70. </el-table-column>
  71. <el-table-column
  72. prop="time"
  73. label="提交时间"
  74. min-width="15"
  75. align="center"
  76. >
  77. </el-table-column>
  78. <el-table-column
  79. prop="time"
  80. label="是否批改"
  81. min-width="15"
  82. align="center"
  83. >
  84. <template slot-scope="scope">
  85. <div>{{ scope.row.type == 3 ? '是' : '否' }}</div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="操作" width="200px">
  89. <template slot-scope="scope">
  90. <el-button
  91. @click="getTest(scope.row)"
  92. type="primary"
  93. size="small"
  94. >查看</el-button
  95. >
  96. <el-button
  97. @click="delTest(scope.row.id)"
  98. type="primary"
  99. size="small"
  100. >删除</el-button
  101. >
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. </div>
  106. <div class="student_page">
  107. <el-pagination
  108. background
  109. layout="prev, pager, next"
  110. :page-size="pageSize"
  111. :total="total"
  112. @current-change="handleCurrentChange"
  113. >
  114. </el-pagination>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </template>
  122. <script>
  123. export default {
  124. components: {},
  125. data() {
  126. return {
  127. userid: this.$route.query.userid,
  128. oid: this.$route.query.oid,
  129. org: this.$route.query.org,
  130. role: this.$route.query.role,
  131. cid: this.$route.query.cid,
  132. uid: this.$route.query.uid,
  133. back: this.$route.query.back,
  134. title: "",
  135. testType: [],
  136. see: false,
  137. cJson: [],
  138. loading: false,
  139. look: "",
  140. tableHeight: 500,
  141. isLoading: false,
  142. pageSize: 10,
  143. total: 0,
  144. page: 1,
  145. tableData: [],
  146. };
  147. },
  148. watch: {},
  149. methods: {
  150. retrunCourse() {
  151. this.goTo(
  152. "/test?userid=" +
  153. this.userid +
  154. "&oid=" +
  155. this.oid +
  156. "&org=" +
  157. this.org +
  158. "&role=" +
  159. this.role
  160. );
  161. },
  162. goTo(path) {
  163. this.$router.push(path);
  164. },
  165. tableRowClassName({ row, rowIndex }) {
  166. if ((rowIndex + 1) % 2 === 0) {
  167. return "even_row";
  168. } else {
  169. return "";
  170. }
  171. },
  172. changeHeight() {
  173. this.tableHeight = this.$refs.stepBox.offsetHeight - 100;
  174. if (this.tableHeight <= 530) {
  175. this.tableHeight = 530;
  176. }
  177. // 监听窗口大小变化
  178. let self = this;
  179. window.onresize = function () {
  180. self.tableHeight = this.$refs.stepBox.offsetHeight - 100;
  181. if (self.tableHeight <= 530) {
  182. self.tableHeight = 530;
  183. }
  184. };
  185. // this.$refs.table.$el.offsetTop:表格距离浏览器的高度 //200表示你想要调整的表格距离底部的高度(你可以自己随意调整),因为我们一般都有放分页组件的,所以需要给它留一个高度
  186. },
  187. handleCurrentChange(val) {
  188. this.page = val;
  189. this.getData();
  190. },
  191. getTest(row) {
  192. this.$router.push(
  193. "/checkTest2?cid=" +
  194. row.courseid +
  195. "&userid=" +
  196. this.userid +
  197. "&userid2=" +
  198. row.userid +
  199. "&tid=" +
  200. row.id +
  201. "&oid=" +
  202. this.oid +
  203. "&org=" +
  204. this.org +
  205. "&type=3" +
  206. "&role=" +
  207. this.role
  208. );
  209. },
  210. delTest(tid){
  211. let _this = this
  212. _this
  213. .$confirm("确定删除此提交的表单么?", "提示", {
  214. confirmButtonText: "确定",
  215. cancelButtonText: "取消",
  216. type: "warning",
  217. })
  218. .then(() => {
  219. let params = [{
  220. tid: tid,
  221. }];
  222. _this.ajax
  223. .post(_this.$store.state.api + "deleteTestCourseWorks", params)
  224. .then((res) => {
  225. _this.$message.success("删除成功");
  226. _this.getData();
  227. })
  228. .catch((err) => {
  229. console.error(err);
  230. });
  231. })
  232. .catch(() => {
  233. return;
  234. });
  235. },
  236. getData() {
  237. this.isLoading = true;
  238. let params = {
  239. cid: this.uid,
  240. page: this.page,
  241. pageSize: this.pageSize,
  242. };
  243. this.ajax
  244. .get(this.$store.state.api + "getTestWorksPage2", params)
  245. .then((res) => {
  246. this.isLoading = false;
  247. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  248. this.tableData = res.data[0];
  249. })
  250. .catch((err) => {
  251. console.error(err);
  252. });
  253. },
  254. },
  255. mounted() {
  256. this.$nextTick(function () {
  257. this.page = 1;
  258. this.changeHeight();
  259. this.getData();
  260. });
  261. },
  262. };
  263. </script>
  264. <style scoped>
  265. .pb_content {
  266. height: 100% !important;
  267. /* margin: 0 20px 0 20px; */
  268. }
  269. .pb_content_body {
  270. width: 100% !important;
  271. height: 100%;
  272. }
  273. .right {
  274. height: 100%;
  275. width: 100%;
  276. display: flex;
  277. overflow: hidden;
  278. flex-direction: column;
  279. }
  280. .basic_box {
  281. margin: 0 auto;
  282. position: relative;
  283. padding: 0 20px 0 20px;
  284. }
  285. .courseTop {
  286. display: flex;
  287. flex-direction: row;
  288. justify-content: space-between;
  289. align-items: center;
  290. width: calc(100% - 40px);
  291. margin: 0 auto;
  292. padding: 10px 0;
  293. }
  294. .stepsNav {
  295. display: flex;
  296. flex-direction: row;
  297. justify-content: flex-start;
  298. align-items: center;
  299. }
  300. .step_box {
  301. width: calc(100% - 40px);
  302. margin: 0 auto;
  303. height: calc(100% - 38px);
  304. overflow: auto;
  305. }
  306. .el-table >>> .even_row {
  307. background-color: #f1f1f1 !important;
  308. }
  309. .student_page {
  310. margin-top: 10px;
  311. }
  312. </style>