Lijy 11 месяцев назад
Родитель
Сommit
7e19807227

+ 1 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/api.ts

@@ -20,6 +20,7 @@ export const REFIENAMEFILE = `/business-opportunity/reFileName`
 export const UPLOADFILEFILE = `/business-opportunity/uploadFile`
 export const URL_IMPOERBUSINESS = `/business-opportunity/importData`
 export const URL_DETELESTAGE = `/business-opportunity/deleteStage`
+export const URL_SAVECONTACT = `/business-opportunity/saveContactsId`
 
 
 export const stageStatus = [

+ 61 - 8
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/component/information.vue

@@ -3,9 +3,10 @@
         <div class="flex justify-between">
             <div class="title">基本信息</div>
             <div>
-                <el-button type="primary">关联联系人</el-button>
+                <el-button type="primary" @click="associateContact()" v-if="!information.cuntactsId">关联联系人</el-button>
                 <el-button type="primary" @click="claimBusiness()" v-if="!information.customerId">认领</el-button>
-                <el-button type="primary" @click="showVisible('transferBusinessVisible')" v-else>转移</el-button>
+                <el-button type="primary" @click="showVisible('transferBusinessVisible')"
+                    v-if="information.customerId">转移</el-button>
                 <el-button type="primary" @click="showVisible('editBusinessVisible')">编辑</el-button>
             </div>
         </div>
@@ -69,7 +70,8 @@
                 <div class="flex justify-between items-center border-b pb-3 dialog-header">
                     <h4 :id="titleId">{{ '转移商机' }}</h4>
                     <div>
-                        <el-button type="primary" :loading="allLoading.transferBusinessLoading" @click="transferBusiness()">转移</el-button>
+                        <el-button type="primary" :loading="allLoading.transferBusinessLoading"
+                            @click="transferBusiness()">转移</el-button>
                         <el-button @click="allVisible.transferBusinessVisible = false">取消</el-button>
                     </div>
                 </div>
@@ -84,16 +86,39 @@
                 <div class="pl-3 text-[#e94a4a]">转移后,将看不到此商机</div>
             </div>
         </el-dialog>
+
+        <!-- 关联 -->
+        <el-dialog v-model="allVisible.saveContactVisible" width="600" :show-close="false" top="10vh">
+            <template #header="{ close, titleId, titleClass }">
+                <div class="flex justify-between items-center border-b pb-3 dialog-header">
+                    <h4 :id="titleId">{{ '关联联系人' }}</h4>
+                    <div>
+                        <el-button type="primary" :loading="allLoading.saveContactLoading"
+                            @click="saveAssociateContact()">关联</el-button>
+                        <el-button @click="allVisible.saveContactVisible = false">取消</el-button>
+                    </div>
+                </div>
+            </template>
+            <div class="scroll-bar m-6">
+                <div class="flex mb-4">
+                    <div class="w-20 flex items-center justify-end pr-4">联系人:</div>
+                    <el-select v-model="contactsId" placeholder="请选择" class="flex1">
+                        <el-option v-for="item in contactsList" :key="item.value" :label="item.label" :value="item.value" />
+                    </el-select>
+                </div>
+            </div>
+        </el-dialog>
     </div>
 </template>
 <script lang="ts" setup>
 import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue'
 import { GenerateForm } from '@zmjs/form-design';
 import { get, post } from '@/utils/request';
-import { BATCHTRANSFER, GETGENERATEFOEM, GETPERSONNEL, UPDATEINSET } from '../api';
+import { BATCHTRANSFER, GETGENERATEFOEM, GETPERSONNEL, UPDATEINSET, URL_SAVECONTACT } from '../api';
 import { formatDateTime } from '@/utils/times';
 import { confirmAction } from '@/utils/tools';
 import { useStore } from '@/store/index'
+import { URL_GETALL } from '@/pages/contacts/api';
 
 const { userInfo } = useStore()
 const globalPopup = inject<GlobalPopup>('globalPopup')
@@ -107,20 +132,49 @@ const transferValue = ref('')
 const transferOptions = ref<personnelInterface[]>([])
 const generateFormValue = ref({})
 const generateForm = ref<typeof GenerateForm>() // 自定义表单dom
+const contactsId = ref('')
+const contactsList = ref<optionType[]>([])
 const allVisible = reactive({
     editBusinessVisible: false,
-    transferBusinessVisible: false
+    transferBusinessVisible: false,
+    saveContactVisible: false
 })
 const allLoading = reactive({
     editBusinessLoading: false,
     businessSaveLading: false,
-    transferBusinessLoading: false
+    transferBusinessLoading: false,
+    saveContactLoading: false
 })
 const generateFormData = ref({
     config: {},
     list: []
 }) // 自定义表单数据
 
+function associateContact() {
+    contactsId.value = ''
+    getContactList()
+    showVisible('saveContactVisible')
+}
+
+function getContactList() {
+    post(URL_GETALL, { customerId: information.value.customerId }).then(({ data }) => {
+        contactsList.value = data.map((item: any) => {
+            return { value: item.id, label: item.name }
+        })
+    })
+}
+
+function saveAssociateContact() {
+    allLoading.saveContactLoading = false
+    post(URL_SAVECONTACT, { id: information.value.id, contactsId: contactsId.value }).then(() => {
+        globalPopup?.showSuccess('关联成功')
+        closeVisible('saveContactVisible')
+        emits('refreshData')
+    }).finally(() => {
+        allLoading.saveContactLoading = false
+    })
+}
+
 function transferBusiness() {
     const ids = information.value?.id
     const inchargerId = information.value?.inchargerName ? transferValue.value : userInfo.id
@@ -222,5 +276,4 @@ onMounted(() => {
             line-height: 1.5;
         }
     }
-}
-</style>
+}</style>