deptUnassignedIndex.vue 17 KB

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