index.vue 31 KB

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