index.vue 41 KB

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