index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="follow_wrap">
  3. <u-navbar placeholder :autoBack="true" title="添加跟进记录" @rightClick="handleNavSaveClick">
  4. <view class="u-nav-slot" slot="right">
  5. 保存
  6. </view>
  7. </u-navbar>
  8. <view class="form_wrap">
  9. <u--form labelPosition="left" labelWidth="80" :model="form" :rules="rules" ref="form" class="form_wrap">
  10. <u-form-item label="跟进内容" prop="content">
  11. <u--textarea v-model="form.content" placeholder="请输入内容" count confirmType="done" maxlength="500">
  12. </u--textarea>
  13. </u-form-item>
  14. </u--form>
  15. </view>
  16. <!-- <drag-button :isDock="true" /> -->
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. rules: {
  24. 'content': {
  25. type: 'string',
  26. required: true,
  27. message: '请输入内容',
  28. trigger: ['blur', 'change']
  29. },
  30. },
  31. form: {
  32. clueId : undefined,
  33. orderId: undefined,
  34. content: '',
  35. type: 'clue' // 标识当前模式:clue 或 order
  36. },
  37. }
  38. },
  39. methods: {
  40. handleNavSaveClick() {
  41. this.$refs.form.validate().then(async () => {
  42. if (this.form.type === 'order') {
  43. // 订单跟进,调用 addOrderFollow 接口
  44. const orderFormData = {
  45. orderId: this.form.orderId,
  46. content: this.form.content
  47. };
  48. await uni.$u.api.addOrderFollow(orderFormData);
  49. } else {
  50. // 线索跟进,调用 addClueFollow 接口
  51. const clueFormData = {
  52. clueId: this.form.clueId,
  53. content: this.form.content
  54. };
  55. await uni.$u.api.addClueFollow(clueFormData);
  56. }
  57. uni.$u.toast("保存成功");
  58. this.timer = setTimeout(()=>{
  59. uni.$emit('addFollowSuccess', this.form.type);
  60. uni.navigateBack();
  61. clearTimeout(this.timer);
  62. },1000)
  63. })
  64. },
  65. },
  66. onLoad(option) {
  67. if (option.orderId) {
  68. // 订单跟进模式
  69. this.form.orderId = option.orderId;
  70. this.form.type = 'order';
  71. } else if (option.clueId) {
  72. // 线索跟进模式
  73. this.form.clueId = option.clueId;
  74. this.form.type = 'clue';
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .form_wrap {
  81. background-color: #fff;
  82. margin: 20rpx 0;
  83. .form_wrap {
  84. ::v-deep .u-form-item__body {
  85. padding: 20rpx 40rpx;
  86. }
  87. }
  88. }
  89. </style>