deptLossIndex.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. deptLossIndex<template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
  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="createTime">
  33. <el-date-picker clearable size="small"
  34. v-model="queryParams.createTime"
  35. type="date"
  36. value-format="yyyy-MM-dd"
  37. placeholder="添加时间">
  38. </el-date-picker>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button
  48. type="warning"
  49. plain
  50. icon="el-icon-download"
  51. size="mini"
  52. :loading="exportLoading"
  53. @click="handleExport"
  54. v-hasPermi="['qw:externalContact:export']"
  55. >导出</el-button>
  56. </el-col>
  57. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. <el-tabs type="card" v-model="queryParams.status" @tab-click="handleClickX">
  60. <el-tab-pane label="流失" name="3"></el-tab-pane>
  61. <el-tab-pane label="删除" name="4"></el-tab-pane>
  62. </el-tabs>
  63. <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
  64. <el-table-column type="selection" width="55" align="center" />
  65. <el-table-column label="企微员工账号" align="center" prop="userId" width="120px"/>
  66. <el-table-column label="企微员工名称" align="center" prop="qwUserName" width="120px"/>
  67. <el-table-column label="客户名称" align="center" prop="name" />
  68. <el-table-column label="头像" align="center" prop="avatar" width="100px">
  69. <template slot-scope="scope">
  70. <el-popover
  71. placement="right"
  72. title=""
  73. trigger="hover">
  74. <img slot="reference" :src="scope.row.avatar" width="60px">
  75. <img :src="scope.row.avatar" style="max-width: 200px;">
  76. </el-popover>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="用户类别" align="center" prop="type">
  80. <template slot-scope="scope">
  81. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="添加时间" align="center" prop="createTime"/>
  85. <el-table-column label="流失时间" align="center" prop="lossTime" v-if="queryParams.status==3"/>
  86. <el-table-column label="删除时间" align="center" prop="delTime" v-if="queryParams.status==4"/>
  87. <el-table-column label="状态" align="center" prop="status" width="100px">
  88. <template slot-scope="scope">
  89. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="是否绑定CRM" width="110px" fixed="right">
  93. <template slot-scope="scope">
  94. <el-button
  95. v-if="scope.row.customerId"
  96. type="success"
  97. size="mini"
  98. plain>
  99. 已绑定
  100. </el-button>
  101. <el-button
  102. v-else
  103. type="danger"
  104. size="mini"
  105. plain>
  106. 未绑定
  107. </el-button>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
  111. <template slot-scope="scope">
  112. <el-button v-if="scope.row.customerId"
  113. size="mini"
  114. type="text"
  115. icon="el-icon-paperclip"
  116. @click="handleShow(scope.row)"
  117. >CRM客户详情</el-button>
  118. </template>
  119. </el-table-column>
  120. </el-table>
  121. <pagination
  122. v-show="total>0"
  123. :total="total"
  124. :page.sync="queryParams.pageNum"
  125. :limit.sync="queryParams.pageSize"
  126. @pagination="getList"
  127. />
  128. <!-- 添加或修改企业微信客户对话框 -->
  129. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  130. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  131. <el-form-item label="属于用户账号" prop="userId">
  132. <el-input v-model="form.userId" placeholder="请输入属于用户账号" />
  133. </el-form-item>
  134. <el-form-item label="外部联系人账号" prop="externalUserId">
  135. <el-input v-model="form.externalUserId" placeholder="请输入外部联系人账号" />
  136. </el-form-item>
  137. <el-form-item label="名称" prop="name">
  138. <el-input v-model="form.name" placeholder="请输入名称" />
  139. </el-form-item>
  140. <el-form-item label="头像" prop="avatar">
  141. <el-input v-model="form.avatar" placeholder="请输入头像" />
  142. </el-form-item>
  143. <el-form-item label="用户类别" prop="type">
  144. <el-select v-model="form.type" placeholder="请选择用户类别">
  145. <el-option
  146. v-for="dict in typeOptions"
  147. :key="dict.dictValue"
  148. :label="dict.dictLabel"
  149. :value="parseInt(dict.dictValue)"
  150. ></el-option>
  151. </el-select>
  152. </el-form-item>
  153. <el-form-item label="性别" prop="gender">
  154. <el-input v-model="form.gender" placeholder="请输入性别" />
  155. </el-form-item>
  156. <el-form-item label="备注" prop="remark">
  157. <el-input v-model="form.remark" placeholder="请输入备注" />
  158. </el-form-item>
  159. <el-form-item label="描述信息" prop="description">
  160. <el-input v-model="form.description" placeholder="请输入描述信息" />
  161. </el-form-item>
  162. <el-form-item label="标签id" prop="tagIds">
  163. <el-input v-model="form.tagIds" placeholder="请输入标签id" />
  164. </el-form-item>
  165. <el-form-item label="备注电话号码" prop="remarkMobiles">
  166. <el-input v-model="form.remarkMobiles" placeholder="请输入备注电话号码" />
  167. </el-form-item>
  168. <el-form-item label="备注企业名称" prop="remarkCorpName">
  169. <el-input v-model="form.remarkCorpName" placeholder="请输入备注企业名称" />
  170. </el-form-item>
  171. <el-form-item label="来源" prop="addWay">
  172. <el-input v-model="form.addWay" placeholder="请输入来源" />
  173. </el-form-item>
  174. <el-form-item label="企业id" prop="corpId">
  175. <el-input v-model="form.corpId" placeholder="请输入企业id" />
  176. </el-form-item>
  177. <el-form-item label="公司id" prop="companyId">
  178. <el-input v-model="form.companyId" placeholder="请输入公司id" />
  179. </el-form-item>
  180. </el-form>
  181. <div slot="footer" class="dialog-footer">
  182. <el-button type="primary" @click="submitForm">确 定</el-button>
  183. <el-button @click="cancel">取 消</el-button>
  184. </div>
  185. </el-dialog>
  186. <el-drawer size="75%" :title="show.title" :visible.sync="show.open">
  187. <customer-details ref="customerDetails" />
  188. </el-drawer>
  189. </div>
  190. </template>
  191. <script>
  192. import { myDeptExtList,listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact } from "@/api/qw/externalContact";
  193. import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
  194. import customerDetails from '@/views/qw/externalContact/customerDetails'
  195. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  196. export default {
  197. name: "deptLossIndex",
  198. components:{customerDetails},
  199. data() {
  200. return {
  201. // 遮罩层
  202. loading: true,
  203. // 导出遮罩层
  204. exportLoading: false,
  205. // 选中数组
  206. ids: [],
  207. // 非单个禁用
  208. single: true,
  209. // 非多个禁用
  210. multiple: true,
  211. myQwCompanyList:[],
  212. // 显示搜索条件
  213. showSearch: true,
  214. // 总条数
  215. total: 0,
  216. // 企业微信客户表格数据
  217. externalContactList: [],
  218. // 弹出层标题
  219. title: "",
  220. // 是否显示弹出层
  221. open: false,
  222. show:{
  223. title:"客户详情",
  224. open:false,
  225. },
  226. // 用户类别字典
  227. typeOptions: [],
  228. // 性别字典
  229. genderOptions: [],
  230. // 来源字典
  231. addWayOptions: [],
  232. // 查询参数
  233. queryParams: {
  234. pageNum: 1,
  235. pageSize: 10,
  236. userId: null,
  237. qwUserName:null,
  238. externalUserId: null,
  239. name: null,
  240. avatar: null,
  241. type: null,
  242. createTime:null,
  243. gender: null,
  244. description: null,
  245. tagIds: null,
  246. remarkMobiles: null,
  247. remarkCorpName: null,
  248. addWay: null,
  249. operUserid: null,
  250. corpId: null,
  251. companyId: null,
  252. status:"3",
  253. transferStatus:null
  254. },
  255. // 表单参数
  256. form: {},
  257. tagList:[],
  258. transferStatusOptions:[],
  259. statusOptions:[],
  260. // 表单校验
  261. rules: {
  262. }
  263. };
  264. },
  265. created() {
  266. getMyQwCompanyList().then(response => {
  267. this.myQwCompanyList = response.data;
  268. if(this.myQwCompanyList!=null){
  269. this.queryParams.corpId=this.myQwCompanyList[0].dictValue
  270. this.getList();
  271. }
  272. });
  273. this.getDicts("sys_qw_externalContact_type").then(response => {
  274. this.typeOptions = response.data;
  275. });
  276. this.getDicts("sys_sex").then(response => {
  277. this.genderOptions = response.data;
  278. });
  279. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  280. this.addWayOptions = response.data;
  281. });
  282. listTag().then(response => {
  283. this.tagList = response.rows;
  284. });
  285. this.getDicts("sys_qw_external_contact_status").then(response => {
  286. this.statusOptions = response.data;
  287. });
  288. this.getDicts("sys_qw_transfer_status").then(response => {
  289. this.transferStatusOptions = response.data;
  290. });
  291. },
  292. methods: {
  293. updateCorpId(){
  294. this.getList();
  295. },
  296. /** 查询企业微信客户列表 */
  297. getList() {
  298. this.loading = true;
  299. myDeptExtList(this.queryParams).then(response => {
  300. this.externalContactList = response.rows;
  301. this.total = response.total;
  302. this.loading = false;
  303. });
  304. },
  305. handleClickX(tab, event) {
  306. this.queryParams.status=tab.name;
  307. this.handleQuery();
  308. },
  309. /** 查看客户详情 */
  310. handleShow(row){
  311. this.show.open=true;
  312. var that=this;
  313. const tab = "visit";
  314. setTimeout(() => {
  315. that.$refs.customerDetails.getDetails(row.customerId);
  316. that.$refs.customerDetails.handleClick(tab);
  317. }, 200);
  318. },
  319. // 取消按钮
  320. cancel() {
  321. this.open = false;
  322. this.reset();
  323. },
  324. // 表单重置
  325. reset() {
  326. this.form = {
  327. id: null,
  328. userId: null,
  329. externalUserId: null,
  330. name: null,
  331. avatar: null,
  332. type: null,
  333. gender: null,
  334. remark: null,
  335. description: null,
  336. tagIds: null,
  337. remarkMobiles: null,
  338. remarkCorpName: null,
  339. addWay: null,
  340. operUserid: null,
  341. corpId: null,
  342. companyId: null
  343. };
  344. this.resetForm("form");
  345. },
  346. /** 搜索按钮操作 */
  347. handleQuery() {
  348. this.queryParams.pageNum = 1;
  349. this.getList();
  350. },
  351. /** 重置按钮操作 */
  352. resetQuery() {
  353. this.resetForm("queryForm");
  354. this.queryParams.corpId= this.myQwCompanyList[0].dictValue;
  355. this.handleQuery();
  356. },
  357. // 多选框选中数据
  358. handleSelectionChange(selection) {
  359. this.ids = selection.map(item => item.id)
  360. this.single = selection.length!==1
  361. this.multiple = !selection.length
  362. },
  363. /** 新增按钮操作 */
  364. handleAdd() {
  365. addExternalContact(this.form).then(response => {
  366. this.msgSuccess("同步成功");
  367. this.getList();
  368. });
  369. },
  370. /** 修改按钮操作 */
  371. handleUpdate(row) {
  372. this.reset();
  373. const id = row.id || this.ids
  374. getExternalContact(id).then(response => {
  375. this.form = response.data;
  376. this.open = true;
  377. this.title = "修改企业微信客户";
  378. });
  379. },
  380. /** 提交按钮 */
  381. submitForm() {
  382. this.$refs["form"].validate(valid => {
  383. this.form.corpId=this.queryParams.corpId;
  384. if (valid) {
  385. if (this.form.id != null) {
  386. updateExternalContact(this.form).then(response => {
  387. this.msgSuccess("修改成功");
  388. this.open = false;
  389. this.getList();
  390. });
  391. } else {
  392. addExternalContact(this.form).then(response => {
  393. this.msgSuccess("新增成功");
  394. this.open = false;
  395. this.getList();
  396. });
  397. }
  398. }
  399. });
  400. },
  401. /** 删除按钮操作 */
  402. handleDelete(row) {
  403. const ids = row.id || this.ids;
  404. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  405. confirmButtonText: "确定",
  406. cancelButtonText: "取消",
  407. type: "warning"
  408. }).then(function() {
  409. return delExternalContact(ids);
  410. }).then(() => {
  411. this.getList();
  412. this.msgSuccess("删除成功");
  413. }).catch(() => {});
  414. },
  415. /** 导出按钮操作 */
  416. handleExport() {
  417. const queryParams = this.queryParams;
  418. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  419. confirmButtonText: "确定",
  420. cancelButtonText: "取消",
  421. type: "warning"
  422. }).then(() => {
  423. this.exportLoading = true;
  424. return exportExternalContact(queryParams);
  425. }).then(response => {
  426. this.download(response.msg);
  427. this.exportLoading = false;
  428. }).catch(() => {});
  429. }
  430. }
  431. };
  432. </script>