chuanzuoye.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div id="homework">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <el-col :span="24" class="leaveBtn"> </el-col>
  10. <el-col :span="24" class="leaveList">
  11. <shangchuan :form="form" @onConfirm="onsave"></shangchuan>
  12. </el-col>
  13. <el-col :span="24" class="foot">
  14. <footInfo></footInfo>
  15. </el-col>
  16. </el-col>
  17. </el-col>
  18. </el-row>
  19. </div>
  20. </template>
  21. <script>
  22. import NavBar from '@/layout/common/topInfo.vue';
  23. import shangchuan from '@/layout/user/shangchuan.vue';
  24. import footInfo from '@/layout/common/footInfo.vue';
  25. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  26. const { mapActions: mapUploadtask } = createNamespacedHelpers('uploadtask');
  27. export default {
  28. name: 'homework',
  29. props: {},
  30. components: {
  31. NavBar, //头部导航
  32. shangchuan,
  33. footInfo,
  34. },
  35. data: () => ({
  36. form: {
  37. // picrul: [{ url: 'fksdfhksdhfsk' }],
  38. },
  39. show: false,
  40. navShow: true,
  41. title: '',
  42. isleftarrow: '',
  43. }),
  44. mounted() {
  45. this.title = this.$route.meta.title;
  46. this.isleftarrow = this.$route.meta.isleftarrow;
  47. },
  48. watch: {
  49. $route(to, from) {
  50. this.title = to.meta.title;
  51. this.isleftarrow = to.meta.isleftarrow;
  52. },
  53. },
  54. created() {},
  55. computed: {
  56. ...mapState(['user']),
  57. id() {
  58. return this.$route.query.id;
  59. },
  60. lessonid() {
  61. return this.$route.query.lessonid;
  62. },
  63. name() {
  64. return this.$route.query.name;
  65. },
  66. },
  67. methods: {
  68. ...mapUploadtask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
  69. //提交上传
  70. async onsave(form) {
  71. this.form.termid = this.user.termid;
  72. this.form.batchid = this.user.batchid;
  73. this.form.classid = this.user.classid;
  74. this.form.studentid = this.user.userid;
  75. this.form.lessonid = this.lessonid;
  76. this.form.lessonname = this.name;
  77. let data = this.form;
  78. console.log();
  79. if (data.picrul) {
  80. let res = await this.add(data);
  81. this.$checkRes(res, '提交成功', res.errmsg);
  82. } else {
  83. this.$message({
  84. showClose: true,
  85. message: '请上传图片',
  86. type: 'error',
  87. });
  88. }
  89. //
  90. },
  91. },
  92. };
  93. </script>
  94. <style lang="less" scoped>
  95. .style {
  96. width: 100%;
  97. min-height: 667px;
  98. position: relative;
  99. background-color: #f9fafc;
  100. }
  101. .top {
  102. height: 46px;
  103. overflow: hidden;
  104. }
  105. .main {
  106. min-height: 570px;
  107. }
  108. .main .leaveBtn {
  109. text-align: center;
  110. padding: 15px 0;
  111. }
  112. </style>