my.vue 14 KB

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