index.vue 18 KB

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