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/contact/components/ContactList.vue |  185 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 185 insertions(+), 0 deletions(-)

diff --git a/src/views/crm/contact/components/ContactList.vue b/src/views/crm/contact/components/ContactList.vue
new file mode 100644
index 0000000..1c12ca8
--- /dev/null
+++ b/src/views/crm/contact/components/ContactList.vue
@@ -0,0 +1,185 @@
+<template>
+  <!-- 鎿嶄綔鏍� -->
+  <el-row justify="end">
+    <el-button @click="openForm">
+      <Icon class="mr-5px" icon="system-uicons:contacts" />
+      鍒涘缓鑱旂郴浜�
+    </el-button>
+    <el-button
+      v-if="queryParams.businessId"
+      v-hasPermi="['crm:contact:create-business']"
+      @click="openBusinessModal"
+    >
+      <Icon class="mr-5px" icon="ep:circle-plus" />
+      鍏宠仈
+    </el-button>
+    <el-button
+      v-if="queryParams.businessId"
+      v-hasPermi="['crm:contact:delete-business']"
+      @click="deleteContactBusinessList"
+    >
+      <Icon class="mr-5px" icon="ep:remove" />
+      瑙i櫎鍏宠仈
+    </el-button>
+  </el-row>
+
+  <!-- 鍒楄〃 -->
+  <ContentWrap class="mt-10px">
+    <el-table
+      ref="contactRef"
+      v-loading="loading"
+      :data="list"
+      :show-overflow-tooltip="true"
+      :stripe="true"
+    >
+      <el-table-column v-if="queryParams.businessId" type="selection" width="55" />
+      <el-table-column align="center" fixed="left" label="濮撳悕" prop="name">
+        <template #default="scope">
+          <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
+            {{ scope.row.name }}
+          </el-link>
+        </template>
+      </el-table-column>
+      <el-table-column align="center" label="鎵嬫満鍙�" prop="mobile" />
+      <el-table-column align="center" label="鑱屼綅" prop="post" />
+      <el-table-column align="center" label="鐩村睘涓婄骇" prop="parentName" />
+      <el-table-column align="center" label="鏄惁鍏抽敭鍐崇瓥浜�" min-width="100" prop="master">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 鍒嗛〉 -->
+    <Pagination
+      v-model:limit="queryParams.pageSize"
+      v-model:page="queryParams.pageNo"
+      :total="total"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 琛ㄥ崟寮圭獥锛氭坊鍔� -->
+  <ContactForm ref="formRef" @success="getList" />
+  <!-- 鍏宠仈鍟嗘満閫夋嫨寮规 -->
+  <ContactListModal
+    v-if="customerId"
+    ref="contactModalRef"
+    :customer-id="customerId"
+    @success="createContactBusinessList"
+  />
+</template>
+<script lang="ts" setup>
+import * as ContactApi from '@/api/crm/contact'
+import ContactForm from './../ContactForm.vue'
+import { DICT_TYPE } from '@/utils/dict'
+import { BizTypeEnum } from '@/api/crm/permission'
+import ContactListModal from './ContactListModal.vue'
+
+defineOptions({ name: 'CrmContactList' })
+const props = defineProps<{
+  bizType: number // 涓氬姟绫诲瀷
+  bizId: number // 涓氬姟缂栧彿
+  customerId?: number // 鐗规畩锛氬鎴风紪鍙凤紱鍦ㄣ�愬晢鏈恒�戣鎯呬腑锛屽彲浠ヤ紶閫掑鎴风紪鍙凤紝榛樿鏂板缓鐨勮仈绯讳汉鍏宠仈鍒拌瀹㈡埛
+  businessId?: number // 鐗规畩锛氬晢鏈虹紪鍙凤紱鍦ㄣ�愬晢鏈恒�戣鎯呬腑锛屽彲浠ヤ紶閫掑晢鏈虹紪鍙凤紝榛樿鏂板缓鐨勮仈绯讳汉鍏宠仈鍒拌鍟嗘満
+}>()
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  customerId: undefined as unknown, // 鍏佽 undefined + number
+  businessId: undefined as unknown // 鍏佽 undefined + number
+})
+const message = useMessage()
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+  loading.value = true
+  try {
+    // 缃┖鍙傛暟
+    queryParams.customerId = undefined
+    // 鎵ц鏌ヨ
+    let data = { list: [], total: 0 }
+    switch (props.bizType) {
+      case BizTypeEnum.CRM_CUSTOMER:
+        queryParams.customerId = props.bizId
+        data = await ContactApi.getContactPageByCustomer(queryParams)
+        break
+      case BizTypeEnum.CRM_BUSINESS:
+        queryParams.businessId = props.bizId
+        data = await ContactApi.getContactPageByBusiness(queryParams)
+        break
+      default:
+        return
+    }
+    list.value = data.list
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getList()
+}
+
+/** 娣诲姞鎿嶄綔 */
+const formRef = ref()
+const openForm = () => {
+  formRef.value.open('create', undefined, props.customerId, props.businessId)
+}
+
+/** 鎵撳紑鑱旂郴浜鸿鎯� */
+const { push } = useRouter()
+const openDetail = (id: number) => {
+  push({ name: 'CrmContactDetail', params: { id } })
+}
+
+/** 鎵撳紑鑱旂郴浜轰笌鍟嗘満鐨勫叧鑱斿脊绐� */
+const contactModalRef = ref()
+const openBusinessModal = () => {
+  contactModalRef.value.open()
+}
+const createContactBusinessList = async (contactIds: number[]) => {
+  const data = {
+    businessId: props.bizId,
+    contactIds: contactIds
+  } as ContactApi.ContactBusiness2ReqVO
+  contactRef.value.getSelectionRows().forEach((row: ContactApi.ContactVO) => {
+    data.contactIds.push(row.id)
+  })
+  await ContactApi.createContactBusinessList2(data)
+  // 鍒锋柊鍒楄〃
+  message.success('鍏宠仈鑱旂郴浜烘垚鍔�')
+  handleQuery()
+}
+
+/** 瑙i櫎鑱旂郴浜轰笌鍟嗘満鐨勫叧鑱� */
+const contactRef = ref()
+const deleteContactBusinessList = async () => {
+  const data = {
+    businessId: props.bizId,
+    contactIds: contactRef.value.getSelectionRows().map((row: ContactApi.ContactVO) => row.id)
+  } as ContactApi.ContactBusiness2ReqVO
+  if (data.contactIds.length === 0) {
+    return message.error('鏈�夋嫨鑱旂郴浜�')
+  }
+  await ContactApi.deleteContactBusinessList2(data)
+  // 鍒锋柊鍒楄〃
+  message.success('鍙栧叧鑱旂郴浜烘垚鍔�')
+  handleQuery()
+}
+
+/** 鐩戝惉鎵撳紑鐨� bizId + bizType锛屼粠鑰屽姞杞芥渶鏂扮殑鍒楄〃 */
+watch(
+  () => [props.bizId, props.bizType],
+  () => {
+    handleQuery()
+  },
+  { immediate: true, deep: true }
+)
+</script>

--
Gitblit v1.8.0