Procházet zdrojové kódy

患者信息表增加认领逻辑

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

+ 42 - 1
src/views/qw/companyCustomer/index.vue

@@ -60,11 +60,12 @@
       </el-table-column>
       <el-table-column label="客服姓名" align="center" prop="companyUserName" />
       <el-table-column label="负责医生" align="center" prop="doctorName" />
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240">
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300">
         <template slot-scope="scope">
           <el-button size="mini" type="text" icon="el-icon-info" @click="handleDetail(scope.row)">详情</el-button>
           <el-button size="mini" type="text" icon="el-icon-edit" v-if="scope.row.myCustomerFlag" @click="handleUpdate(scope.row)">修改</el-button>
           <el-button size="mini" type="text" icon="el-icon-delete" v-if="scope.row.myCustomerFlag" @click="handleDelete(scope.row)">删除</el-button>
+          <el-button size="mini" type="text" icon="el-icon-user" v-if="!scope.row.companyUserId" @click="handleClaim(scope.row)">认领客户</el-button>
           <el-button size="mini" type="text" icon="el-icon-view" @click="handlePrescribe(scope.row)">查看处方</el-button>
           <el-button size="mini" type="text" icon="el-icon-document" @click="handleCollection(scope.row)">查看信息采集</el-button>
         </template>
@@ -342,6 +343,46 @@ export default {
         this.loading = false;
       });
     },
+    /** 认领客户(打开编辑弹窗并预填当前客服&医生信息) */
+    handleClaim(row) {
+      this.reset(); // 重置表单、关闭只读模式
+      const id = row.id;
+      // 先调用详情接口获取最新客户信息
+      getCustomer(id).then(customerRes => {
+        const customerData = customerRes.data;
+        // 检查是否已被认领
+        if (customerData.companyUserId && customerData.companyUserId !== '') {
+          this.$message.warning('该客户已被认领,无法重复认领');
+          return;
+        }
+        // 未被认领,继续获取当前客服信息
+        getCompanyUserAndDoctor().then(userRes => {
+          const userData = userRes.data;
+          if (!userData || !userData.doctorId) {
+            this.$modal.msgError("未找到绑定医生!请绑定医生后再操作!");
+            return;
+          }
+          // 合并数据:保留原客户信息,覆盖客服和医生字段
+          customerData.companyUserId = userData.companyUserId;
+          customerData.companyUserName = userData.companyUserName;
+          customerData.doctorId = userData.doctorId;
+          customerData.doctorName = userData.doctorName;
+          // 性别转换
+          if (customerData.sex !== undefined && customerData.sex !== null) {
+            customerData.sex = String(customerData.sex);
+          }
+          this.form = customerData;
+          this.open = true;
+          this.title = "认领客户";
+        }).catch(error => {
+          console.error("获取客服医生信息失败", error);
+          this.$message.error("获取信息失败,无法认领");
+        });
+      }).catch(error => {
+        console.error("获取客户详情失败", error);
+        this.$message.error("获取客户信息失败,请重试");
+      });
+    },
     sexFormat(row) {
       return this.sexOptions.find(o => o.value === row.sex)?.label ?? row.sex;
     },