index.vue 51 KB

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