From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/views/crm/followup/FollowUpRecordForm.vue |  188 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 188 insertions(+), 0 deletions(-)

diff --git a/src/views/crm/followup/FollowUpRecordForm.vue b/src/views/crm/followup/FollowUpRecordForm.vue
new file mode 100644
index 0000000..eb626f0
--- /dev/null
+++ b/src/views/crm/followup/FollowUpRecordForm.vue
@@ -0,0 +1,188 @@
+<!-- 璺熻繘璁板綍鐨勬坊鍔犺〃鍗曞脊绐� -->
+<template>
+  <Dialog v-model="dialogVisible" title="娣诲姞璺熻繘璁板綍" width="50%">
+    <el-form
+      ref="formRef"
+      v-loading="formLoading"
+      :model="formData"
+      :rules="formRules"
+      label-width="120px"
+    >
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="璺熻繘绫诲瀷" prop="type">
+            <el-select v-model="formData.type" placeholder="璇烽�夋嫨璺熻繘绫诲瀷">
+              <el-option
+                v-for="dict in getIntDictOptions(DICT_TYPE.CRM_FOLLOW_UP_TYPE)"
+                :key="dict.value"
+                :label="dict.label"
+                :value="dict.value"
+              />
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="涓嬫鑱旂郴鏃堕棿" prop="nextTime">
+            <el-date-picker
+              v-model="formData.nextTime"
+              placeholder="閫夋嫨涓嬫鑱旂郴鏃堕棿"
+              type="date"
+              value-format="x"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="24">
+          <el-form-item label="璺熻繘鍐呭" prop="content">
+            <el-input v-model="formData.content" :rows="3" type="textarea" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="鍥剧墖" prop="picUrls">
+            <UploadImgs v-model="formData.picUrls" class="min-w-80px" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="闄勪欢" prop="fileUrls">
+            <UploadFile v-model="formData.fileUrls" class="min-w-80px" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" v-if="formData.bizType == BizTypeEnum.CRM_CUSTOMER">
+          <el-form-item label="鍏宠仈鑱旂郴浜�" prop="contactIds">
+            <el-button @click="handleOpenContact">
+              <Icon class="mr-5px" icon="ep:plus" />
+              娣诲姞鑱旂郴浜�
+            </el-button>
+            <FollowUpRecordContactForm :contacts="formData.contacts" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" v-if="formData.bizType == BizTypeEnum.CRM_CUSTOMER">
+          <el-form-item label="鍏宠仈鍟嗘満" prop="businessIds">
+            <el-button @click="handleOpenBusiness">
+              <Icon class="mr-5px" icon="ep:plus" />
+              娣诲姞鍟嗘満
+            </el-button>
+            <FollowUpRecordBusinessForm :businesses="formData.businesses" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template #footer>
+      <el-button :disabled="formLoading" type="primary" @click="submitForm">纭� 瀹�</el-button>
+      <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+    </template>
+  </Dialog>
+
+  <!-- 寮圭獥 -->
+  <ContactListModal
+    ref="contactTableSelectRef"
+    :customer-id="formData.bizId"
+    @success="handleAddContact"
+  />
+  <BusinessListModal
+    ref="businessTableSelectRef"
+    :customer-id="formData.bizId"
+    @success="handleAddBusiness"
+  />
+</template>
+<script lang="ts" setup>
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
+import { BizTypeEnum } from '@/api/crm/permission'
+import FollowUpRecordBusinessForm from './components/FollowUpRecordBusinessForm.vue'
+import FollowUpRecordContactForm from './components/FollowUpRecordContactForm.vue'
+import BusinessListModal from '@/views/crm/business/components/BusinessListModal.vue'
+import * as BusinessApi from '@/api/crm/business'
+import ContactListModal from '@/views/crm/contact/components/ContactListModal.vue'
+import * as ContactApi from '@/api/crm/contact'
+
+defineOptions({ name: 'FollowUpRecordForm' })
+
+const { t } = useI18n() // 鍥介檯鍖�
+const message = useMessage() // 娑堟伅寮圭獥
+
+const dialogVisible = ref(false) // 寮圭獥鐨勬槸鍚﹀睍绀�
+const dialogTitle = ref('') // 寮圭獥鐨勬爣棰�
+const formLoading = ref(false) // 琛ㄥ崟鐨勫姞杞戒腑锛�1锛変慨鏀规椂鐨勬暟鎹姞杞斤紱2锛夋彁浜ょ殑鎸夐挳绂佺敤
+const formData = ref({
+  bizType: undefined,
+  bizId: undefined,
+  businesses: [],
+  contacts: []
+})
+const formRules = reactive({
+  type: [{ required: true, message: '璺熻繘绫诲瀷涓嶈兘涓虹┖', trigger: 'change' }],
+  content: [{ required: true, message: '璺熻繘鍐呭涓嶈兘涓虹┖', trigger: 'blur' }],
+  nextTime: [{ required: true, message: '涓嬫鑱旂郴鏃堕棿涓嶈兘涓虹┖', trigger: 'blur' }]
+})
+
+const formRef = ref() // 琛ㄥ崟 Ref
+
+/** 鎵撳紑寮圭獥 */
+const open = async (bizType: number, bizId: number) => {
+  dialogVisible.value = true
+  resetForm()
+  formData.value.bizType = bizType
+  formData.value.bizId = bizId
+}
+defineExpose({ open }) // 鎻愪緵 open 鏂规硶锛岀敤浜庢墦寮�寮圭獥
+
+/** 鎻愪氦琛ㄥ崟 */
+const emit = defineEmits(['success']) // 瀹氫箟 success 浜嬩欢锛岀敤浜庢搷浣滄垚鍔熷悗鐨勫洖璋�
+const submitForm = async () => {
+  // 鏍¢獙琛ㄥ崟
+  await formRef.value.validate()
+  // 鎻愪氦璇锋眰
+  formLoading.value = true
+  try {
+    const data = {
+      ...formData.value,
+      contactIds: formData.value.contacts.map((item) => item.id),
+      businessIds: formData.value.businesses.map((item) => item.id)
+    } as unknown as FollowUpRecordVO
+    await FollowUpRecordApi.createFollowUpRecord(data)
+    message.success(t('common.createSuccess'))
+    dialogVisible.value = false
+    // 鍙戦�佹搷浣滄垚鍔熺殑浜嬩欢
+    emit('success')
+  } finally {
+    formLoading.value = false
+  }
+}
+
+/** 鍏宠仈鑱旂郴浜� */
+const contactTableSelectRef = ref<InstanceType<typeof ContactListModal>>()
+const handleOpenContact = () => {
+  contactTableSelectRef.value?.open()
+}
+const handleAddContact = (contactId: [], newContacts: ContactApi.ContactVO[]) => {
+  newContacts.forEach((contact) => {
+    if (!formData.value.contacts.some((item) => item.id === contact.id)) {
+      formData.value.contacts.push(contact)
+    }
+  })
+}
+
+/** 鍏宠仈鍟嗘満 */
+const businessTableSelectRef = ref<InstanceType<typeof BusinessListModal>>()
+const handleOpenBusiness = () => {
+  businessTableSelectRef.value?.open()
+}
+const handleAddBusiness = (businessId: [], newBusinesses: BusinessApi.BusinessVO[]) => {
+  newBusinesses.forEach((business) => {
+    if (!formData.value.businesses.some((item) => item.id === business.id)) {
+      formData.value.businesses.push(business)
+    }
+  })
+}
+
+/** 閲嶇疆琛ㄥ崟 */
+const resetForm = () => {
+  formRef.value?.resetFields()
+  formData.value = {
+    bizId: undefined,
+    bizType: undefined,
+    businesses: [],
+    contacts: []
+  }
+}
+</script>

--
Gitblit v1.8.0