deptTransferIndex.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px">
  4. <!-- <el-form-item label="外部联系人账号" prop="externalUserId">-->
  5. <!-- <el-input-->
  6. <!-- v-model="queryParams.externalUserId"-->
  7. <!-- placeholder="外部联系人账号"-->
  8. <!-- clearable-->
  9. <!-- size="small"-->
  10. <!-- @keyup.enter.native="handleQuery"-->
  11. <!-- />-->
  12. <!-- </el-form-item>-->
  13. <el-form-item label="企微公司" prop="corpId">
  14. <el-select v-model="queryParams.corpId" placeholder="企微公司" size="small" @change="updateCorpId()">
  15. <el-option
  16. v-for="dict in myQwCompanyList"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="客户名称" prop="name">
  24. <el-input
  25. v-model="queryParams.name"
  26. placeholder="请输入客户名称"
  27. clearable
  28. size="small"
  29. @keyup.enter.native="handleQuery"
  30. />
  31. </el-form-item>
  32. <el-form-item label="所属员工" prop="qwUserName">
  33. <el-input
  34. v-model="queryParams.qwUserName"
  35. placeholder="请输入所属员工名称"
  36. clearable
  37. size="small"
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item label="用户类别" prop="type">
  42. <el-select v-model="queryParams.type" placeholder="请选择用户类别" clearable size="small">
  43. <el-option
  44. v-for="dict in typeOptions"
  45. :key="dict.dictValue"
  46. :label="dict.dictLabel"
  47. :value="dict.dictValue"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="客户等级" prop="level">
  52. <el-select v-model="queryParams.level" placeholder="客户等级" clearable size="small">
  53. <el-option
  54. v-for="dict in ratingType"
  55. :key="dict.dictValue"
  56. :label="dict.dictLabel"
  57. :value="dict.dictValue"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="性别" prop="gender">
  62. <el-input
  63. v-model="queryParams.gender"
  64. placeholder="请输入性别"
  65. clearable
  66. size="small"
  67. @keyup.enter.native="handleQuery"
  68. />
  69. </el-form-item>
  70. <el-form-item label="转接状态" prop="addWay">
  71. <el-select v-model="queryParams.transferStatus" placeholder="转接状态" clearable size="small">
  72. <el-option
  73. v-for="dict in transferStatusOptions"
  74. :key="dict.dictValue"
  75. :label="dict.dictLabel"
  76. :value="dict.dictValue"
  77. />
  78. </el-select>
  79. </el-form-item>
  80. <el-form-item label="标签" prop="tagIds">
  81. <el-select v-model="selectTags" remote multiple placeholder="请选择" filterable style="width: 100%;">
  82. <el-option
  83. v-for="dict in tagList"
  84. :label="dict.name"
  85. :value="dict.tagId">
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="添加时间" prop="createTime">
  90. <el-date-picker clearable size="small"
  91. v-model="queryParams.createTime"
  92. type="date"
  93. value-format="yyyy-MM-dd"
  94. placeholder="选择添加时间">
  95. </el-date-picker>
  96. </el-form-item>
  97. <el-form-item>
  98. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  99. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  100. </el-form-item>
  101. </el-form>
  102. <el-row :gutter="10" class="mb8">
  103. <!-- <el-col :span="1.5">
  104. <el-button
  105. type="primary"
  106. plain
  107. size="mini"
  108. @click="handleAdd"
  109. v-hasPermi="['qw:externalContact:add']"
  110. >同步</el-button>
  111. </el-col> -->
  112. <el-col :span="1.5">
  113. <el-button
  114. type="warning"
  115. plain
  116. icon="el-icon-download"
  117. size="mini"
  118. :loading="exportLoading"
  119. @click="handleExport"
  120. v-hasPermi="['qw:externalContact:export']"
  121. >导出</el-button>
  122. </el-col>
  123. <el-col :span="1.5">
  124. <el-button
  125. type="primary"
  126. plain
  127. size="mini"
  128. @click="handleTransfer"
  129. v-hasPermi="['qw:externalContact:transfer']"
  130. >分配客户</el-button>
  131. </el-col>
  132. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  133. </el-row>
  134. <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
  135. <el-table-column type="selection" width="55" align="center" />
  136. <el-table-column label="所属员工" align="center" prop="qwUserName" width="120px"/>
  137. <el-table-column label="员工部门" align="center" prop="departmentName" width="120px"/>
  138. <!-- <el-table-column label="外部联系人账号" align="center" prop="externalUserId" width="120px"/>-->
  139. <el-table-column label="客户名称" align="center" prop="name" />
  140. <el-table-column label="头像" align="center" prop="avatar" width="100px">
  141. <template slot-scope="scope">
  142. <el-popover
  143. placement="right"
  144. title=""
  145. trigger="hover">
  146. <img slot="reference" :src="scope.row.avatar" width="60px">
  147. <img :src="scope.row.avatar" style="max-width: 200px;">
  148. </el-popover>
  149. </template>
  150. </el-table-column>
  151. <el-table-column label="用户类别" align="center" prop="type">
  152. <template slot-scope="scope">
  153. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="性别" align="center" prop="gender">
  157. <template slot-scope="scope">
  158. <dict-tag :options="genderOptions" :value="scope.row.gender"/>
  159. </template>
  160. </el-table-column>
  161. <el-table-column label="备注" align="center" prop="remark" />
  162. <el-table-column label="描述信息" align="center" prop="description" />
  163. <el-table-column label="标签" align="center" prop="tagIds" width="300px">
  164. <template slot-scope="scope">
  165. <div class="tag-container">
  166. <div class="tag-list">
  167. <div v-for="i in JSON.parse(scope.row.tagIds)" :key="i" style="display: inline;">
  168. <el-tag type="success" v-for="ii in tagList" :key="ii.id" style="margin: 3px;" v-if="ii.tagId==i">{{ii.name}}</el-tag>
  169. </div>
  170. </div>
  171. </div>
  172. </template>
  173. </el-table-column>
  174. <el-table-column label="客户等级" align="center" prop="level" width="120px" >
  175. <template slot-scope="scope">
  176. <dict-tag :options="ratingType" :value="scope.row.level"/>
  177. </template>
  178. </el-table-column>
  179. <el-table-column label="添加时间" align="center" prop="createTime" width="100px"/>
  180. <el-table-column label="状态" align="center" prop="status" width="100px">
  181. <template slot-scope="scope">
  182. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px">
  186. <template slot-scope="scope">
  187. <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
  188. </template>
  189. </el-table-column>
  190. <el-table-column label="企业id" align="center" prop="corpId" />
  191. <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
  192. <template slot-scope="scope">
  193. <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</span>
  194. </template>
  195. </el-table-column>
  196. <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
  197. <el-table-column label="来源" align="center" prop="addWay" width="100px">
  198. <template slot-scope="scope">
  199. <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
  200. </template>
  201. </el-table-column>
  202. <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  203. <template slot-scope="scope">
  204. <el-button
  205. size="mini"
  206. type="text"
  207. icon="el-icon-edit"
  208. @click="handleUpdate(scope.row)"
  209. v-hasPermi="['qw:externalContact:edit']"
  210. >修改</el-button>
  211. </template>
  212. </el-table-column> -->
  213. </el-table>
  214. <pagination
  215. v-show="total>0"
  216. :total="total"
  217. :page.sync="queryParams.pageNum"
  218. :limit.sync="queryParams.pageSize"
  219. @pagination="getList"
  220. />
  221. <!-- 添加或修改企业微信客户对话框 -->
  222. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  223. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  224. <div style="background-color: rgb(239, 250, 255); margin: 10px;padding: 15px;">
  225. <div>可将选中的客户转接给其他员工,进行后续服务</div>
  226. <div>注意:90天内客户只能被转接一次,一个客户最多只能被转接两次</div>
  227. </div>
  228. <el-form-item label="接替员工" prop="userId">
  229. <!-- <el-button type="success" v-if="this.nickName">{{ nickName }}</el-button>-->
  230. <el-input style="width: 150px" disabled>
  231. <template slot="prefix">
  232. <el-button
  233. plain
  234. size="small"
  235. type="success"
  236. v-if="this.nickName">
  237. {{ nickName }}
  238. </el-button>
  239. </template>
  240. </el-input>
  241. </el-form-item>
  242. <el-form-item label="清除标签" prop="needClearTag">
  243. <el-radio v-model="form.needClearTag" :label="0">不清除</el-radio>
  244. <el-radio v-model="form.needClearTag" :label="1">清除</el-radio>
  245. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  246. <i class="el-icon-info"></i>
  247. <span v-if="form.needClearTag === 0">不清除标签:客户转接后会保留原标签,不会被清除。</span>
  248. <span v-else>清除标签:客户转接后原标签不会保留,仅会存在自动添加的标签。</span>
  249. </div>
  250. </el-form-item>
  251. <el-form-item label="消息内容" prop="content">
  252. <el-input v-model="form.content" placeholder="请输入内容" />
  253. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  254. <i class="el-icon-info"></i>
  255. 自定义转接的时候发给客户的消息内容(选填)ps:不填则是官方默认话术
  256. </div>
  257. </el-form-item>
  258. <el-card>
  259. <qwUserSelectOne ref="qwUserSelectOne" @selectUser="selectUser"></qwUserSelectOne>
  260. </el-card>
  261. </el-form>
  262. <div slot="footer" class="dialog-footer">
  263. <el-button type="primary" @click="submitForm">确 定</el-button>
  264. <el-button @click="cancel">取 消</el-button>
  265. </div>
  266. </el-dialog>
  267. </div>
  268. </template>
  269. <script>
  270. import { myDeptExtList,transfer,listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact } from "@/api/qw/externalContact";
  271. import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
  272. import { qwUserList } from "@/api/qw/user";
  273. import qwUserSelectOne from '@/views/qw/user/qwUserSelectOne.vue'
  274. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  275. export default {
  276. name: "deptTransferIndex",
  277. components: { qwUserSelectOne },
  278. data() {
  279. return {
  280. // 遮罩层
  281. loading: true,
  282. // 导出遮罩层
  283. exportLoading: false,
  284. // 选中数组
  285. ids: [],
  286. myQwCompanyList:[],
  287. // 非单个禁用
  288. single: true,
  289. // 非多个禁用
  290. multiple: true,
  291. // 显示搜索条件
  292. showSearch: true,
  293. // 总条数
  294. total: 0,
  295. // 企业微信客户表格数据
  296. externalContactList: [],
  297. // 弹出层标题
  298. title: "",
  299. // 是否显示弹出层
  300. open: false,
  301. // 用户类别字典
  302. typeOptions: [],
  303. ratingType: [],
  304. selectTags:[],
  305. // 性别字典
  306. genderOptions: [],
  307. // 来源字典
  308. addWayOptions: [],
  309. nickName:null,
  310. qwUserList:[],
  311. // 查询参数
  312. queryParams: {
  313. pageNum: 1,
  314. pageSize: 10,
  315. userId: null,
  316. externalUserId: null,
  317. name: null,
  318. avatar: null,
  319. type: null,
  320. gender: null,
  321. description: null,
  322. tagIds: null,
  323. remarkMobiles: null,
  324. remarkCorpName: null,
  325. addWay: null,
  326. operUserid: null,
  327. corpId: null,
  328. companyId: null,
  329. status:0,
  330. transferStatus:null
  331. },
  332. // 表单参数
  333. form: {
  334. needClearTag: 0
  335. },
  336. tagList:[],
  337. transferStatusOptions:[],
  338. statusOptions:[],
  339. // 表单校验
  340. rules: {
  341. userId: [{ required: true, message: '请选择接替员工', trigger: 'blur' }],
  342. }
  343. };
  344. },
  345. created() {
  346. getMyQwCompanyList().then(response => {
  347. this.myQwCompanyList = response.data;
  348. if(this.myQwCompanyList!=null){
  349. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  350. listTag({corpId:this.queryParams.corpId}).then(response => {
  351. this.tagList = response.rows;
  352. });
  353. qwUserList(this.queryParams.corpId).then(response => {
  354. this.qwUserList = response.rows;
  355. });
  356. this.getList();
  357. }
  358. });
  359. this.getDicts("sys_qw_externalContact_type").then(response => {
  360. this.typeOptions = response.data;
  361. });
  362. this.getDicts("sys_user_sex").then(response => {
  363. this.genderOptions = response.data;
  364. });
  365. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  366. this.addWayOptions = response.data;
  367. });
  368. this.getDicts("sys_qw_sop_rating_type").then(response => {
  369. this.ratingType = response.data;
  370. });
  371. this.getDicts("sys_qw_external_contact_status").then(response => {
  372. this.statusOptions = response.data;
  373. });
  374. this.getDicts("sys_qw_transfer_status").then(response => {
  375. this.transferStatusOptions = response.data;
  376. });
  377. },
  378. methods: {
  379. updateCorpId(){
  380. listTag({corpId:this.queryParams.corpId}).then(response => {
  381. this.tagList = response.rows;
  382. });
  383. qwUserList(this.queryParams.corpId).then(response => {
  384. this.qwUserList = response.rows;
  385. });
  386. this.getList();
  387. },
  388. /** 查询企业微信客户列表 */
  389. getList() {
  390. this.loading = true;
  391. myDeptExtList(this.queryParams).then(response => {
  392. this.externalContactList = response.rows;
  393. this.total = response.total;
  394. this.loading = false;
  395. });
  396. },
  397. // 取消按钮
  398. cancel() {
  399. this.open = false;
  400. this.reset();
  401. },
  402. // 表单重置
  403. reset() {
  404. this.form = {
  405. id: null,
  406. userId: null,
  407. externalUserId: null,
  408. name: null,
  409. avatar: null,
  410. type: null,
  411. gender: null,
  412. remark: null,
  413. description: null,
  414. tagIds: null,
  415. remarkMobiles: null,
  416. remarkCorpName: null,
  417. addWay: null,
  418. operUserid: null,
  419. corpId: null,
  420. companyId: null,
  421. needClearTag: 0
  422. };
  423. this.resetForm("form");
  424. },
  425. selectUser(row){
  426. this.form.userId=row.id
  427. console.log(row)
  428. this.nickName=row.qwUserName
  429. },
  430. /** 搜索按钮操作 */
  431. handleQuery() {
  432. this.queryParams.tagIds=this.selectTags.join(',')
  433. this.queryParams.pageNum = 1;
  434. this.getList();
  435. },
  436. /** 重置按钮操作 */
  437. resetQuery() {
  438. this.selectTags=[];
  439. this.resetForm("queryForm");
  440. this.queryParams.transferStatus = null;
  441. this.handleQuery();
  442. },
  443. // 多选框选中数据
  444. handleSelectionChange(selection) {
  445. this.ids = selection.map(item => item.id)
  446. this.single = selection.length!==1
  447. this.multiple = !selection.length
  448. },
  449. /** 新增按钮操作 */
  450. handleAdd() {
  451. addExternalContact(this.form).then(response => {
  452. this.msgSuccess("同步成功");
  453. this.getList();
  454. });
  455. },
  456. handleTransfer(row) {
  457. this.reset();
  458. if(this.ids==null||this.ids==""){
  459. return this.$message('请选择需要分配的客户');
  460. }
  461. setTimeout(() => {
  462. this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
  463. }, 1);
  464. this.open = true;
  465. this.title = "分配客户";
  466. },
  467. /** 提交按钮 */
  468. submitForm() {
  469. this.$refs["form"].validate(valid => {
  470. if (valid) {
  471. var form={
  472. ids:this.ids,
  473. userId:this.form.userId,
  474. corpId:this.queryParams.corpId,
  475. content:this.form.content,
  476. needClearTag: 0
  477. }
  478. transfer(form).then(response => {
  479. this.msgSuccess(response.msg);
  480. this.open = false;
  481. this.getList();
  482. });
  483. }
  484. });
  485. },
  486. /** 删除按钮操作 */
  487. handleDelete(row) {
  488. const ids = row.id || this.ids;
  489. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  490. confirmButtonText: "确定",
  491. cancelButtonText: "取消",
  492. type: "warning"
  493. }).then(function() {
  494. return delExternalContact(ids);
  495. }).then(() => {
  496. this.getList();
  497. this.msgSuccess("删除成功");
  498. }).catch(() => {});
  499. },
  500. /** 导出按钮操作 */
  501. handleExport() {
  502. const queryParams = this.queryParams;
  503. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  504. confirmButtonText: "确定",
  505. cancelButtonText: "取消",
  506. type: "warning"
  507. }).then(() => {
  508. this.exportLoading = true;
  509. return exportExternalContact(queryParams);
  510. }).then(response => {
  511. this.download(response.msg);
  512. this.exportLoading = false;
  513. }).catch(() => {});
  514. }
  515. }
  516. };
  517. </script>
  518. <style scoped>
  519. .tag-container {
  520. max-height: 300px;
  521. overflow-y: auto;
  522. padding: 1px;
  523. border: 1px solid #ebeef5;
  524. border-radius: 1px;
  525. background-color: #fafafa;
  526. }
  527. .tag-list {
  528. display: flex;
  529. flex-wrap: wrap;
  530. gap: 8px;
  531. }
  532. .scroll-hint {
  533. text-align: center;
  534. color: #909399;
  535. font-size: 12px;
  536. padding: 1px 0;
  537. }
  538. .container {
  539. max-width: 800px;
  540. margin: 0 auto;
  541. padding: 10px;
  542. }
  543. .title {
  544. text-align: center;
  545. color: #303133;
  546. margin-bottom: 30px;
  547. }
  548. .demo-table {
  549. width: 100%;
  550. margin-bottom: 30px;
  551. }
  552. .instructions {
  553. background-color: #f5f7fa;
  554. padding: 15px;
  555. border-radius: 1px;
  556. margin-bottom: 20px;
  557. }
  558. </style>