courseForm.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="form" label-width="140">
  4. <u-form-item label="评价星级" prop="star">
  5. <u-rate :count="10" v-model="form.star" :size="40" :gutter="10" :active-color="mainColor"></u-rate>
  6. </u-form-item>
  7. <u-form-item label="评价内容" prop="remark" required>
  8. <u-input v-model="form.remark" placeholder="请输入评价内容" />
  9. </u-form-item>
  10. <!-- <u-form-item label="上传附件" label-position="top">
  11. <u-upload max-count="5" :multiple="false" :action="uploadUrl" :header="uploadHeader" @on-success="uploadSuccess"
  12. @on-error="uploadError" @on-remove="uploadRemove"></u-upload>
  13. </u-form-item> -->
  14. </u-form>
  15. <view class="handle-fix-box">
  16. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm()">提交</u-button>
  17. </view>
  18. <u-top-tips ref="uTips"></u-top-tips>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mapGetters
  24. } from 'vuex'
  25. const NET = require('@/utils/request')
  26. const API = require('@/config/api')
  27. export default {
  28. computed: {
  29. ...mapGetters([
  30. 'mainColor',
  31. 'customStyle',
  32. ])
  33. },
  34. data() {
  35. return {
  36. form: {
  37. signId: '',
  38. classId:'',
  39. star: 10,
  40. remark: '',
  41. isCoach: false
  42. },
  43. // uploadUrl: API.uploadFile,
  44. // uploadHeader: {
  45. // Authorization: uni.getStorageSync('token')
  46. // },
  47. rules: {
  48. content: [{
  49. required: true,
  50. message: '请输入评价内容',
  51. trigger: 'change'
  52. }],
  53. },
  54. }
  55. },
  56. onLoad(options) {
  57. this.form.signId = parseInt(options.id)
  58. this.form.classId = parseInt(options.classId)
  59. },
  60. onReady() {
  61. this.$refs.form.setRules(this.rules);
  62. },
  63. methods: {
  64. // 提交表单
  65. submitForm() {
  66. this.$refs.form.validate(valid => {
  67. if (valid) {
  68. NET.request(API.setSignRemark, {
  69. ...this.form
  70. }, 'POST').then(res => {
  71. this.$refs.uTips.show({
  72. title: '填写成功',
  73. type: 'success',
  74. })
  75. setTimeout(() => {
  76. uni.navigateBack()
  77. }, 1000)
  78. }).catch(error => {
  79. this.$refs.uTips.show({
  80. title: error.message,
  81. type: 'warning',
  82. })
  83. })
  84. }
  85. });
  86. }
  87. // // 文件上传成功回调
  88. // uploadSuccess(res, index, lists, name) {
  89. // this.form.fileId.push(res.data.id)
  90. // this.$refs.uTips.show({
  91. // title: '文件上传成功',
  92. // type: 'success',
  93. // })
  94. // return true
  95. // },
  96. // // 文件上传失败回调
  97. // uploadError(res, index, lists, name) {
  98. // this.$refs.uTips.show({
  99. // title: '文件上传失败',
  100. // type: 'warning',
  101. // })
  102. // },
  103. // // 移除文件回调
  104. // uploadRemove(index, lists, name) {
  105. // this.form.fileId.splice(index, 1)
  106. // },
  107. },
  108. }
  109. </script>
  110. <style>
  111. page {
  112. width: 100%;
  113. height: 100%;
  114. position: relative;
  115. }
  116. </style>
  117. <style lang="scss" scoped>
  118. @import "@/static/css/themes.scss";
  119. .content {
  120. width: 100%;
  121. float: left;
  122. padding: 0 15px 60px 15px;
  123. box-sizing: border-box;
  124. }
  125. </style>