deptTransferIndex.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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="content">
  243. <el-input v-model="form.content" placeholder="请输入内容" />
  244. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  245. <i class="el-icon-info"></i>
  246. 自定义转接的时候发给客户的消息内容(选填)ps:不填则是官方默认话术
  247. </div>
  248. </el-form-item>
  249. <el-card>
  250. <qwUserSelectOne ref="qwUserSelectOne" @selectUser="selectUser"></qwUserSelectOne>
  251. </el-card>
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button type="primary" @click="submitForm">确 定</el-button>
  255. <el-button @click="cancel">取 消</el-button>
  256. </div>
  257. </el-dialog>
  258. </div>
  259. </template>
  260. <script>
  261. import { myDeptExtList,transfer,listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact } from "@/api/qw/externalContact";
  262. import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
  263. import { qwUserList } from "@/api/qw/user";
  264. import qwUserSelectOne from '@/views/qw/user/qwUserSelectOne.vue'
  265. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  266. export default {
  267. name: "deptTransferIndex",
  268. components: { qwUserSelectOne },
  269. data() {
  270. return {
  271. // 遮罩层
  272. loading: true,
  273. // 导出遮罩层
  274. exportLoading: false,
  275. // 选中数组
  276. ids: [],
  277. myQwCompanyList:[],
  278. // 非单个禁用
  279. single: true,
  280. // 非多个禁用
  281. multiple: true,
  282. // 显示搜索条件
  283. showSearch: true,
  284. // 总条数
  285. total: 0,
  286. // 企业微信客户表格数据
  287. externalContactList: [],
  288. // 弹出层标题
  289. title: "",
  290. // 是否显示弹出层
  291. open: false,
  292. // 用户类别字典
  293. typeOptions: [],
  294. ratingType: [],
  295. selectTags:[],
  296. // 性别字典
  297. genderOptions: [],
  298. // 来源字典
  299. addWayOptions: [],
  300. nickName:null,
  301. qwUserList:[],
  302. // 查询参数
  303. queryParams: {
  304. pageNum: 1,
  305. pageSize: 10,
  306. userId: null,
  307. externalUserId: null,
  308. name: null,
  309. avatar: null,
  310. type: null,
  311. gender: null,
  312. description: null,
  313. tagIds: null,
  314. remarkMobiles: null,
  315. remarkCorpName: null,
  316. addWay: null,
  317. operUserid: null,
  318. corpId: null,
  319. companyId: null,
  320. status:0,
  321. transferStatus:null
  322. },
  323. // 表单参数
  324. form: {},
  325. tagList:[],
  326. transferStatusOptions:[],
  327. statusOptions:[],
  328. // 表单校验
  329. rules: {
  330. userId: [{ required: true, message: '请选择接替员工', trigger: 'blur' }],
  331. }
  332. };
  333. },
  334. created() {
  335. getMyQwCompanyList().then(response => {
  336. this.myQwCompanyList = response.data;
  337. if(this.myQwCompanyList!=null){
  338. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  339. listTag({corpId:this.queryParams.corpId}).then(response => {
  340. this.tagList = response.rows;
  341. });
  342. qwUserList(this.queryParams.corpId).then(response => {
  343. this.qwUserList = response.rows;
  344. });
  345. this.getList();
  346. }
  347. });
  348. this.getDicts("sys_qw_externalContact_type").then(response => {
  349. this.typeOptions = response.data;
  350. });
  351. this.getDicts("sys_user_sex").then(response => {
  352. this.genderOptions = response.data;
  353. });
  354. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  355. this.addWayOptions = response.data;
  356. });
  357. this.getDicts("sys_qw_sop_rating_type").then(response => {
  358. this.ratingType = response.data;
  359. });
  360. this.getDicts("sys_qw_external_contact_status").then(response => {
  361. this.statusOptions = response.data;
  362. });
  363. this.getDicts("sys_qw_transfer_status").then(response => {
  364. this.transferStatusOptions = response.data;
  365. });
  366. },
  367. methods: {
  368. updateCorpId(){
  369. listTag({corpId:this.queryParams.corpId}).then(response => {
  370. this.tagList = response.rows;
  371. });
  372. qwUserList(this.queryParams.corpId).then(response => {
  373. this.qwUserList = response.rows;
  374. });
  375. this.getList();
  376. },
  377. /** 查询企业微信客户列表 */
  378. getList() {
  379. this.loading = true;
  380. myDeptExtList(this.queryParams).then(response => {
  381. this.externalContactList = response.rows;
  382. this.total = response.total;
  383. this.loading = false;
  384. });
  385. },
  386. // 取消按钮
  387. cancel() {
  388. this.open = false;
  389. this.reset();
  390. },
  391. // 表单重置
  392. reset() {
  393. this.form = {
  394. id: null,
  395. userId: null,
  396. externalUserId: null,
  397. name: null,
  398. avatar: null,
  399. type: null,
  400. gender: null,
  401. remark: null,
  402. description: null,
  403. tagIds: null,
  404. remarkMobiles: null,
  405. remarkCorpName: null,
  406. addWay: null,
  407. operUserid: null,
  408. corpId: null,
  409. companyId: null
  410. };
  411. this.resetForm("form");
  412. },
  413. selectUser(row){
  414. this.form.userId=row.id
  415. console.log(row)
  416. this.nickName=row.qwUserName
  417. },
  418. /** 搜索按钮操作 */
  419. handleQuery() {
  420. this.queryParams.tagIds=this.selectTags.join(',')
  421. this.queryParams.pageNum = 1;
  422. this.getList();
  423. },
  424. /** 重置按钮操作 */
  425. resetQuery() {
  426. this.selectTags=[];
  427. this.resetForm("queryForm");
  428. this.handleQuery();
  429. },
  430. // 多选框选中数据
  431. handleSelectionChange(selection) {
  432. this.ids = selection.map(item => item.id)
  433. this.single = selection.length!==1
  434. this.multiple = !selection.length
  435. },
  436. /** 新增按钮操作 */
  437. handleAdd() {
  438. addExternalContact(this.form).then(response => {
  439. this.msgSuccess("同步成功");
  440. this.getList();
  441. });
  442. },
  443. handleTransfer(row) {
  444. this.reset();
  445. if(this.ids==null||this.ids==""){
  446. return this.$message('请选择需要分配的客户');
  447. }
  448. setTimeout(() => {
  449. this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
  450. }, 1);
  451. this.open = true;
  452. this.title = "分配客户";
  453. },
  454. /** 提交按钮 */
  455. submitForm() {
  456. this.$refs["form"].validate(valid => {
  457. if (valid) {
  458. var form={
  459. ids:this.ids,
  460. userId:this.form.userId,
  461. corpId:this.queryParams.corpId,
  462. content:this.form.content,
  463. }
  464. transfer(form).then(response => {
  465. this.msgSuccess(response.msg);
  466. this.open = false;
  467. this.getList();
  468. });
  469. }
  470. });
  471. },
  472. /** 删除按钮操作 */
  473. handleDelete(row) {
  474. const ids = row.id || this.ids;
  475. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  476. confirmButtonText: "确定",
  477. cancelButtonText: "取消",
  478. type: "warning"
  479. }).then(function() {
  480. return delExternalContact(ids);
  481. }).then(() => {
  482. this.getList();
  483. this.msgSuccess("删除成功");
  484. }).catch(() => {});
  485. },
  486. /** 导出按钮操作 */
  487. handleExport() {
  488. const queryParams = this.queryParams;
  489. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  490. confirmButtonText: "确定",
  491. cancelButtonText: "取消",
  492. type: "warning"
  493. }).then(() => {
  494. this.exportLoading = true;
  495. return exportExternalContact(queryParams);
  496. }).then(response => {
  497. this.download(response.msg);
  498. this.exportLoading = false;
  499. }).catch(() => {});
  500. }
  501. }
  502. };
  503. </script>
  504. <style scoped>
  505. .tag-container {
  506. max-height: 300px;
  507. overflow-y: auto;
  508. padding: 1px;
  509. border: 1px solid #ebeef5;
  510. border-radius: 1px;
  511. background-color: #fafafa;
  512. }
  513. .tag-list {
  514. display: flex;
  515. flex-wrap: wrap;
  516. gap: 8px;
  517. }
  518. .scroll-hint {
  519. text-align: center;
  520. color: #909399;
  521. font-size: 12px;
  522. padding: 1px 0;
  523. }
  524. .container {
  525. max-width: 800px;
  526. margin: 0 auto;
  527. padding: 10px;
  528. }
  529. .title {
  530. text-align: center;
  531. color: #303133;
  532. margin-bottom: 30px;
  533. }
  534. .demo-table {
  535. width: 100%;
  536. margin-bottom: 30px;
  537. }
  538. .instructions {
  539. background-color: #f5f7fa;
  540. padding: 15px;
  541. border-radius: 1px;
  542. margin-bottom: 20px;
  543. }
  544. </style>