Procházet zdrojové kódy

患者信息表修改认领逻辑

cgp před 2 týdny
rodič
revize
cad00a075f
1 změnil soubory, kde provedl 24 přidání a 26 odebrání
  1. 24 26
      src/views/qw/companyCustomer/index.vue

+ 24 - 26
src/views/qw/companyCustomer/index.vue

@@ -124,7 +124,7 @@
       @pagination="getList"
     />
 
-    <!-- ========== 新增/编辑/详情 弹窗(保持不变,但已移除认领逻辑) ========== -->
+    <!-- ========== 新增/编辑/详情 弹窗 ========== -->
     <el-dialog :title="title" :visible.sync="open" width="1100px" append-to-body :close-on-click-modal="false">
       <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="small">
         <!-- 第一行:客户姓名、性别、年龄、电话 -->
@@ -250,7 +250,7 @@
     <!-- 信息采集弹窗 -->
     <collection-info-dialog :visible.sync="collectionVisible" :id="currentId"/>
 
-    <!-- ========== 新增:独立的认领确认弹窗 ========== -->
+    <!-- ========== 独立的认领确认弹窗 ========== -->
     <el-dialog title="认领客户" :visible.sync="claimDialogVisible" width="400px" append-to-body
                :close-on-click-modal="false">
       <div>
@@ -371,7 +371,7 @@ export default {
       collectionVisible: false,
       // 详情弹窗只读模式
       isDetail: false,
-      // 新增:独立认领弹窗相关
+      // 独立认领弹窗相关
       claimDialogVisible: false,
       claimSubmitLoading: false,
       currentClaimRow: null,
@@ -424,23 +424,19 @@ export default {
       this.handleQuery();
     },
     /**
-     * 修改后的认领客户逻辑:打开独立的确认弹窗(不打开编辑弹窗)
-     * 先校验客户是否已被认领,再校验当前用户是否有绑定的医生信息
+     * 认领客户:打开独立确认弹窗
      */
     handleClaim(row) {
-      // 二次确认(虽然按钮已控制显示,但防止脚本调用)
       if (row.companyUserId) {
         this.$message.warning('该客户已被认领,无法重复认领');
         return;
       }
-      // 预检:当前用户是否绑定了医生(避免点击确认后才发现无法认领)
       getCompanyUserAndDoctor().then(res => {
         const userData = res.data;
         if (!userData || !userData.doctorId) {
           this.$modal.msgError("未找到绑定医生!请先绑定医生后再操作!");
           return;
         }
-        // 通过预检,打开独立弹窗
         this.currentClaimRow = row;
         this.claimDialogVisible = true;
       }).catch(err => {
@@ -448,16 +444,17 @@ export default {
         this.$message.error("获取用户信息失败,无法认领");
       });
     },
-    /** 执行认领提交(独立弹窗的确认按钮) */
+    /**
+     * 执行认领提交:成功后自动打开编辑弹窗(修改模式)
+     */
     submitClaim() {
       if (!this.currentClaimRow || !this.currentClaimRow.id) {
         this.$message.error("客户信息异常,请刷新后重试");
         this.claimDialogVisible = false;
         return;
       }
-      // 避免重复提交
       this.claimSubmitLoading = true;
-      // 重新获取最新的客服和医生信息(确保认领时数据准确)
+      // 获取最新的客服和医生信息
       getCompanyUserAndDoctor().then(res => {
         const userData = res.data;
         if (!userData || !userData.doctorId) {
@@ -466,7 +463,6 @@ export default {
           this.claimDialogVisible = false;
           return;
         }
-        // 构造认领参数:只需要客户ID、客服ID/姓名、医生ID/姓名
         const claimParams = {
           id: this.currentClaimRow.id,
           companyUserId: userData.companyUserId,
@@ -477,12 +473,24 @@ export default {
         claimCustomer(claimParams).then(() => {
           this.$message.success("认领成功");
           this.claimDialogVisible = false;
-          // 刷新表格显示最新认领状态
+          // 刷新列表(让表格显示最新状态
           this.getList();
+          // 打开编辑弹窗,让用户继续完善信息
+          return getCustomer(this.currentClaimRow.id);
+        }).then(response => {
+          // 重置表单状态(确保不是只读模式)
+          this.reset();
+          this.form = response.data;
+          if (this.form.sex !== undefined && this.form.sex !== null) {
+            this.form.sex = String(this.form.sex);
+          }
+          this.open = true;
+          this.title = "修改客户信息";
+          this.isDetail = false;
         }).catch(error => {
-          console.error("认领失败", error);
-          const msg = error?.message || error?.msg || "认领失败,请重试";
-          this.$message.error(msg);
+          // 如果打开编辑弹窗失败(例如获取详情接口报错),仅提示,不影响认领成功的消息
+          console.error("获取客户详情失败", error);
+          this.$message.error("获取客户详情失败,请手动刷新后编辑");
         }).finally(() => {
           this.claimSubmitLoading = false;
         });
@@ -500,19 +508,14 @@ export default {
       this.open = false;
       this.reset();
     },
-    /**
-     * 处理详情按钮点击
-     */
     handleDetail(row) {
       this.reset();
       const id = row.id;
       getCustomer(id).then(response => {
         this.form = response.data;
-        // 将数字类型的 sex 转换为字符串,以匹配 el-select 的 value
         if (this.form.sex !== undefined && this.form.sex !== null) {
           this.form.sex = String(this.form.sex);
         }
-        // 设置为详情模式,开启只读
         this.isDetail = true;
         this.open = true;
         this.title = "客户详情";
@@ -539,7 +542,6 @@ export default {
         allergyHistory: null
       };
       this.resetForm("form");
-      // 重置详情模式(注意:不再包含 isClaim)
       this.isDetail = false;
     },
     handleQuery() {
@@ -588,7 +590,6 @@ export default {
         const valid = await this.$refs["form"].validate();
         if (!valid) return;
 
-        // 普通新增或修改(不再包含认领分支)
         if (this.form.id != null) {
           await updateCustomer(this.form);
           this.$message.success("修改成功");
@@ -642,7 +643,6 @@ export default {
       }
       return params;
     },
-    /** 打开处方弹窗 */
     handlePrescribe(row) {
       if (!row.phone) {
         this.$message.warning('该客户未登记手机号,无法查询处方');
@@ -653,7 +653,6 @@ export default {
       this.prescribeOpen = true;
       this.getPrescribeList();
     },
-    /** 查询处方列表 */
     getPrescribeList() {
       this.prescribeLoading = true;
       const params = {
@@ -669,7 +668,6 @@ export default {
         this.prescribeLoading = false;
       });
     },
-    /** 打开信息采集弹窗 */
     handleCollection(row) {
       if (!row.phone) {
         this.$message.warning('该客户未登记手机号,无法查看信息采集表')