communicateForm.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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="text" placeholder="请输入沟通内容" />
  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. this.type = options.type
  45. },
  46. onReady() {
  47. this.$refs.form.setRules(this.rules);
  48. },
  49. methods: {
  50. // 提交表单
  51. submitForm() {
  52. this.$refs.form.validate(valid => {
  53. if (valid) {
  54. NET.request(this.type == 2 ? API.submitRenewCommunicateForm : API.submitSignCommunicateForm, {
  55. studentId: this.id,
  56. ...this.form
  57. }, 'POST').then(res => {
  58. this.$refs.uTips.show({
  59. title: '提交成功',
  60. type: 'success',
  61. })
  62. setTimeout(() => {
  63. uni.navigateBack()
  64. }, 1000)
  65. }).catch(error => {
  66. this.$refs.uTips.show({
  67. title: error.message,
  68. type: 'warning',
  69. })
  70. })
  71. }
  72. });
  73. },
  74. },
  75. }
  76. </script>
  77. <style>
  78. page {
  79. width: 100%;
  80. height: 100%;
  81. position: relative;
  82. }
  83. </style>
  84. <style lang="scss" scoped>
  85. @import "@/static/css/themes.scss";
  86. .content {
  87. width: 100%;
  88. float: left;
  89. padding: 0 15px 60px 15px;
  90. box-sizing: border-box;
  91. }
  92. </style>