addEvaluate.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view class="evaluate">
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="form">
  4. <u-form-item label="评价" prop="evaluateDes">
  5. <u--textarea v-model="form.evaluateDes" placeholder="请输入评价内容" height="100" count :maxlength="200">
  6. </u--textarea>
  7. </u-form-item>
  8. <u-form-item>
  9. <u-button type="primary" text="评价" @click="submitForm" :loading="loading" />
  10. </u-form-item>
  11. </u--form>
  12. <u-toast ref="uToast"></u-toast>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. loading: false,
  20. form: {
  21. evaluateDes: '',
  22. deviceExcptionId: ''
  23. },
  24. rules: {
  25. evaluateDes: {
  26. type: 'string',
  27. required: true,
  28. message: '请填写评价内容',
  29. trigger: ['blur', 'change']
  30. },
  31. }
  32. }
  33. },
  34. onLoad(page) {
  35. this.form.deviceExcptionId = page.id
  36. },
  37. methods: {
  38. submitForm() {
  39. this.$refs.form.validate().then(res => {
  40. this.loading = true
  41. uni.$u.api.deviceAbnormalApi.addDeviceAbnormalRecordsEvaluateApi(this.form).then(res => {
  42. if (res.code === 200) {
  43. this.$refs.uToast.show({
  44. loading: true,
  45. message: '添加评论成功!',
  46. type: 'success',
  47. complete() {
  48. this.loading = false
  49. uni.$u.route({
  50. type: 'back'
  51. })
  52. }
  53. });
  54. } else {
  55. this.$refs.uToast.show({
  56. message: '添加评论失败!',
  57. type: 'error'
  58. });
  59. }
  60. })
  61. }).catch(errors => {
  62. uni.$u.toast('校验失败')
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .evaluate {
  70. padding: 15px;
  71. }
  72. </style>