Explorar el Código

修复认领功能

沐梦. hace 1 mes
padre
commit
5bcae7d6f7

+ 9 - 5
src/api/customer/customerInfo/index.ts

@@ -83,13 +83,17 @@ export function transferServiceStaff(data: any) {
 }
 
 /**
- * 退回到公海
+ * 退回到公海(支持批量)
+ * @param customerIds 客户ID列表
+ * @param reason 原因
  */
-export function releaseToPool(customerId: number | string, reason: string) {
+export function releaseToPool(customerIds: (number | string)[] | number | string, reason: string = '') {
+  // 兼容单个 ID 或数组
+  const ids = Array.isArray(customerIds) ? customerIds : [customerIds];
   return request({
-    url: '/customer/customerInfo/release',
-    method: 'put',
-    params: { customerId, reason }
+    url: '/customer/customerInfo/releaseToPool',
+    method: 'post',
+    data: { customerIds: ids, reason }
   });
 }
 

+ 8 - 3
src/views/customer/customerPool/index.vue

@@ -48,8 +48,7 @@
           <el-form-item label="部门" prop="deptId" style="width: 100%">
             <el-input v-model="queryParams.deptId" placeholder="请输入部门" clearable @keyup.enter="handleQuery" />
           </el-form-item>
-        </el-col>
-        <el-col :span="6">
+        </el-col>        <el-col :span="6">
           <el-form-item label="合作状态" prop="status" style="width: 100%">
             <el-select v-model="queryParams.status" placeholder="请选择" clearable style="width: 100%">
               <el-option v-for="item in cooperationOptions" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
@@ -563,7 +562,13 @@ function handleClaim(row) {
 function submitClaim() {
   proxy.$refs["claimRef"].validate(valid => {
     if (valid) {
-      claimPool(claimForm.value).then(response => {
+      const data = { ...claimForm.value };
+      // 自动填充业务员所属部门
+      const selectedStaff = staffOptions.value.find(s => s.staffId === claimForm.value.salesPersonId);
+      if (selectedStaff) {
+        data.deptId = selectedStaff.deptId;
+      }
+      claimPool(data).then(response => {
         proxy.$modal.msgSuccess("认领成功");
         claimOpen.value = false;
         getList();

+ 9 - 4
src/views/customer/highseas/index.vue

@@ -51,8 +51,7 @@
             <el-form-item label="部门" prop="belongingDepartmentId" class="custom-form-item">
               <el-input v-model="queryParams.belongingDepartmentId" placeholder="请输入部门" clearable />
             </el-form-item>
-          </el-col>
-          <el-col :span="6">
+          </el-col>          <el-col :span="6">
             <el-form-item label="合作状态" prop="cooperation" class="custom-form-item">
               <el-select v-model="queryParams.cooperation" placeholder="请选择" clearable style="width: 100%">
                 <el-option v-for="item in cooperationOptions" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
@@ -280,12 +279,18 @@ const submitClaimForm = () => {
     if (valid) {
       loading.value = true;
       try {
-        await claimPool({
+        const data = {
           id: claimForm.customerId,
           salesPersonId: claimForm.salespersonId,
           serviceStaffId: claimForm.serviceStaffId,
           keepOldManager: claimForm.keepOwner
-        });
+        };
+        // 自动带出业务员所属部门
+        const selectedStaff = staffOptions.value.find(s => s.staffId === claimForm.salespersonId);
+        if (selectedStaff) {
+          data.deptId = selectedStaff.deptId;
+        }
+        await claimPool(data);
         proxy.$modal.msgSuccess("认领成功");
         claimOpen.value = false;
         getList();

+ 74 - 15
src/views/customer/valid/index.vue

@@ -57,8 +57,7 @@
             <el-form-item label="部门" prop="belongingDepartmentId" class="custom-form-item">
               <el-input v-model="queryParams.belongingDepartmentId" placeholder="请输入部门" clearable />
             </el-form-item>
-          </el-col>
-        </el-row>
+          </el-col>        </el-row>
 
         <!-- 第三行 -->
         <el-row :gutter="20" class="mt-15">
@@ -101,9 +100,9 @@
           </div>
         </div>
         <div class="tools-right">
-          <el-button type="primary" icon="Back" class="blue-btn">退回到客户公海池</el-button>
-          <el-button type="primary" icon="Switch" class="blue-btn">转移业务员</el-button>
-          <el-button type="primary" icon="UserFilled" class="blue-btn">转移客服人员</el-button>
+          <el-button type="primary" icon="Back" class="blue-btn" @click="handleReturnHighSeas">退回到客户公海池</el-button>
+          <el-button type="primary" icon="Switch" class="blue-btn" @click="handleTransferSales">转移业务员</el-button>
+          <el-button type="primary" icon="UserFilled" class="blue-btn" @click="handleTransferSupport">转移客服人员</el-button>
         </div>
       </div>
 
@@ -146,6 +145,26 @@
       />
     </el-card>
 
+    <!-- 转移人员弹窗 -->
+    <el-dialog :title="transferDialog.title" v-model="transferDialog.visible" width="400px" append-to-body>
+      <el-form ref="transferRef" :model="transferForm" :rules="transferRules" label-width="100px">
+        <el-form-item label="选择人员:" prop="staffId">
+          <template #label>
+            <span style="color: #f56c6c; margin-right: 4px;">*</span>选择人员:
+          </template>
+          <el-select v-model="transferForm.staffId" placeholder="请选择" filterable style="width: 100%">
+            <el-option v-for="item in staffOptions" :key="item.staffId" :label="item.staffName" :value="item.staffId" />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="transferDialog.visible = false">取 消</el-button>
+          <el-button type="primary" @click="submitTransfer">确 认</el-button>
+        </div>
+      </template>
+    </el-dialog>
+
     <!-- 客户详情组件 (有效客户专用) -->
     <valid-customer-info ref="detailRef" />
   </div>
@@ -154,7 +173,7 @@
 <script setup name="CustomerValid">
 import { ref, reactive, onMounted, getCurrentInstance } from 'vue';
 import { useRouter } from 'vue-router';
-import { listValidCustomer, releaseToPool, listCompanyOption } from "@/api/customer/customerInfo/index";
+import { listValidCustomer, releaseToPool, listCompanyOption, transferSalesPerson, transferServiceStaff } from "@/api/customer/customerInfo/index";
 import { listIndustryCategory } from "@/api/customer/industryCategory";
 import { listLevel } from "@/api/customer/customerLevel";
 import { selectStaffOptionList } from "@/api/customer/crmStaff";
@@ -241,28 +260,68 @@ const handleReturnHighSeas = () => {
   if (ids.value.length === 0) { proxy.$modal.msgWarning("请选择要操作的数据"); return; }
   proxy.$modal.confirm(`是否将选中的${ids.value.length}个客户退回到客户公海池?`).then(() => {
     loading.value = true;
-    const promises = ids.value.map(id => releaseToPool(id, "有效客户退回"));
-    Promise.all(promises).then(() => {
+    // 一次性调用批量接口
+    releaseToPool(ids.value, "有效客户退回").then(() => {
       proxy.$modal.msgSuccess("退回成功");
-      getList();
+      // 跳转到公海池页面
+      router.push('/customer/highseas');
     }).catch(() => {
       loading.value = false;
     });
   }).catch(() => {});
 };
 
+const transferDialog = reactive({
+  visible: false,
+  title: '',
+  type: '' // 'sales' 或 'support'
+});
+const transferForm = reactive({
+  staffId: undefined
+});
+const transferRules = {
+  staffId: [{ required: true, message: '请选择人员', trigger: 'change' }]
+};
+const transferRef = ref(null);
+
 const handleTransferSales = () => {
   if (ids.value.length === 0) { proxy.$modal.msgWarning("请选择要操作的数据"); return; }
-  proxy.$modal.confirm("是否转移选中客户的业务负责人?").then(() => {
-    proxy.$modal.msgSuccess("操作成功");
-  }).catch(() => {});
+  transferDialog.title = '转移业务员';
+  transferDialog.type = 'sales';
+  transferForm.staffId = undefined;
+  if (transferRef.value) transferRef.value.clearValidate();
+  transferDialog.visible = true;
 };
 
 const handleTransferSupport = () => {
   if (ids.value.length === 0) { proxy.$modal.msgWarning("请选择要操作的数据"); return; }
-  proxy.$modal.confirm("是否转移选中客户的客服助理?").then(() => {
-    proxy.$modal.msgSuccess("操作成功");
-  }).catch(() => {});
+  transferDialog.title = '转移客服人员';
+  transferDialog.type = 'support';
+  transferForm.staffId = undefined;
+  if (transferRef.value) transferRef.value.clearValidate();
+  transferDialog.visible = true;
+};
+
+const submitTransfer = () => {
+  transferRef.value.validate(valid => {
+    if (valid) {
+      const data = { customerIds: ids.value };
+      let apiCall = null;
+      if (transferDialog.type === 'sales') {
+        data.salesPersonId = transferForm.staffId;
+        apiCall = transferSalesPerson(data);
+      } else {
+        data.serviceStaffId = transferForm.staffId;
+        apiCall = transferServiceStaff(data);
+      }
+      
+      apiCall.then(() => {
+        proxy.$modal.msgSuccess("转移成功");
+        transferDialog.visible = false;
+        getList();
+      });
+    }
+  });
 };
 
 const handleQuery = debounce(() => {