courseForm.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="form" label-width="140">
  4. <u-form-item label="评价内容" prop="estimateContent" required>
  5. <u-input v-model="form.estimateContent" placeholder="请输入评价内容" type="textarea" auto-height :height="100" />
  6. </u-form-item>
  7. <u-form-item label="上传附件" prop="estimateContent" required>
  8. <u-upload :action="uploadAaction" :head="uploadHeader" max-count="5" :multiple="false" :file-list="fileList"></u-upload>
  9. </u-form-item>
  10. </u-form>
  11. <view class="handle-fix-box">
  12. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm()">提交</u-button>
  13. </view>
  14. <u-top-tips ref="uTips"></u-top-tips>
  15. </view>
  16. </template>
  17. <script>
  18. import {
  19. mapGetters
  20. } from 'vuex'
  21. const NET = require('@/utils/request')
  22. const API = require('@/config/api')
  23. export default {
  24. computed: {
  25. ...mapGetters([
  26. 'customStyle',
  27. ])
  28. },
  29. data() {
  30. return {
  31. classId: '',
  32. form: {
  33. level: 0,
  34. estimateContent: '',
  35. },
  36. uploadAaction: '',
  37. uploadHeader: {},
  38. fileList: [],
  39. rules: {
  40. level: [{
  41. required: true,
  42. message: '请选择评价星级',
  43. trigger: 'change'
  44. }],
  45. estimateContent: [{
  46. required: true,
  47. message: '请输入评价内容',
  48. trigger: 'change'
  49. }],
  50. },
  51. }
  52. },
  53. onLoad(options) {
  54. this.classId = options.id
  55. },
  56. onReady() {
  57. this.$refs.form.setRules(this.rules);
  58. },
  59. methods: {
  60. // 提交表单
  61. submitForm() {
  62. this.$refs.form.validate(valid => {
  63. if (valid) {
  64. NET.request(API.submitLevelForm, {
  65. classId: this.classId,
  66. ...this.form
  67. }, 'POST').then(res => {
  68. this.$refs.uTips.show({
  69. title: '评价成功',
  70. type: 'success',
  71. })
  72. setTimeout(() => {
  73. uni.navigateBack()
  74. }, 1000)
  75. }).catch(error => {
  76. this.$refs.uTips.show({
  77. title: '评价失败',
  78. type: 'warning',
  79. })
  80. })
  81. }
  82. });
  83. },
  84. },
  85. }
  86. </script>
  87. <style>
  88. page {
  89. width: 100%;
  90. height: 100%;
  91. position: relative;
  92. }
  93. </style>
  94. <style lang="scss" scoped>
  95. @import "@/static/css/themes.scss";
  96. .content {
  97. width: 100%;
  98. float: left;
  99. padding: 0 15px 60px 15px;
  100. box-sizing: border-box;
  101. }
  102. </style>