index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" style="border: 1px solid transparent">
  4. <el-form-item label="销售公司" prop="companyId">
  5. <el-select v-model="queryParams.companyId" placeholder="销售公司" size="small" @change="getAllUserlist(queryParams.companyId)" clearable>
  6. <el-option
  7. v-for="dict in qwCompanyList"
  8. :key="dict.companyId"
  9. :label="dict.companyName"
  10. :value="dict.companyId"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="销售账号" prop="companyUserName">
  15. <el-select v-model="queryParams.companyUserName" placeholder="销售账号" size="small" clearable>
  16. <el-option
  17. v-for="dict in companyUserNameList"
  18. :key="dict.userId"
  19. :label="dict.userName"
  20. :value="dict.userName"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="企微微信" prop="companyUserName">
  25. <el-select v-model="queryParams.qwUserId" placeholder="企微微信" size="small" clearable>
  26. <el-option
  27. v-for="dict in qwUserList"
  28. :key="dict.id"
  29. :label="dict.qwUserName"
  30. :value="dict.id"
  31. />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="客户名称" prop="name">
  35. <el-input
  36. v-model="queryParams.name"
  37. placeholder="请输入客户名称"
  38. clearable
  39. size="small"
  40. @keyup.enter.native="handleQuery"
  41. />
  42. </el-form-item>
  43. <el-form-item label="销售企微昵称" prop="qwUserName">
  44. <el-input
  45. v-model="queryParams.qwUserName"
  46. placeholder="请输入销售企微昵称"
  47. clearable
  48. size="small"
  49. @keyup.enter.native="handleQuery"
  50. />
  51. </el-form-item>
  52. <el-form-item label="用户类别" prop="type">
  53. <el-select v-model="queryParams.type" placeholder="请选择用户类别" clearable size="small">
  54. <el-option
  55. v-for="dict in typeOptions"
  56. :key="dict.dictValue"
  57. :label="dict.dictLabel"
  58. :value="dict.dictValue"
  59. />
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="性别" prop="gender">
  63. <el-select v-model="queryParams.gender" placeholder="状态" clearable size="small">
  64. <el-option
  65. v-for="dict in genderOptions"
  66. :key="dict.dictValue"
  67. :label="dict.dictLabel"
  68. :value="dict.dictValue"
  69. />
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item label="客户等级" prop="level">
  73. <el-select v-model="queryParams.level" placeholder="客户等级" clearable size="small">
  74. <el-option
  75. v-for="dict in ratingType"
  76. :key="dict.dictValue"
  77. :label="dict.dictLabel"
  78. :value="dict.dictValue"
  79. />
  80. </el-select>
  81. </el-form-item>
  82. <el-form-item label="等级升降" prop="levelType">
  83. <el-select v-model="queryParams.levelType" placeholder="等级升降" clearable size="small">
  84. <el-option
  85. v-for="dict in ratingUpFall"
  86. :key="dict.dictValue"
  87. :label="dict.dictLabel"
  88. :value="dict.dictValue"
  89. />
  90. </el-select>
  91. </el-form-item>
  92. <el-form-item label="电话号码" prop="remarkMobiles">
  93. <el-input
  94. v-model="queryParams.remarkMobiles"
  95. placeholder="请输入备注电话号码"
  96. clearable
  97. size="small"
  98. @keyup.enter.native="handleQuery"
  99. />
  100. </el-form-item>
  101. <el-form-item label="来源" prop="addWay">
  102. <el-select v-model="queryParams.addWay" placeholder="来源" clearable size="small">
  103. <el-option
  104. v-for="dict in addWayOptions"
  105. :key="dict.dictValue"
  106. :label="dict.dictLabel"
  107. :value="dict.dictValue"
  108. />
  109. </el-select>
  110. </el-form-item>
  111. <el-form-item label="状态" prop="status">
  112. <el-select v-model="queryParams.status" placeholder="状态" clearable size="small">
  113. <el-option
  114. v-for="dict in statusOptions"
  115. :key="dict.dictValue"
  116. :label="dict.dictLabel"
  117. :value="dict.dictValue"
  118. />
  119. </el-select>
  120. </el-form-item>
  121. <el-form-item label="转接状态" prop="addWay">
  122. <el-select v-model="queryParams.transferStatus" placeholder="转接状态" clearable size="small">
  123. <el-option
  124. v-for="dict in transferStatusOptions"
  125. :key="dict.dictValue"
  126. :label="dict.dictLabel"
  127. :value="dict.dictValue"
  128. />
  129. </el-select>
  130. </el-form-item>
  131. <el-form-item label="是否绑定会员" prop="isBindMini">
  132. <el-select v-model="queryParams.isBindMini" placeholder="是否绑定会员" clearable size="small" @change="handleQuery" >
  133. <el-option
  134. v-for="dict in isBindMiniOptions"
  135. :key="dict.dictValue"
  136. :label="dict.dictLabel"
  137. :value="dict.dictValue"
  138. />
  139. </el-select>
  140. </el-form-item>
  141. <el-form-item label="标签" prop="tagIds">
  142. <div @click="hangleChangeTags()" style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 250px">
  143. <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
  144. <el-tag type="success"
  145. closable
  146. :disable-transitions="false"
  147. v-for="list in this.selectTags"
  148. :key="list.tagId"
  149. @close="handleCloseTags(list)"
  150. style="margin: 3px;"
  151. >{{list.name}}
  152. </el-tag>
  153. </div>
  154. </div>
  155. </el-form-item>
  156. <el-form-item label="备注" prop="remark">
  157. <el-input
  158. v-model="queryParams.remark"
  159. placeholder="请输入备注"
  160. clearable
  161. size="small"
  162. @keyup.enter.native="handleQuery"
  163. />
  164. </el-form-item>
  165. <el-form-item label="所属销售" prop="companyUser">
  166. <el-input
  167. v-model="queryParams.companyUser"
  168. placeholder="请输入昵称或者手机号"
  169. clearable
  170. size="small"
  171. @keyup.enter.native="handleQuery"
  172. />
  173. </el-form-item>
  174. <el-form-item label="添加时间" prop="createTime">
  175. <el-date-picker v-model="queryParams.createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  176. </el-form-item>
  177. <el-form-item label="流失时间" prop="lossTime">
  178. <el-date-picker clearable size="small"
  179. v-model="queryParams.lossTime"
  180. type="date"
  181. value-format="yyyy-MM-dd"
  182. placeholder="选择流失时间">
  183. </el-date-picker>
  184. </el-form-item>
  185. <el-form-item label="删除时间" prop="delTime">
  186. <el-date-picker clearable size="small"
  187. v-model="queryParams.delTime"
  188. type="date"
  189. value-format="yyyy-MM-dd"
  190. placeholder="选择删除时间">
  191. </el-date-picker>
  192. </el-form-item>
  193. <el-form-item>
  194. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  195. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  196. </el-form-item>
  197. </el-form>
  198. <el-row :gutter="10" class="mb8">
  199. <el-col :span="1.5">
  200. <el-button
  201. type="warning"
  202. plain
  203. icon="el-icon-download"
  204. size="mini"
  205. :loading="exportLoading"
  206. @click="handleExport"
  207. v-hasPermi="['qw:externalContact:export']"
  208. >导出</el-button>
  209. </el-col>
  210. <el-col :span="1.5">
  211. <el-button
  212. type="warning"
  213. plain
  214. icon="el-icon-download"
  215. size="mini"
  216. :loading="exportUnionidLoading"
  217. @click="handleExportUnionId"
  218. v-hasPermi="['qw:externalContact:export']"
  219. >导出unionid</el-button>
  220. </el-col>
  221. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  222. </el-row>
  223. <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
  224. <el-table-column type="selection" width="55" align="center" />
  225. <el-table-column label="企微客户ID" align="center" prop="id" />
  226. <el-table-column label="企微客户头像" align="center" prop="avatar" width="100px">
  227. <template slot-scope="scope">
  228. <el-popover
  229. placement="right"
  230. title=""
  231. trigger="hover">
  232. <img slot="reference" :src="scope.row.avatar" width="60px">
  233. <img :src="scope.row.avatar" style="max-width: 200px;">
  234. </el-popover>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="企微客户名称" prop="name" width="110px"/>
  238. <el-table-column label="客户称呼" prop="stageStatus" width="110px"/>
  239. <el-table-column label="销售企微昵称" align="center" prop="qwUserName" width="120px"/>
  240. <el-table-column label="企微部门" align="center" prop="departmentName" width="120px"/>
  241. <el-table-column label="用户类别" align="center" prop="type">
  242. <template slot-scope="scope">
  243. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  244. </template>
  245. </el-table-column>
  246. <el-table-column label="性别" align="center" prop="gender">
  247. <template slot-scope="scope">
  248. <dict-tag :options="genderOptions" :value="scope.row.gender"/>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="备注" align="center" prop="remark" />
  252. <el-table-column label="描述信息" align="center" prop="description" />
  253. <el-table-column label="标签" align="center" prop="tagIdsName" width="250px">
  254. <template slot-scope="scope">
  255. <div v-for="name in scope.row.tagIdsName" style="display: inline;">
  256. <el-tag type="success">{{ name }}</el-tag>
  257. </div>
  258. </template>
  259. </el-table-column>
  260. <el-table-column label="状态" align="center" prop="status" width="120px" >
  261. <template slot-scope="scope">
  262. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  263. </template>
  264. </el-table-column>
  265. <el-table-column label="客户等级" align="center" prop="level" width="120px" >
  266. <template slot-scope="scope">
  267. <dict-tag :options="ratingType" :value="scope.row.level"/>
  268. </template>
  269. </el-table-column>
  270. <el-table-column label="等级状态" align="center" prop="levelType" width="120px" >
  271. <template slot-scope="scope">
  272. <dict-tag :options="ratingUpFall" :value="scope.row.levelType"/>
  273. </template>
  274. </el-table-column>
  275. <el-table-column label="添加时间" align="center" prop="createTime" width="100px" />
  276. <el-table-column label="流失时间" align="center" prop="lossTime" width="100px" />
  277. <el-table-column label="删除时间" align="center" prop="delTime" width="100px" />
  278. <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
  279. <template slot-scope="scope">
  280. <div v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</div>
  281. </template>
  282. </el-table-column>
  283. <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
  284. <el-table-column label="来源" align="center" prop="addWay" width="100px">
  285. <template slot-scope="scope">
  286. <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
  287. </template>
  288. </el-table-column>
  289. <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px" >
  290. <template slot-scope="scope">
  291. <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
  292. </template>
  293. </el-table-column>
  294. <el-table-column label="企业id" align="center" prop="corpId" />
  295. <el-table-column label="是否绑定会员" width="100px" align="center" fixed="right">
  296. <template slot-scope="scope">
  297. <el-tag v-if="scope.row.fsUserId" >已绑定</el-tag>
  298. <el-tag v-else type="info"> 未绑定</el-tag>
  299. </template>
  300. </el-table-column>
  301. <!-- <el-table-column label="修改" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">-->
  302. <!-- <template slot-scope="scope">-->
  303. <!-- <el-button-->
  304. <!-- v-if="scope.row.status==0||scope.row.status==2"-->
  305. <!-- size="mini"-->
  306. <!-- type="text"-->
  307. <!-- icon="el-icon-edit"-->
  308. <!-- @click="handleUpdate(scope.row)"-->
  309. <!-- v-hasPermi="['qw:externalContact:edit']"-->
  310. <!-- >修改备注</el-button>-->
  311. <!-- <el-button-->
  312. <!-- size="mini"-->
  313. <!-- type="text"-->
  314. <!-- icon="el-icon-user-solid"-->
  315. <!-- @click="handleAppellation(scope.row)"-->
  316. <!-- >修改客户称呼</el-button>-->
  317. <!-- </template>-->
  318. <!-- </el-table-column>-->
  319. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
  320. <!-- <template slot-scope="scope">-->
  321. <!-- <el-button-->
  322. <!-- size="mini"-->
  323. <!-- type="text"-->
  324. <!-- icon="el-icon-edit-outline"-->
  325. <!-- @click="handleUpdateUser(scope.row)"-->
  326. <!-- >-->
  327. <!-- <span v-if="scope.row.fsUserId">换绑会员</span>-->
  328. <!-- <span v-else>绑定会员</span>-->
  329. <!-- </el-button>-->
  330. <!-- <el-button-->
  331. <!-- v-if="scope.row.fsUserId"-->
  332. <!-- size="mini"-->
  333. <!-- type="text"-->
  334. <!-- icon="el-icon-thumb"-->
  335. <!-- @click="handleUnBindUserId(scope.row)"-->
  336. <!-- v-hasPermi="['qw:externalContact:unBindUserId']"-->
  337. <!-- >-->
  338. <!-- <span>解除会员绑定</span>-->
  339. <!-- </el-button>-->
  340. <!-- <el-button-->
  341. <!-- size="mini"-->
  342. <!-- type="text"-->
  343. <!-- @click="handledetails(scope.row)"-->
  344. <!-- >AI获取用户信息-->
  345. <!-- </el-button>-->
  346. <!-- </template>-->
  347. </el-table-column>
  348. </el-table>
  349. <pagination-more
  350. :total="total"
  351. :page.sync="queryParams.pageNum"
  352. :limit.sync="queryParams.pageSize"
  353. @pagination="getList"
  354. />
  355. <!-- 搜索标签 -->
  356. <el-dialog :title="changeTagDialog.title" :visible.sync="changeTagDialog.open" style="width:100%;height: 100%" append-to-body>
  357. <div>搜索标签:
  358. <el-input v-model="queryTagParams.name" placeholder="请输入标签名称" clearable size="small" style="width: 200px;margin-right: 10px" />
  359. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags(queryTagParams.name)">搜索</el-button>
  360. <el-button type="primary" icon="el-icon-plus" size="mini" @click="cancelSearchTags">重置</el-button>
  361. </div>
  362. <div v-for="item in tagGroupList" :key="item.id" >
  363. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  364. <span class="name-background">{{ item.name }}</span>
  365. </div>
  366. <div class="tag-container">
  367. <a
  368. v-for="tagItem in item.tag"
  369. class="tag-box"
  370. @click="tagSelection(tagItem)"
  371. :class="{ 'tag-selected': tagItem.isSelected }"
  372. >
  373. {{ tagItem.name }}
  374. </a>
  375. </div>
  376. </div>
  377. <pagination
  378. v-show="tagTotal>0"
  379. :total="tagTotal"
  380. :page.sync="queryTagParams.pageNum"
  381. :limit.sync="queryTagParams.pageSize"
  382. @pagination="getPageListTagGroup"
  383. />
  384. <div slot="footer" class="dialog-footer">
  385. <el-button type="primary" @click="tagSubmitForm()">确 定</el-button>
  386. <el-button @click="tagCancel()">取消</el-button>
  387. </div>
  388. </el-dialog>
  389. </div>
  390. </template>
  391. <script>
  392. import { listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact, exportUnionId } from "@/api/qw/externalContact";
  393. import {getCompanyList} from "@/api/company/company";
  394. import {getAllUserlist} from "@/api/company/companyUser";
  395. import {getQwUserInfo} from "@/api/qw/qwUser";
  396. import { allListTagGroup} from "@/api/qw/tagGroup";
  397. import {searchTags,} from "@/api/qw/tag";
  398. import PaginationMore from '@/components/PaginationMore/index.vue'
  399. export default {
  400. name: "ExternalContact",
  401. components: { PaginationMore },
  402. data() {
  403. return {
  404. // 遮罩层
  405. loading: false,
  406. // 导出遮罩层
  407. exportLoading: false,
  408. exportUnionidLoading: false,
  409. //等级状态
  410. ratingUpFall: [],
  411. // 性别字典
  412. genderOptions: [],
  413. // 用户类别字典
  414. typeOptions: [],
  415. //状态
  416. statusOptions:[],
  417. //客户等级
  418. ratingType: [],
  419. // 来源字典
  420. addWayOptions: [],
  421. //转接状态
  422. transferStatusOptions:[],
  423. // 选中数组
  424. ids: [],
  425. // 非单个禁用
  426. single: true,
  427. // 非多个禁用
  428. multiple: true,
  429. // 显示搜索条件
  430. showSearch: true,
  431. // 总条数
  432. total: 0,
  433. // 企业微信客户表格数据
  434. externalContactList: [],
  435. //销售员工数据
  436. companyUserNameList:[],
  437. //企微用户信息数据
  438. qwUserList:[],
  439. // 弹出层标题
  440. title: "",
  441. // 是否显示弹出层
  442. open: false,
  443. //标签
  444. tagGroupList: [],
  445. // 查询参数
  446. queryParams: {
  447. companyUser:null,
  448. pageNum: 1,
  449. pageSize: 10,
  450. qwUserName:null,
  451. userId: null,
  452. externalUserId: null,
  453. name: null,
  454. avatar: null,
  455. type: null,
  456. gender: null,
  457. description: null,
  458. tagIds: null,
  459. remarkMobiles: null,
  460. remarkCorpName: null,
  461. addWay: null,
  462. operUserid: null,
  463. corpId: null,
  464. companyId: null,
  465. companyUserId: null,
  466. qwUserId: null,
  467. customerId: null,
  468. transferStatus: null,
  469. status: null,
  470. stageStatus: null,
  471. transferTime: null,
  472. transferNum: null,
  473. lossTime: null,
  474. delTime: null,
  475. state: null,
  476. wayId: null,
  477. fsUserId: null,
  478. openId: null,
  479. unionid: null,
  480. uploadAddWxStatus: null,
  481. uploadRegisterStatus: null,
  482. uploadFinishedStatus: null,
  483. welcomeStatus: null,
  484. isInteract: null,
  485. level: null,
  486. companyUserName:null,
  487. levelType: null,
  488. firstTime: null,
  489. lastWatchTime: null,
  490. isRepeat: null,
  491. commentStatus: null,
  492. isBindMini:null,
  493. },
  494. //标签
  495. changeTagDialog:{
  496. title:"",
  497. open:false,
  498. },
  499. selectTags:[],
  500. tagTotal:0,
  501. queryTagParams:{
  502. pageNum: 1,
  503. pageSize: 10,
  504. total:0,
  505. name:null,
  506. corpId:null,
  507. },
  508. isBindMiniOptions:[
  509. {dictLabel:"已绑定",dictValue:'isBindMini'},
  510. {dictLabel:"未绑定",dictValue:'noBindMini'},
  511. ],
  512. qwCompanyList:[],
  513. // 表单参数
  514. form: {},
  515. // 表单校验
  516. rules: {
  517. }
  518. };
  519. },
  520. created() {
  521. //用户类别
  522. this.getDicts("sys_qw_externalContact_type").then(response => {
  523. this.typeOptions = response.data;
  524. });
  525. //客户等级
  526. this.getDicts("sys_qw_sop_rating_type").then(response => {
  527. this.ratingType = response.data;
  528. });
  529. //等级状态
  530. this.getDicts("sys_qw_sop_rating_upFall").then(response => {
  531. this.ratingUpFall = response.data;
  532. });
  533. //性别
  534. this.getDicts("sys_sex").then(response => {
  535. this.genderOptions = response.data;
  536. });
  537. //状态
  538. this.getDicts("sys_qw_external_contact_status").then(response => {
  539. this.statusOptions = response.data;
  540. });
  541. //来源
  542. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  543. this.addWayOptions = response.data;
  544. });
  545. //转接状态
  546. this.getDicts("sys_qw_transfer_status").then(response => {
  547. this.transferStatusOptions = response.data;
  548. });
  549. //获取企业
  550. getCompanyList().then(response => {
  551. this.qwCompanyList = response.data;
  552. if(this.qwCompanyList!=null){
  553. this.queryParams.companyId=this.qwCompanyList[0].companyId;
  554. this.getAllUserlist(this.queryParams.companyId);
  555. }
  556. });
  557. },
  558. methods: {
  559. /** 获取销售账号列表 **/
  560. getAllUserlist(companyId){
  561. if(companyId){
  562. this.getList();
  563. getAllUserlist({companyId}).then(response => {
  564. this.companyUserNameList=response.data;
  565. });
  566. //企业微信
  567. getQwUserInfo({companyId}).then(response => {
  568. this.qwUserList=response.data;
  569. })
  570. }
  571. },
  572. tagSelection(row){
  573. row.isSelected= !row.isSelected;
  574. this.$forceUpdate();
  575. },
  576. /** 查询企业微信客户列表 */
  577. getList() {
  578. this.loading = true;
  579. listExternalContact(this.queryParams).then(response => {
  580. this.externalContactList = response.rows;
  581. this.total = response.total;
  582. this.loading = false;
  583. });
  584. },
  585. // 取消按钮
  586. cancel() {
  587. this.open = false;
  588. this.reset();
  589. },
  590. // 表单重置
  591. reset() {
  592. this.form = {
  593. id: null,
  594. userId: null,
  595. externalUserId: null,
  596. name: null,
  597. avatar: null,
  598. type: null,
  599. gender: null,
  600. remark: null,
  601. description: null,
  602. tagIds: null,
  603. remarkMobiles: null,
  604. remarkCorpName: null,
  605. addWay: null,
  606. operUserid: null,
  607. corpId: null,
  608. companyId: null,
  609. companyUserId: null,
  610. qwUserId: null,
  611. customerId: null,
  612. transferStatus: 0,
  613. status: 0,
  614. stageStatus: "0",
  615. createBy: null,
  616. createTime: null,
  617. updateBy: null,
  618. updateTime: null,
  619. transferTime: null,
  620. transferNum: null,
  621. lossTime: null,
  622. delTime: null,
  623. state: null,
  624. wayId: null,
  625. fsUserId: null,
  626. openId: null,
  627. unionid: null,
  628. uploadAddWxStatus: 0,
  629. uploadRegisterStatus: 0,
  630. uploadFinishedStatus: 0,
  631. welcomeStatus: 0,
  632. isInteract: null,
  633. level: null,
  634. levelType: null,
  635. firstTime: null,
  636. lastWatchTime: null,
  637. isRepeat: null,
  638. commentStatus: 0
  639. };
  640. this.resetForm("form");
  641. },
  642. change(){
  643. if(this.createTime!=null){
  644. this.queryParams.sTime=this.createTime[0];
  645. this.queryParams.eTime=this.createTime[1];
  646. }else{
  647. this.queryParams.sTime=null;
  648. this.queryParams.eTime=null;
  649. }
  650. },
  651. /** 搜索按钮操作 */
  652. handleQuery() {
  653. //验证是否选择企业
  654. if(!this.queryParams.companyId){
  655. return this.$message.warning({
  656. message: "请先选择企业!",
  657. duration: 3000
  658. })
  659. }
  660. if (this.selectTags!=null && this.selectTags.length>0){
  661. // 确保 this.form.tags 是数组
  662. if (!this.queryParams.tagIds) {
  663. this.queryParams.tagIds = []; // 如果未定义,初始化
  664. } else {
  665. this.queryParams.tagIds = []; // 清空已有数据
  666. }
  667. // 遍历并添加 tagId
  668. this.selectTags.forEach(tag => {
  669. if (tag.tagId) { // 确保 tagId 存在
  670. this.queryParams.tagIds.push(tag.tagId);
  671. }
  672. });
  673. this.queryParams.tagIds=this.queryParams.tagIds.join(",");
  674. }else {
  675. this.queryParams.tagIds=null;
  676. }
  677. this.queryParams.pageNum = 1;
  678. this.getList();
  679. },
  680. /** 重置按钮操作 */
  681. resetQuery() {
  682. this.resetForm("queryForm");
  683. this.queryParams.corpId= this.qwCompanyList[0].dictValue;
  684. this.selectTags=[];
  685. this.queryParams.qwUserId = null;
  686. this.createTime=null;
  687. this.queryParams.sTime=null;
  688. this.queryParams.eTime=null;
  689. this.externalContactList=[];
  690. if(this.qwCompanyList!=null){
  691. this.queryParams.companyId=this.qwCompanyList[0].companyId;
  692. this.getAllUserlist(this.queryParams.companyId);
  693. }
  694. },
  695. handleSearchTags(name){
  696. searchTags({name:name,corpId:this.queryParams.corpId}).then(response => {
  697. this.tagGroupList = response.rows;
  698. });
  699. },
  700. cancelSearchTags(){
  701. this.resetSearchQueryTag()
  702. this.getPageListTagGroup();
  703. },
  704. resetSearchQueryTag(){
  705. this.queryTagParams= {
  706. pageNum: 1,
  707. pageSize: 10,
  708. total:0,
  709. name:null,
  710. };
  711. },
  712. //确定选择标签
  713. tagSubmitForm(){
  714. for (let i = 0; i < this.tagGroupList.length; i++) {
  715. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  716. if (this.tagGroupList[i].tag[x].isSelected === true) {
  717. if (!this.selectTags) {
  718. this.selectTags = [];
  719. }
  720. // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
  721. let tagExists = this.selectTags.some(
  722. tag => tag.id === this.tagGroupList[i].tag[x].id
  723. );
  724. // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
  725. if (!tagExists) {
  726. this.selectTags.push(this.tagGroupList[i].tag[x]);
  727. }
  728. }
  729. }
  730. }
  731. if (!this.selectTags || this.selectTags.length === 0) {
  732. return this.$message('请选择标签');
  733. }
  734. this.changeTagDialog.open = false;
  735. },
  736. getPageListTagGroup(){
  737. this.queryTagParams.corpId=this.queryParams.corpId
  738. allListTagGroup(this.queryTagParams).then(response => {
  739. this.tagGroupList = response.rows;
  740. this.tagTotal = response.total;
  741. });
  742. },
  743. //取消选择标签
  744. tagCancel(){
  745. this.changeTagDialog.open = false;
  746. },
  747. //删除一些选择的标签
  748. handleCloseTags(list){
  749. const ls = this.selectTags.findIndex(t => t.tagId === list.tagId);
  750. if (ls !== -1) {
  751. this.selectTags.splice(ls, 1);
  752. this.selectTags = [...this.selectTags];
  753. }
  754. if (this.selectTags!=null && this.selectTags.length>0){
  755. // 确保 this.form.tags 是数组
  756. if (!this.queryParams.tagIds) {
  757. this.queryParams.tagIds = []; // 如果未定义,初始化
  758. } else {
  759. this.queryParams.tagIds = []; // 清空已有数据
  760. }
  761. // 遍历并添加 tagId
  762. this.selectTags.forEach(tag => {
  763. if (tag.tagId) { // 确保 tagId 存在
  764. this.queryParams.tagIds.push(tag.tagId);
  765. }
  766. });
  767. this.queryParams.tagIds=this.queryParams.tagIds.join(",");
  768. }else {
  769. this.queryParams.tagIds=null;
  770. }
  771. },
  772. //搜索的标签
  773. hangleChangeTags(){
  774. this.changeTagDialog.title="搜索的标签"
  775. this.changeTagDialog.open=true;
  776. // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
  777. const selectedTagIds = new Set(
  778. (this.selectTags || []).map(tagItem => tagItem?.tagId)
  779. );
  780. this.queryTagParams.name=null;
  781. this.getPageListTagGroup();
  782. setTimeout(() => {
  783. for (let i = 0; i < this.tagGroupList.length; i++) {
  784. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  785. this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(this.tagGroupList[i].tag[x].tagId);
  786. }
  787. }
  788. }, 200);
  789. },
  790. // 多选框选中数据
  791. handleSelectionChange(selection) {
  792. this.ids = selection.map(item => item.id)
  793. this.single = selection.length!==1
  794. this.multiple = !selection.length
  795. },
  796. /** 新增按钮操作 */
  797. handleAdd() {
  798. this.reset();
  799. this.open = true;
  800. this.title = "添加企业微信客户";
  801. },
  802. /** 修改按钮操作 */
  803. handleUpdate(row) {
  804. this.reset();
  805. const id = row.id || this.ids
  806. getExternalContact(id).then(response => {
  807. this.form = response.data;
  808. this.open = true;
  809. this.title = "修改企业微信客户";
  810. });
  811. },
  812. /** 提交按钮 */
  813. submitForm() {
  814. this.$refs["form"].validate(valid => {
  815. if (valid) {
  816. if (this.form.id != null) {
  817. updateExternalContact(this.form).then(response => {
  818. this.msgSuccess("修改成功");
  819. this.open = false;
  820. this.getList();
  821. });
  822. } else {
  823. addExternalContact(this.form).then(response => {
  824. this.msgSuccess("新增成功");
  825. this.open = false;
  826. this.getList();
  827. });
  828. }
  829. }
  830. });
  831. },
  832. /** 删除按钮操作 */
  833. handleDelete(row) {
  834. const ids = row.id || this.ids;
  835. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  836. confirmButtonText: "确定",
  837. cancelButtonText: "取消",
  838. type: "warning"
  839. }).then(function() {
  840. return delExternalContact(ids);
  841. }).then(() => {
  842. this.getList();
  843. this.msgSuccess("删除成功");
  844. }).catch(() => {});
  845. },
  846. /** 导出按钮操作 */
  847. handleExport() {
  848. //验证是否选择企业
  849. if(!this.queryParams.companyId){
  850. return this.$message.warning({
  851. message: "请先选择企业!",
  852. duration: 3000
  853. })
  854. }
  855. const queryParams = this.queryParams;
  856. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  857. confirmButtonText: "确定",
  858. cancelButtonText: "取消",
  859. type: "warning"
  860. }).then(() => {
  861. this.exportLoading = true;
  862. return exportExternalContact(queryParams);
  863. }).then(response => {
  864. this.download(response.msg);
  865. this.exportLoading = false;
  866. }).catch(() => {});
  867. },
  868. /** 导出Unionid按钮操作 */
  869. handleExportUnionId() {
  870. //验证是否选择企业
  871. if(!this.queryParams.companyId){
  872. return this.$message.warning({
  873. message: "请先选择企业!",
  874. duration: 3000
  875. })
  876. }
  877. const queryParams = this.queryParams;
  878. this.$confirm('是否确认导出所有企业微信客户unionid数据项?', "警告", {
  879. confirmButtonText: "确定",
  880. cancelButtonText: "取消",
  881. type: "warning"
  882. }).then(() => {
  883. this.exportUnionidLoading = true;
  884. return exportUnionId(queryParams);
  885. }).then(response => {
  886. this.download(response.msg);
  887. this.exportUnionidLoading = false;
  888. }).catch(() => {});
  889. },
  890. }
  891. };
  892. </script>
  893. <style scoped>
  894. /* CSS 样式 */
  895. .tag-container {
  896. display: flex;
  897. flex-wrap: wrap; /* 超出宽度时自动换行 */
  898. gap: 8px; /* 设置标签之间的间距 */
  899. }
  900. .name-background {
  901. display: inline-block;
  902. background-color: #abece6; /* 背景颜色 */
  903. padding: 4px 8px; /* 调整内边距,让背景包裹文字 */
  904. border-radius: 4px; /* 可选:设置圆角 */
  905. }
  906. /* CSS 样式 */
  907. .tag-container {
  908. display: flex;
  909. flex-wrap: wrap; /* 超出宽度时自动换行 */
  910. gap: 8px; /* 设置标签之间的间距 */
  911. }
  912. .name-background {
  913. display: inline-block;
  914. background-color: #abece6; /* 背景颜色 */
  915. padding: 4px 8px; /* 调整内边距,让背景包裹文字 */
  916. border-radius: 4px; /* 可选:设置圆角 */
  917. }
  918. .tag-box {
  919. padding: 8px 12px;
  920. border: 1px solid #989797;
  921. border-radius: 4px;
  922. cursor: pointer;
  923. display: inline-block;
  924. }
  925. .tag-selected {
  926. background-color: #00bc98;
  927. color: #fff;
  928. border-color: #00bc98;
  929. }
  930. .el-tag + .el-tag {
  931. margin-left: 10px;
  932. }
  933. .button-new-tag {
  934. margin-left: 10px;
  935. height: 32px;
  936. line-height: 30px;
  937. padding-top: 0;
  938. padding-bottom: 0;
  939. }
  940. .input-new-tag {
  941. width: 90px;
  942. margin-left: 10px;
  943. vertical-align: bottom;
  944. }
  945. </style>