index旧.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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 class="tag-container">
  168. <div class="tag-list">
  169. <div v-for="i in JSON.parse(scope.row.tagIds)" :key="i" style="display: inline;">
  170. <el-tag type="success" v-for="ii in tagList" :key="ii.id" style="margin: 3px;" v-if="ii.tagId==i">{{ii.name}}</el-tag>
  171. </div>
  172. </div>
  173. </div>
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
  177. <template slot-scope="scope">
  178. <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</span>
  179. </template>
  180. </el-table-column>
  181. <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
  182. <el-table-column label="来源" align="center" prop="addWay" width="100px">
  183. <template slot-scope="scope">
  184. <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="添加时间" align="center" prop="createTime" width="100px"/>
  188. <el-table-column label="状态" align="center" prop="status" width="100px">
  189. <template slot-scope="scope">
  190. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px">
  194. <template slot-scope="scope">
  195. <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
  196. </template>
  197. </el-table-column>
  198. <el-table-column label="企业id" align="center" prop="corpId" />
  199. <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  200. <template slot-scope="scope">
  201. <el-button
  202. size="mini"
  203. type="text"
  204. icon="el-icon-edit"
  205. @click="handleUpdate(scope.row)"
  206. v-hasPermi="['qw:externalContact:edit']"
  207. >修改</el-button>
  208. </template>
  209. </el-table-column> -->
  210. </el-table>
  211. <pagination
  212. v-show="total>0"
  213. :total="total"
  214. :page.sync="queryParams.pageNum"
  215. :limit.sync="queryParams.pageSize"
  216. :page-sizes="[100, 200, 300, 500]"
  217. @pagination="getList"
  218. />
  219. <!-- 添加或修改企业微信客户对话框 -->
  220. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  221. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  222. <div style="background-color: rgb(239, 250, 255); margin: 10px;padding: 15px;">
  223. <div>可将选中的客户转接给其他员工,进行后续服务</div>
  224. <div>注意:90天内客户只能被转接一次,一个客户最多只能被转接两次</div>
  225. </div>
  226. <el-form-item label="接替员工" prop="userId">
  227. <!-- <el-button type="success" v-if="this.nickName">{{ nickName }}</el-button>-->
  228. <el-input style="width: 150px" disabled>
  229. <template slot="prefix">
  230. <el-button
  231. plain
  232. size="small"
  233. type="success"
  234. v-if="this.nickName">
  235. {{ nickName }}
  236. </el-button>
  237. </template>
  238. </el-input>
  239. </el-form-item>
  240. <el-form-item label="消息内容" prop="content">
  241. <el-input v-model="form.content" placeholder="请输入内容" />
  242. </el-form-item>
  243. <el-card>
  244. <qwUserSelectOne ref="qwUserSelectOne" @selectUser="selectUser"></qwUserSelectOne>
  245. </el-card>
  246. </el-form>
  247. <div slot="footer" class="dialog-footer">
  248. <el-button type="primary" @click="submitForm">确 定</el-button>
  249. <el-button @click="cancel">取 消</el-button>
  250. </div>
  251. </el-dialog>
  252. </div>
  253. </template>
  254. <script>
  255. import { transfer,listExternalContact, getExternalContact, delExternalContact, addExternalContact, updateExternalContact, exportExternalContact } from "../../../api/qw/externalContact";
  256. import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
  257. import { qwUserList,userList } from "@/api/qw/user";
  258. import qwUserSelectOne from '@/views/qw/user/qwUserSelectOne.vue'
  259. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  260. export default {
  261. name: "ExternalContact",
  262. components: { qwUserSelectOne },
  263. data() {
  264. return {
  265. // 遮罩层
  266. loading: true,
  267. // 导出遮罩层
  268. exportLoading: false,
  269. // 选中数组
  270. ids: [],
  271. myQwCompanyList:[],
  272. // 非单个禁用
  273. single: true,
  274. // 非多个禁用
  275. multiple: true,
  276. // 显示搜索条件
  277. showSearch: true,
  278. // 总条数
  279. total: 0,
  280. // 企业微信客户表格数据
  281. externalContactList: [],
  282. // 弹出层标题
  283. title: "",
  284. // 是否显示弹出层
  285. open: false,
  286. // 用户类别字典
  287. typeOptions: [],
  288. selectTags:[],
  289. // 性别字典
  290. genderOptions: [],
  291. // 来源字典
  292. addWayOptions: [],
  293. nickName:null,
  294. qwUserList:[],
  295. isQwUserISNull:false,
  296. qwUserNameList:[],
  297. qwUserName:null,
  298. type:'0',
  299. qwUserNameParam:{
  300. qwUserName:null
  301. },
  302. // 查询参数
  303. queryParams: {
  304. pageNum: 1,
  305. pageSize: 300,
  306. userId: null,
  307. externalUserId: null,
  308. name: null,
  309. avatar: null,
  310. type: null,
  311. gender: null,
  312. description: null,
  313. tagIds: null,
  314. remarkMobiles: null,
  315. remarkCorpName: null,
  316. addWay: null,
  317. operUserid: null,
  318. corpId: null,
  319. companyId: null,
  320. status:0,
  321. transferStatus:null
  322. },
  323. // 表单参数
  324. form: {},
  325. tagList:[],
  326. transferStatusOptions:[],
  327. statusOptions:[],
  328. // 表单校验
  329. rules: {
  330. userId: [{ required: true, message: '请选择接替员工', trigger: 'blur' }],
  331. }
  332. };
  333. },
  334. created() {
  335. getMyQwCompanyList().then(response => {
  336. this.myQwCompanyList = response.data;
  337. if(this.myQwCompanyList!=null){
  338. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  339. listTag({corpId:this.queryParams.corpId}).then(response => {
  340. this.tagList = response.rows;
  341. });
  342. qwUserList(this.queryParams.corpId).then(response => {
  343. this.qwUserList = response.rows;
  344. });
  345. this.getList();
  346. }
  347. });
  348. this.getDicts("sys_qw_externalContact_type").then(response => {
  349. this.typeOptions = response.data;
  350. });
  351. this.getDicts("sys_user_sex").then(response => {
  352. this.genderOptions = response.data;
  353. });
  354. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  355. this.addWayOptions = response.data;
  356. });
  357. this.getDicts("sys_qw_external_contact_status").then(response => {
  358. this.statusOptions = response.data;
  359. });
  360. this.getDicts("sys_qw_transfer_status").then(response => {
  361. this.transferStatusOptions = response.data;
  362. });
  363. },
  364. methods: {
  365. qwUserMethod(query) {
  366. if (query !== '') {
  367. this.qwUserNameParam.qwUserName = query;
  368. userList(this.qwUserNameParam).then(response => {
  369. this.qwUserNameList = response.rows;
  370. });
  371. }
  372. },
  373. handleSelectChange(value) {
  374. console.log('选中的值:', value);
  375. if(value == ''){
  376. this.qwUserNameList=null
  377. this.isQwUserISNull = false;
  378. }else{
  379. this.isQwUserISNull = true;
  380. }
  381. },
  382. updateCorpId(){
  383. listTag({corpId:this.queryParams.corpId}).then(response => {
  384. this.tagList = response.rows;
  385. });
  386. qwUserList(this.queryParams.corpId).then(response => {
  387. this.qwUserList = response.rows;
  388. });
  389. this.getList();
  390. },
  391. /** 查询企业微信客户列表 */
  392. getList() {
  393. this.loading = true;
  394. listExternalContact(this.queryParams).then(response => {
  395. this.externalContactList = response.rows;
  396. this.total = response.total;
  397. this.loading = false;
  398. });
  399. },
  400. // 取消按钮
  401. cancel() {
  402. this.open = false;
  403. this.reset();
  404. },
  405. // 表单重置
  406. reset() {
  407. this.form = {
  408. id: null,
  409. userId: null,
  410. externalUserId: null,
  411. name: null,
  412. avatar: null,
  413. type: null,
  414. gender: null,
  415. remark: null,
  416. description: null,
  417. tagIds: null,
  418. remarkMobiles: null,
  419. remarkCorpName: null,
  420. addWay: null,
  421. operUserid: null,
  422. corpId: null,
  423. companyId: null
  424. };
  425. this.resetForm("form");
  426. },
  427. selectUser(row){
  428. this.form.userId=row.id
  429. console.log(row)
  430. this.nickName=row.qwUserName
  431. },
  432. /** 搜索按钮操作 */
  433. handleQuery() {
  434. this.queryParams.tagIds=this.selectTags.join(',')
  435. this.queryParams.pageNum = 1;
  436. this.getList();
  437. },
  438. /** 重置按钮操作 */
  439. resetQuery() {
  440. this.qwUserNameList=null
  441. this.isQwUserISNull = false;
  442. this.selectTags=[];
  443. this.resetForm("queryForm");
  444. this.handleQuery();
  445. },
  446. // 多选框选中数据
  447. handleSelectionChange(selection) {
  448. this.ids = selection.map(item => item.id)
  449. this.single = selection.length!==1
  450. this.multiple = !selection.length
  451. },
  452. /** 新增按钮操作 */
  453. handleAdd() {
  454. addExternalContact(this.form).then(response => {
  455. this.msgSuccess("同步成功");
  456. this.getList();
  457. });
  458. },
  459. handleTransfer(row) {
  460. this.reset();
  461. this.type="0";
  462. if(this.ids==null||this.ids==""){
  463. return this.$message('请选择需要分配的客户');
  464. }
  465. setTimeout(() => {
  466. this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
  467. }, 1);
  468. this.open = true;
  469. this.title = "分配客户";
  470. },
  471. handleTransferAll(row) {
  472. this.reset();
  473. this.qwUserName=this.queryParams.qwUserName;
  474. this.type="1";
  475. setTimeout(() => {
  476. this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
  477. }, 1);
  478. this.open = true;
  479. this.title = "分配该员工所有客户";
  480. },
  481. /** 提交按钮 */
  482. submitForm() {
  483. this.$refs["form"].validate(valid => {
  484. if (valid) {
  485. var form={
  486. ids:this.ids,
  487. qwUserName:this.qwUserName,
  488. type:this.type,
  489. userId:this.form.userId,
  490. corpId:this.queryParams.corpId,
  491. content:this.form.content,
  492. }
  493. transfer(form).then(response => {
  494. this.msgSuccess(response.msg);
  495. this.open = false;
  496. this.getList();
  497. });
  498. }
  499. });
  500. this.qwUserName=null;
  501. },
  502. /** 删除按钮操作 */
  503. handleDelete(row) {
  504. const ids = row.id || this.ids;
  505. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  506. confirmButtonText: "确定",
  507. cancelButtonText: "取消",
  508. type: "warning"
  509. }).then(function() {
  510. return delExternalContact(ids);
  511. }).then(() => {
  512. this.getList();
  513. this.msgSuccess("删除成功");
  514. }).catch(() => {});
  515. },
  516. /** 导出按钮操作 */
  517. handleExport() {
  518. const queryParams = this.queryParams;
  519. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  520. confirmButtonText: "确定",
  521. cancelButtonText: "取消",
  522. type: "warning"
  523. }).then(() => {
  524. this.exportLoading = true;
  525. return exportExternalContact(queryParams);
  526. }).then(response => {
  527. this.download(response.msg);
  528. this.exportLoading = false;
  529. }).catch(() => {});
  530. }
  531. }
  532. };
  533. </script>
  534. <style scoped>
  535. .tag-container {
  536. max-height: 300px;
  537. overflow-y: auto;
  538. padding: 1px;
  539. border: 1px solid #ebeef5;
  540. border-radius: 1px;
  541. background-color: #fafafa;
  542. }
  543. .tag-list {
  544. display: flex;
  545. flex-wrap: wrap;
  546. gap: 8px;
  547. }
  548. .scroll-hint {
  549. text-align: center;
  550. color: #909399;
  551. font-size: 12px;
  552. padding: 1px 0;
  553. }
  554. .container {
  555. max-width: 800px;
  556. margin: 0 auto;
  557. padding: 10px;
  558. }
  559. .title {
  560. text-align: center;
  561. color: #303133;
  562. margin-bottom: 30px;
  563. }
  564. .demo-table {
  565. width: 100%;
  566. margin-bottom: 30px;
  567. }
  568. .instructions {
  569. background-color: #f5f7fa;
  570. padding: 15px;
  571. border-radius: 1px;
  572. margin-bottom: 20px;
  573. }
  574. </style>