recordForm.vue 1.8 KB

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