Browse Source

1.在职转接 离职继承新增标签查询和回复时间端查询

wjj 13 hours ago
parent
commit
29e028ad51

+ 1 - 0
src/views/qw/externalContact/myExternalContact.vue

@@ -511,6 +511,7 @@
           <span class="name-background">{{ item.name }}</span>
         </div>
 
+        
         <!-- 添加外层滚动容器 -->
         <div class="scroll-wrapper">
           <div class="tag-container">

+ 644 - 173
src/views/qw/externalContactTransfer/index.vue

@@ -1,25 +1,35 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px">
-
-<!--      <el-form-item label="外部联系人账号" prop="externalUserId">-->
-<!--        <el-input-->
-<!--          v-model="queryParams.externalUserId"-->
-<!--          placeholder="外部联系人账号"-->
-<!--          clearable-->
-<!--          size="small"-->
-<!--          @keyup.enter.native="handleQuery"-->
-<!--        />-->
-<!--      </el-form-item>-->
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      :inline="true"
+      v-show="showSearch"
+      label-width="110px"
+    >
+      <!--      <el-form-item label="外部联系人账号" prop="externalUserId">-->
+      <!--        <el-input-->
+      <!--          v-model="queryParams.externalUserId"-->
+      <!--          placeholder="外部联系人账号"-->
+      <!--          clearable-->
+      <!--          size="small"-->
+      <!--          @keyup.enter.native="handleQuery"-->
+      <!--        />-->
+      <!--      </el-form-item>-->
       <el-form-item label="企微公司" prop="corpId">
-            <el-select v-model="queryParams.corpId" placeholder="企微公司"  size="small" @change="updateCorpId()">
-              <el-option
-                v-for="dict in myQwCompanyList"
-                :key="dict.dictValue"
-                :label="dict.dictLabel"
-                :value="dict.dictValue"
-              />
-            </el-select>
+        <el-select
+          v-model="queryParams.corpId"
+          placeholder="企微公司"
+          size="small"
+          @change="updateCorpId()"
+        >
+          <el-option
+            v-for="dict in myQwCompanyList"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </el-select>
       </el-form-item>
       <el-form-item label="客户名称" prop="name">
         <el-input
@@ -40,7 +50,12 @@
         />
       </el-form-item>
       <el-form-item label="用户类别" prop="type">
-        <el-select v-model="queryParams.type" placeholder="请选择用户类别" clearable size="small">
+        <el-select
+          v-model="queryParams.type"
+          placeholder="请选择用户类别"
+          clearable
+          size="small"
+        >
           <el-option
             v-for="dict in typeOptions"
             :key="dict.dictValue"
@@ -50,7 +65,12 @@
         </el-select>
       </el-form-item>
       <el-form-item label="客户等级" prop="level">
-        <el-select v-model="queryParams.level" placeholder="客户等级" clearable size="small">
+        <el-select
+          v-model="queryParams.level"
+          placeholder="客户等级"
+          clearable
+          size="small"
+        >
           <el-option
             v-for="dict in ratingType"
             :key="dict.dictValue"
@@ -69,7 +89,12 @@
         />
       </el-form-item>
       <el-form-item label="转接状态" prop="addWay">
-        <el-select v-model="queryParams.transferStatus" placeholder="转接状态" clearable size="small">
+        <el-select
+          v-model="queryParams.transferStatus"
+          placeholder="转接状态"
+          clearable
+          size="small"
+        >
           <el-option
             v-for="dict in transferStatusOptions"
             :key="dict.dictValue"
@@ -78,7 +103,7 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item label="标签" prop="tagIds">
+      <!-- <el-form-item label="标签" prop="tagIds">
         <el-select v-model="selectTags" remote multiple placeholder="请选择" filterable  style="width: 100%;">
           <el-option
             v-for="dict in tagList"
@@ -86,6 +111,45 @@
             :value="dict.tagId">
           </el-option>
         </el-select>
+      </el-form-item> -->
+      <el-form-item label="标签" prop="tagIds">
+        <div
+          @click="hangleChangeTags()"
+          style="
+            cursor: pointer;
+            border: 1px solid #e6e6e6;
+            background-color: white;
+            overflow: hidden;
+            flex-grow: 1;
+            width: 250px;
+          "
+        >
+          <div style="min-height: 35px; max-height: 200px; overflow-y: auto">
+            <el-tag
+              type="success"
+              closable
+              :disable-transitions="false"
+              v-for="list in this.selectTags"
+              :key="list.tagId"
+              @close="handleCloseTags(list)"
+              style="margin: 3px"
+              >{{ list.name }}
+            </el-tag>
+          </div>
+        </div>
+      </el-form-item>
+      <el-form-item label="回复时间" prop="lastReplyTime">
+        <el-date-picker
+          v-model="lastReplyTime"
+          size="small"
+          style="width: 220px"
+          value-format="yyyy-MM-dd"
+          type="daterange"
+          range-separator="-"
+          start-placeholder="开始日期"
+          end-placeholder="结束日期"
+          @change="change"
+        ></el-date-picker>
       </el-form-item>
       <el-form-item label="备注" prop="remark">
         <el-input
@@ -97,21 +161,32 @@
         />
       </el-form-item>
       <el-form-item label="添加时间" prop="createTime">
-        <el-date-picker clearable size="small"
-                        v-model="queryParams.createTime"
-                        type="date"
-                        value-format="yyyy-MM-dd"
-                        placeholder="选择添加时间">
+        <el-date-picker
+          clearable
+          size="small"
+          v-model="queryParams.createTime"
+          type="date"
+          value-format="yyyy-MM-dd"
+          placeholder="选择添加时间"
+        >
         </el-date-picker>
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
+          >重置</el-button
+        >
       </el-form-item>
     </el-form>
 
     <el-row :gutter="10" class="mb8">
-   <!--   <el-col :span="1.5">
+      <!--   <el-col :span="1.5">
         <el-button
           type="primary"
           plain
@@ -129,7 +204,8 @@
           :loading="exportLoading"
           @click="handleExport"
           v-hasPermi="['qw:externalContact:export']"
-        >导出</el-button>
+          >导出</el-button
+        >
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -138,78 +214,135 @@
           size="mini"
           @click="handleTransfer"
           v-hasPermi="['qw:externalContact:transfer']"
-        >分配客户</el-button>
+          >分配客户</el-button
+        >
       </el-col>
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList"
+      ></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
+    <el-table
+      v-loading="loading"
+      :data="externalContactList"
+      @selection-change="handleSelectionChange"
+      border
+    >
       <el-table-column type="selection" width="55" align="center" />
 
-      <el-table-column label="所属员工" align="center" prop="qwUserName" width="120px"/>
-      <el-table-column label="员工部门" align="center" prop="departmentName" width="120px"/>
-<!--      <el-table-column label="外部联系人账号" align="center" prop="externalUserId" width="120px"/>-->
+      <el-table-column
+        label="所属员工"
+        align="center"
+        prop="qwUserName"
+        width="120px"
+      />
+      <el-table-column
+        label="员工部门"
+        align="center"
+        prop="departmentName"
+        width="120px"
+      />
+      <!--      <el-table-column label="外部联系人账号" align="center" prop="externalUserId" width="120px"/>-->
       <el-table-column label="客户名称" align="center" prop="name" />
       <el-table-column label="头像" align="center" prop="avatar" width="100px">
         <template slot-scope="scope">
-          <el-popover
-            placement="right"
-            title=""
-            trigger="hover">
-            <img slot="reference" :src="scope.row.avatar" width="60px">
-            <img :src="scope.row.avatar" style="max-width: 200px;">
+          <el-popover placement="right" title="" trigger="hover">
+            <img slot="reference" :src="scope.row.avatar" width="60px" />
+            <img :src="scope.row.avatar" style="max-width: 200px" />
           </el-popover>
         </template>
       </el-table-column>
       <el-table-column label="用户类别" align="center" prop="type">
         <template slot-scope="scope">
-          <dict-tag :options="typeOptions" :value="scope.row.type"/>
+          <dict-tag :options="typeOptions" :value="scope.row.type" />
         </template>
       </el-table-column>
       <el-table-column label="性别" align="center" prop="gender">
         <template slot-scope="scope">
-          <dict-tag :options="genderOptions" :value="scope.row.gender"/>
+          <dict-tag :options="genderOptions" :value="scope.row.gender" />
         </template>
       </el-table-column>
       <el-table-column label="备注" align="center" prop="remark" />
+      <el-table-column label="回复时间" align="center" prop="lastReplyTime" />
       <el-table-column label="描述信息" align="center" prop="description" />
       <el-table-column label="标签" align="center" prop="tagIds" width="300px">
         <template slot-scope="scope">
           <div class="tag-container">
             <div class="tag-list">
-              <div v-for="i in JSON.parse(scope.row.tagIds)" :key="i" style="display: inline;">
-              <el-tag type="success" v-for="ii in tagList" :key="ii.id" style="margin: 3px;" v-if="ii.tagId==i">{{ii.name}}</el-tag>
+              <div
+                v-for="i in JSON.parse(scope.row.tagIds)"
+                :key="i"
+                style="display: inline"
+              >
+                <el-tag
+                  type="success"
+                  v-for="ii in tagList"
+                  :key="ii.id"
+                  style="margin: 3px"
+                  v-if="ii.tagId == i"
+                  >{{ ii.name }}</el-tag
+                >
               </div>
             </div>
           </div>
         </template>
       </el-table-column>
-      <el-table-column label="客户等级" align="center" prop="level" width="120px" >
+      <el-table-column
+        label="客户等级"
+        align="center"
+        prop="level"
+        width="120px"
+      >
         <template slot-scope="scope">
-          <dict-tag :options="ratingType" :value="scope.row.level"/>
+          <dict-tag :options="ratingType" :value="scope.row.level" />
         </template>
       </el-table-column>
-      <el-table-column label="添加时间" align="center" prop="createTime" width="100px"/>
+      <el-table-column
+        label="添加时间"
+        align="center"
+        prop="createTime"
+        width="100px"
+      />
       <el-table-column label="状态" align="center" prop="status" width="100px">
         <template slot-scope="scope">
-          <dict-tag :options="statusOptions" :value="scope.row.status"/>
+          <dict-tag :options="statusOptions" :value="scope.row.status" />
         </template>
       </el-table-column>
-      <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px">
+      <el-table-column
+        label="转接状态"
+        align="center"
+        prop="transferStatus"
+        width="100px"
+      >
         <template slot-scope="scope">
-          <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
+          <dict-tag
+            :options="transferStatusOptions"
+            :value="scope.row.transferStatus"
+          />
         </template>
       </el-table-column>
       <el-table-column label="企业id" align="center" prop="corpId" />
-      <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
+      <el-table-column
+        label="备注电话号码"
+        align="center"
+        prop="remarkMobiles"
+        width="150px"
+      >
         <template slot-scope="scope">
-          <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</span>
+          <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{
+            i
+          }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
+      <el-table-column
+        label="备注企业名称"
+        align="center"
+        prop="remarkCorpName"
+      />
       <el-table-column label="来源" align="center" prop="addWay" width="100px">
         <template slot-scope="scope">
-          <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
+          <dict-tag :options="addWayOptions" :value="scope.row.addWay" />
         </template>
       </el-table-column>
       <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -226,48 +359,119 @@
       </el-table-column> -->
     </el-table>
     <pagination
-      v-show="total>0"
+      v-show="total > 0"
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
       @pagination="getList"
     />
+    <!--  搜索标签   -->
+    <el-dialog
+      :title="changeTagDialog.title"
+      :visible.sync="changeTagDialog.open"
+      style="width: 100%; height: 100%"
+      append-to-body
+    >
+      <div>
+        搜索标签:
+        <el-input
+          v-model="queryTagParams.name"
+          placeholder="请输入标签名称"
+          clearable
+          size="small"
+          style="width: 200px; margin-right: 10px"
+        />
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleSearchTags(queryTagParams.name)"
+          >搜索</el-button
+        >
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="cancelSearchTags"
+          >重置</el-button
+        >
+      </div>
+      <div v-for="item in tagGroupList" :key="item.id">
+        <div style="font-size: 20px; margin-top: 20px; margin-bottom: 20px">
+          <span class="name-background">{{ item.name }}</span>
+        </div>
 
+        <!-- 添加外层滚动容器 -->
+        <div class="scroll-wrapper">
+          <div class="tag-container">
+            <a
+              v-for="tagItem in item.tag"
+              class="tag-box"
+              @click="tagSelection(tagItem)"
+              :class="{ 'tag-selected': tagItem.isSelected }"
+            >
+              {{ tagItem.name }}
+            </a>
+          </div>
+        </div>
+      </div>
+      <pagination
+        v-show="tagTotal > 0"
+        :total="tagTotal"
+        :page.sync="queryTagParams.pageNum"
+        :limit.sync="queryTagParams.pageSize"
+        @pagination="getPageListTagGroup"
+      />
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="tagSubmitForm()">确 定</el-button>
+        <el-button @click="tagCancel()">取消</el-button>
+      </div>
+    </el-dialog>
     <!-- 添加或修改企业微信客户对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <div style="background-color: rgb(239, 250, 255); margin: 10px;padding: 15px;">
+        <div
+          style="
+            background-color: rgb(239, 250, 255);
+            margin: 10px;
+            padding: 15px;
+          "
+        >
           <div>可将选中的客户转接给其他员工,进行后续服务</div>
           <div>注意:90天内客户只能被转接一次,一个客户最多只能被转接两次</div>
         </div>
 
         <el-form-item label="接替员工" prop="userId">
-<!--          <el-button type="success" v-if="this.nickName">{{ nickName }}</el-button>-->
+          <!--          <el-button type="success" v-if="this.nickName">{{ nickName }}</el-button>-->
           <el-input style="width: 150px" disabled>
             <template slot="prefix">
-              <el-button
-                plain
-                size="small"
-                type="success"
-                v-if="this.nickName">
+              <el-button plain size="small" type="success" v-if="this.nickName">
                 {{ nickName }}
               </el-button>
             </template>
           </el-input>
         </el-form-item>
-		<el-form-item label="消息内容" prop="content">
-		  <el-input v-model="form.content" placeholder="请输入内容" />
-      <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
-        <i class="el-icon-info"></i>
-        自定义转接的时候发给客户的消息内容(选填)ps:不填则是官方默认话术
-      </div>
-		</el-form-item>
+        <el-form-item label="消息内容" prop="content">
+          <el-input v-model="form.content" placeholder="请输入内容" />
+          <div
+            style="
+              color: #999;
+              font-size: 14px;
+              display: flex;
+              align-items: center;
+            "
+          >
+            <i class="el-icon-info"></i>
+            自定义转接的时候发给客户的消息内容(选填)ps:不填则是官方默认话术
+          </div>
+        </el-form-item>
 
         <el-card>
-          <qwUserSelectOne ref="qwUserSelectOne" @selectUser="selectUser"></qwUserSelectOne>
+          <qwUserSelectOne
+            ref="qwUserSelectOne"
+            @selectUser="selectUser"
+          ></qwUserSelectOne>
         </el-card>
-
-
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -278,11 +482,28 @@
 </template>
 
 <script>
-import { transfer,listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact } from "@/api/qw/externalContact";
-import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
+import {
+  transfer,
+  listExternalContact,
+  getExternalContact,
+  delExternalContact,
+  addExternalContact,
+  updateExternalContact,
+  exportExternalContact,
+} from "@/api/qw/externalContact";
+import {
+  listTag,
+  getTag,
+  delTag,
+  addTag,
+  updateTag,
+  exportTag,
+  searchTags,
+} from "@/api/qw/tag";
 import { qwUserList } from "@/api/qw/user";
-import qwUserSelectOne from '@/views/qw/user/qwUserSelectOne.vue'
-import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
+import qwUserSelectOne from "@/views/qw/user/qwUserSelectOne.vue";
+import { getMyQwUserList, getMyQwCompanyList } from "@/api/qw/user";
+import { allListTagGroup } from "../../../api/qw/tagGroup";
 
 export default {
   name: "ExternalContact",
@@ -295,7 +516,7 @@ export default {
       exportLoading: false,
       // 选中数组
       ids: [],
-      myQwCompanyList:[],
+      myQwCompanyList: [],
       // 非单个禁用
       single: true,
       // 非多个禁用
@@ -314,13 +535,13 @@ export default {
       // 用户类别字典
       typeOptions: [],
       ratingType: [],
-      selectTags:[],
+      selectTags: [],
       // 性别字典
       genderOptions: [],
       // 来源字典
       addWayOptions: [],
-      nickName:null,
-      qwUserList:[],
+      nickName: null,
+      qwUserList: [],
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -330,7 +551,7 @@ export default {
         name: null,
         avatar: null,
         type: null,
-        remark:null,
+        remark: null,
         gender: null,
         description: null,
         tagIds: null,
@@ -340,72 +561,225 @@ export default {
         operUserid: null,
         corpId: null,
         companyId: null,
-        status:0,
-        transferStatus:null
+        status: 0,
+        transferStatus: null,
       },
       // 表单参数
       form: {},
-      tagList:[],
-      transferStatusOptions:[],
-      statusOptions:[],
+      tagList: [],
+      transferStatusOptions: [],
+      statusOptions: [],
       // 表单校验
       rules: {
-        userId: [{ required: true, message: '请选择接替员工', trigger: 'blur' }],
-      }
+        userId: [
+          { required: true, message: "请选择接替员工", trigger: "blur" },
+        ],
+      },
+
+      // ----标签开始----
+      changeTagDialog: {
+        title: "",
+        open: false,
+      },
+      queryTagParams: {
+        pageNum: 1,
+        pageSize: 5,
+        total: 0,
+        name: null,
+        corpId: null,
+      },
+      tagGroupList: [],
+      tagTotal: 0,
+      selectTags: [],
+      // ----标签结束----
+
+      sLastReplyTime: null,
+      eLastReplyTime: null,
+      lastReplyTime: null,
     };
   },
   created() {
-    getMyQwCompanyList().then(response => {
-            this.myQwCompanyList = response.data;
-            if(this.myQwCompanyList!=null){
-              this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
-              listTag({corpId:this.queryParams.corpId}).then(response => {
-                this.tagList = response.rows;
-              });
-              qwUserList(this.queryParams.corpId).then(response => {
-                this.qwUserList = response.rows;
-              });
-
-              this.getList();
-            }
+    getMyQwCompanyList().then((response) => {
+      this.myQwCompanyList = response.data;
+      if (this.myQwCompanyList != null) {
+        this.queryParams.corpId = this.myQwCompanyList[0].dictValue;
+        listTag({ corpId: this.queryParams.corpId }).then((response) => {
+          this.tagList = response.rows;
+        });
+        qwUserList(this.queryParams.corpId).then((response) => {
+          this.qwUserList = response.rows;
+        });
+
+        this.getList();
+      }
     });
 
-    this.getDicts("sys_qw_externalContact_type").then(response => {
+    this.getDicts("sys_qw_externalContact_type").then((response) => {
       this.typeOptions = response.data;
     });
-    this.getDicts("sys_user_sex").then(response => {
+    this.getDicts("sys_user_sex").then((response) => {
       this.genderOptions = response.data;
     });
-    this.getDicts("sys_qw_externalContact_addWay").then(response => {
+    this.getDicts("sys_qw_externalContact_addWay").then((response) => {
       this.addWayOptions = response.data;
     });
-    this.getDicts("sys_qw_sop_rating_type").then(response => {
+    this.getDicts("sys_qw_sop_rating_type").then((response) => {
       this.ratingType = response.data;
     });
 
-
-    this.getDicts("sys_qw_external_contact_status").then(response => {
+    this.getDicts("sys_qw_external_contact_status").then((response) => {
       this.statusOptions = response.data;
     });
-    this.getDicts("sys_qw_transfer_status").then(response => {
+    this.getDicts("sys_qw_transfer_status").then((response) => {
       this.transferStatusOptions = response.data;
     });
-
   },
   methods: {
-    updateCorpId(){
-      listTag({corpId:this.queryParams.corpId}).then(response => {
+    change() {
+      if (this.lastReplyTime != null) {
+        this.queryParams.sLastReplyTime = this.lastReplyTime[0];
+        this.queryParams.eLastReplyTime = this.lastReplyTime[1];
+      } else {
+        this.queryParams.sLastReplyTime = null;
+        this.queryParams.eLastReplyTime = null;
+      }
+    },
+    // ----标签开始----
+    //删除一些选择的标签
+    handleCloseTags(list) {
+      const ls = this.selectTags.findIndex((t) => t.tagId === list.tagId);
+      if (ls !== -1) {
+        this.selectTags.splice(ls, 1);
+        this.selectTags = [...this.selectTags];
+      }
+
+      if (this.selectTags != null && this.selectTags.length > 0) {
+        // 确保 this.form.tags 是数组
+        if (!this.queryParams.tagIds) {
+          this.queryParams.tagIds = []; // 如果未定义,初始化
+        } else {
+          this.queryParams.tagIds = []; // 清空已有数据
+        }
+
+        // 遍历并添加 tagId
+        this.selectTags.forEach((tag) => {
+          if (tag.tagId) {
+            // 确保 tagId 存在
+            this.queryParams.tagIds.push(tag.tagId);
+          }
+        });
+        this.queryParams.tagIds = this.queryParams.tagIds.join(",");
+      } else {
+        this.queryParams.tagIds = null;
+      }
+    },
+    //搜索的标签
+    hangleChangeTags() {
+      this.changeTagDialog.title = "搜索的标签";
+      this.changeTagDialog.open = true;
+
+      // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
+      const selectedTagIds = new Set(
+        (this.selectTags || []).map((tagItem) => tagItem?.tagId)
+      );
+
+      this.queryTagParams.name = null;
+      this.getPageListTagGroup();
+
+      setTimeout(() => {
+        for (let i = 0; i < this.tagGroupList.length; i++) {
+          for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+            this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(
+              this.tagGroupList[i].tag[x].tagId
+            );
+          }
+        }
+      }, 200);
+    },
+    //确定选择标签
+    tagSubmitForm() {
+      for (let i = 0; i < this.tagGroupList.length; i++) {
+        for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+          if (this.tagGroupList[i].tag[x].isSelected === true) {
+            if (!this.selectTags) {
+              this.selectTags = [];
+            }
+
+            // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
+            let tagExists = this.selectTags.some(
+              (tag) => tag.id === this.tagGroupList[i].tag[x].id
+            );
+
+            // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
+            if (!tagExists) {
+              this.selectTags.push(this.tagGroupList[i].tag[x]);
+            }
+          }
+        }
+      }
+      if (!this.selectTags || this.selectTags.length === 0) {
+        return this.$message("请选择标签");
+      }
+
+      this.changeTagDialog.open = false;
+    },
+
+    //取消选择标签
+    tagCancel() {
+      this.changeTagDialog.open = false;
+    },
+    tagSelection(row) {
+      row.isSelected = !row.isSelected;
+      this.$forceUpdate();
+    },
+    handleSearchTags(name) {
+      if (!name) {
+        return this.$message.error("请输入要搜索的标签");
+      }
+
+      this.queryTagParams.name = name;
+      this.queryTagParams.corpId = this.queryParams.corpId;
+
+      searchTags(this.queryTagParams).then((response) => {
+        this.tagGroupList = response.rows;
+      });
+    },
+    getPageListTagGroup() {
+      this.queryTagParams.corpId = this.queryParams.corpId;
+      allListTagGroup(this.queryTagParams).then((response) => {
+        this.tagGroupList = response.rows;
+        this.tagTotal = response.total;
+      });
+    },
+    cancelSearchTags() {
+      this.resetSearchQueryTag();
+
+      this.getPageListTagGroup();
+    },
+
+    resetSearchQueryTag() {
+      this.queryTagParams = {
+        pageNum: 1,
+        pageSize: 5,
+        total: 0,
+        name: null,
+      };
+    },
+
+    // ----标签结束----
+    updateCorpId() {
+      listTag({ corpId: this.queryParams.corpId }).then((response) => {
         this.tagList = response.rows;
       });
-      qwUserList(this.queryParams.corpId).then(response => {
+      qwUserList(this.queryParams.corpId).then((response) => {
         this.qwUserList = response.rows;
       });
       this.getList();
-     },
+    },
     /** 查询企业微信客户列表 */
     getList() {
       this.loading = true;
-      listExternalContact(this.queryParams).then(response => {
+      listExternalContact(this.queryParams).then((response) => {
         this.externalContactList = response.rows;
         this.total = response.total;
         this.loading = false;
@@ -434,51 +808,71 @@ export default {
         addWay: null,
         operUserid: null,
         corpId: null,
-        companyId: null
+        companyId: null,
       };
       this.resetForm("form");
     },
 
-    selectUser(row){
-      this.form.userId=row.id
-	  console.log(row)
-      this.nickName=row.qwUserName
+    selectUser(row) {
+      this.form.userId = row.id;
+      console.log(row);
+      this.nickName = row.qwUserName;
     },
     /** 搜索按钮操作 */
     handleQuery() {
-      this.queryParams.tagIds=this.selectTags.join(',')
+      if (this.selectTags != null && this.selectTags.length > 0) {
+        // 确保 this.form.tags 是数组
+        if (!this.queryParams.tagIds) {
+          this.queryParams.tagIds = []; // 如果未定义,初始化
+        } else {
+          this.queryParams.tagIds = []; // 清空已有数据
+        }
+
+        // 遍历并添加 tagId
+        this.selectTags.forEach((tag) => {
+          if (tag.tagId) {
+            // 确保 tagId 存在
+            this.queryParams.tagIds.push(tag.tagId);
+          }
+        });
+        this.queryParams.tagIds = this.queryParams.tagIds.join(",");
+      } else {
+        this.queryParams.tagIds = null;
+      }
       this.queryParams.pageNum = 1;
       this.getList();
     },
     /** 重置按钮操作 */
     resetQuery() {
-      this.selectTags=[];
+      this.lastReplyTime = null;
+      this.selectTags = [];
+      this.queryParams.sLastReplyTime = null;
+      this.queryParams.eLastReplyTime = null;
       this.resetForm("queryForm");
       this.handleQuery();
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.id)
-      this.single = selection.length!==1
-      this.multiple = !selection.length
+      this.ids = selection.map((item) => item.id);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
     },
     /** 新增按钮操作 */
     handleAdd() {
-     addExternalContact(this.form).then(response => {
-       this.msgSuccess("同步成功");
-       this.getList();
-     });
-
+      addExternalContact(this.form).then((response) => {
+        this.msgSuccess("同步成功");
+        this.getList();
+      });
     },
 
     handleTransfer(row) {
       this.reset();
-      if(this.ids==null||this.ids==""){
-        return  this.$message('请选择需要分配的客户');
+      if (this.ids == null || this.ids == "") {
+        return this.$message("请选择需要分配的客户");
       }
       setTimeout(() => {
-                    this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
-       }, 1);
+        this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
+      }, 1);
       this.open = true;
       this.filter = false;
       this.title = "分配客户";
@@ -486,68 +880,145 @@ export default {
 
     /** 提交按钮 */
     submitForm() {
-      this.$refs["form"].validate(valid => {
-
-
-        let obj = JSON.parse(JSON.stringify(this.queryParams))
-        if(obj.tagIds == "" && obj.tagIds.length == 0){
+      this.$refs["form"].validate((valid) => {
+        let obj = JSON.parse(JSON.stringify(this.queryParams));
+        if (obj.tagIds == "" && obj.tagIds.length == 0) {
           obj.tagIds = null;
         }
-        if(obj.tagIds !== null && obj.tagIds !== undefined){
+        if (obj.tagIds !== null && obj.tagIds !== undefined) {
           obj.tagIds = obj.tagIds.split(",");
         }
         if (valid) {
-            var form={
-              ids:this.ids,
-              addType: 0,
-              filter: this.filter,
-              param: obj,
-              userId:this.form.userId,
-              corpId:this.queryParams.corpId,
-			        content:this.form.content,
-            }
-            transfer(form).then(response => {
-              this.msgSuccess(response.msg);
-              this.open = false;
-              this.getList();
-            });
-
+          var form = {
+            ids: this.ids,
+            addType: 0,
+            filter: this.filter,
+            param: obj,
+            userId: this.form.userId,
+            corpId: this.queryParams.corpId,
+            content: this.form.content,
+          };
+          transfer(form).then((response) => {
+            this.msgSuccess(response.msg);
+            this.open = false;
+            this.getList();
+          });
         }
       });
     },
     /** 删除按钮操作 */
     handleDelete(row) {
       const ids = row.id || this.ids;
-      this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
+      this.$confirm(
+        '是否确认删除企业微信客户编号为"' + ids + '"的数据项?',
+        "警告",
+        {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
+          type: "warning",
+        }
+      )
+        .then(function () {
           return delExternalContact(ids);
-        }).then(() => {
+        })
+        .then(() => {
           this.getList();
           this.msgSuccess("删除成功");
-        }).catch(() => {});
+        })
+        .catch(() => {});
     },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;
-      this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
+      this.$confirm("是否确认导出所有企业微信客户数据项?", "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
           this.exportLoading = true;
           return exportExternalContact(queryParams);
-        }).then(response => {
+        })
+        .then((response) => {
           this.download(response.msg);
           this.exportLoading = false;
-        }).catch(() => {});
-    }
-  }
+        })
+        .catch(() => {});
+    },
+  },
 };
 </script>
-<style  scoped>
+<style scoped>
+/* CSS 样式 */
+.tag-container {
+  display: flex;
+  flex-wrap: wrap;
+  /* 超出宽度时自动换行 */
+  gap: 8px;
+  /* 设置标签之间的间距 */
+}
+
+.name-background {
+  display: inline-block;
+  background-color: #abece6;
+  /* 背景颜色 */
+  padding: 4px 8px;
+  /* 调整内边距,让背景包裹文字 */
+  border-radius: 4px;
+  /* 可选:设置圆角 */
+}
+
+.tag-box {
+  padding: 8px 12px;
+  border: 1px solid #989797;
+  border-radius: 4px;
+  cursor: pointer;
+  display: inline-block;
+}
+
+.tag-selected {
+  background-color: #00bc98;
+  color: #fff;
+  border-color: #00bc98;
+}
+
+.el-tag + .el-tag {
+  margin-left: 10px;
+}
+
+.button-new-tag {
+  margin-left: 10px;
+  height: 32px;
+  line-height: 30px;
+  padding-top: 0;
+  padding-bottom: 0;
+}
+
+.input-new-tag {
+  width: 90px;
+  margin-left: 10px;
+  vertical-align: bottom;
+}
+
+/* 新增的滚动容器样式(不影响原有样式) */
+.scroll-wrapper {
+  max-height: 130px;
+  /* 大约三行的高度 */
+  overflow-y: auto;
+  /* 垂直滚动 */
+  padding-right: 5px;
+  /* 为滚动条留出空间 */
+}
+
+/* 美化滚动条(可选) */
+.scroll-wrapper::-webkit-scrollbar {
+  width: 6px;
+}
+
+.scroll-wrapper::-webkit-scrollbar-thumb {
+  background: rgba(0, 0, 0, 0.2);
+  border-radius: 3px;
+}
 .tag-container {
   max-height: 300px;
   overflow-y: auto;

+ 628 - 178
src/views/qw/externalContactUnassigned/index.vue

@@ -1,29 +1,49 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px">
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      :inline="true"
+      v-show="showSearch"
+      label-width="110px"
+    >
       <el-form-item label="企微公司" prop="corpId">
-                      <el-select v-model="queryParams.corpId" placeholder="企微公司"  size="small" @change="updateCorpId()">
-                        <el-option
-                          v-for="dict in myQwCompanyList"
-                          :key="dict.dictValue"
-                          :label="dict.dictLabel"
-                          :value="dict.dictValue"
-                        />
-                      </el-select>
+        <el-select
+          v-model="queryParams.corpId"
+          placeholder="企微公司"
+          size="small"
+          @change="updateCorpId()"
+        >
+          <el-option
+            v-for="dict in myQwCompanyList"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </el-select>
       </el-form-item>
 
       <el-form-item label="原所属员工" prop="qwUserName">
-              <el-select @change="handleSelectChange" v-model="queryParams.qwUserName" remote filterable clearable reserve-keyword
-                         placeholder="请输入原所属员工名称" :remote-method="qwUserMethod">
-                <el-option
-                  v-for="item in qwUserNameList"
-                  :key="item.id"
-                  :label="item.qwUserName"
-                  :value="item.qwUserName">
-                  <span style="float: left">{{ item.qwUserName }}</span>
-                </el-option>
-              </el-select>
-            </el-form-item>
+        <el-select
+          @change="handleSelectChange"
+          v-model="queryParams.qwUserName"
+          remote
+          filterable
+          clearable
+          reserve-keyword
+          placeholder="请输入原所属员工名称"
+          :remote-method="qwUserMethod"
+        >
+          <el-option
+            v-for="item in qwUserNameList"
+            :key="item.id"
+            :label="item.qwUserName"
+            :value="item.qwUserName"
+          >
+            <span style="float: left">{{ item.qwUserName }}</span>
+          </el-option>
+        </el-select>
+      </el-form-item>
 
       <el-form-item label="客户名称" prop="name">
         <el-input
@@ -36,7 +56,12 @@
       </el-form-item>
 
       <el-form-item label="用户类别" prop="type">
-        <el-select v-model="queryParams.type" placeholder="请选择用户类别" clearable size="small">
+        <el-select
+          v-model="queryParams.type"
+          placeholder="请选择用户类别"
+          clearable
+          size="small"
+        >
           <el-option
             v-for="dict in typeOptions"
             :key="dict.dictValue"
@@ -55,7 +80,12 @@
         />
       </el-form-item>
       <el-form-item label="转接状态" prop="addWay">
-        <el-select v-model="queryParams.transferStatus" placeholder="转接状态" clearable size="small">
+        <el-select
+          v-model="queryParams.transferStatus"
+          placeholder="转接状态"
+          clearable
+          size="small"
+        >
           <el-option
             v-for="dict in transferStatusOptions"
             :key="dict.dictValue"
@@ -64,9 +94,32 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item label="标签" prop="tagIds">
+        <div @click="hangleChangeTags()"
+          style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 250px">
+          <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
+            <el-tag type="success" closable :disable-transitions="false" v-for="list in this.selectTags"
+              :key="list.tagId" @close="handleCloseTags(list)" style="margin: 3px;">{{ list.name }}
+            </el-tag>
+          </div>
+        </div>
+      </el-form-item>
+      <el-form-item label="回复时间" prop="lastReplyTime">
+        <el-date-picker v-model="lastReplyTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"
+          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
+          @change="change"></el-date-picker>
+      </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
+          >重置</el-button
+        >
       </el-form-item>
     </el-form>
 
@@ -78,7 +131,8 @@
           size="mini"
           @click="handleAdd"
           v-hasPermi="['qw:externalContact:add']"
-        >同步</el-button>
+          >同步</el-button
+        >
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -89,7 +143,8 @@
           :loading="exportLoading"
           @click="handleExport"
           v-hasPermi="['qw:externalContact:export']"
-        >导出</el-button>
+          >导出</el-button
+        >
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -98,80 +153,134 @@
           size="mini"
           @click="handleTransfer"
           v-hasPermi="['qw:externalContact:transfer']"
-        >分配客户</el-button>
+          >分配客户</el-button
+        >
       </el-col>
-       <el-col :span="1.5">
-        <el-button v-if="isQwUserISNull"
+      <el-col :span="1.5">
+        <el-button
+          v-if="isQwUserISNull"
           type="primary"
           plain
           size="mini"
           @click="handleTransferAll"
           v-hasPermi="['qw:externalContact:transfer']"
-        >分配此员工所有客户</el-button>
+          >分配此员工所有客户</el-button
+        >
       </el-col>
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList"
+      ></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
+    <el-table
+      v-loading="loading"
+      :data="externalContactList"
+      @selection-change="handleSelectionChange"
+      border
+    >
       <el-table-column type="selection" width="55" align="center" />
 
-      <el-table-column label="原所属员工" align="center" prop="qwUserName" width="120px"/>
-      <el-table-column label="原员工部门" align="center" prop="departmentName" width="120px"/>
-      <el-table-column label="外部联系人账号" align="center" prop="externalUserId" width="120px"/>
+      <el-table-column
+        label="原所属员工"
+        align="center"
+        prop="qwUserName"
+        width="120px"
+      />
+      <el-table-column
+        label="原员工部门"
+        align="center"
+        prop="departmentName"
+        width="120px"
+      />
+      <el-table-column
+        label="外部联系人账号"
+        align="center"
+        prop="externalUserId"
+        width="120px"
+      />
       <el-table-column label="客户名称" align="center" prop="name" />
       <el-table-column label="头像" align="center" prop="avatar" width="120px">
         <template slot-scope="scope">
-          <el-popover
-            placement="right"
-            title=""
-            trigger="hover">
-            <img slot="reference" :src="scope.row.avatar" width="100px">
-            <img :src="scope.row.avatar" style="max-width: 150px;">
+          <el-popover placement="right" title="" trigger="hover">
+            <img slot="reference" :src="scope.row.avatar" width="100px" />
+            <img :src="scope.row.avatar" style="max-width: 150px" />
           </el-popover>
         </template>
       </el-table-column>
       <el-table-column label="用户类别" align="center" prop="type">
         <template slot-scope="scope">
-          <dict-tag :options="typeOptions" :value="scope.row.type"/>
+          <dict-tag :options="typeOptions" :value="scope.row.type" />
         </template>
       </el-table-column>
       <el-table-column label="性别" align="center" prop="gender">
         <template slot-scope="scope">
-          <dict-tag :options="genderOptions" :value="scope.row.gender"/>
+          <dict-tag :options="genderOptions" :value="scope.row.gender" />
         </template>
       </el-table-column>
       <el-table-column label="备注" align="center" prop="remark" />
+      <el-table-column label="回复时间" align="center" prop="lastReplyTime" />
       <el-table-column label="描述信息" align="center" prop="description" />
       <el-table-column label="标签" align="center" prop="tagIds" width="150px">
         <template slot-scope="scope">
           <div class="tag-container">
             <div class="tag-list">
-              <div v-for="i in JSON.parse(scope.row.tagIds)" :key="i" style="display: inline;">
-                <el-tag type="success" v-for="ii in tagList" :key="ii.id" style="margin: 3px;" v-if="ii.tagId==i">{{ii.name}}</el-tag>
+              <div
+                v-for="i in JSON.parse(scope.row.tagIds)"
+                :key="i"
+                style="display: inline"
+              >
+                <el-tag
+                  type="success"
+                  v-for="ii in tagList"
+                  :key="ii.id"
+                  style="margin: 3px"
+                  v-if="ii.tagId == i"
+                  >{{ ii.name }}</el-tag
+                >
               </div>
             </div>
           </div>
         </template>
       </el-table-column>
-      <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
+      <el-table-column
+        label="备注电话号码"
+        align="center"
+        prop="remarkMobiles"
+        width="150px"
+      >
         <template slot-scope="scope">
-          <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</span>
+          <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{
+            i
+          }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
+      <el-table-column
+        label="备注企业名称"
+        align="center"
+        prop="remarkCorpName"
+      />
       <el-table-column label="来源" align="center" prop="addWay" width="100px">
         <template slot-scope="scope">
-          <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
+          <dict-tag :options="addWayOptions" :value="scope.row.addWay" />
         </template>
       </el-table-column>
       <el-table-column label="状态" align="center" prop="status" width="100px">
         <template slot-scope="scope">
-          <dict-tag :options="statusOptions" :value="scope.row.status"/>
+          <dict-tag :options="statusOptions" :value="scope.row.status" />
         </template>
       </el-table-column>
-      <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px">
+      <el-table-column
+        label="转接状态"
+        align="center"
+        prop="transferStatus"
+        width="100px"
+      >
         <template slot-scope="scope">
-          <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
+          <dict-tag
+            :options="transferStatusOptions"
+            :value="scope.row.transferStatus"
+          />
         </template>
       </el-table-column>
       <el-table-column label="企业id" align="center" prop="corpId" />
@@ -191,41 +300,111 @@
     </el-table>
 
     <pagination
-      v-show="total>0"
+      v-show="total > 0"
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
       :page-sizes="[100, 200, 300, 500]"
       @pagination="getList"
     />
+    <!--  搜索标签   -->
+    <el-dialog
+      :title="changeTagDialog.title"
+      :visible.sync="changeTagDialog.open"
+      style="width: 100%; height: 100%"
+      append-to-body
+    >
+      <div>
+        搜索标签:
+        <el-input
+          v-model="queryTagParams.name"
+          placeholder="请输入标签名称"
+          clearable
+          size="small"
+          style="width: 200px; margin-right: 10px"
+        />
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleSearchTags(queryTagParams.name)"
+          >搜索</el-button
+        >
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="cancelSearchTags"
+          >重置</el-button
+        >
+      </div>
+      <div v-for="item in tagGroupList" :key="item.id">
+        <div style="font-size: 20px; margin-top: 20px; margin-bottom: 20px">
+          <span class="name-background">{{ item.name }}</span>
+        </div>
 
+        <!-- 添加外层滚动容器 -->
+        <div class="scroll-wrapper">
+          <div class="tag-container">
+            <a
+              v-for="tagItem in item.tag"
+              class="tag-box"
+              @click="tagSelection(tagItem)"
+              :class="{ 'tag-selected': tagItem.isSelected }"
+            >
+              {{ tagItem.name }}
+            </a>
+          </div>
+        </div>
+      </div>
+      <pagination
+        v-show="tagTotal > 0"
+        :total="tagTotal"
+        :page.sync="queryTagParams.pageNum"
+        :limit.sync="queryTagParams.pageSize"
+        @pagination="getPageListTagGroup"
+      />
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="tagSubmitForm()">确 定</el-button>
+        <el-button @click="tagCancel()">取消</el-button>
+      </div>
+    </el-dialog>
     <!-- 添加或修改企业微信客户对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="800px"  append-to-body>
-      <el-form ref="form" :model="form" :rules="rules" label-width="100px" style="height: 100%">
-        <div style="background-color: rgb(239, 250, 255); margin: 10px;padding: 15px;">
-          <div>原跟进成员离职时间不能超过1年且离职前一年内至少登录过一次企业微信</div>
+    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
+      <el-form
+        ref="form"
+        :model="form"
+        :rules="rules"
+        label-width="100px"
+        style="height: 100%"
+      >
+        <div
+          style="
+            background-color: rgb(239, 250, 255);
+            margin: 10px;
+            padding: 15px;
+          "
+        >
+          <div>
+            原跟进成员离职时间不能超过1年且离职前一年内至少登录过一次企业微信
+          </div>
           <div>接替成员最近一年内至少登陆过一次企业微信。</div>
         </div>
         <el-form-item label="接替员工:" prop="userId">
-
           <el-input style="width: 150px" disabled>
             <template slot="prefix">
-              <el-button
-                plain
-                size="small"
-                type="success"
-                v-if="this.nickName">
+              <el-button plain size="small" type="success" v-if="this.nickName">
                 {{ nickName }}
               </el-button>
             </template>
           </el-input>
-
-
         </el-form-item>
         <el-card>
-        <qwUserSelectOne ref="qwUserSelectOne" @selectUser="selectUser"></qwUserSelectOne>
+          <qwUserSelectOne
+            ref="qwUserSelectOne"
+            @selectUser="selectUser"
+          ></qwUserSelectOne>
         </el-card>
-
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -236,15 +415,33 @@
 </template>
 
 <script>
-import { addUnassigned,resignedTransfer,listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact } from "@/api/qw/externalContact";
-import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
-import { qwUserList,userList } from "@/api/qw/user";
+import {
+  addUnassigned,
+  resignedTransfer,
+  listExternalContact,
+  getExternalContact,
+  delExternalContact,
+  addExternalContact,
+  updateExternalContact,
+  exportExternalContact,
+} from "@/api/qw/externalContact";
+import {
+  listTag,
+  getTag,
+  delTag,
+  addTag,
+  updateTag,
+  exportTag,
+  searchTags,
+} from "@/api/qw/tag";
+import { qwUserList, userList } from "@/api/qw/user";
 import qwUserSelectOne from "@/views/qw/user/qwUserSelectOne.vue";
-import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
+import { getMyQwUserList, getMyQwCompanyList } from "@/api/qw/user";
+import { allListTagGroup } from "../../../api/qw/tagGroup";
 
 export default {
   name: "ExternalContact",
-  components:{qwUserSelectOne},
+  components: { qwUserSelectOne },
   data() {
     return {
       // 遮罩层
@@ -269,17 +466,17 @@ export default {
       open: false,
       // 用户类别字典
       typeOptions: [],
-      myQwCompanyList:[],
+      myQwCompanyList: [],
       genderOptions: [],
       // 来源字典
       addWayOptions: [],
-      qwUserList:[],
-      isQwUserISNull:false,
-      qwUserName:null,
-      type:'0',
-       qwUserNameList:[],
-      qwUserNameParam:{
-        qwUserName:null
+      qwUserList: [],
+      isQwUserISNull: false,
+      qwUserName: null,
+      type: "0",
+      qwUserNameList: [],
+      qwUserNameParam: {
+        qwUserName: null,
       },
       // 查询参数
       queryParams: {
@@ -300,82 +497,238 @@ export default {
         operUserid: null,
         corpId: null,
         companyId: null,
-        status:1,
-        transferStatus:null
+        status: 1,
+        transferStatus: null,
       },
-      nickName:null,
+      nickName: null,
       // 表单参数
-      form: {
-      },
-      tagList:[],
-      transferStatusOptions:[],
-      statusOptions:[],
+      form: {},
+      tagList: [],
+      transferStatusOptions: [],
+      statusOptions: [],
       // 表单校验
       rules: {
-        userId:[   { required: true, message: "接替员工不能为空", trigger: "blur" }]
+        userId: [
+          { required: true, message: "接替员工不能为空", trigger: "blur" },
+        ],
+      },
 
-      }
+      // ----标签开始----
+      changeTagDialog: {
+        title: "",
+        open: false,
+      },
+      queryTagParams: {
+        pageNum: 1,
+        pageSize: 5,
+        total: 0,
+        name: null,
+        corpId: null,
+      },
+      tagGroupList: [],
+      tagTotal: 0,
+      selectTags: [],
+      // ----标签结束----
+
+      sLastReplyTime: null,
+      eLastReplyTime: null,
+      lastReplyTime: null,
     };
   },
   created() {
-    getMyQwCompanyList().then(response => {
-            this.myQwCompanyList = response.data;
-            if(this.myQwCompanyList!=null){
-              this.queryParams.corpId=this.myQwCompanyList[0].dictValue
-              listTag({corpId:this.queryParams.corpId}).then(response => {
-                this.tagList = response.rows;
-              });
-              this.getList();
-            }
+    getMyQwCompanyList().then((response) => {
+      this.myQwCompanyList = response.data;
+      if (this.myQwCompanyList != null) {
+        this.queryParams.corpId = this.myQwCompanyList[0].dictValue;
+        listTag({ corpId: this.queryParams.corpId }).then((response) => {
+          this.tagList = response.rows;
+        });
+        this.getList();
+      }
     });
-    this.getDicts("sys_qw_externalContact_type").then(response => {
+    this.getDicts("sys_qw_externalContact_type").then((response) => {
       this.typeOptions = response.data;
     });
-    this.getDicts("sys_sex").then(response => {
+    this.getDicts("sys_sex").then((response) => {
       this.genderOptions = response.data;
     });
-    this.getDicts("sys_qw_externalContact_addWay").then(response => {
+    this.getDicts("sys_qw_externalContact_addWay").then((response) => {
       this.addWayOptions = response.data;
     });
 
-    this.getDicts("sys_qw_external_contact_status").then(response => {
+    this.getDicts("sys_qw_external_contact_status").then((response) => {
       this.statusOptions = response.data;
     });
-    this.getDicts("sys_qw_transfer_status").then(response => {
+    this.getDicts("sys_qw_transfer_status").then((response) => {
       this.transferStatusOptions = response.data;
     });
     // qwUserList().then(response => {
     //   this.qwUserList = response.rows;
     // });
-
   },
   methods: {
-     qwUserMethod(query) {
-      if (query !== '') {
+    change() {
+      if (this.lastReplyTime != null) {
+        this.queryParams.sLastReplyTime = this.lastReplyTime[0];
+        this.queryParams.eLastReplyTime = this.lastReplyTime[1];
+      } else {
+        this.queryParams.sLastReplyTime = null;
+        this.queryParams.eLastReplyTime = null;
+      }
+
+    },
+    // ----标签开始----
+        //删除一些选择的标签
+    handleCloseTags(list) {
+      const ls = this.selectTags.findIndex(t => t.tagId === list.tagId);
+      if (ls !== -1) {
+        this.selectTags.splice(ls, 1);
+        this.selectTags = [...this.selectTags];
+      }
+
+      if (this.selectTags != null && this.selectTags.length > 0) {
+        // 确保 this.form.tags 是数组
+        if (!this.queryParams.tagIds) {
+          this.queryParams.tagIds = []; // 如果未定义,初始化
+        } else {
+          this.queryParams.tagIds = []; // 清空已有数据
+        }
+
+        // 遍历并添加 tagId
+        this.selectTags.forEach(tag => {
+          if (tag.tagId) { // 确保 tagId 存在
+            this.queryParams.tagIds.push(tag.tagId);
+          }
+        });
+        this.queryParams.tagIds = this.queryParams.tagIds.join(",");
+      } else {
+        this.queryParams.tagIds = null;
+      }
+
+    },
+    //搜索的标签
+    hangleChangeTags() {
+
+      this.changeTagDialog.title = "搜索的标签"
+      this.changeTagDialog.open = true;
+
+      // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
+      const selectedTagIds = new Set(
+        (this.selectTags || []).map(tagItem => tagItem?.tagId)
+      );
+
+      this.queryTagParams.name = null;
+      this.getPageListTagGroup();
+
+      setTimeout(() => {
+        for (let i = 0; i < this.tagGroupList.length; i++) {
+          for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+            this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(this.tagGroupList[i].tag[x].tagId);
+          }
+        }
+      }, 200);
+    },
+    //确定选择标签
+    tagSubmitForm() {
+
+      for (let i = 0; i < this.tagGroupList.length; i++) {
+        for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+          if (this.tagGroupList[i].tag[x].isSelected === true) {
+
+            if (!this.selectTags) {
+              this.selectTags = [];
+            }
+
+            // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
+            let tagExists = this.selectTags.some(
+              tag => tag.id === this.tagGroupList[i].tag[x].id
+            );
+
+            // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
+            if (!tagExists) {
+              this.selectTags.push(this.tagGroupList[i].tag[x]);
+            }
+          }
+        }
+      }
+      if (!this.selectTags || this.selectTags.length === 0) {
+        return this.$message('请选择标签');
+      }
+
+      this.changeTagDialog.open = false;
+    },
+
+    //取消选择标签
+    tagCancel() {
+      this.changeTagDialog.open = false;
+    },
+    tagSelection(row) {
+
+      row.isSelected = !row.isSelected;
+      this.$forceUpdate();
+    },
+    handleSearchTags(name) {
+
+      if (!name) {
+        return this.$message.error("请输入要搜索的标签")
+      }
+
+      this.queryTagParams.name = name;
+      this.queryTagParams.corpId = this.queryParams.corpId;
+
+      searchTags(this.queryTagParams).then(response => {
+        this.tagGroupList = response.rows;
+      });
+    },
+    getPageListTagGroup() {
+      this.queryTagParams.corpId = this.queryParams.corpId
+      allListTagGroup(this.queryTagParams).then(response => {
+        this.tagGroupList = response.rows;
+        this.tagTotal = response.total;
+      });
+    },
+    cancelSearchTags() {
+      this.resetSearchQueryTag();
+
+      this.getPageListTagGroup();
+    },
+
+    resetSearchQueryTag() {
+      this.queryTagParams = {
+        pageNum: 1,
+        pageSize: 5,
+        total: 0,
+        name: null,
+      };
+    },
+
+    // ----标签结束----
+    qwUserMethod(query) {
+      if (query !== "") {
         this.qwUserNameParam.qwUserName = query;
-        userList(this.qwUserNameParam).then(response => {
+        userList(this.qwUserNameParam).then((response) => {
           this.qwUserNameList = response.rows;
         });
       }
     },
-     handleSelectChange(value) {
-    console.log('选中的值:', value);
-    if(value == ''){
-      this.qwUserNameList=null
-    this.isQwUserISNull = false;
-    }else{
-    this.isQwUserISNull = true;
-    }
-  },
-    updateCorpId(){
-      listTag({corpId:this.queryParams.corpId}).then(response => {
+    handleSelectChange(value) {
+      console.log("选中的值:", value);
+      if (value == "") {
+        this.qwUserNameList = null;
+        this.isQwUserISNull = false;
+      } else {
+        this.isQwUserISNull = true;
+      }
+    },
+    updateCorpId() {
+      listTag({ corpId: this.queryParams.corpId }).then((response) => {
         this.tagList = response.rows;
       });
       this.getList();
     },
     getList() {
       this.loading = true;
-      listExternalContact(this.queryParams).then(response => {
+      listExternalContact(this.queryParams).then((response) => {
         this.externalContactList = response.rows;
         this.total = response.total;
         this.loading = false;
@@ -404,127 +757,224 @@ export default {
         addWay: null,
         operUserid: null,
         corpId: null,
-        companyId: null
+        companyId: null,
       };
       this.resetForm("form");
     },
 
-    selectUser(row){
-      this.form.userId=row.id
+    selectUser(row) {
+      this.form.userId = row.id;
       // console.log("row",row)
-      this.nickName=row.nickName
+      this.nickName = row.nickName;
     },
     /** 搜索按钮操作 */
     handleQuery() {
+      if (this.selectTags != null && this.selectTags.length > 0) {
+        // 确保 this.form.tags 是数组
+        if (!this.queryParams.tagIds) {
+          this.queryParams.tagIds = []; // 如果未定义,初始化
+        } else {
+          this.queryParams.tagIds = []; // 清空已有数据
+        }
+
+        // 遍历并添加 tagId
+        this.selectTags.forEach(tag => {
+          if (tag.tagId) { // 确保 tagId 存在
+            this.queryParams.tagIds.push(tag.tagId);
+          }
+        });
+        this.queryParams.tagIds = this.queryParams.tagIds.join(",");
+      } else {
+        this.queryParams.tagIds = null;
+      }
       this.queryParams.pageNum = 1;
       this.getList();
     },
     /** 重置按钮操作 */
     resetQuery() {
-      this.qwUserNameList=null
-       this.isQwUserISNull = false;
+      this.qwUserNameList = null;
+      this.isQwUserISNull = false;
+      this.lastReplyTime = null;
+      this.selectTags = [];
+      this.queryParams.sLastReplyTime = null;
+      this.queryParams.eLastReplyTime = null;
       this.resetForm("queryForm");
-      this.queryParams.corpId= this.myQwCompanyList[0].dictValue
+      this.queryParams.corpId = this.myQwCompanyList[0].dictValue;
       this.handleQuery();
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.id)
-      this.single = selection.length!==1
-      this.multiple = !selection.length
+      this.ids = selection.map((item) => item.id);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
     },
     /** 新增按钮操作 */
     handleAdd() {
-      this.form.corpId=this.queryParams.corpId;
-     addUnassigned(this.form).then(response => {
-       this.msgSuccess("同步成功");
-       this.getList();
-     });
-
+      this.form.corpId = this.queryParams.corpId;
+      addUnassigned(this.form).then((response) => {
+        this.msgSuccess("同步成功");
+        this.getList();
+      });
     },
 
     handleTransfer(row) {
       this.reset();
-      this.type = '0'
-      if(this.ids==null||this.ids==""){
-        return  this.$message('请选择需要分配的客户');
+      this.type = "0";
+      if (this.ids == null || this.ids == "") {
+        return this.$message("请选择需要分配的客户");
       }
       setTimeout(() => {
-              this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
+        this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
       }, 1);
       this.open = true;
       this.title = "分配客户";
-
     },
 
-
-     handleTransferAll(row) {
+    handleTransferAll(row) {
       this.reset();
-     this.qwUserName=this.queryParams.qwUserName;
-       this.type="1";
+      this.qwUserName = this.queryParams.qwUserName;
+      this.type = "1";
       setTimeout(() => {
-                    this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
-       }, 1);
+        this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
+      }, 1);
       this.open = true;
       this.title = "分配该员工所有客户";
-
     },
     /** 提交按钮 */
     submitForm() {
-      this.nickName=null;
-      this.$refs["form"].validate(valid => {
+      this.nickName = null;
+      this.$refs["form"].validate((valid) => {
         if (valid) {
-            var form={
-              qwUserName:this.qwUserName,
-              type:this.type,
-              ids:this.ids,
-              userId:this.form.userId,
-              corpId:this.queryParams.corpId,
-            }
-            resignedTransfer(form).then(response => {
-              this.msgSuccess(response.msg);
-              this.open = false;
-              this.getList();
-            });
-
+          var form = {
+            qwUserName: this.qwUserName,
+            type: this.type,
+            ids: this.ids,
+            userId: this.form.userId,
+            corpId: this.queryParams.corpId,
+          };
+          resignedTransfer(form).then((response) => {
+            this.msgSuccess(response.msg);
+            this.open = false;
+            this.getList();
+          });
         }
       });
-      this.qwUserName=null;
+      this.qwUserName = null;
     },
     /** 删除按钮操作 */
     handleDelete(row) {
       const ids = row.id || this.ids;
-      this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
+      this.$confirm(
+        '是否确认删除企业微信客户编号为"' + ids + '"的数据项?',
+        "警告",
+        {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
+          type: "warning",
+        }
+      )
+        .then(function () {
           return delExternalContact(ids);
-        }).then(() => {
+        })
+        .then(() => {
           this.getList();
           this.msgSuccess("删除成功");
-        }).catch(() => {});
+        })
+        .catch(() => {});
     },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;
-      this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
+      this.$confirm("是否确认导出所有企业微信客户数据项?", "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
           this.exportLoading = true;
           return exportExternalContact(queryParams);
-        }).then(response => {
+        })
+        .then((response) => {
           this.download(response.msg);
           this.exportLoading = false;
-        }).catch(() => {});
-    }
-  }
+        })
+        .catch(() => {});
+    },
+  },
 };
 </script>
 <style scoped>
+/* CSS 样式 */
+.tag-container {
+  display: flex;
+  flex-wrap: wrap;
+  /* 超出宽度时自动换行 */
+  gap: 8px;
+  /* 设置标签之间的间距 */
+}
 
+.name-background {
+  display: inline-block;
+  background-color: #abece6;
+  /* 背景颜色 */
+  padding: 4px 8px;
+  /* 调整内边距,让背景包裹文字 */
+  border-radius: 4px;
+  /* 可选:设置圆角 */
+}
+
+.tag-box {
+  padding: 8px 12px;
+  border: 1px solid #989797;
+  border-radius: 4px;
+  cursor: pointer;
+  display: inline-block;
+}
+
+.tag-selected {
+  background-color: #00bc98;
+  color: #fff;
+  border-color: #00bc98;
+}
+
+.el-tag+.el-tag {
+  margin-left: 10px;
+}
+
+
+.button-new-tag {
+  margin-left: 10px;
+  height: 32px;
+  line-height: 30px;
+  padding-top: 0;
+  padding-bottom: 0;
+}
+
+.input-new-tag {
+  width: 90px;
+  margin-left: 10px;
+  vertical-align: bottom;
+}
+
+/* 新增的滚动容器样式(不影响原有样式) */
+.scroll-wrapper {
+  max-height: 130px;
+  /* 大约三行的高度 */
+  overflow-y: auto;
+  /* 垂直滚动 */
+  padding-right: 5px;
+  /* 为滚动条留出空间 */
+}
+
+/* 美化滚动条(可选) */
+.scroll-wrapper::-webkit-scrollbar {
+  width: 6px;
+}
+
+.scroll-wrapper::-webkit-scrollbar-thumb {
+  background: rgba(0, 0, 0, 0.2);
+  border-radius: 3px;
+}
 .tag-container {
   max-height: 120px;
   overflow-y: auto;