Ver Fonte

Merge branch 'ysy_company' of http://1.14.104.71:10880/root/ylrz_his_scrm_companyUI into ysy_company

wjj há 3 semanas atrás
pai
commit
747a30702e
2 ficheiros alterados com 215 adições e 1 exclusões
  1. 25 0
      src/api/company/companyUser.js
  2. 190 1
      src/views/company/companyUser/index.vue

+ 25 - 0
src/api/company/companyUser.js

@@ -346,3 +346,28 @@ export function changeCreateStatus(userId, createOpen) {
     data: data
   })
 }
+
+// 获取所有销售人员列表(不分页)
+export function getSaleList() {
+  return request({
+    url: '/company/user/getSaleList',
+    method: 'get'
+  })
+}
+
+// 获取指定销售人员管理的客户列表
+export function getSaleCustomerList(companyUserId) {
+  return request({
+    url: '/company/user/getSaleCustomerList/' + companyUserId,
+    method: 'get'
+  })
+}
+
+// 执行客户转交
+export function transferCustomer(data) {
+  return request({
+    url: '/company/user/transferCustomer',
+    method: 'post',
+    data: data
+  })
+}

+ 190 - 1
src/views/company/companyUser/index.vue

@@ -299,6 +299,11 @@
               <el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['company:user:resetPwd']">重置密码</el-button>
               <el-button size="mini" type="text" icon="el-icon-edit" @click="checkBindSipCallUser(scope.row)" v-if="scope.row.aiSipCallUserId==null">绑定sip角色</el-button>
               <el-button size="mini" type="text" icon="el-icon-search" @click="checkChangeSipCallUser(scope.row)" v-if="scope.row.aiSipCallUserId">修改sip角色</el-button>
+              <el-button
+                size="mini"
+                type="text"
+                @click="openCustomerTransfer(scope.row)"
+              >转交客户</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -701,6 +706,67 @@
       <selectDoctor ref="selectDoctor" @bindCompanyUserDoctorId="bindCompanyUserDoctorId"></selectDoctor>
     </el-dialog>
     <ai-sip-call-user ref="aiSipCallUser" v-show="false" @refreshParentData="getList" />
+
+    <!-- ======================== 客户转交弹窗 ======================== -->
+    <el-dialog title="客户转交" :visible.sync="transferCustomerDialogVisible" width="800px" append-to-body @close="closeCustomerTransfer">
+      <el-row :gutter="20">
+        <!-- 选择目标销售人员 -->
+        <el-col :span="24">
+          <el-form :inline="true" size="small">
+            <el-form-item label="目标销售" required>
+              <el-select v-model="transferCustomerForm.targetUserId" placeholder="请选择目标销售人员" filterable clearable style="width: 280px;">
+                <el-option
+                  v-for="item in saleUserList"
+                  :key="item.userId"
+                  :label="item.nickName || item.userName"
+                  :value="item.userId"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-form>
+        </el-col>
+      </el-row>
+
+      <!-- 客户列表 -->
+      <el-row :gutter="20">
+        <el-col :span="24">
+          <div style="margin-bottom: 10px;">
+            <span style="font-weight: bold;">当前销售客户列表(共 {{ customerList.length }} 人)</span>
+            <el-button type="primary" size="mini" style="margin-left: 15px;" @click="toggleAllCustomers">
+              {{ isCustomerAllSelected ? '取消全选' : '全选客户' }}
+            </el-button>
+          </div>
+          <el-table
+            ref="customerTable"
+            :data="customerList"
+            border
+            height="350"
+            @selection-change="handleCustomerSelectionChange"
+          >
+            <el-table-column type="selection" width="55" align="center" />
+            <el-table-column label="客户姓名" prop="customerName" show-overflow-tooltip />
+            <el-table-column label="性别" prop="sex" width="80">
+              <template slot-scope="scope">
+                <span>{{ scope.row.sex == 0 ? '女' : scope.row.sex == 1 ? '男' : '未知' }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="年龄" prop="age" width="80" />
+            <el-table-column label="电话" prop="phone" width="130" />
+            <el-table-column label="建档时间" prop="filingTime" width="160">
+              <template slot-scope="scope">
+                <span>{{ parseTime(scope.row.filingTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-col>
+      </el-row>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" :disabled="!transferCustomerForm.targetUserId || transferCustomerForm.selectedCustomerIds.length === 0" @click="submitCustomerTransfer">提 交</el-button>
+        <el-button @click="closeCustomerTransfer">取 消</el-button>
+      </div>
+    </el-dialog>
+    <!-- ======================== 客户转交弹窗结束 ======================== -->
   </div>
 </template>
 
@@ -719,7 +785,10 @@ import {
   generateSubDomain,
   setIsRegisterMember,
   updateCompanyUserAreaList,
-  isAllowedAllRegister,isAllowedEveryoneView, unBindDoctorId, bindDoctorId,updateBatchUserRoles,changeCreateStatus,bindCompanyUserReplyTxt
+  isAllowedAllRegister,isAllowedEveryoneView, unBindDoctorId, bindDoctorId,updateBatchUserRoles,changeCreateStatus,bindCompanyUserReplyTxt,
+  getSaleList,
+  getSaleCustomerList,
+  transferCustomer
 } from "@/api/company/companyUser";
 import { getToken } from "@/utils/auth";
 import { treeselect } from "@/api/company/companyDept";
@@ -859,6 +928,15 @@ export default {
       registerForm: {
         status: false
       },
+      // ========== 客户转交相关数据 ==========
+      transferCustomerDialogVisible: false,
+      transferCustomerForm: {
+        targetUserId: null,
+        selectedCustomerIds: []
+      },
+      customerList: [],
+      saleUserList: [],
+      currentSaleUserId: null,
       // 表单校验
       rules: {
         userName: [
@@ -967,6 +1045,13 @@ export default {
       this.myQwCompanyList = response.data;
     });
   },
+  computed: {
+    // 是否已全选客户
+    isCustomerAllSelected() {
+      if (this.customerList.length === 0) return false;
+      return this.transferCustomerForm.selectedCustomerIds.length === this.customerList.length;
+    }
+  },
   methods: {
     checkBindSipCallUser(row){
 
@@ -1768,6 +1853,110 @@ export default {
         this.getList();
       })
     },
+    // ======================== 客户转交相关方法 ========================
+    /** 打开转交弹窗 */
+    openCustomerTransfer(row) {
+      this.transferCustomerDialogVisible = true;
+      this.currentSaleUserId = row.userId;
+      this.transferCustomerForm.targetUserId = null;
+      this.customerList = [];
+      // 加载该销售下的客户列表
+      this.loadSaleCustomerList(row.userId);
+      // 加载所有销售人员列表(供目标选择)
+      this.loadSaleUserList();
+    },
+
+    /** 获取指定销售的客户列表 */
+    loadSaleCustomerList(companyUserId) {
+      getSaleCustomerList(companyUserId).then(response => {
+        this.customerList = response.data;
+        // 清空表格选中
+        this.$nextTick(() => {
+          if (this.$refs.customerTable) {
+            this.$refs.customerTable.clearSelection();
+          }
+        });
+      }).catch(() => {
+        this.$message.error('获取客户列表失败');
+      });
+    },
+
+    /** 获取所有销售人员列表 */
+    loadSaleUserList() {
+      getSaleList().then(response => {
+        this.saleUserList = response.data;
+      }).catch(() => {
+        this.$message.error('获取销售人员列表失败');
+      });
+    },
+
+    /** 客户表格多选变化 */
+    handleCustomerSelectionChange(selection) {
+      this.transferCustomerForm.selectedCustomerIds = selection.map(item => item.id);
+    },
+
+    /** 全选/取消全选 */
+    toggleAllCustomers() {
+      if (this.isCustomerAllSelected) {
+        this.$refs.customerTable.clearSelection();
+      } else {
+        this.customerList.forEach(row => {
+          this.$refs.customerTable.toggleRowSelection(row, true);
+        });
+      }
+    },
+
+    /** 提交转交 */
+    submitCustomerTransfer() {
+      if (!this.transferCustomerForm.targetUserId) {
+        this.$message.warning('请选择目标销售人员');
+        return;
+      }
+      if (this.transferCustomerForm.selectedCustomerIds.length === 0) {
+        this.$message.warning('请至少选择一位客户');
+        return;
+      }
+
+      // 从 saleUserList 中获取目标销售名称
+      const targetUser = this.saleUserList.find(item => item.userId === this.transferCustomerForm.targetUserId);
+      const targetUserName = targetUser ? (targetUser.nickName || targetUser.userName) : '';
+
+      this.$confirm(`确认将选中的 ${this.transferCustomerForm.selectedCustomerIds.length} 位客户转交给目标销售“${targetUserName}”吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        const param = {
+          targetDoctorId: this.transferCustomerForm.targetUserId,   // 对应 TransferCustomerParam.targetDoctorId
+          targetDoctorName: targetUserName,                        // 对应 TransferCustomerParam.targetDoctorName
+          customerIds: this.transferCustomerForm.selectedCustomerIds
+        };
+        transferCustomer(param).then(response => {
+          if (response.code === 200) {
+            this.$message.success('客户转交成功');
+            this.transferCustomerDialogVisible = false;
+            // 可刷新列表或重新加载
+            this.getList();
+          } else {
+            this.$message.error(response.msg || '转交失败');
+          }
+        }).catch(() => {
+          this.$message.error('转交请求失败');
+        });
+      }).catch(() => {});
+    },
+
+    /** 关闭弹窗 */
+    closeCustomerTransfer() {
+      this.transferCustomerDialogVisible = false;
+      this.currentSaleUserId = null;
+      this.customerList = [];
+      this.transferCustomerForm = {
+        targetUserId: null,
+        selectedCustomerIds: []
+      };
+    },
+// ======================== 客户转交相关方法结束 ========================
   },
 }
 </script>