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/business/components/BusinessList.vue |  186 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 186 insertions(+), 0 deletions(-)

diff --git a/src/views/crm/business/components/BusinessList.vue b/src/views/crm/business/components/BusinessList.vue
new file mode 100644
index 0000000..f990606
--- /dev/null
+++ b/src/views/crm/business/components/BusinessList.vue
@@ -0,0 +1,186 @@
+<template>
+  <!-- 鎿嶄綔鏍� -->
+  <el-row justify="end">
+    <el-button @click="openForm">
+      <Icon class="mr-5px" icon="ep:opportunity" />
+      鍒涘缓鍟嗘満
+    </el-button>
+    <el-button
+      @click="openBusinessModal"
+      v-hasPermi="['crm:contact:create-business']"
+      v-if="queryParams.contactId"
+    >
+      <Icon class="mr-5px" icon="ep:circle-plus" />鍏宠仈
+    </el-button>
+    <el-button
+      @click="deleteContactBusinessList"
+      v-hasPermi="['crm:contact:delete-business']"
+      v-if="queryParams.contactId"
+    >
+      <Icon class="mr-5px" icon="ep:remove" />瑙i櫎鍏宠仈
+    </el-button>
+  </el-row>
+
+  <!-- 鍒楄〃 -->
+  <ContentWrap class="mt-10px">
+    <el-table
+      ref="businessRef"
+      v-loading="loading"
+      :data="list"
+      :stripe="true"
+      :show-overflow-tooltip="true"
+    >
+      <el-table-column type="selection" width="55" v-if="queryParams.contactId" />
+      <el-table-column label="鍟嗘満鍚嶇О" fixed="left" align="center" prop="name">
+        <template #default="scope">
+          <el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
+            {{ scope.row.name }}
+          </el-link>
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="鍟嗘満閲戦"
+        align="center"
+        prop="price"
+        :formatter="erpPriceTableColumnFormatter"
+      />
+      <el-table-column label="瀹㈡埛鍚嶇О" align="center" prop="customerName" />
+      <el-table-column label="鍟嗘満缁�" align="center" prop="statusTypeName" />
+      <el-table-column label="鍟嗘満闃舵" align="center" prop="statusName" />
+    </el-table>
+    <!-- 鍒嗛〉 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 琛ㄥ崟寮圭獥锛氭坊鍔� -->
+  <BusinessForm ref="formRef" @success="getList" />
+  <!-- 鍏宠仈鍟嗘満閫夋嫨寮规 -->
+  <BusinessListModal
+    ref="businessModalRef"
+    :customer-id="props.customerId"
+    @success="createContactBusinessList"
+  />
+</template>
+<script setup lang="ts">
+import * as BusinessApi from '@/api/crm/business'
+import * as ContactApi from '@/api/crm/contact'
+import BusinessForm from './../BusinessForm.vue'
+import { BizTypeEnum } from '@/api/crm/permission'
+import BusinessListModal from './BusinessListModal.vue'
+import { erpPriceTableColumnFormatter } from '@/utils'
+
+const message = useMessage() // 娑堟伅
+
+defineOptions({ name: 'CrmBusinessList' })
+const props = defineProps<{
+  bizType: number // 涓氬姟绫诲瀷
+  bizId: number // 涓氬姟缂栧彿
+  customerId?: number // 鍏宠仈鑱旂郴浜轰笌鍟嗘満鏃讹紝闇�瑕佷紶鍏� customerId 杩涜绛涢��
+  contactId?: 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
+  contactId: undefined as unknown // 鍏佽 undefined + number
+})
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+  loading.value = true
+  try {
+    // 缃┖鍙傛暟
+    queryParams.customerId = undefined
+    queryParams.contactId = undefined
+    // 鎵ц鏌ヨ
+    let data = { list: [], total: 0 }
+    switch (props.bizType) {
+      case BizTypeEnum.CRM_CUSTOMER:
+        queryParams.customerId = props.bizId
+        data = await BusinessApi.getBusinessPageByCustomer(queryParams)
+        break
+      case BizTypeEnum.CRM_CONTACT:
+        queryParams.contactId = props.bizId
+        data = await BusinessApi.getBusinessPageByContact(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', null, props.customerId, props.contactId)
+}
+
+/** 鎵撳紑鑱旂郴浜鸿鎯� */
+const { push } = useRouter()
+const openDetail = (id: number) => {
+  push({ name: 'CrmBusinessDetail', params: { id } })
+}
+
+/** 鎵撳紑鑱旂郴浜轰笌鍟嗘満鐨勫叧鑱斿脊绐� */
+const businessModalRef = ref()
+const openBusinessModal = () => {
+  businessModalRef.value.open()
+}
+const createContactBusinessList = async (businessIds: number[]) => {
+  const data = {
+    contactId: props.bizId,
+    businessIds: businessIds
+  } as ContactApi.ContactBusinessReqVO
+  businessRef.value.getSelectionRows().forEach((row: BusinessApi.BusinessVO) => {
+    data.businessIds.push(row.id)
+  })
+  await ContactApi.createContactBusinessList(data)
+  // 鍒锋柊鍒楄〃
+  message.success('鍏宠仈鍟嗘満鎴愬姛')
+  handleQuery()
+}
+
+/** 瑙i櫎鑱旂郴浜轰笌鍟嗘満鐨勫叧鑱� */
+const businessRef = ref()
+const deleteContactBusinessList = async () => {
+  const data = {
+    contactId: props.bizId,
+    businessIds: businessRef.value.getSelectionRows().map((row: BusinessApi.BusinessVO) => row.id)
+  } as ContactApi.ContactBusinessReqVO
+  if (data.businessIds.length === 0) {
+    return message.error('鏈�夋嫨鍟嗘満')
+  }
+  await ContactApi.deleteContactBusinessList(data)
+  // 鍒锋柊鍒楄〃
+  message.success('鍙栧叧鍟嗘満鎴愬姛')
+  handleQuery()
+}
+
+/** 鐩戝惉鎵撳紑鐨� bizId + bizType锛屼粠鑰屽姞杞芥渶鏂扮殑鍒楄〃 */
+watch(
+  () => [props.bizId, props.bizType],
+  () => {
+    handleQuery()
+  },
+  { immediate: true, deep: true }
+)
+</script>

--
Gitblit v1.8.0