Ver Fonte

销售端认领逻辑优化

cgp há 3 semanas atrás
pai
commit
758cc73451
2 ficheiros alterados com 132 adições e 178 exclusões
  1. 15 0
      src/api/qw/companyCustomer.js
  2. 117 178
      src/views/qw/companyCustomer/index.vue

+ 15 - 0
src/api/qw/companyCustomer.js

@@ -218,3 +218,18 @@ export function createPhoneQRCode(materialId) {
     data: { materialId: materialId }
   });
 }
+// 判断是否可快捷认领
+export function canClaimCustomer(id) {
+  return request({
+    url: '/qw/companyCustomer/canClaimCustomer/' + id,
+    method: 'get'
+  });
+}
+// 快捷认领并完善信息
+export function quickClaimAndImprove(data) {
+  return request({
+    url: '/qw/companyCustomer/quickClaimAndImprove',
+    method: 'put',
+    data: data
+  });
+}

+ 117 - 178
src/views/qw/companyCustomer/index.vue

@@ -370,12 +370,14 @@
         prop="kdzlAddWechatStatus"
       >
         <template slot-scope="scope">
-          <el-tag v-if="scope.row.kdzlAddWechatStatus === 1" type="success"
-            >已加</el-tag
-          >
-          <el-tag v-else-if="scope.row.kdzlAddWechatStatus === 0" type="warning"
-            >未加</el-tag
-          >
+          <!-- 1 为已加 -->
+          <el-tag v-if="scope.row.kdzlAddWechatStatus === 1" type="success">
+            已加
+          </el-tag>
+          <!-- 0 或 空值(null/undefined/'') 均显示未加 -->
+          <el-tag v-else-if="scope.row.kdzlAddWechatStatus === 0 || !scope.row.kdzlAddWechatStatus" type="warning">
+            未加
+          </el-tag>
           <span v-else>-</span>
         </template>
       </el-table-column>
@@ -564,15 +566,21 @@
       </div>
     </el-dialog>
 
-    <!-- ========== 新增/编辑/详情 弹窗 ========== -->
+    <!-- ========== 新增/编辑/详情/快捷认领 弹窗 ========== -->
     <el-dialog
       :title="title"
       :visible.sync="open"
       width="1100px"
       append-to-body
       :close-on-click-modal="false"
+      @close="handleDialogClose"
     >
-      <!-- 内容不变-->
+      <!-- 快捷认领提示(仅在快捷认领模式下显示) -->
+      <div v-if="isQuickClaimMode" style="color: #E6A23C; font-size: 14px; margin-bottom: 15px; padding: 10px; background: #fdf6ec; border-radius: 4px;">
+        <i class="el-icon-warning"></i>
+        请完整填写以下信息(带*为必填),其中病情主诉、现病史、现用药情况、过敏史至少填写一项
+      </div>
+
       <el-form
         ref="form"
         :model="form"
@@ -581,201 +589,68 @@
         size="small"
       >
         <!-- 第一行 -->
-        <div
-          style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px"
-        >
-          <el-form-item
-            label="客户姓名"
-            prop="customerName"
-            style="flex: 1; min-width: 140px; margin-bottom: 0"
-          >
-            <el-input
-              v-model="form.customerName"
-              placeholder="请输入客户姓名"
-              :disabled="isDetail"
-            />
+        <div style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px">
+          <el-form-item label="客户姓名" prop="customerName" style="flex: 1; min-width: 140px; margin-bottom: 0">
+            <el-input v-model="form.customerName" placeholder="请输入客户姓名" :disabled="isDetail" />
           </el-form-item>
-          <el-form-item
-            label="性别"
-            prop="sex"
-            style="flex: 0.6; min-width: 100px; margin-bottom: 0"
-          >
-            <el-select
-              v-model="form.sex"
-              placeholder="请选择"
-              style="width: 100%"
-              :disabled="isDetail"
-            >
-              <el-option
-                v-for="dict in sexOptions"
-                :key="dict.value"
-                :label="dict.label"
-                :value="dict.value"
-              />
+          <el-form-item label="性别" prop="sex" style="flex: 0.6; min-width: 100px; margin-bottom: 0">
+            <el-select v-model="form.sex" placeholder="请选择" style="width: 100%" :disabled="isDetail">
+              <el-option v-for="dict in sexOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
             </el-select>
           </el-form-item>
-          <el-form-item
-            label="年龄"
-            prop="age"
-            style="flex: 0.7; min-width: 120px; margin-bottom: 0"
-          >
-            <el-input-number
-              v-model="form.age"
-              :min="18"
-              :max="200"
-              placeholder="年龄"
-              controls-position="right"
-              style="width: 100%"
-              :disabled="isDetail"
-            />
+          <el-form-item label="年龄" prop="age" style="flex: 0.7; min-width: 120px; margin-bottom: 0">
+            <el-input-number v-model="form.age" :min="18" :max="200" placeholder="年龄" controls-position="right" style="width: 100%" :disabled="isDetail" />
           </el-form-item>
-          <el-form-item
-            label="电话"
-            prop="phone"
-            style="flex: 1.2; min-width: 150px; margin-bottom: 0"
-          >
-            <el-input
-              v-model="form.phone"
-              placeholder="请输入电话"
-              :disabled="isDetail"
-            />
+          <el-form-item label="电话" prop="phone" style="flex: 1.2; min-width: 150px; margin-bottom: 0">
+            <el-input v-model="form.phone" placeholder="请输入电话" :disabled="isDetail" />
           </el-form-item>
         </div>
         <!-- 第二行 -->
-        <div
-          style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px"
-        >
-          <el-form-item
-            label="地址"
-            prop="address"
-            style="flex: 2; min-width: 200px; margin-bottom: 0"
-          >
-            <el-input
-              v-model="form.address"
-              placeholder="请输入地址"
-              :disabled="isDetail"
-            />
+        <div style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px">
+          <el-form-item label="地址" prop="address" style="flex: 2; min-width: 200px; margin-bottom: 0">
+            <el-input v-model="form.address" placeholder="请输入地址" :disabled="isDetail" />
           </el-form-item>
-          <el-form-item
-            label="建档时间"
-            prop="filingTime"
-            style="flex: 1; min-width: 180px; margin-bottom: 0"
-          >
-            <el-date-picker
-              v-model="form.filingTime"
-              type="datetime"
-              placeholder="选择建档时间"
-              value-format="yyyy-MM-dd HH:mm:ss"
-              style="width: 100%"
-              :disabled="isDetail"
-            />
+          <el-form-item label="建档时间" prop="filingTime" style="flex: 1; min-width: 180px; margin-bottom: 0">
+            <el-date-picker v-model="form.filingTime" type="datetime" placeholder="选择建档时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" :disabled="isDetail" />
           </el-form-item>
         </div>
         <!-- 第三行 -->
-        <div
-          style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px"
-        >
-          <el-form-item
-            label="客服姓名"
-            prop="companyUserName"
-            style="flex: 1; min-width: 130px; margin-bottom: 0"
-          >
-            <el-input
-              v-model="form.companyUserName"
-              placeholder="客服姓名"
-              :disabled="isDetail"
-            />
+        <div style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px">
+          <el-form-item label="客服姓名" prop="companyUserName" style="flex: 1; min-width: 130px; margin-bottom: 0">
+            <el-input v-model="form.companyUserName" placeholder="客服姓名" :disabled="isDetail" />
             <input type="hidden" v-model="form.companyUserId" />
           </el-form-item>
-          <el-form-item
-            label="约诊时间"
-            prop="appointmentTime"
-            style="flex: 1.2; min-width: 180px; margin-bottom: 0"
-          >
-            <el-date-picker
-              v-model="form.appointmentTime"
-              type="datetime"
-              placeholder="选择约诊时间"
-              value-format="yyyy-MM-dd HH:mm:ss"
-              style="width: 100%"
-              :disabled="isDetail"
-            />
+          <el-form-item label="约诊时间" prop="appointmentTime" style="flex: 1.2; min-width: 180px; margin-bottom: 0">
+            <el-date-picker v-model="form.appointmentTime" type="datetime" placeholder="选择约诊时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" :disabled="isDetail" />
           </el-form-item>
-          <el-form-item
-            label="负责医生"
-            prop="doctorName"
-            style="flex: 1; min-width: 130px; margin-bottom: 0"
-          >
-            <el-input
-              v-model="form.doctorName"
-              placeholder="负责医生"
-              :disabled="isDetail"
-            />
+          <el-form-item label="负责医生" prop="doctorName" style="flex: 1; min-width: 130px; margin-bottom: 0">
+            <el-input v-model="form.doctorName" placeholder="负责医生" :disabled="isDetail" />
             <input type="hidden" v-model="form.doctorId" />
           </el-form-item>
         </div>
         <!-- 文本域 -->
         <div style="margin-bottom: 15px">
-          <el-form-item
-            label="患者病情主诉"
-            prop="patientMainComplaint"
-            style="margin-bottom: 0"
-          >
-            <el-input
-              type="textarea"
-              v-model="form.patientMainComplaint"
-              placeholder="患者病情主诉"
-              :rows="3"
-              :disabled="isDetail"
-            />
+          <el-form-item label="患者病情主诉" prop="patientMainComplaint" style="margin-bottom: 0">
+            <el-input type="textarea" v-model="form.patientMainComplaint" placeholder="患者病情主诉" :rows="3" :disabled="isDetail" />
           </el-form-item>
         </div>
         <div style="margin-bottom: 15px">
-          <el-form-item
-            label="现病史"
-            prop="presentIllness"
-            style="margin-bottom: 0"
-          >
-            <el-input
-              type="textarea"
-              v-model="form.presentIllness"
-              placeholder="请输入现病史"
-              :rows="3"
-              :disabled="isDetail"
-            />
+          <el-form-item label="现病史" prop="presentIllness" style="margin-bottom: 0">
+            <el-input type="textarea" v-model="form.presentIllness" placeholder="请输入现病史" :rows="3" :disabled="isDetail" />
           </el-form-item>
         </div>
         <div style="margin-bottom: 15px">
-          <el-form-item
-            label="现用药情况"
-            prop="currentMedication"
-            style="margin-bottom: 0"
-          >
-            <el-input
-              type="textarea"
-              v-model="form.currentMedication"
-              placeholder="请输入现用药情况"
-              :rows="3"
-              :disabled="isDetail"
-            />
+          <el-form-item label="现用药情况" prop="currentMedication" style="margin-bottom: 0">
+            <el-input type="textarea" v-model="form.currentMedication" placeholder="请输入现用药情况" :rows="3" :disabled="isDetail" />
           </el-form-item>
         </div>
         <div style="margin-bottom: 0">
-          <el-form-item
-            label="过敏史"
-            prop="allergyHistory"
-            style="margin-bottom: 0"
-          >
-            <el-input
-              type="textarea"
-              v-model="form.allergyHistory"
-              placeholder="请输入过敏史"
-              :rows="3"
-              :disabled="isDetail"
-            />
+          <el-form-item label="过敏史" prop="allergyHistory" style="margin-bottom: 0">
+            <el-input type="textarea" v-model="form.allergyHistory" placeholder="请输入过敏史" :rows="3" :disabled="isDetail" />
           </el-form-item>
         </div>
       </el-form>
+
       <div slot="footer" class="dialog-footer" v-if="!isDetail">
         <el-button type="primary" @click="submitForm">确 定</el-button>
         <el-button @click="cancel">取 消</el-button>
@@ -1730,6 +1605,8 @@ import {
   getShareMaterialWxCode,
   getShareMaterialList,
   createPhoneQRCode,
+  canClaimCustomer,
+  quickClaimAndImprove,
 } from "@/api/qw/companyCustomer";
 import { treeselect } from "@/api/company/companyDept";
 import { parseTime } from "@/utils/common";
@@ -1822,6 +1699,8 @@ export default {
       }
     };
     return {
+      // 快捷认领弹窗
+      isQuickClaimMode: false,
       deptOptions: [], // 树形部门数据
       cascaderProps: {
         // el-cascader 配置
@@ -2906,12 +2785,38 @@ export default {
       this.queryParams.deptId = null;
     },
     handleClaim(row) {
-      this.currentClaimRow = row;
-      this.claimForm.claimNumber = "";
-      this.claimForm.kdzlAddWechatStatus = null;
-      this.claimDialogVisible = true;
-      this.$nextTick(() => {
-        if (this.$refs.claimForm) this.$refs.claimForm.clearValidate();
+      // 先调用快捷判断接口
+      canClaimCustomer(row.id).then(response => {
+        const flag = response.data; // 0 或 1
+        if (flag === 1) {
+          // 符合快捷认领 → 打开编辑弹窗(快捷模式)
+          this.isQuickClaimMode = true;
+          // 获取客户详情填充到表单
+          getCustomer(row.id).then(res => {
+            this.form = res.data;
+            if (this.form.sex !== undefined && this.form.sex !== null) {
+              this.form.sex = String(this.form.sex);
+            }
+            this.open = true;
+            this.title = "认领客户 - 请完善信息";
+          }).catch(() => {
+            this.isQuickClaimMode = false;   // 失败时重置
+            this.$message.error('获取客户信息失败');
+          });
+        } else {
+          // 不符合 → 走原有普通认领弹窗
+          this.isQuickClaimMode = false;
+          this.currentClaimRow = row;
+          this.claimForm.claimNumber = '';
+          this.claimForm.kdzlAddWechatStatus = null;
+          this.claimDialogVisible = true;
+          this.$nextTick(() => {
+            if (this.$refs.claimForm) this.$refs.claimForm.clearValidate();
+          });
+        }
+      }).catch(error => {
+        this.isQuickClaimMode = false;   // 异常时重置
+        this.$message.error(error.msg || '判断快捷认领失败');
       });
     },
     submitClaim() {
@@ -2999,6 +2904,7 @@ export default {
       };
       this.resetForm("form");
       this.isDetail = false;
+      this.isQuickClaimMode = false;
     },
     handleQuery() {
       this.queryParams.pageNum = 1;
@@ -3045,8 +2951,36 @@ export default {
     },
     async submitForm() {
       try {
+        // ========== 第一步:执行原有表单校验(所有字段) ==========
         const valid = await this.$refs["form"].validate();
         if (!valid) return;
+
+        // ========== 第二步:快捷认领模式下,额外校验 ==========
+        if (this.isQuickClaimMode) {
+          const { patientMainComplaint, presentIllness, currentMedication, allergyHistory } = this.form;
+          const hasAny = [
+            patientMainComplaint,
+            presentIllness,
+            currentMedication,
+            allergyHistory
+          ].some(val => val && val.trim() !== '');
+
+          if (!hasAny) {
+            this.$message.error('病情主诉、现病史、现用药情况、过敏史至少填写一项');
+            return;
+          }
+
+          // ========== 第三步:调用快捷认领接口(传递完整表单数据) ==========
+          // 注意:后端 quickClaimAndImprove 需要接收完整的 FsCompanyCustomer 对象
+          await quickClaimAndImprove(this.form);
+          this.$message.success('快捷认领并完善信息成功');
+          this.open = false;
+          this.isQuickClaimMode = false;
+          this.getList();
+          return;
+        }
+
+        // ========== 普通新增/编辑逻辑(不变) ==========
         if (this.form.id != null) {
           await updateCustomer(this.form);
           this.$message.success("修改成功");
@@ -3057,6 +2991,7 @@ export default {
         this.open = false;
         await this.$nextTick();
         this.getList();
+
       } catch (e) {
         console.warn("提交失败", e);
         if (e.message) this.$message.error(e.message);
@@ -3436,6 +3371,10 @@ export default {
       this.selectedPhoneMaterialId = null;
       this.phoneFilteredMaterialList = [];
       this.phoneMaterialList = [];
+    },
+    handleDialogClose() {
+      this.isQuickClaimMode = false;
+      this.reset();
     }
   },
 };