form.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <script setup>
  2. import { reactive, ref } from 'vue'
  3. import { addClue } from '@/api/crm'
  4. import { PAGE_PATHS } from '@/config/api'
  5. const submitting = ref(false)
  6. const form = reactive({
  7. clueName: '',
  8. mobile: '',
  9. company: '',
  10. customerType: 'company',
  11. position: '',
  12. source: '其它',
  13. level: 'C',
  14. industry: '',
  15. parkArea: '',
  16. province: '',
  17. city: '',
  18. remark: ''
  19. })
  20. const goBack = () => {
  21. uni.navigateBack({
  22. fail: () => uni.navigateTo({ url: PAGE_PATHS.crmClueList })
  23. })
  24. }
  25. const submit = async () => {
  26. if (!form.clueName.trim()) {
  27. uni.showToast({ title: '请填写线索姓名', icon: 'none' })
  28. return
  29. }
  30. if (!form.mobile.trim()) {
  31. uni.showToast({ title: '请填写手机号', icon: 'none' })
  32. return
  33. }
  34. if (!form.company.trim()) {
  35. uni.showToast({ title: '请填写公司名称', icon: 'none' })
  36. return
  37. }
  38. submitting.value = true
  39. try {
  40. await addClue({
  41. ...form,
  42. position: form.position || '-',
  43. industry: form.industry || '-',
  44. parkArea: form.parkArea || '-',
  45. province: form.province || '-',
  46. city: form.city || '-'
  47. })
  48. uni.showToast({ title: '创建成功', icon: 'success' })
  49. setTimeout(() => goBack(), 500)
  50. } catch (e) {
  51. uni.showToast({ title: e.message || '创建失败', icon: 'none' })
  52. } finally {
  53. submitting.value = false
  54. }
  55. }
  56. </script>
  57. <template>
  58. <view class="mp-page mp-page--sub mp-page--with-bottom">
  59. <view class="mp-header">
  60. <text class="mp-subpage-back" @click="goBack">← 返回</text>
  61. <text class="mp-header__title" style="margin-top: 16rpx">新增线索</text>
  62. </view>
  63. <view class="mp-form-panel">
  64. <view class="mp-form-row">
  65. <text class="mp-form-label mp-form-label--req">线索姓名</text>
  66. <input v-model="form.clueName" class="mp-form-input" placeholder="联系人姓名" />
  67. </view>
  68. <view class="mp-form-row">
  69. <text class="mp-form-label mp-form-label--req">手机号</text>
  70. <input v-model="form.mobile" class="mp-form-input" type="number" placeholder="手机号" />
  71. </view>
  72. <view class="mp-form-row">
  73. <text class="mp-form-label mp-form-label--req">公司名称</text>
  74. <input v-model="form.company" class="mp-form-input" placeholder="公司 / 单位" />
  75. </view>
  76. <view class="mp-form-row">
  77. <text class="mp-form-label">职位</text>
  78. <input v-model="form.position" class="mp-form-input" placeholder="职位" />
  79. </view>
  80. <view class="mp-form-row">
  81. <text class="mp-form-label">来源</text>
  82. <input v-model="form.source" class="mp-form-input" placeholder="线索来源" />
  83. </view>
  84. <view class="mp-form-row">
  85. <text class="mp-form-label">行业</text>
  86. <input v-model="form.industry" class="mp-form-input" placeholder="所属行业" />
  87. </view>
  88. <view class="mp-form-row">
  89. <text class="mp-form-label">园区</text>
  90. <input v-model="form.parkArea" class="mp-form-input" placeholder="所在园区" />
  91. </view>
  92. <view class="mp-form-row">
  93. <text class="mp-form-label">备注</text>
  94. <textarea v-model="form.remark" class="mp-form-textarea" placeholder="备注" />
  95. </view>
  96. </view>
  97. <view class="mp-bottom-bar">
  98. <view class="mp-btn mp-btn--ghost" @click="goBack">取消</view>
  99. <view class="mp-btn mp-btn--primary" @click="submit">
  100. {{ submitting ? '提交中…' : '保存' }}
  101. </view>
  102. </view>
  103. </view>
  104. </template>