index.vue 17 KB

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