myExternalContact.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="企微账号" prop="qwUserId">
  5. <el-select v-model="queryParams.qwUserId" placeholder="企微账号" size="small" @change="updateQwuser()">
  6. <el-option
  7. v-for="dict in myQwUserList"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel+'('+dict.corpName+')'"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="客户名称" prop="name">
  15. <el-input
  16. v-model="queryParams.name"
  17. placeholder="请输入客户名称"
  18. clearable
  19. size="small"
  20. @keyup.enter.native="handleQuery"
  21. />
  22. </el-form-item>
  23. <el-form-item label="用户类别" prop="type">
  24. <el-select v-model="queryParams.type" placeholder="请选择用户类别" clearable size="small">
  25. <el-option
  26. v-for="dict in typeOptions"
  27. :key="dict.dictValue"
  28. :label="dict.dictLabel"
  29. :value="dict.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="性别" prop="gender">
  34. <el-select v-model="queryParams.gender" placeholder="状态" clearable size="small">
  35. <el-option
  36. v-for="dict in genderOptions"
  37. :key="dict.dictValue"
  38. :label="dict.dictLabel"
  39. :value="dict.dictValue"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="电话号码" prop="remarkMobiles">
  44. <el-input
  45. v-model="queryParams.remarkMobiles"
  46. placeholder="请输入备注电话号码"
  47. clearable
  48. size="small"
  49. @keyup.enter.native="handleQuery"
  50. />
  51. </el-form-item>
  52. <el-form-item label="来源" prop="addWay">
  53. <el-select v-model="queryParams.addWay" placeholder="来源" clearable size="small">
  54. <el-option
  55. v-for="dict in addWayOptions"
  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="status">
  63. <el-select v-model="queryParams.status" placeholder="状态" clearable size="small">
  64. <el-option
  65. v-for="dict in statusOptions"
  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="addWay">
  93. <el-select v-model="queryParams.transferStatus" placeholder="转接状态" clearable size="small">
  94. <el-option
  95. v-for="dict in transferStatusOptions"
  96. :key="dict.dictValue"
  97. :label="dict.dictLabel"
  98. :value="dict.dictValue"
  99. />
  100. </el-select>
  101. </el-form-item>
  102. <el-form-item label="是否绑定会员" prop="isBindMini">
  103. <el-select v-model="queryParams.isBindMini" placeholder="是否绑定会员" clearable size="small" @change="handleQuery" >
  104. <el-option
  105. v-for="dict in isBindMiniOptions"
  106. :key="dict.dictValue"
  107. :label="dict.dictLabel"
  108. :value="dict.dictValue"
  109. />
  110. </el-select>
  111. </el-form-item>
  112. <el-form-item label="标签" prop="tagIds">
  113. <!-- <el-select v-model="selectTags" remote multiple placeholder="请选择" filterable style="width: 100%;">-->
  114. <!-- <el-option-->
  115. <!-- v-for="dict in tagList"-->
  116. <!-- :label="dict.name"-->
  117. <!-- :value="dict.tagId">-->
  118. <!-- </el-option>-->
  119. <!-- </el-select>-->
  120. <div @click="hangleChangeTags()" style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 250px">
  121. <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
  122. <el-tag type="success"
  123. closable
  124. :disable-transitions="false"
  125. v-for="list in this.selectTags"
  126. :key="list.tagId"
  127. @close="handleCloseTags(list)"
  128. style="margin: 3px;"
  129. >{{list.name}}
  130. </el-tag>
  131. </div>
  132. </div>
  133. </el-form-item>
  134. <el-form-item label="备注" prop="remark">
  135. <el-input
  136. v-model="queryParams.remark"
  137. placeholder="请输入备注"
  138. clearable
  139. size="small"
  140. @keyup.enter.native="handleQuery"
  141. />
  142. </el-form-item>
  143. <el-form-item label="添加时间" prop="createTime">
  144. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  145. </el-form-item>
  146. <el-form-item label="流失时间" prop="lossTime">
  147. <el-date-picker clearable size="small"
  148. v-model="queryParams.lossTime"
  149. type="date"
  150. value-format="yyyy-MM-dd"
  151. placeholder="选择流失时间">
  152. </el-date-picker>
  153. </el-form-item>
  154. <el-form-item label="删除时间" prop="delTime">
  155. <el-date-picker clearable size="small"
  156. v-model="queryParams.delTime"
  157. type="date"
  158. value-format="yyyy-MM-dd"
  159. placeholder="选择删除时间">
  160. </el-date-picker>
  161. </el-form-item>
  162. <el-form-item>
  163. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  164. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  165. </el-form-item>
  166. </el-form>
  167. <el-row :gutter="10" class="mb8">
  168. <!-- <el-col :span="1.5">
  169. <el-button
  170. type="primary"
  171. plain
  172. icon="el-icon-plus"
  173. size="mini"
  174. @click="handleAdd"
  175. v-hasPermi="['qw:externalContact:add']"
  176. >同步</el-button>
  177. </el-col> -->
  178. <el-col :span="1.5">
  179. <el-button
  180. type="success"
  181. plain
  182. icon="el-icon-edit"
  183. size="mini"
  184. :disabled="single"
  185. @click="handleUpdate"
  186. v-hasPermi="['qw:externalContact:edit']"
  187. >修改备注</el-button>
  188. </el-col>
  189. <el-col :span="1.5">
  190. <el-button
  191. type="warning"
  192. plain
  193. icon="el-icon-download"
  194. size="mini"
  195. :loading="exportLoading"
  196. @click="handleSyncMyExternalContact"
  197. v-hasPermi="['qw:externalContact:export']"
  198. >同步我的客户</el-button>
  199. <el-button
  200. type="warning"
  201. plain
  202. icon="el-icon-download"
  203. size="mini"
  204. :loading="exportLoading"
  205. @click="handleSyncAddMyExternalContact"
  206. v-hasPermi="['qw:externalContact:export']"
  207. >新客同步</el-button>
  208. </el-col>
  209. <el-col :span="1.5">
  210. <el-button
  211. type="warning"
  212. plain
  213. icon="el-icon-download"
  214. size="mini"
  215. :loading="exportLoading"
  216. @click="handleExport"
  217. v-hasPermi="['qw:externalContact:export']"
  218. >导出</el-button>
  219. </el-col>
  220. <el-col :span="1.5">
  221. <el-button
  222. type="primary"
  223. plain
  224. size="mini"
  225. @click="addUserTag"
  226. v-hasPermi="['qw:externalContact:addTag']"
  227. >批量添加标签</el-button>
  228. </el-col>
  229. <el-col :span="1.5">
  230. <el-button
  231. type="primary"
  232. plain
  233. size="mini"
  234. @click="delUserTag"
  235. v-hasPermi="['qw:externalContact:delTag']"
  236. >批量移除标签</el-button>
  237. </el-col>
  238. <el-col :span="1.5">
  239. <el-button
  240. type="primary"
  241. plain
  242. size="mini"
  243. @click="updateTalk"
  244. >批量更改交流状态</el-button>
  245. </el-col>
  246. <el-col :span="1.5">
  247. <el-button
  248. type="primary"
  249. plain
  250. size="mini"
  251. @click="updateAllTalk"
  252. >更改全部交流状态</el-button>
  253. </el-col>
  254. <!-- <el-col :span="1.5">-->
  255. <!-- <el-button-->
  256. <!-- type="primary"-->
  257. <!-- plain-->
  258. <!-- size="mini"-->
  259. <!-- @click="setUserCourseSop"-->
  260. <!-- v-hasPermi="['qw:externalContact:setCourseSop']"-->
  261. <!-- >批量设置SOP</el-button>-->
  262. <!-- </el-col>-->
  263. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  264. </el-row>
  265. <!-- <el-tabs type="card" v-model="isBindActiveName" @tab-click="handleClickX">-->
  266. <!-- <el-tab-pane label="全部" name="all"></el-tab-pane>-->
  267. <!-- <el-tab-pane label="已绑定CRM" name="isBind"></el-tab-pane>-->
  268. <!-- <el-tab-pane label="未绑定CRM" name="noBind"></el-tab-pane>-->
  269. <!-- </el-tabs>-->
  270. <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
  271. <el-table-column type="selection" width="55" align="center" />
  272. <el-table-column label="企微客户ID" align="center" prop="id"/>
  273. <el-table-column label="企微客户头像" align="center" prop="avatar" width="100px">
  274. <template slot-scope="scope">
  275. <el-popover
  276. placement="right"
  277. title=""
  278. trigger="hover">
  279. <img slot="reference" :src="scope.row.avatar" width="60px">
  280. <img :src="scope.row.avatar" style="max-width: 200px;">
  281. </el-popover>
  282. </template>
  283. </el-table-column>
  284. <el-table-column label="企微客户名称" prop="name" width="110px"/>
  285. <el-table-column label="客户称呼" prop="stageStatus" width="110px"/>
  286. <el-table-column label="销售企微昵称" align="center" prop="qwUserName" width="120px"/>
  287. <el-table-column label="企微部门" align="center" prop="departmentName" width="120px"/>
  288. <el-table-column label="用户类别" align="center" prop="type">
  289. <template slot-scope="scope">
  290. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  291. </template>
  292. </el-table-column>
  293. <el-table-column label="性别" align="center" prop="gender">
  294. <template slot-scope="scope">
  295. <dict-tag :options="genderOptions" :value="scope.row.gender"/>
  296. </template>
  297. </el-table-column>
  298. <el-table-column label="备注" align="center" prop="remark" />
  299. <el-table-column label="描述信息" align="center" prop="description" />
  300. <el-table-column label="标签" align="center" prop="tagIdsName" width="250px">
  301. <template slot-scope="scope">
  302. <div v-for="name in scope.row.tagIdsName" style="display: inline;">
  303. <el-tag type="success">{{ name }}</el-tag>
  304. </div>
  305. </template>
  306. </el-table-column>
  307. <el-table-column label="状态" align="center" prop="status" width="120px" >
  308. <template slot-scope="scope">
  309. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="客户等级" align="center" prop="level" width="120px" >
  313. <template slot-scope="scope">
  314. <dict-tag :options="ratingType" :value="scope.row.level"/>
  315. </template>
  316. </el-table-column>
  317. <el-table-column label="等级状态" align="center" prop="levelType" width="120px" >
  318. <template slot-scope="scope">
  319. <dict-tag :options="ratingUpFall" :value="scope.row.levelType"/>
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="添加时间" align="center" prop="createTime" width="100px" />
  323. <el-table-column label="流失时间" align="center" prop="lossTime" width="100px" />
  324. <el-table-column label="删除时间" align="center" prop="delTime" width="100px" />
  325. <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
  326. <template slot-scope="scope">
  327. <div v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</div>
  328. </template>
  329. </el-table-column>
  330. <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
  331. <el-table-column label="来源" align="center" prop="addWay" width="100px">
  332. <template slot-scope="scope">
  333. <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
  334. </template>
  335. </el-table-column>
  336. <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px" >
  337. <template slot-scope="scope">
  338. <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
  339. </template>
  340. </el-table-column>
  341. <el-table-column label="企业id" align="center" prop="corpId" />
  342. <el-table-column label="是否绑定会员" width="100px" align="center" fixed="right">
  343. <template slot-scope="scope">
  344. <el-tag v-if="scope.row.fsUserId" >已绑定</el-tag>
  345. <el-tag v-else type="info"> 未绑定</el-tag>
  346. </template>
  347. </el-table-column>
  348. <el-table-column label="修改" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
  349. <template slot-scope="scope">
  350. <el-button
  351. v-show="scope.row.status==0||scope.row.status==2"
  352. size="mini"
  353. type="text"
  354. icon="el-icon-edit"
  355. @click="handleUpdate(scope.row)"
  356. v-hasPermi="['qw:externalContact:edit']"
  357. >修改备注</el-button>
  358. <el-button
  359. size="mini"
  360. type="text"
  361. icon="el-icon-user-solid"
  362. @click="handleAppellation(scope.row)"
  363. >修改客户称呼</el-button>
  364. </template>
  365. </el-table-column>
  366. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
  367. <template slot-scope="scope">
  368. <!-- <el-button-->
  369. <!-- size="mini"-->
  370. <!-- type="text"-->
  371. <!-- icon="el-icon-edit-outline"-->
  372. <!-- @click="handleUpdateCustomer(scope.row)"-->
  373. <!-- >-->
  374. <!-- <span v-if="scope.row.customerId">换绑CRM</span>-->
  375. <!-- <span v-else>绑定CRM</span>-->
  376. <!-- </el-button>-->
  377. <el-button
  378. size="mini"
  379. type="text"
  380. icon="el-icon-edit-outline"
  381. @click="handleUpdateUser(scope.row)"
  382. >
  383. <span v-if="scope.row.fsUserId">换绑会员</span>
  384. <span v-else>绑定会员</span>
  385. </el-button>
  386. <el-button v-show="scope.row.fsUserId"
  387. size="mini"
  388. type="text"
  389. icon="el-icon-thumb"
  390. @click="handleUnBindUserId(scope.row)"
  391. v-hasPermi="['qw:externalContact:unBindUserId']"
  392. >
  393. <span>解除会员绑定</span>
  394. </el-button>
  395. <!-- <el-button v-if="scope.row.customerId"-->
  396. <!-- size="mini"-->
  397. <!-- type="text"-->
  398. <!-- icon="el-icon-paperclip"-->
  399. <!-- @click="handleShow(scope.row)"-->
  400. <!-- >CRM客户详情</el-button>-->
  401. <el-button
  402. size="mini"
  403. type="text"
  404. @click="handledetails(scope.row)"
  405. >用户信息
  406. </el-button>
  407. <!-- <el-button v-if="scope.row.customerId"
  408. size="mini"
  409. type="text"
  410. icon="el-icon-setting"
  411. @click="setCourseSOP(scope.row)"
  412. >设置课程SOP</el-button> -->
  413. </template>
  414. </el-table-column>
  415. </el-table>
  416. <pagination-more
  417. v-show="total>0"
  418. :total="total"
  419. :page.sync="queryParams.pageNum"
  420. :limit.sync="queryParams.pageSize"
  421. @pagination="getList"
  422. />
  423. <el-drawer size="75%" :title="show.title" :visible.sync="show.open">
  424. <customer-details ref="customerDetails" @refreshList="refreshList"/>
  425. </el-drawer>
  426. <!-- 搜索标签 -->
  427. <el-dialog :title="changeTagDialog.title" :visible.sync="changeTagDialog.open" style="width:100%;height: 100%" append-to-body>
  428. <div>搜索标签:
  429. <el-input v-model="queryTagParams.name" placeholder="请输入标签名称" clearable size="small" style="width: 200px;margin-right: 10px" />
  430. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags(queryTagParams.name)">搜索</el-button>
  431. <el-button type="primary" icon="el-icon-plus" size="mini" @click="cancelSearchTags">重置</el-button>
  432. </div>
  433. <div v-for="item in tagGroupList" :key="item.id" >
  434. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  435. <span class="name-background">{{ item.name }}</span>
  436. </div>
  437. <div class="tag-container">
  438. <a
  439. v-for="tagItem in item.tag"
  440. class="tag-box"
  441. @click="tagSelection(tagItem)"
  442. :class="{ 'tag-selected': tagItem.isSelected }"
  443. >
  444. {{ tagItem.name }}
  445. </a>
  446. </div>
  447. </div>
  448. <pagination
  449. v-show="tagTotal>0"
  450. :total="tagTotal"
  451. :page.sync="queryTagParams.pageNum"
  452. :limit.sync="queryTagParams.pageSize"
  453. @pagination="getPageListTagGroup"
  454. />
  455. <div slot="footer" class="dialog-footer">
  456. <el-button type="primary" @click="tagSubmitForm()">确 定</el-button>
  457. <el-button @click="tagCancel()">取消</el-button>
  458. </div>
  459. </el-dialog>
  460. <el-dialog title="批量添加标签" :visible.sync="tagOpen" width="800px" append-to-body>
  461. <div>搜索标签:
  462. <el-input v-model="tagChange.tagName" placeholder="请输入标签名称" clearable size="small" style="width: 200px;margin-right: 10px" />
  463. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags(tagChange.tagName)">搜索</el-button>
  464. <el-button type="primary" icon="el-icon-plus" size="mini" @click="cancelSearchTags">重置</el-button>
  465. </div>
  466. <el-form ref="form" :model="addTagForm" label-width="80px">
  467. <div v-for="item in tagGroupList" :key="item.id" >
  468. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  469. <span class="name-background">{{ item.name }}</span>
  470. </div>
  471. <div class="tag-container">
  472. <a
  473. v-for="tagItem in item.tag"
  474. class="tag-box"
  475. @click="tagSelection(tagItem)"
  476. :class="{ 'tag-selected': tagItem.isSelected }"
  477. >
  478. {{ tagItem.name }}
  479. </a>
  480. </div>
  481. </div>
  482. </el-form>
  483. <pagination
  484. v-show="tagTotal>0"
  485. :total="tagTotal"
  486. :page.sync="queryTagParams.pageNum"
  487. :limit.sync="queryTagParams.pageSize"
  488. @pagination="getPageListTagGroup"
  489. />
  490. <div slot="footer" class="dialog-footer">
  491. <el-button type="primary" @click="addTagSubmitForm()">确 定</el-button>
  492. <el-button @click="addTagCancel">取 消</el-button>
  493. </div>
  494. </el-dialog>
  495. <el-dialog title="批量移除标签" :visible.sync="tagDelOpen" width="800px" append-to-body>
  496. <div>搜索标签:
  497. <el-input v-model="tagChange.tagName" placeholder="请输入标签名称" clearable size="small" style="width: 200px;margin-right: 10px" />
  498. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags(tagChange.tagName)">搜索</el-button>
  499. <el-button type="primary" icon="el-icon-plus" size="mini" @click="cancelSearchTags">重置</el-button>
  500. </div>
  501. <el-form ref="form" :model="addTagForm" label-width="80px">
  502. <div v-for="item in tagGroupList" :key="item.id" >
  503. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  504. <span class="name-background">{{ item.name }}</span>
  505. </div>
  506. <div class="tag-container">
  507. <a
  508. v-for="tagItem in item.tag"
  509. class="tag-box"
  510. @click="tagSelection(tagItem)"
  511. :class="{ 'tag-selected': tagItem.isSelected }"
  512. >
  513. {{ tagItem.name }}
  514. </a>
  515. </div>
  516. </div>
  517. </el-form>
  518. <pagination
  519. v-show="tagTotal>0"
  520. :total="tagTotal"
  521. :page.sync="queryTagParams.pageNum"
  522. :limit.sync="queryTagParams.pageSize"
  523. @pagination="getPageListTagGroup"
  524. />
  525. <div slot="footer" class="dialog-footer">
  526. <el-button type="primary" @click="tagDelSubmitForm()">确 定</el-button>
  527. <el-button @click="DelTagCancel">取 消</el-button>
  528. </div>
  529. </el-dialog>
  530. <!-- 添加或修改企业微信客户对话框 -->
  531. <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
  532. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  533. <el-form-item label="备注" prop="remark">
  534. <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
  535. </el-form-item>
  536. <el-form-item label="描述信息" prop="description">
  537. <el-input v-model="form.description" type="textarea" :rows="3" placeholder="请输入描述信息" />
  538. </el-form-item>
  539. <el-form-item label="备注电话号码" prop="remarkMobiles">
  540. <el-tag
  541. :key="tag"
  542. v-for="tag in remarkMobiles"
  543. closable
  544. :disable-transitions="false"
  545. @close="handleClose(tag)">
  546. {{tag}}
  547. </el-tag>
  548. <el-input
  549. style="width:110px"
  550. class="input-new-tag"
  551. v-if="inputVisible"
  552. v-model="inputValue"
  553. ref="saveTagInput"
  554. size="small"
  555. @keyup.enter.native="handleInputConfirm"
  556. @blur="handleInputConfirm"
  557. >
  558. </el-input>
  559. <el-button v-else class="button-new-tag" size="small" style="width: 110px" @click="showInput">新增电话</el-button>
  560. </el-form-item>
  561. <el-form-item label="备注企业名称" prop="remarkCorpName">
  562. <el-input v-model="form.remarkCorpName" placeholder="请输入备注企业名称" />
  563. </el-form-item>
  564. </el-form>
  565. <div slot="footer" class="dialog-footer">
  566. <el-button type="primary" @click="submitForm">确 定</el-button>
  567. <el-button @click="cancel">取 消</el-button>
  568. </div>
  569. </el-dialog>
  570. <el-dialog :title="callOpen.title" :visible.sync="callOpen.open" width="500px" append-to-body>
  571. <el-form ref="callOpenFrom" :model="callOpenFrom" :rules="callOpenRule" label-width="110px">
  572. <el-form-item label="客户称呼" prop="stageStatus">
  573. <el-input v-model="callOpenFrom.stageStatus" placeholder="请输入客户称呼" />
  574. </el-form-item>
  575. </el-form>
  576. <div slot="footer" class="dialog-footer" >
  577. <el-button type="primary" @click="submitCallOpenFrom">确 定</el-button>
  578. </div>
  579. </el-dialog>
  580. <!-- 绑定客户 -->
  581. <el-dialog :title="bindCustomer.title" :visible.sync="bindCustomer.open" width="1200px" append-to-body>
  582. <mycustomer ref="mycustomer" @bindCustomerId="bindCustomerId"></mycustomer>
  583. </el-dialog>
  584. <!-- 设置一个课程sop-->
  585. <el-dialog :title="setSop.title" :visible.sync="setSop.open" width="1200px" append-to-body>
  586. <SopDialog ref="SopDialog" @bindCourseSop="bindCourseSop"></SopDialog>
  587. </el-dialog>
  588. <el-drawer
  589. :with-header="false"
  590. size="75%"
  591. :title="show.title" :visible.sync="show.open">
  592. <info ref="Details" />
  593. </el-drawer>
  594. <el-dialog :title="user.title" :visible.sync="user.open" width="800px" append-to-body>
  595. <selectUser ref="selectUser" @bindMiniCustomerId="bindMiniCustomerId"></selectUser>
  596. </el-dialog>
  597. </div>
  598. </template>
  599. <script>
  600. import {
  601. myList,
  602. bindUserId,
  603. addTag,
  604. delTag,
  605. listExternalContact,
  606. getExternalContact,
  607. delExternalContact,
  608. addExternalContact,
  609. updateExternalContact,
  610. exportExternalContact,
  611. editbindCustomer,
  612. syncMyAddExternalContact,
  613. setCustomerCourseSop,
  614. getCustomerCourseSop,
  615. setCustomerCourseSopList,
  616. syncMyExternalContact, unBindUserId, updateExternalContactCall
  617. } from '@/api/qw/externalContact'
  618. import info from "@/views/qw/externalContact/info.vue";
  619. import {getMyQwUserList, getMyQwCompanyList, handleInputAuthAppKey, updateUser} from "@/api/qw/user";
  620. import {listTag, getTag, searchTags,} from "@/api/qw/tag";
  621. import { allListTagGroup} from "../../../api/qw/tagGroup";
  622. import mycustomer from '@/views/qw/externalContact/mycustomer'
  623. import customerDetails from '@/views/qw/externalContact/customerDetails'
  624. import SopDialog from '@/views/course/sop/SopDialog.vue'
  625. import selectUser from "@/views/qw/externalContact/selectUser.vue";
  626. import { editTalk,editAllTalk } from "@/api/qw/externalContactInfo";
  627. import {createLinkUrl} from "@/api/course/sopCourseLink";
  628. export default {
  629. name: "ExternalContact",
  630. components:{mycustomer,customerDetails,SopDialog,selectUser,info},
  631. data() {
  632. return {
  633. user:{
  634. open:false,
  635. title:"修改客户"
  636. },
  637. userForm:{
  638. id:null,
  639. fsUserId:null,
  640. },
  641. myQwUserList:[],
  642. // 遮罩层
  643. loading: false,
  644. // 导出遮罩层
  645. exportLoading: false,
  646. tagOpen:false,
  647. tagDelOpen:false,
  648. sTime:null,
  649. eTime:null,
  650. createTime:null,
  651. // 选中数组
  652. ids: [],
  653. isBindMiniOptions:[
  654. {dictLabel:"已绑定",dictValue:'isBindMini'},
  655. {dictLabel:"未绑定",dictValue:'noBindMini'},
  656. ],
  657. isBindActiveName:"all",
  658. remarkMobiles: [],
  659. inputVisible: false,
  660. inputValue: '',
  661. // 非单个禁用
  662. single: true,
  663. tagGroupList: [],
  664. //标签弹窗选择
  665. tagChange:{
  666. open:false,
  667. index:null,
  668. },
  669. // 非多个禁用
  670. multiple: true,
  671. // 显示搜索条件
  672. showSearch: true,
  673. // 总条数
  674. total: 0,
  675. // 企业微信客户表格数据
  676. externalContactList: [],
  677. // 弹出层标题
  678. title: "",
  679. // 是否显示弹出层
  680. open: false,
  681. // 用户类别字典
  682. typeOptions: [],
  683. ratingType: [],
  684. ratingUpFall: [],
  685. // 性别字典
  686. genderOptions: [],
  687. addTagForm:{
  688. userIds:[],
  689. tagIds:[]
  690. },
  691. myQwCompanyList:[],
  692. // show:{
  693. // title:"客户详情",
  694. // open:false,
  695. // },
  696. //存储选择的客户
  697. chooseCustomerSOP:null,
  698. setSop:{
  699. title:"选择课节SOP",
  700. open:false,
  701. //区分单选1还是多选2
  702. type:null,
  703. },
  704. //合成的客户-课节SOP参数
  705. customerCourseForm:{},
  706. //查询是否已经设置过客户-某个课节的SOP
  707. customerCourseFormLogs:{},
  708. //绑定客户
  709. bindCustomer:{
  710. title:null,
  711. open:false,
  712. },
  713. callOpen:{
  714. open:false,
  715. title: '修改客户称呼',
  716. },
  717. callOpenFrom:{
  718. id:null,
  719. stageStatus:null,
  720. },
  721. callOpenRule:{
  722. stageStatus:[{required:true,message:"员工称呼不能为空",trigger:"blur"}]
  723. },
  724. //绑定的参数表
  725. qwFormCustomer:{
  726. externalContactId:null,
  727. customerId:null,
  728. },
  729. show:{
  730. title:"用户信息",
  731. open:false,
  732. },
  733. // 来源字典
  734. addWayOptions: [],
  735. // 查询参数
  736. queryParams: {
  737. pageNum: 1,
  738. pageSize: 10,
  739. userId: null,
  740. qwUserName:null,
  741. externalUserId: null,
  742. name: null,
  743. avatar: null,
  744. type: null,
  745. qwUserId:null,
  746. gender: null,
  747. description: null,
  748. tagIds: null,
  749. remark:null,
  750. remarkMobiles: null,
  751. remarkCorpName: null,
  752. addWay: null,
  753. operUserid: null,
  754. corpId: null,
  755. companyId: null,
  756. status:null,
  757. transferStatus:null,
  758. isBind:null,
  759. isBindMini:null,
  760. lossTime:null,
  761. createTime:null,
  762. level:null,
  763. levelType:null
  764. },
  765. queryTagParams:{
  766. pageNum: 1,
  767. pageSize: 10,
  768. total:0,
  769. name:null,
  770. corpId:null,
  771. },
  772. tagTotal:0,
  773. //标签
  774. changeTagDialog:{
  775. title:"",
  776. open:false,
  777. },
  778. selectTags:[],
  779. // 表单参数
  780. form: {},
  781. tagList:[],
  782. transferStatusOptions:[],
  783. statusOptions:[],
  784. // 表单校验
  785. rules: {
  786. }
  787. };
  788. },
  789. created() {
  790. this.getDicts("sys_qw_externalContact_type").then(response => {
  791. this.typeOptions = response.data;
  792. });
  793. this.getDicts("sys_qw_sop_rating_type").then(response => {
  794. this.ratingType = response.data;
  795. });
  796. this.getDicts("sys_qw_sop_rating_upFall").then(response => {
  797. this.ratingUpFall = response.data;
  798. });
  799. this.handleGetMyQwUserList();
  800. this.getDicts("sys_sex").then(response => {
  801. this.genderOptions = response.data;
  802. });
  803. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  804. this.addWayOptions = response.data;
  805. });
  806. this.getDicts("sys_qw_external_contact_status").then(response => {
  807. this.statusOptions = response.data;
  808. });
  809. this.getDicts("sys_qw_transfer_status").then(response => {
  810. this.transferStatusOptions = response.data;
  811. });
  812. },
  813. methods: {
  814. change(){
  815. if(this.createTime!=null){
  816. this.queryParams.sTime=this.createTime[0];
  817. this.queryParams.eTime=this.createTime[1];
  818. }else{
  819. this.queryParams.sTime=null;
  820. this.queryParams.eTime=null;
  821. }
  822. },
  823. handledetails(row){
  824. this.show.open=true;
  825. setTimeout(() => {
  826. this.$refs.Details.getDetails(row.id);
  827. }, 1);
  828. },
  829. updateQwuser(){
  830. for (const user of this.myQwUserList) {
  831. if (user.dictValue == this.queryParams.qwUserId) {
  832. this.queryParams.corpId=user.corpId;
  833. break;
  834. }
  835. }
  836. var listTagFrom={corpId:this.queryParams.corpId}
  837. listTag(listTagFrom).then(response => {
  838. this.tagList = response.rows;
  839. });
  840. this.getList();
  841. },
  842. //搜索的标签
  843. hangleChangeTags(){
  844. this.changeTagDialog.title="搜索的标签"
  845. this.changeTagDialog.open=true;
  846. // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
  847. const selectedTagIds = new Set(
  848. (this.selectTags || []).map(tagItem => tagItem?.tagId)
  849. );
  850. this.queryTagParams.name=null;
  851. this.getPageListTagGroup();
  852. setTimeout(() => {
  853. for (let i = 0; i < this.tagGroupList.length; i++) {
  854. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  855. this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(this.tagGroupList[i].tag[x].tagId);
  856. }
  857. }
  858. }, 200);
  859. },
  860. //确定选择标签
  861. tagSubmitForm(){
  862. for (let i = 0; i < this.tagGroupList.length; i++) {
  863. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  864. if (this.tagGroupList[i].tag[x].isSelected === true) {
  865. if (!this.selectTags) {
  866. this.selectTags = [];
  867. }
  868. // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
  869. let tagExists = this.selectTags.some(
  870. tag => tag.id === this.tagGroupList[i].tag[x].id
  871. );
  872. // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
  873. if (!tagExists) {
  874. this.selectTags.push(this.tagGroupList[i].tag[x]);
  875. }
  876. }
  877. }
  878. }
  879. if (!this.selectTags || this.selectTags.length === 0) {
  880. return this.$message('请选择标签');
  881. }
  882. this.changeTagDialog.open = false;
  883. },
  884. //取消选择标签
  885. tagCancel(){
  886. this.changeTagDialog.open = false;
  887. },
  888. //删除一些选择的标签
  889. handleCloseTags(list){
  890. const ls = this.selectTags.findIndex(t => t.tagId === list.tagId);
  891. if (ls !== -1) {
  892. this.selectTags.splice(ls, 1);
  893. this.selectTags = [...this.selectTags];
  894. }
  895. if (this.selectTags!=null && this.selectTags.length>0){
  896. // 确保 this.form.tags 是数组
  897. if (!this.queryParams.tagIds) {
  898. this.queryParams.tagIds = []; // 如果未定义,初始化
  899. } else {
  900. this.queryParams.tagIds = []; // 清空已有数据
  901. }
  902. // 遍历并添加 tagId
  903. this.selectTags.forEach(tag => {
  904. if (tag.tagId) { // 确保 tagId 存在
  905. this.queryParams.tagIds.push(tag.tagId);
  906. }
  907. });
  908. this.queryParams.tagIds=this.queryParams.tagIds.join(",");
  909. }else {
  910. this.queryParams.tagIds=null;
  911. }
  912. },
  913. /** 查询企业微信客户列表 */
  914. getList() {
  915. this.loading = true;
  916. myList(this.queryParams).then(response => {
  917. this.externalContactList = response.rows;
  918. this.total = response.total;
  919. this.loading = false;
  920. });
  921. },
  922. getPageListTagGroup(){
  923. this.queryTagParams.corpId=this.queryParams.corpId
  924. allListTagGroup(this.queryTagParams).then(response => {
  925. this.tagGroupList = response.rows;
  926. this.tagTotal = response.total;
  927. });
  928. },
  929. handleSearchTags(name){
  930. searchTags({name:name,corpId:this.queryParams.corpId}).then(response => {
  931. this.tagGroupList = response.rows;
  932. });
  933. },
  934. handleGetMyQwUserList(){
  935. getMyQwUserList().then(response => {
  936. this.myQwUserList = response.data;
  937. if(this.myQwUserList!=null){
  938. this.queryParams.qwUserId=this.myQwUserList[0].dictValue
  939. this.queryParams.corpId=this.myQwUserList[0].corpId
  940. this.handleGetTagsList();
  941. this.getList();
  942. }
  943. });
  944. },
  945. cancelSearchTags(){
  946. this.resetSearchQueryTag()
  947. this.getPageListTagGroup();
  948. },
  949. resetSearchQueryTag(){
  950. this.queryTagParams= {
  951. pageNum: 1,
  952. pageSize: 10,
  953. total:0,
  954. name:null,
  955. };
  956. },
  957. handleGetTagsList(){
  958. var listTagFrom={corpId:this.queryParams.corpId}
  959. listTag(listTagFrom).then(response => {
  960. this.tagList = response.rows;
  961. });
  962. },
  963. bindMiniCustomerId(row){
  964. this.userForm.fsUserId=row;
  965. bindUserId(this.userForm).then(res=>{
  966. if (res.code==200){
  967. this.$message.success('绑定成功')
  968. }else {
  969. this.$message.error('绑定失败:',res.msg)
  970. }
  971. this.getList()
  972. this.user.open=false;
  973. })
  974. },
  975. /** 查看客户详情 */
  976. handleShow(row){
  977. this.show.open=true;
  978. var that=this;
  979. const tab = "visit";
  980. setTimeout(() => {
  981. that.$refs.customerDetails.getDetails(row.customerId);
  982. that.$refs.customerDetails.handleClick(tab);
  983. }, 200);
  984. },
  985. handleClickX(tab, event) {
  986. this.queryParams.isBind=tab.name;
  987. this.handleQuery();
  988. },
  989. handleClose(tag) {
  990. this.remarkMobiles.splice(this.remarkMobiles.indexOf(tag), 1);
  991. },
  992. showInput() {
  993. this.inputVisible = true;
  994. this.$nextTick(_ => {
  995. this.$refs.saveTagInput.$refs.input.focus();
  996. });
  997. },
  998. handleInputConfirm() {
  999. let inputValue = this.inputValue;
  1000. if (inputValue) {
  1001. this.remarkMobiles.push(inputValue);
  1002. }
  1003. this.inputVisible = false;
  1004. this.inputValue = '';
  1005. },
  1006. addUserTag(){
  1007. if(this.ids==null||this.ids==""){
  1008. return this.$message('请选择需要添加标签的客户');
  1009. }
  1010. this.getPageListTagGroup();
  1011. setTimeout(() => {
  1012. for (let i = 0; i < this.tagGroupList.length; i++) {
  1013. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  1014. this.tagGroupList[i].tag[x].isSelected=false;
  1015. }
  1016. }
  1017. }, 200);
  1018. this.tagOpen = true;
  1019. },
  1020. delUserTag(){
  1021. if(this.ids==null||this.ids==""){
  1022. return this.$message('请选择需要移除标签的客户');
  1023. }
  1024. this.getPageListTagGroup();
  1025. setTimeout(() => {
  1026. for (let i = 0; i < this.tagGroupList.length; i++) {
  1027. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  1028. this.tagGroupList[i].tag[x].isSelected=false;
  1029. }
  1030. }
  1031. }, 200);
  1032. this.tagDelOpen = true;
  1033. },
  1034. //重新获取页面数据
  1035. refreshList(){
  1036. this.getList();
  1037. },
  1038. //批量设置课程sop
  1039. setUserCourseSop(){
  1040. if(this.ids==null||this.ids==""){
  1041. return this.$message('请选择需要设置课程SOP的客户');
  1042. }
  1043. this.$confirm('批量设置客户课节SOP可能会存在重复,确定要批量设置吗?', "警告", {
  1044. confirmButtonText: "确定",
  1045. cancelButtonText: "取消",
  1046. type: "warning"
  1047. }).then(() => {
  1048. this.setSop.open = true;
  1049. this.setSop.type = 2;
  1050. })
  1051. .catch(() => {
  1052. // 可以处理用户点击“取消”的逻辑
  1053. });
  1054. },
  1055. tagSelection(row){
  1056. row.isSelected= !row.isSelected;
  1057. this.$forceUpdate();
  1058. },
  1059. // 取消按钮
  1060. cancel() {
  1061. this.open = false;
  1062. this.reset();
  1063. },
  1064. addTagCancel() {
  1065. this.tagOpen = false;
  1066. this.addTagForm={
  1067. userIds:[],
  1068. tagIds:[]
  1069. };
  1070. },
  1071. DelTagCancel() {
  1072. this.tagDelOpen = false;
  1073. this.addTagForm={
  1074. userIds:[],
  1075. tagIds:[]
  1076. };
  1077. },
  1078. addTagSubmitForm(){
  1079. for (let i = 0; i < this.tagGroupList.length; i++) {
  1080. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  1081. if(this.tagGroupList[i].tag[x].isSelected==true){
  1082. this.addTagForm.tagIds.push(this.tagGroupList[i].tag[x].tagId)
  1083. }
  1084. }
  1085. }
  1086. if(this.addTagForm.tagIds==[]||this.addTagForm.tagIds==null||this.addTagForm.tagIds==""){
  1087. return this.$message('请选择标签');
  1088. }
  1089. this.addTagForm.corpId=this.queryParams.corpId
  1090. this.addTagForm.userIds=this.ids;
  1091. let loadingRock = this.$loading({
  1092. lock: true,
  1093. text: '正在执行中请稍后~~请不要刷新页面!!',
  1094. spinner: 'el-icon-loading',
  1095. background: 'rgba(0, 0, 0, 0.7)'
  1096. });
  1097. addTag(this.addTagForm).then(response => {
  1098. this.msgSuccess(response.msg);
  1099. this.tagOpen = false;
  1100. loadingRock.close();
  1101. this.addTagForm={
  1102. userIds:[],
  1103. tagIds:[]
  1104. };
  1105. this.getList()
  1106. }).finally(res=>{
  1107. loadingRock.close();
  1108. });
  1109. },
  1110. tagDelSubmitForm(){
  1111. for (let i = 0; i < this.tagGroupList.length; i++) {
  1112. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  1113. if(this.tagGroupList[i].tag[x].isSelected==true){
  1114. this.addTagForm.tagIds.push(this.tagGroupList[i].tag[x].tagId)
  1115. }
  1116. }
  1117. }
  1118. if(this.addTagForm.tagIds==[]||this.addTagForm.tagIds==null||this.addTagForm.tagIds==""){
  1119. return this.$message('请选择标签');
  1120. }
  1121. this.addTagForm.corpId=this.queryParams.corpId
  1122. this.addTagForm.userIds=this.ids;
  1123. let loadingRock = this.$loading({
  1124. lock: true,
  1125. text: '正在执行中请稍后~~请不要刷新页面!!',
  1126. spinner: 'el-icon-loading',
  1127. background: 'rgba(0, 0, 0, 0.7)'
  1128. });
  1129. delTag(this.addTagForm).then(response => {
  1130. this.msgSuccess(response.msg);
  1131. this.tagDelOpen = false;
  1132. loadingRock.close();
  1133. this.addTagForm={
  1134. userIds:[],
  1135. tagIds:[]
  1136. };
  1137. this.getList()
  1138. }).finally(res=>{
  1139. loadingRock.close();
  1140. });
  1141. },
  1142. // 表单重置
  1143. reset() {
  1144. this.form = {
  1145. id: null,
  1146. userId: null,
  1147. externalUserId: null,
  1148. name: null,
  1149. companyUserId:null,
  1150. customerId:null,
  1151. avatar: null,
  1152. type: null,
  1153. gender: null,
  1154. remark: null,
  1155. description: null,
  1156. tagIds: null,
  1157. remarkMobiles: null,
  1158. remarkCorpName: null,
  1159. addWay: null,
  1160. operUserid: null,
  1161. corpId: null,
  1162. companyId: null,
  1163. transferStatus:null,
  1164. status:null,
  1165. createTime:null,
  1166. transferTime:null,
  1167. transferNum:null,
  1168. lossTime:null,
  1169. delTime:null,
  1170. state:null,
  1171. wayId:null,
  1172. stageStatus:null,
  1173. customerName:null
  1174. };
  1175. this.resetForm("form");
  1176. },
  1177. /** 搜索按钮操作 */
  1178. handleQuery() {
  1179. if (this.selectTags!=null && this.selectTags.length>0){
  1180. // 确保 this.form.tags 是数组
  1181. if (!this.queryParams.tagIds) {
  1182. this.queryParams.tagIds = []; // 如果未定义,初始化
  1183. } else {
  1184. this.queryParams.tagIds = []; // 清空已有数据
  1185. }
  1186. // 遍历并添加 tagId
  1187. this.selectTags.forEach(tag => {
  1188. if (tag.tagId) { // 确保 tagId 存在
  1189. this.queryParams.tagIds.push(tag.tagId);
  1190. }
  1191. });
  1192. this.queryParams.tagIds=this.queryParams.tagIds.join(",");
  1193. }else {
  1194. this.queryParams.tagIds=null;
  1195. }
  1196. this.queryParams.pageNum = 1;
  1197. this.getList();
  1198. },
  1199. /** 重置按钮操作 */
  1200. resetQuery() {
  1201. this.resetForm("queryForm");
  1202. this.queryParams.qwUserId=this.myQwUserList[0].dictValue;
  1203. this.queryParams.corpId=this.myQwUserList[0].corpId;
  1204. this.selectTags=[];
  1205. this.createTime=null;
  1206. this.queryParams.sTime=null;
  1207. this.queryParams.eTime=null;
  1208. this.handleQuery();
  1209. },
  1210. // 多选框选中数据
  1211. handleSelectionChange(selection) {
  1212. this.ids = selection.map(item => item.id)
  1213. this.single = selection.length!==1
  1214. this.multiple = !selection.length
  1215. },
  1216. /** 新增按钮操作 */
  1217. handleAdd() {
  1218. this.loading=true;
  1219. this.form.corpId=this.queryParams.corpId
  1220. addExternalContact(this.form).then(response => {
  1221. this.msgSuccess("同步成功");
  1222. this.getList();
  1223. }).finally(()=>{
  1224. this.loading=false;
  1225. });
  1226. },
  1227. /** 修改按钮操作 */
  1228. handleUpdate(row) {
  1229. this.reset();
  1230. const id = row.id || this.ids
  1231. getExternalContact(id).then(response => {
  1232. this.form = response.data;
  1233. if(this.form.remarkMobiles!=null){
  1234. this.remarkMobiles=JSON.parse(this.form.remarkMobiles)
  1235. }else{
  1236. this.remarkMobiles=[]
  1237. }
  1238. this.open = true;
  1239. this.title = "修改企业微信客户";
  1240. });
  1241. },
  1242. handleAppellation(val){
  1243. this.callOpen.open=true;
  1244. this.callOpenFrom.stageStatus=val.stageStatus;
  1245. this.callOpenFrom.id=val.id;
  1246. },
  1247. /** 绑定客户操作 */
  1248. handleUpdateCustomer(row){
  1249. this.bindCustomer.title="绑定客户"
  1250. this.bindCustomer.open=true;
  1251. this.form.id=row.id
  1252. this.form.externalUserId=row.externalUserId
  1253. this.form.name=row.name
  1254. },
  1255. handleUpdateUser(row){
  1256. this.user.title="绑定客户"
  1257. this.user.open=true;
  1258. this.userForm.id=row.id;
  1259. },
  1260. handleUnBindUserId(val){
  1261. this.$confirm(
  1262. '确认解绑客户:<span style="color: green;">' + val.name + '' +
  1263. '</span> 的小程序用户?<br><span style="color: red;">【ps:可能会导致客户无法看课】</span>',
  1264. {
  1265. confirmButtonText: "确定",
  1266. cancelButtonText: "取消",
  1267. type: "warning",
  1268. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  1269. }
  1270. ).then(() => {
  1271. return unBindUserId(val.id);
  1272. }).then(response => {
  1273. this.getList();
  1274. this.msgSuccess("解绑成功");
  1275. }).finally(res=>{
  1276. this.getList();
  1277. })
  1278. },
  1279. bindCustomerId(row){
  1280. console.log("row",row)
  1281. // this.qwFormCustomer.customerId=row;
  1282. this.form.customerId=row;
  1283. this.form.corpId=this.queryParams.corpId;
  1284. this.msgWarning("绑定中.....同步信息中.....");
  1285. editbindCustomer(this.form).then(res=>{
  1286. //清空表单
  1287. this.reset();
  1288. this.bindCustomer.open = false;
  1289. this.msgSuccess("绑定成功");
  1290. this.getList();
  1291. })
  1292. },
  1293. //设置一个SOP
  1294. setCourseSOP(row) {
  1295. // 检查 row.miniUserId 是否为 null
  1296. if (row.miniUserId === null || row.miniUserId === undefined) {
  1297. return this.$confirm('当前客户【CRM客户详情】中 未绑定小程序客户,请先绑定', "警告", {
  1298. confirmButtonText: "确定",
  1299. cancelButtonText: "取消",
  1300. type: "warning"
  1301. }).catch(error => {
  1302. this.msgWarning("操作取消:", error);
  1303. });
  1304. } else {
  1305. this.chooseCustomerSOP = row;
  1306. this.setSop.open = true;
  1307. this.setSop.type=1;
  1308. }
  1309. },
  1310. //选择课程SOP
  1311. // 用于设置 customerCourseForm 和 customerCourseFormLogs 的共同属性
  1312. setCommonProperties(form, row) {
  1313. form.qwUserid = this.chooseCustomerSOP.userId;
  1314. form.companyUserId = this.chooseCustomerSOP.companyUserId;
  1315. form.externalUserId = this.chooseCustomerSOP.externalUserId;
  1316. form.customerId = this.chooseCustomerSOP.customerId;
  1317. form.miniUserId = this.chooseCustomerSOP.miniUserId;
  1318. form.businessId = row.businessId;
  1319. },
  1320. bindCourseSop(row,days) {
  1321. if (this.setSop.type==2){
  1322. this.setSop.open = false;
  1323. this.loading=true;
  1324. this.msgWarning("设定中.....同步信息中.....");
  1325. setCustomerCourseSopList({ids:this.ids,fsCourseSopId:row.id,days:days}).then(res=>{
  1326. let msg=" 批量设置成功数【" + res.successNum + "】,<br>"
  1327. if (res.failCRM.length>0){
  1328. msg+="失败的客户【" + res.failCRM + "】,原因是未绑定CRM客户。<br>"
  1329. }
  1330. if (res.failMiNi.length>0){
  1331. msg+="失败的客户【" + res.failMiNi + "】,原因是CRM中未绑定小程序客户。<br>"
  1332. }
  1333. if (res.failCompany.length>0){
  1334. msg+="失败的客户【" + res.failCompany + "】,原因是客户没有所属成员。<br>"
  1335. }
  1336. return this.$confirm(msg, "提示", {
  1337. confirmButtonText: "确定",
  1338. cancelButtonText: "取消",
  1339. type: "warning",
  1340. dangerouslyUseHTMLString: true // 允许使用HTML标签
  1341. }).catch(error => {
  1342. this.msgSuccess("操作完成~");
  1343. });
  1344. }).finally(()=>{
  1345. this.loading = false;
  1346. this.getList();
  1347. })
  1348. }else if (this.setSop.type==1){
  1349. // 设置 customerCourseFormLogs 的属性
  1350. this.setCommonProperties(this.customerCourseFormLogs, row);
  1351. // 设置 customerCourseForm 的属性
  1352. this.setCommonProperties(this.customerCourseForm, row);
  1353. this.customerCourseForm.sopId = row.id;
  1354. this.customerCourseForm.sopType = row.sopType;
  1355. this.customerCourseForm.setting = row.setting;
  1356. this.customerCourseForm.days = days;
  1357. // 执行异步操作
  1358. getCustomerCourseSop(this.customerCourseFormLogs)
  1359. .then(res => {
  1360. if (res) {
  1361. return this.$confirm('当前客户已设置过相同课程课节SOP,确定还要再次设置吗?', "警告", {
  1362. confirmButtonText: "确定",
  1363. cancelButtonText: "取消",
  1364. type: "warning"
  1365. });
  1366. } else {
  1367. return Promise.resolve(); // 如果没有设置过,直接执行后续操作
  1368. }
  1369. })
  1370. .then(() => {
  1371. this.loading = true;
  1372. this.setSop.open = false;
  1373. this.msgSuccess("设定中.....同步信息中.....");
  1374. return setCustomerCourseSop(this.customerCourseForm);
  1375. })
  1376. .then(() => {
  1377. this.msgSuccess("设定成功");
  1378. })
  1379. .catch(error => {
  1380. this.msgWarning("操作取消:", error);
  1381. })
  1382. .finally(() => {
  1383. this.loading = false;
  1384. this.getList();
  1385. });
  1386. }
  1387. },
  1388. submitCallOpenFrom(){
  1389. this.$refs["callOpenFrom"].validate(valid => {
  1390. if (valid) {
  1391. if (this.callOpenFrom.id != null && this.callOpenFrom.stageStatus != null) {
  1392. updateExternalContactCall(this.callOpenFrom).then(res=>{
  1393. this.$message.success('修改成功');
  1394. this.callOpen.open=false;
  1395. this.getList();
  1396. });
  1397. }
  1398. }
  1399. });
  1400. },
  1401. /** 提交按钮 */
  1402. submitForm() {
  1403. this.$refs["form"].validate(valid => {
  1404. if (valid) {
  1405. if (this.form.id != null) {
  1406. this.form.remarkMobiles=JSON.stringify(this.remarkMobiles)
  1407. updateExternalContact(this.form).then(response => {
  1408. this.msgSuccess("修改成功");
  1409. this.open = false;
  1410. this.getList();
  1411. });
  1412. } else {
  1413. addExternalContact(this.form).then(response => {
  1414. this.msgSuccess("新增成功");
  1415. this.open = false;
  1416. this.getList();
  1417. });
  1418. }
  1419. }
  1420. });
  1421. },
  1422. /** 删除按钮操作 */
  1423. handleDelete(row) {
  1424. const ids = row.id || this.ids;
  1425. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  1426. confirmButtonText: "确定",
  1427. cancelButtonText: "取消",
  1428. type: "warning"
  1429. }).then(function() {
  1430. return delExternalContact(ids);
  1431. }).then(() => {
  1432. this.getList();
  1433. this.msgSuccess("删除成功");
  1434. }).catch(() => {});
  1435. },
  1436. handleSyncMyExternalContact(){
  1437. this.loading=true;
  1438. let loadingRock = this.$loading({
  1439. lock: true,
  1440. text: '正在执行中请稍后~~请不要刷新页面!!',
  1441. spinner: 'el-icon-loading',
  1442. background: 'rgba(0, 0, 0, 0.7)'
  1443. });
  1444. syncMyExternalContact(this.queryParams.qwUserId).then(res => {
  1445. this.msgSuccess("同步成功");
  1446. this.loading=false;
  1447. loadingRock.close();
  1448. this.getList();
  1449. }).catch(res=>{
  1450. console.log("asdasdwaaw ")
  1451. loadingRock.close();
  1452. }).finally(res=>{
  1453. loadingRock.close();
  1454. this.loading=false;
  1455. })
  1456. },
  1457. handleSyncAddMyExternalContact(){
  1458. this.loading=true;
  1459. let loadingRock = this.$loading({
  1460. lock: true,
  1461. text: '正在执行中请稍后~~请不要刷新页面!!',
  1462. spinner: 'el-icon-loading',
  1463. background: 'rgba(0, 0, 0, 0.7)'
  1464. });
  1465. syncMyAddExternalContact(this.queryParams.qwUserId).then(res => {
  1466. this.msgSuccess("同步成功");
  1467. this.loading=false;
  1468. loadingRock.close();
  1469. this.getList();
  1470. }).finally(()=>{
  1471. loadingRock.close();
  1472. this.loading=false;
  1473. })
  1474. },
  1475. updateTalk(row){
  1476. const ids = row.id || this.ids;
  1477. this.$confirm('是否确认批量更改用户信息为非首次交流', "警告", {
  1478. confirmButtonText: "确定",
  1479. cancelButtonText: "取消",
  1480. type: "warning"
  1481. }).then(function() {
  1482. return editTalk(ids);
  1483. }).then(() => {
  1484. this.getList();
  1485. this.msgSuccess("成功");
  1486. }).catch(() => {});
  1487. },
  1488. updateAllTalk(row){
  1489. const id = this.queryParams.qwUserId
  1490. this.$confirm('是否确认更改全部用户信息为非首次交流', "警告", {
  1491. confirmButtonText: "确定",
  1492. cancelButtonText: "取消",
  1493. type: "warning"
  1494. }).then(function() {
  1495. return editAllTalk(id);
  1496. }).then(() => {
  1497. this.getList();
  1498. this.msgSuccess("成功");
  1499. }).catch(() => {});
  1500. },
  1501. /** 导出按钮操作 */
  1502. handleExport() {
  1503. const queryParams = this.queryParams;
  1504. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  1505. confirmButtonText: "确定",
  1506. cancelButtonText: "取消",
  1507. type: "warning"
  1508. }).then(() => {
  1509. this.exportLoading = true;
  1510. return exportExternalContact(queryParams);
  1511. }).then(response => {
  1512. this.download(response.msg);
  1513. this.exportLoading = false;
  1514. }).catch(() => {});
  1515. }
  1516. }
  1517. };
  1518. </script>
  1519. <style scoped>
  1520. /* CSS 样式 */
  1521. .tag-container {
  1522. display: flex;
  1523. flex-wrap: wrap; /* 超出宽度时自动换行 */
  1524. gap: 8px; /* 设置标签之间的间距 */
  1525. }
  1526. .name-background {
  1527. display: inline-block;
  1528. background-color: #abece6; /* 背景颜色 */
  1529. padding: 4px 8px; /* 调整内边距,让背景包裹文字 */
  1530. border-radius: 4px; /* 可选:设置圆角 */
  1531. }
  1532. .tag-box {
  1533. padding: 8px 12px;
  1534. border: 1px solid #989797;
  1535. border-radius: 4px;
  1536. cursor: pointer;
  1537. display: inline-block;
  1538. }
  1539. .tag-selected {
  1540. background-color: #00bc98;
  1541. color: #fff;
  1542. border-color: #00bc98;
  1543. }
  1544. .el-tag + .el-tag {
  1545. margin-left: 10px;
  1546. }
  1547. .button-new-tag {
  1548. margin-left: 10px;
  1549. height: 32px;
  1550. line-height: 30px;
  1551. padding-top: 0;
  1552. padding-bottom: 0;
  1553. }
  1554. .input-new-tag {
  1555. width: 90px;
  1556. margin-left: 10px;
  1557. vertical-align: bottom;
  1558. }
  1559. </style>