<template>
  <div>
    <div class="app-container">
      <el-alert
        title="注意事项"
        type="warning"
        description="1、因企业微信接口限制，提醒成员完成群发任务，24小时内每个群发最多触发三次提醒,多点无效噢。2、客户每个月最多接收来自同一企业的管理员的30条群发消息，每位客户每日可收到1次群发内容"
        :closable="false"
        show-icon>
      </el-alert>
    </div>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
        <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-form-item>
        <el-form-item label="消息文本" prop="textContent">
          <el-input
            v-model="queryParams.textContent"
            placeholder="请输入想查询的消息文本内容"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </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" size="mini" @click="handleAdd()">新建群发</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="groupMsgList" @selection-change="handleSelectionChange" border>
        <el-table-column label="消息文本内容" align="left" prop="textContent" width="350px">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" :content="scope.row.textContent" placement="top">
              <div style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis;">
                <span>{{ scope.row.textContent }}</span>
              </div>
            </el-tooltip>
          </template>
        </el-table-column>

        <el-table-column label="群发任务的类型" align="center" prop="chatType">
          <template slot-scope="scope">
            <span v-for="it in groupMsgChatType" v-if="it.dictValue==scope.row.chatType">{{it.dictLabel}}</span>
          </template>
        </el-table-column>

        <el-table-column label="发送类型" align="center" prop="isTimerSend">
          <template slot-scope="scope">
            <span v-for="it in groupMsgTimerType" v-if="it.dictValue==scope.row.isTimerSend">{{it.dictLabel}}</span>
          </template>
        </el-table-column>

        <el-table-column label="消息类型" align="center" prop="msgType" >
          <template slot-scope="scope">
            <span   v-for="(item, index) in msgTypeOptions"    v-if="scope.row.msgType==item.dictValue">{{item.dictLabel}}</span>
          </template>
        </el-table-column>

        <el-table-column label="发送时间" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.isTimerSend==2">{{scope.row.createTime}}</span>
            <span v-else>{{ scope.row.timerSend }}</span>
          </template>
        </el-table-column>


        <el-table-column label="发送状态" align="center"  width="110px">
          <template slot-scope="scope">
            <el-tag
              v-if="scope.row.isSend==1"
              type="success"
              size="mini"
              plain>
              发送成功
            </el-tag >
            <el-tag
              v-else-if="scope.row.isSend==0"
              type="danger"
              size="mini"
              plain>
              发送失败
            </el-tag >
            <el-tag
              v-else-if="scope.row.isSend==2"
              type="primary"
              size="mini"
              plain>
              发送成功待录入详细信息
            </el-tag >
            <el-tag
              v-else-if="scope.row.isSend==3"
              type="warning"
              size="mini"
              plain>
              待发送
            </el-tag >
          </template>
        </el-table-column>
        <el-table-column label="已发送成员数" align="center" prop="fromUserCount" />
        <el-table-column label="送达客户数" align="center" prop="toUserCount" />
        <el-table-column label="未发送成员数" align="center" prop="fromUserNum" />
        <el-table-column label="未送达客户数" align="center" prop="toUserNum" />
        <el-table-column label="创建人" align="center" prop="createName" width="120px" />
        <el-table-column label="创建时间" align="center" prop="createTime" width="160px"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-message-solid"
              @click="triggerRemindGroupMsg(scope.row)"
            >提醒成员群发</el-button>

            <el-button
              size="mini"
              type="text"
              icon="el-icon-notebook-2"
              @click="hangdleDitels(scope.row)"
              v-hasPermi="['qw:groupMsg:query']"
            >详情</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['qw:groupMsg:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 添加客户群发记录主对话框 -->
      <el-dialog v-loading="loading" :title="title" :visible.sync="open" width="1500px" @close="closeData" style="font-weight: bold;font-size: 20px" append-to-body>

        <div style="display: flex;flex-wrap: wrap">
          <div style="width: 1000px;">
            <el-form ref="form" :model="form" :rules="rules" label-width="160px" size="medium" style="font-size: 20px" >
              <div>
                <span style="font-size: 20px">基础信息</span>
                <el-divider></el-divider>
              </div>

              <el-form-item label="选择群发成员账号:" prop="userIdsSelectList" style="font-size: 30px">
                <div>
                  <div>
                    <el-button
                      size="medium"
                      icon="el-icon-circle-plus-outline"
                      plain
                      @click="handlelistUser">请选择群发账号</el-button>
                  </div>
                  <div>
                    <el-tag
                      style="margin-left: 5px"
                      size="medium"
                      :key="list.id"
                      v-for="list in userSelectList"
                      closable
                      :disable-transitions="false"
                      @close="handleClosegroupUser(list)">
                      {{list.qwUserName}}({{list.nickName}})
                    </el-tag>
<!--                    <span v-for="item in userSelectList" class="user-box">{{item.nickName}}</span>-->
                  </div>
                </div>

                <el-alert
                  title="系统会推送任务给最后跟客户进行聊天互动的企业成员"
                  type="warning"
                  style="font-size: 15px;margin-top: 2%"
                  :closable="false"
                  show-icon>
                </el-alert>
              </el-form-item>
              <el-form-item label="选择客户：">
                <el-radio-group v-model="form.selectType" @input="clearExpectCountCustomer" size="medium ">
                  <el-radio :label="item.dictValue" v-for="item in groupMsgTypeOptions"  >{{item.dictLabel}}</el-radio>
                </el-radio-group>
                <div style="background-color:#ecf8fe;width: 100%;margin-top: 1%" v-if="form.selectType==1">
                  <span style="padding: 3%;font-size: 15px" >查看该消息预计送达人数:</span>
                  <el-link style="color: #1aa4ff;" v-if="this.expectCountCustomer==null" @click="viewReceiveNum">点我查看
                  </el-link>
                  <span style="color: #d440ec;margin-left: 2%" v-if="this.expectCountCustomer!=null">{{this.expectCountCustomer}} 人</span>
                </div>
                <div v-if="form.selectType==2" style="padding-top: 1%;background-color: #fbfbfb">
                  <el-form-item label="按性别筛选客户:" class="elFormItemClass">
                    <el-radio-group v-model="form.gender"  @input="clearExpectCountCustomer">
                      <el-radio v-for="item in sysUserSex" :label="item.dictValue">{{item.dictLabel}}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="按所在群聊筛选:" class="elFormItemClass">
                    <div>
                      <div>
                        <el-button
                          icon="el-icon-s-comment"
                          plain
                          @click="handleGroupChatList">请选择群聊</el-button>
                      </div>
                      <div>
                        <div>
                          <el-tag
                            style="margin-left: 5px"
                            size="medium"
                            :key="list.chatId"
                            v-for="list in groupChatList"
                            closable
                            :disable-transitions="false"
                            @close="handleClosegroupChat(list)">
                            {{list.name}}
                          </el-tag>

                        </div>
<!--                        <span v-for="item in groupChatList" class="user-box">{{item.name}}</span>-->
                      </div>
                    </div>

                  </el-form-item>
                  <el-form-item label="按添加时间筛选" class="elFormItemClass">
                    <div style="width: 100%;display: flex">
                      <el-date-picker
                        v-model="form.timeScreenCharge"
                        @change="clearExpectCountCustomer"
                        type="daterange"
                        align="right"
                        unlink-panels
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        :picker-options="pickerOptions"
                        :default-time="['00:00:00', '23:59:59']">
                      </el-date-picker>
                    </div>

                  </el-form-item>
                  <el-form-item label="按客户标签筛选:" class="elFormItemClass">
                    <div>
                      <div>
                        <el-button icon="el-icon-s-check" plain @click="hangleChangeTags">请选择标签</el-button>
                      </div>
                      <el-tag type="success"
                              closable
                              :disable-transitions="false"
                              v-for="list in tagsIdsChangeSelectList"
                              :key="list.tagId"
                              @close="handleCloseTags(list)"
                              style="margin: 3px;"
                      >{{list.name}}
                      </el-tag>
<!--                      <div>-->
<!--                        <el-tag-->
<!--                          style="margin-left: 5px"-->
<!--                          size="medium"-->
<!--                          :key="tag[0]"-->
<!--                          v-for="(tag,index) in tagsIdsChangeSelectList"-->
<!--                          closable-->
<!--                          :disable-transitions="false"-->
<!--                          @close="handleCloseTags(tag)">-->
<!--                          {{tag[1]}}-->
<!--                        </el-tag>-->
<!--                      </div>-->

                    </div>
                  </el-form-item>

                  <el-form-item label="排除标签筛选" class="elFormItemClass">
                    <div>
                      <div>
                        <el-button icon="el-icon-s-check" plain @click="hangleChangeOutTags">请选择排除的标签</el-button>
                      </div>

                      <div>
                        <el-tag type="success"
                                closable
                                :disable-transitions="false"
                                v-for="list in outTagsIdsChangeSelectList"
                                :key="list.tagId"
                                @close="handleCloseOutTags(list)"
                                style="margin: 3px;"
                        >{{list.name}}
                        </el-tag>
<!--                        <el-tag-->
<!--                          style="margin-left: 5px"-->
<!--                          size="medium"-->
<!--                          :key="tag[0]"-->
<!--                          v-for="(tag,index) in outTagsIdsChangeSelectList"-->
<!--                          closable-->
<!--                          :disable-transitions="false"-->
<!--                          @close="handleCloseOutTags(tag)">-->
<!--                          {{tag[1]}}-->
<!--                        </el-tag>-->
                      </div>

                    </div>
                  </el-form-item>

                  <div style="background-color:#ecf8fe;width: 100%;height: 10%;margin-top: 3%">
                    <span style="margin-left: 2%;font-size: 15px" v-if="this.expectCountGroupChat==null">查看该消息预计送达人数:</span>
                    <el-link style="color: #1aa4ff;margin-left: 3%" v-if="this.expectCountGroupChat==null" @click="viewReceiveGroupChatNum">点我查看
                    </el-link>
                    <span style="color: #d440ec;margin-left: 2%" v-if="this.expectCountGroupChat!=null">{{this.expectCountGroupChat}} 人</span>
                  </div>
                </div>


              </el-form-item>

              <div v-if="form.chatType=='group'">
                <el-form-item label="客户群名:" prop="groupChatNames">
                  <el-input v-model="form.groupChatNamesList" placeholder="请输入客户群名" />
                </el-form-item>
              </div>

              <div>
                <span>编辑群发信息</span>
                <el-divider></el-divider>
              </div>
            </el-form>
          </div>
        </div>

        <WelComeAdd ref="WelComeAdd"></WelComeAdd>

        <div slot="footer" class="dialog-footer" style="display: flex;justify-content: center">
          <el-button type="primary" @click="submitForm">确定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 选择群发账号弹窗   -->
      <el-dialog :title="listUser.title" :visible.sync="listUser.open" style="width: 1600px;height: 100%" append-to-body>
        <qwUserList ref="qwUserList" @selectUserList="selectUserList"></qwUserList>
      </el-dialog>

      <!-- 选择群聊    -->
      <el-dialog :title="groupChart.title" :visible.sync="groupChart.open" style="width: 1300px;height: 100%" append-to-body>
        <group-chat ref="GroupChat" @selectGroupChatList="selectGroupChatList"></group-chat>
      </el-dialog>

      <!--  选择的标签   -->
      <el-dialog :title="changeTagDialog.title" :visible.sync="changeTagDialog.open" style="width:100%;height: 100%" append-to-body>

        <div>搜索标签：
          <el-input v-model="tagChange.tagName" placeholder="请输入标签名称" clearable size="small" style="width: 200px;margin-right: 10px" />
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags(tagChange.tagName)">搜索</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="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 slot="footer" class="dialog-footer">
          <el-button type="primary" @click="tagSubmitForm(changeTagDialog.type)">确 定</el-button>
          <el-button @click="tagCancel(changeTagDialog.type)">取消</el-button>
        </div>
      </el-dialog>

      <!--  详情  -->
      <el-drawer :title="detailsDialog.title" :visible.sync="detailsDialog.open" size="75%" style="font-weight: bolder">
        <div style="background-color:  rgb(240 242 245)">
          <div style="display: flex;flex-wrap: nowrap;background-color: rgb(240 242 245);height: 850px;margin: 15px;padding-top: 15px"  >
            <el-card class="box-card" style="width: 700px"  >
              <el-descriptions :column="1"  border  :labelStyle="{width: '150px'}">
                <el-descriptions-item label="群发选择类型:">
                  <template v-for="item in groupMsgTypeOptions" v-if="item.dictValue == formDetails.selectType">
                    <span>{{item.dictLabel}}</span>
                  </template>
                </el-descriptions-item>
                <el-descriptions-item label="消息文本内容:" >
                  <span  class="custom-span">{{formDetails.textContent}}</span>
                </el-descriptions-item>
                <el-descriptions-item label="图片" v-if="formDetails.msgType=='1'">
                  <el-image
                    v-if="formDetails.mediaPicUrl"
                    style="width: 100px; height: 100px"
                    :src="formDetails.mediaPicUrl"
                    fit="contain"
                    @click="openImageViewer(formDetails.mediaPicUrl)"/>
                </el-descriptions-item>
                <el-descriptions-item label="图文标题:" v-if="formDetails.msgType=='2'">
                  <span  class="custom-span-title">{{formDetails.title}}</span>
                </el-descriptions-item>
                <el-descriptions-item label="图文封面:" v-if="formDetails.msgType=='2'">
                  <el-image
                    v-if="formDetails.picurl"
                    style="width: 100px; height: 100px"
                    :src="formDetails.picurl"
                    fit="contain"
                    @click="openImageViewer(formDetails.picurl)"/>
                </el-descriptions-item>
                <el-descriptions-item label="图文的描述:" v-if="formDetails.msgType=='2'">
                  <span  class="custom-span-description">{{formDetails.description}}</span>
                </el-descriptions-item>
                <el-descriptions-item label="图文的链接:" v-if="formDetails.msgType=='2'">
                  <el-link :href="formDetails.url" target="_blank">{{ formDetails.url }}</el-link>
                  <!--                  <el-image-->
<!--                    v-if="formDetails.url"-->
<!--                    style="width: 100px; height: 100px"-->
<!--                    :src="formDetails.url"-->
<!--                    fit="contain"-->
<!--                    @click="openImageViewer(formDetails.url)"/>-->
                </el-descriptions-item>
                <el-descriptions-item label="小程序标题:" v-if="formDetails.msgType=='3'">{{formDetails.miniprogramTitle}}</el-descriptions-item>
                <el-descriptions-item label="小程序封面:" v-if="formDetails.msgType=='3'">
                  <el-image
                    v-if="formDetails.miniprogramPicUrl"
                    style="width: 100px; height: 100px"
                    :src="formDetails.miniprogramPicUrl"
                    fit="contain"
                    @click="openImageViewer(formDetails.miniprogramPicUrl)"/>
                </el-descriptions-item>
                <el-descriptions-item label="小程序appid:" v-if="formDetails.msgType=='3'">{{formDetails.miniprogramAppid}}</el-descriptions-item>
                <el-descriptions-item label="小程序page路径:" v-if="formDetails.msgType=='3'">{{formDetails.miniprogramPage}}</el-descriptions-item>
                <el-descriptions-item label="企微临时文件mediaId:" v-if="formDetails.msgType=='4'">{{formDetails.fileMediaId}}</el-descriptions-item>
                <el-descriptions-item label="文件:" v-if="formDetails.msgType=='4'">
                  <el-link v-if="formDetails.fileUrl" type="primary" :href="formDetails.fileUrl" download>
                    {{formDetails.fileUrl}}
                  </el-link>
                </el-descriptions-item>
                <el-descriptions-item label="视频临时文件mediaId:" v-if="formDetails.msgType=='5'">{{formDetails.videoMediaId}}</el-descriptions-item>
                <el-descriptions-item label="视频:" v-if="formDetails.msgType=='5'">
                  <video v-if="formDetails.videoUrl"
                         :src="formDetails.videoUrl"
                         controls style="width: 200px;height: 100px">
                  </video>
                </el-descriptions-item>
                <el-descriptions-item label="是否允许成员分配:" >
                  <span v-for="dict in allowSelectOptions" v-if="dict.dictValue==formDetails.allowSelect">{{dict.dictLabel}}</span>
                </el-descriptions-item>
                <el-descriptions-item label="创建人:">{{formDetails.createName}}</el-descriptions-item>
                <el-descriptions-item label="创建时间:">{{formDetails.createTime}}</el-descriptions-item>

              </el-descriptions>
            </el-card>
            <div style="width: 700px;background-color:rgb(255 255 255); display: flex;justify-content: center;align-items: center">
              <div class="container">
                <div class="phone">
                <div class="chat-interface">
                  <div class="header">
                    <span class="back">
                       <img src="../../../assets/image/return.png"  class="back">
                    </span>
                    <span class="title">客服账号</span>
                    <span class="menu">
                            <img src="../../../assets/image/more.png"  class="menu">
                    </span>
                  </div>
                  <div class="message-area">

                    <div v-if="formDetails.textContent" class="message-stayle">
                      <img src="../../../assets/image/character.png" style="width: 30px;height: 30px;margin: 5px">
                      <div style="background-color:rgb(255 255 255); padding: 10px;">
                        <span>{{ formDetails.textContent }}</span>
                      </div>
                    </div>
                     <div  v-if="formDetails.mediaPicUrl" class="message-stayle">
                       <img src="../../../assets/image/character.png" style="width: 30px;height: 30px;margin: 5px">
                       <el-image
                         style="width: 100px; height: 100px"
                         :src="formDetails.mediaPicUrl"
                         fit="contain"
                         @click="openImageViewer(formDetails.mediaPicUrl)"/>
                     </div>
                     <div  v-if="formDetails.title"  class="message-stayle" @click="openImageViewer(formDetails.url)">
                       <img src="../../../assets/image/character.png" style="width: 30px;height: 30px;margin: 5px">
                       <div style="background-color: white;padding: 10px;width: 100%">
                         <span>{{formDetails.title}}</span>
                         <div style="display: flex;justify-content:space-between;width: 100%">
                           <span style="font-size: 13px;flex: 1">{{formDetails.description}}</span>
                           <el-image
                             style="width: 50px; height: 50px;flex-shrink: 0"
                             :src="formDetails.picurl"
                             fit="contain"
                             @click="openImageViewer(formDetails.picurl)"/>
                         </div>
                       </div>

                     </div>
                     <div v-if="formDetails.fileUrl"  class="message-stayle" >
                       <img src="../../../assets/image/character.png" style="width: 30px;height: 30px;margin: 5px">
                       <el-link type="primary" :href="formDetails.fileUrl" download style="padding: 10px" >
                         {{formDetails.fileUrl}}
                       </el-link>
                     </div>
                     <div v-if="formDetails.videoUrl" class="message-stayle">
                       <img src="../../../assets/image/character.png" style="width: 30px;height: 30px;margin: 5px">
                       <video
                              :src="formDetails.videoUrl"
                              controls style="width: 200px;height: 100px">
                       </video>
                     </div>

                  </div>
                  <div class="footer">
                    <span class="voice-button">
                       <img src="../../../assets/image/voice.png"  class="voice-button">
                    </span>
                    <input type="text" class="input-box" placeholder="">
                    <span class="emoji-button">
                       <img src="../../../assets/image/smilingface.png" class="emoji-button">
                    </span>
                    <span class="add-button">
                         <img src="../../../assets/image/plus.png"  class="add-button">
                    </span>
                  </div>
                </div>
              </div>
              </div>
            </div>
          </div>
          <div style="width: 100%">
            <customer-group-details ref="customerGroupDetails" :rowDetailFrom="formDetails"></customer-group-details>
          </div>
        </div>
      </el-drawer>

      <!-- 大图预览对话框 -->
      <el-dialog
        :visible.sync="dialogVisible"
        :modal="false"
        width="1200px"
        append-to-body>
        <img
          :src="this.dialogImageUrl"
          style="display: block; max-width: 100%; margin: 0 auto"
        />
      </el-dialog>
    </div>

  </div>
</template>

<script>
import {
  listGroupMsg,
  getGroupMsg,
  delGroupMsg,
  addGroupMsg, remindGroupMsg
} from '@/api/qw/groupMsg'
import GroupMsgUser from '@/views/qw/groupMsgUser/groupMsg'
import ImageUpload from "@/views/qw/material/ImageUpload";
import qwUserList from "@/views/qw/user/qwUserList"
import { selectCountCustomer } from '@/api/qw/externalContact'
import GroupChat from '@/views/qw/groupChat/groupChat'
import WelComeAdd from '@/views/qw/welcome/welComeAdd'
import CustomerGroupDetails from '@/views/qw/groupMsg/customerGroupDetails'
import source from 'echarts/src/data/Source'
import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
import {allListTagGroup} from "@/api/qw/tagGroup";
import {listTag, searchTags} from "@/api/qw/tag";
import  MaterialQw  from "@/views/qw/materialQw/index.vue";
export default {
  name: "GroupMsg",
  components: { CustomerGroupDetails, GroupChat, GroupMsgUser,ImageUpload,qwUserList,WelComeAdd,MaterialQw},
  data() {
    return {
      imageArr:[],
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      myQwCompanyList:[],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      dialogImageUrl:null,
      dialogVisible:false,

      // 客户群发记录主表格数据
      groupMsgList: [],

      //任务类型
      groupMsgChatType:[],

      //发送类型
      groupMsgTimerType:[],

      //选择客户类型
      groupMsgTypeOptions:[],
      //是否允许成员在待发送列表中再次选择
      allowSelectOptions:[],

      //消息类型
      msgTypeOptions:[],
      //客户性别
      sysUserSex:[],
      genderSex:null,
      //预期发送客户人数
      expectCountCustomer:null,

      //部分客户预期发送客户人数
      expectCountGroupChat:null,

      //客户群选择列表
      groupChatList:[],

      //成员选择列表
      userSelectList:[],

      //查询预计通知人数
      countList:{
        //根据成员查
        userIds:{},
        //根据筛选客户条件查
        //1.群聊
        chartIds:{},

      },

      //选择的标签
      tagsIdsChangeSelectList:null,
      //排除的标签
      outTagsIdsChangeSelectList:null,

      //选择群发账号列表
      listUser:{
        title:"",
        open:false
      },
      //选择所在群聊里的人
      groupChart:{
        title:"",
        open:false,
      },

      //标签弹窗选择
      tagChange:{
        open:false,
        index:null,
      },
      //选择标签
      changeTagDialog:{
        title:"",
        open:false,
        type:null,
      },
      detailsDialog:{
        title:"",
        open:false,
        type:null,
      },
      //标签组
      tagGroupList:[],
      //所有标签
      tagList:[],

      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        chatType: "single",
        sender: null,
        allowSelect: null,
        textContent: null,
        msgid: null,
        qwMsgId:null,
        corpId: null,
        companyId: null,
        tagNames: null,
        groupChatNames: null,
        fromUserCount: null,
        toUserCount: null,
        fromUserNum: null,
        toUserNum: null,
      },
      // 表单参数
      form: {},
      //详情
      formDetails:{},
      // 表单校验
      rules: {
        chatType: [
          { required: true, message: "群发任务的类型，默认为single，表示发送给客户，group表示发送给客户群不能为空", trigger: "change" }
        ],
        userIdsSelectList: [
          { required: true, message: "发送企业群发消息的成员账号不能为空", trigger: "blur" }
        ],
        allowSelect: [
          { required: true, message: "是否允许成员在待发送客户列表中重新进行选择，默认为true", trigger: "blur" }
        ],
        textContent:[
          { required: true, message: "消息文本不能为空噢", trigger: "blur" }
        ],
        createName:[
          { required: true, message: "创建人不能为空", trigger: "blur" }
        ]

      },
      //日期快捷选择
      pickerOptions: {
        shortcuts: [
          {
            text: '最近三天',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 3);
              picker.$emit('pick', [start, end]);
            }
          },{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
      },

    };
  },
  created() {
    getMyQwCompanyList().then(response => {
            this.myQwCompanyList = response.data;
            if(this.myQwCompanyList!=null){
              this.queryParams.corpId=this.myQwCompanyList[0].dictValue;

              this.getList();
            }
    });


    //全部客户还是部分客户
    this.getDicts("sys_qw_groupMsg_type").then(response => {
      this.groupMsgTypeOptions = response.data;
    });

    //文本类型字典(复用)
    this.getDicts("sys_qw_welcome_type").then(response => {
      this.msgTypeOptions = response.data;
    });


    this.getDicts("sys_qw_group_msg_chat_type").then(response => {
      this.groupMsgChatType = response.data;
    });

    //发送类型
    this.getDicts("sys_qw_group_msg_timer_type").then(response => {
      this.groupMsgTimerType = response.data;
    });

    //客户性别
    this.getDicts("sys_qw_external_contact_gender").then(response => {
      this.sysUserSex = response.data;

      // 要添加的新对象数据
      let newUserData = {
        dictValue: "99",
        dictLabel: '全部',
      };
      // 添加对象到数组
      this.sysUserSex.push(newUserData);

    });

    //是否允许成员在待发送列表中再次选择
    this.getDicts("sys_qw_allow_select").then(response => {
      this.allowSelectOptions = response.data;
    });
  },

  watch:{
    // 监听 userSelectList 的变化，并同步更新 form.userIdsSelectList
    userSelectList(newList) {
      this.form.userIdsSelectList = newList.map(item => item.qwUserId);
    },
    groupChatList(newList){
      this.form.groupChatSelectList=newList.map(item=>item.chatId)
    },
  },
  methods: {
    updateCorpId(){
           this.getList();
     },

    //关闭弹窗-清空页面
    closeData(){
      this.reset();
    },
    /** 查询客户群发记录主列表 */
    getList() {

      this.loading = true;
      listGroupMsg(this.queryParams).then(response => {

        this.groupMsgList = response.rows;
        this.total = response.total;
        this.loading = false;

      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    //标签的选择
    tagSelection(row){
      row.isSelected= !row.isSelected;
      this.$forceUpdate();
    },
    /** 提醒成员群发 */
    triggerRemindGroupMsg(row){
      this.queryParams.qwMsgId=row.msgId
      remindGroupMsg(this.queryParams).then(res=>{

        if (res.code==200){

          if (res.data.errcode==0){
            return this.msgSuccess("提醒成员群发成功")
          }else if (res.data.errcode==41094){
            return this.msgWarning("此条记录的每日提醒次数超过限制了噢")
          }else {
            return this.msgError(res.data.errmsg)
          }

        }else {
          return this.msgError(res.msg)
        }
      })
    },
    handleSearchTags(name){

      searchTags({name:name,corpId:this.queryParams.corpId}).then(response => {
        this.tagGroupList = response.rows;
      });

    },
    cancelSearchTags(){
      this.afreshData()
    },
    //清除点我查看
    clearExpectCountCustomer(){

      //选择全部客户的统计
      this.expectCountCustomer=null;
      //选择部分客户的统计
      this.expectCountGroupChat=null;
    },

    //查看预计接收人数
    viewReceiveNum(){
      if (this.userSelectList.length==0){
        return  this.msgError("请选择群发成员账号");
      }else {
        this.form.corpId=this.queryParams.corpId;
        selectCountCustomer(this.form).then(res=>{
          this.expectCountCustomer=res.data;
        })
      }
    },

    //查看部分客户预计接收人数
    viewReceiveGroupChatNum(){

      if (this.userSelectList.length==0){
        return  this.msgError("请选择群发成员账号");
      }else {

        // 使用 map 方法和解构赋值提取每个子数组的第一个元素
        // 选择的标签
        if (this.tagsIdsChangeSelectList!=null){
          this.form.tagsIdsSelectList=this.tagsIdsChangeSelectList.map(item => item.tagId);
        }

        //排除的标签
        if (this.outTagsIdsChangeSelectList!=null){
          this.form.outTagsIdsSelectList = this.outTagsIdsChangeSelectList.map(item => item.tagId);
        }
        this.form.corpId=this.queryParams.corpId;
        selectCountCustomer(this.form).then(res=>{
          this.expectCountGroupChat=res.data;
        })

      }
    },

    //选择的成员账号列表
    selectUserList(list){
      this.listUser.open=false;
      //用于显示
      this.userSelectList=list;

      // //用于查询
      // this.form.userIdsSelectList= this.userSelectList.map(item => item.id);

    },

    //选择的部分客户时,选择的群聊里的
    selectGroupChatList(list){

      this.groupChart.open=false;
      //用于显示
      this.groupChatList=list;

      // //用于查询
      // this.form.groupChatSelectList=this.groupChatList.map(item=>item.chatId);

    },
    //确定选择标签
    tagSubmitForm(type){

        //制空选项
        // 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=false;
        //   }
        // }

        if (type==1){
          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.tagsIdsChangeSelectList) {
                  this.tagsIdsChangeSelectList = [];
                }

                // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
                let tagExists = this.tagsIdsChangeSelectList.some(
                  tag => tag.id === this.tagGroupList[i].tag[x].id
                );

                // 如果 tag 不存在于 tagListFormIndex[index] 中，则新增
                if (!tagExists) {
                  this.tagsIdsChangeSelectList.push(this.tagGroupList[i].tag[x]);
                }
              }
            }
          }
          if (!this.tagsIdsChangeSelectList || this.tagsIdsChangeSelectList.length === 0) {
            return this.$message('请选择标签');
          }

        }else if (type==2){

          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.outTagsIdsChangeSelectList) {
                  this.outTagsIdsChangeSelectList = [];
                }

                // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
                let tagExists = this.outTagsIdsChangeSelectList.some(
                  tag => tag.id === this.tagGroupList[i].tag[x].id
                );

                // 如果 tag 不存在于 tagListFormIndex[index] 中，则新增
                if (!tagExists) {
                  this.outTagsIdsChangeSelectList.push(this.tagGroupList[i].tag[x]);
                }
              }
            }
          }
          if (!this.outTagsIdsChangeSelectList || this.outTagsIdsChangeSelectList.length === 0) {
            return this.$message('请选择标签');
          }

        }



      this.changeTagDialog.open = false;
    },

    //取消选择标签
    tagCancel(){
      this.changeTagDialog.open = false;
    },
    // //选择的标签
    // selectTagsList(list,type){
    //
    //   const result = list.flatMap(item => {
    //     return item.tag.map(tag => [tag.tagId, tag.name]);
    //   });
    //
    //   //获取到选择的标签列表
    //   const uniqueResult = Array.from(new Set(result.map(JSON.stringify)), JSON.parse);
    //   this.changeTagDialog.open=false
    //
    //   if (type==1){
    //     this.tagsIdsChangeSelectList=uniqueResult;
    //   }else if (type==2){
    //     this.outTagsIdsChangeSelectList=uniqueResult;
    //   }
    //
    // },

    //删除一些选择了的账号
    handleClosegroupUser(list){

      // 假设 list 对象具有一个 id 属性
      const index = this.userSelectList.findIndex(t => t.id === list.id);
      if (index !== -1) {
        this.userSelectList.splice(index, 1);
      }
      //表单同时清除
      // this.form.userIdsSelectList= this.userSelectList.map(item => item.id);
    },

    //删除一些选择了的群聊
    handleClosegroupChat(list){

      // 假设 list 对象具有一个 id 属性
      const index = this.groupChatList.findIndex(t => t.chatId === list.chatId);
      if (index !== -1) {
        this.groupChatList.splice(index, 1);
      }
      // //表单同时清除
      // this.form.groupChatSelectList=this.groupChatList.map(item=>item.chatId);
    },

    //删除一些选择的标签
    handleCloseTags(list){
      // 假设 list 对象具有一个 id 属性
      const ls = this.tagsIdsChangeSelectList.findIndex(t => t.tagId === list.tagId);
      if (ls !== -1) {
        this.tagsIdsChangeSelectList.splice(ls, 1);
        this.tagsIdsChangeSelectList = [...this.tagsIdsChangeSelectList];
      }
    },

    //删除一些排除的标签
    handleCloseOutTags(list){
      // const index = this.outTagsIdsChangeSelectList.findIndex(t => t[0] === tag[0]);
      // if (index !== -1) {
      //   this.outTagsIdsChangeSelectList.splice(index, 1);
      // }
      // 假设 list 对象具有一个 id 属性
      const ls = this.outTagsIdsChangeSelectList.findIndex(t => t.tagId === list.tagId);
      if (ls !== -1) {
        this.outTagsIdsChangeSelectList.splice(ls, 1);
        this.outTagsIdsChangeSelectList = [...this.outTagsIdsChangeSelectList];
      }
    },

    //选择群发的企业成员账号
    handlelistUser(){

      console.log("imageArr",this.imageArr)

      this.listUser.title="选择企业成员"
      this.listUser.open=true;

      setTimeout(() => {
        this.$refs.qwUserList.getDetails(this.queryParams.corpId)
      }, 200);


      //预计人数制空
      this.expectCountCustomer=null;
    },

    //选择群聊
    handleGroupChatList(){

      this.groupChart.title="选择所在群聊里的客户"
      this.groupChart.open=true;

      setTimeout(() => {
        this.$refs.GroupChat.getDetailsList(this.queryParams.corpId)
      }, 200);

      //预计人数制空
      this.expectCountGroupChat=null;

    },

    //选择标签
    hangleChangeTags(){

      this.changeTagDialog.title="选择标签"
      this.changeTagDialog.open=true;
      this.changeTagDialog.type=1;

      // 获取 tagListFormIndex 中的所有 tagId，用于快速查找
      const selectedTagIds = new Set(this.tagsIdsChangeSelectList.map(tagItem => tagItem.tagId));
      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);
        }
      }

      // setTimeout(() => {
      //    this.$refs.TagGroupList.getTagGroupList(this.queryParams.corpId)
      // }, 200);


      //预计人数制空
      this.expectCountGroupChat=null;
    },

    //选择排除标签
    hangleChangeOutTags(){
      this.changeTagDialog.title="选择排除的标签"
      this.changeTagDialog.open=true;
      this.changeTagDialog.type=2;

      // 获取 tagListFormIndex 中的所有 tagId，用于快速查找
      const selectedTagIds = new Set(this.outTagsIdsChangeSelectList.map(tagItem => tagItem.tagId));
      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);
        }
      }

      // setTimeout(() => {
      //   this.$refs.TagGroupList.getTagGroupList(this.queryParams.corpId)
      // }, 200);
      //

      //预计人数制空
      this.expectCountGroupChat=null;
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        chatType: "single",
        sender: null,
        gender:"99",
        allowSelect: "Y",
        textContent: null,
        msgid: null,
        corpId: null,
        companyId: null,
        tagNames: null,
        groupChatNamesList: [],
        fromUserCount: null,
        toUserCount: null,
        fromUserNum: null,
        toUserNum: null,
        createTime: null,
        updateTime: null,
        msgType:null,
        mediaId: null,
        mediaPicUrl: null,
        title: null,
        picurl: null,
        description: null,
        url: null,
        miniprogramTitle: null,
        miniprogramPicMediaId: null,
        miniprogramPicUrl: null,
        miniprogramAppid: null,
        miniprogramPage: null,
        fileMediaId: null,
        fileUrl: null,
        videoMediaId: null,
        videoUrl: null,
        //选择的成员账号
        userIdsSelectList:[],
        //选择的群聊
        groupChatSelectList:[],
        //选择的时间
        timeScreenCharge:[],

        //全部客户还是部分客户
        selectType:'1',

        //选择的标签列表
        tagsIdsSelectList:[],

        //排除的标签
        outTagsIdsSelectList:[],
      };
      this.userSelectList=[];
      this.expectCountCustomer=null;
      this.groupChatList=[];
      this.tagsIdsChangeSelectList=[];
      this.outTagsIdsChangeSelectList=[];
      this.expectCountGroupChat=[];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    hangdleDitels(row){
      this.reset();
      const id = row.id || this.ids
      getGroupMsg(id).then(response => {
        this.formDetails = response.data;
        this.detailsDialog.open = true;
        this.detailsDialog.title = "客户群发记录详情";
      });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.form.msgType="1"
      this.title = "新建群发";

      this.afreshData();
      // //所有的标签组
      // allListTagGroup({corpId:this.queryParams.corpId}).then(response => {
      //   this.tagGroupList = response.rows;
      // });
      //
      // //所有的标签
      // listTag({corpId:this.queryParams.corpId}).then(response => {
      //   this.tagList = response.rows;
      // });

    },
    /**
     * 重新获取 部分数据
     */
    afreshData(){
      //所有的标签组
      allListTagGroup({corpId:this.queryParams.corpId}).then(response => {
        this.tagGroupList = response.rows;
      });

      //所有的标签
      listTag({corpId:this.queryParams.corpId}).then(response => {
        this.tagList = response.rows;
      });

    },
    /** 获取企业员工列表 */
    // getUserList(){
    //   //获取企业员工
    //   listUser(this.queryParams).then(response => {
    //     this.userList = response.rows;
    //     this.total = response.total;
    //     this.loading = false;
    //   });
    // },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getGroupMsg(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改客户群发记录主";
      });
    },

    openImageViewer(url) {
      // 打开大图预览对话框
      this.dialogImageUrl=url
      this.dialogVisible = true;
    },

    /** 提交按钮 */
    async  submitForm() {
      // 选择的标签
      if (this.tagsIdsChangeSelectList!=null){
        this.form.tagsIdsSelectList=this.tagsIdsChangeSelectList.map(item => item.tagId);
      }

      //排除的标签
      if (this.outTagsIdsChangeSelectList!=null){
        this.form.outTagsIdsSelectList = this.outTagsIdsChangeSelectList.map(item => item.tagId);
      }
      this.form.corpId=this.queryParams.corpId;
      try {
        // 验证子组件表单
        await this.$refs.WelComeAdd.validateChildForm();
        // 父组件表单验证逻辑
        await this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              return this.msgError("没有修改选项");
            } else {
              this.loading=true;
              Object.assign(this.form, this.$refs.WelComeAdd.form);

              this.form.chatType="single";

              addGroupMsg(this.form).then(response => {
                this.msgSuccess("创建成功");
                this.open = false;
                this.loading = false;
                this.getList();
              }).catch(error => {
                this.open=true;
                this.loading = false;

              }).finally(
                  () => {
                    this.$refs["form"].resetFields();
                    this.$refs.WelComeAdd.reset();
                    this.userSelectList=[];
                    this.reset();
                  }
              );
            }
          }
        });

      } catch (error) {
        console.error('表单编辑群发信息验证不用过:', error.message);
      }


    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除客户群发记录主编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return delGroupMsg(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(() => {});
    },
  }
};
</script>
<style scoped>
.user-box {
  width: 50px;           /* 盒子宽度 */
  height: 30px;           /* 盒子高度 */
  padding: 5px 10px;          /* 内边距 */
  border: 1px solid #d5d1d1;/* 边框 */
  margin: 3px;            /* 外边距 */
  background-color: #f9f9f9;/* 背景颜色 */
  color: #333;            /* 文本颜色 */
  font-size: 14px;        /* 字体大小 */
  text-align: center;     /* 文本居中 */
}
.elFormItemClass{
  margin: 20px 0px

}

.message-stayle{
  display: flex;
  justify-content: normal;
  align-items: center;
  margin-top: 10px;
}
.message-stayle .el-link {
  white-space: normal; /* 允许换行 */
  word-break: break-all; /* 单词中间断行 */
  overflow-wrap: break-word; /* 允许在单词内换行 */
}
.message-stayle span {
  word-break: break-all;
}
.container {
  position: relative; /* 使 phone div 的 absolute 定位基于这个容器 */
  width: 100%;
  height: 100%;
}
.phone {
  position: absolute; /* 定位到容器内 */
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 375px;
  height: 100%;
  max-height: 90%;
  border: 8px solid #ccc;
  border-radius: 36px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  background-color: #fff;
  overflow: hidden;
}

.phone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 60px;
  height: 5px;
  background-color: #ccc;
  border-radius: 10px;
  transform: translateX(-50%);
}

.chat-interface {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #fff;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  padding: 0 15px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.header .back,
.header .menu {
  height: 25px;
  width: 25px;
}
.header .title{
  font-size: 16px;
  margin: auto;
}

.message-area {
  flex: 1;
  background-color: rgb(240, 242, 245);
  padding: 10px;
  overflow-y: auto;
}

.footer {
  display: flex;
  align-items: center;
  padding: 10px;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
}

.footer .voice-button,
.footer .emoji-button,
.footer .add-button {
  width: 25px;
  height: 25px;
  border: none;
  cursor: pointer;
  flex-shrink: 0; /* 不允许缩小 */
}
.footer .emoji-button,
.footer .add-button {
  margin: 0px 5px;
}


.footer .input-box {
  flex: 1;
  border: 1px solid #e0e0e0;
  margin-left: 5px;
}

.text-container {
  max-height: 7.5em; /* 设置最大高度为6行，根据字体大小调整 */
  overflow-y: auto; /* 内容超出时显示滚动条 */
  line-height: 1.5em; /* 行高设置，确保每行高度一致 */
}
.el-form-item {
  margin-bottom: 30px;
}

.custom-span {
  display: block; /* 确保元素是块级元素 */
  height: 110px; /* 设置固定高度 */
  overflow-y: auto; /* 超出高度时显示滚动条 */
  word-wrap: break-word; /* 自动换行 */
  word-break: break-all; /* 在必要时进行换行 */
}
.custom-span-description{
  display: block; /* 确保元素是块级元素 */
  height: 110px; /* 设置固定高度 */
  overflow-y: auto; /* 超出高度时显示滚动条 */
  word-wrap: break-word; /* 自动换行 */
  word-break: break-all; /* 在必要时进行换行 */
}
.custom-span-title {
  display: block; /* 确保元素是块级元素 */
  height: 45px; /* 设置固定高度 */
  overflow-y: auto; /* 超出高度时显示滚动条 */
  word-wrap: break-word; /* 自动换行 */
  word-break: break-all; /* 在必要时进行换行 */
}

/* 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;
}
.text-container {
  max-height: 5em; /* 设置最大高度为6行，根据字体大小调整 */
  overflow-y: auto; /* 内容超出时显示滚动条 */
  line-height: 1.5em; /* 行高设置，确保每行高度一致 */
}

</style>
