deptUnassignedIndex.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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 v-for="i in JSON.parse(scope.row.tagIds)" :key="i" style="display: inline;">
  130. <el-tag type="success" v-for="ii in tagList" :key="ii.id" style="margin: 3px;" v-if="ii.tagId==i">{{ii.name}}</el-tag>
  131. </div>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
  135. <template slot-scope="scope">
  136. <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</span>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
  140. <el-table-column label="来源" align="center" prop="addWay" width="100px">
  141. <template slot-scope="scope">
  142. <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="状态" align="center" prop="status" width="100px">
  146. <template slot-scope="scope">
  147. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px">
  151. <template slot-scope="scope">
  152. <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="企业id" align="center" prop="corpId" />
  156. <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  157. <template slot-scope="scope">
  158. <el-button
  159. size="mini"
  160. type="text"
  161. icon="el-icon-edit"
  162. @click="handleUpdate(scope.row)"
  163. v-hasPermi="['qw:externalContact:edit']"
  164. >修改</el-button>
  165. </template>
  166. </el-table-column> -->
  167. </el-table>
  168. <pagination
  169. v-show="total>0"
  170. :total="total"
  171. :page.sync="queryParams.pageNum"
  172. :limit.sync="queryParams.pageSize"
  173. @pagination="getList"
  174. />
  175. <!-- 添加或修改企业微信客户对话框 -->
  176. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  177. <el-form ref="form" :model="form" :rules="rules" label-width="100px" style="height: 100%">
  178. <div style="background-color: rgb(239, 250, 255); margin: 10px;padding: 15px;">
  179. <div>原跟进成员离职时间不能超过1年且离职前一年内至少登录过一次企业微信</div>
  180. <div>接替成员最近一年内至少登陆过一次企业微信。</div>
  181. </div>
  182. <el-form-item label="接替员工:" prop="userId">
  183. <el-input style="width: 150px" disabled>
  184. <template slot="prefix">
  185. <el-button
  186. plain
  187. size="small"
  188. type="success"
  189. v-if="this.nickName">
  190. {{ nickName }}
  191. </el-button>
  192. </template>
  193. </el-input>
  194. </el-form-item>
  195. <el-card>
  196. <qwUserSelectOne ref="qwUserSelectOne" @selectUser="selectUser"></qwUserSelectOne>
  197. </el-card>
  198. </el-form>
  199. <div slot="footer" class="dialog-footer">
  200. <el-button type="primary" @click="submitForm">确 定</el-button>
  201. <el-button @click="cancel">取 消</el-button>
  202. </div>
  203. </el-dialog>
  204. </div>
  205. </template>
  206. <script>
  207. import {
  208. addUnassigned,
  209. resignedTransfer,
  210. listExternalContact,
  211. getExternalContact,
  212. delExternalContact,
  213. addExternalContact,
  214. updateExternalContact,
  215. exportExternalContact,
  216. myDeptExtList
  217. } from "../../../api/qw/externalContact";
  218. import { listTag, getTag, delTag, addTag, updateTag, exportTag } from "@/api/qw/tag";
  219. // import { qwUserList } from "@/api/qw/user";
  220. import qwUserSelectOne from "@/views/qw/user/qwUserSelectOne.vue";
  221. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  222. export default {
  223. name: "deptUnassignedIndex",
  224. components:{qwUserSelectOne},
  225. data() {
  226. return {
  227. // 遮罩层
  228. loading: true,
  229. // 导出遮罩层
  230. exportLoading: false,
  231. // 选中数组
  232. ids: [],
  233. // 非单个禁用
  234. single: true,
  235. // 非多个禁用
  236. multiple: true,
  237. // 显示搜索条件
  238. showSearch: true,
  239. // 总条数
  240. total: 0,
  241. // 企业微信客户表格数据
  242. externalContactList: [],
  243. // 弹出层标题
  244. title: "",
  245. // 是否显示弹出层
  246. open: false,
  247. // 用户类别字典
  248. typeOptions: [],
  249. myQwCompanyList:[],
  250. genderOptions: [],
  251. // 来源字典
  252. addWayOptions: [],
  253. qwUserList:[],
  254. // 查询参数
  255. queryParams: {
  256. pageNum: 1,
  257. pageSize: 10,
  258. userId: null,
  259. qwUserName: null,
  260. externalUserId: null,
  261. name: null,
  262. avatar: null,
  263. type: null,
  264. gender: null,
  265. description: null,
  266. tagIds: null,
  267. remarkMobiles: null,
  268. remarkCorpName: null,
  269. addWay: null,
  270. operUserid: null,
  271. corpId: null,
  272. companyId: null,
  273. status:1,
  274. transferStatus:null
  275. },
  276. nickName:null,
  277. // 表单参数
  278. form: {
  279. },
  280. tagList:[],
  281. transferStatusOptions:[],
  282. statusOptions:[],
  283. // 表单校验
  284. rules: {
  285. userId:[ { required: true, message: "接替员工不能为空", trigger: "blur" }]
  286. }
  287. };
  288. },
  289. created() {
  290. getMyQwCompanyList().then(response => {
  291. this.myQwCompanyList = response.data;
  292. if(this.myQwCompanyList!=null){
  293. this.queryParams.corpId=this.myQwCompanyList[0].dictValue
  294. listTag({corpId:this.queryParams.corpId}).then(response => {
  295. this.tagList = response.rows;
  296. });
  297. this.getList();
  298. }
  299. });
  300. this.getDicts("sys_qw_externalContact_type").then(response => {
  301. this.typeOptions = response.data;
  302. });
  303. this.getDicts("sys_sex").then(response => {
  304. this.genderOptions = response.data;
  305. });
  306. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  307. this.addWayOptions = response.data;
  308. });
  309. this.getDicts("sys_qw_external_contact_status").then(response => {
  310. this.statusOptions = response.data;
  311. });
  312. this.getDicts("sys_qw_transfer_status").then(response => {
  313. this.transferStatusOptions = response.data;
  314. });
  315. // qwUserList().then(response => {
  316. // this.qwUserList = response.rows;
  317. // });
  318. },
  319. methods: {
  320. updateCorpId(){
  321. listTag({corpId:this.queryParams.corpId}).then(response => {
  322. this.tagList = response.rows;
  323. });
  324. this.getList();
  325. },
  326. getList() {
  327. this.loading = true;
  328. myDeptExtList(this.queryParams).then(response => {
  329. this.externalContactList = response.rows;
  330. this.total = response.total;
  331. this.loading = false;
  332. });
  333. },
  334. // 取消按钮
  335. cancel() {
  336. this.open = false;
  337. this.reset();
  338. },
  339. // 表单重置
  340. reset() {
  341. this.form = {
  342. id: null,
  343. userId: null,
  344. externalUserId: null,
  345. name: null,
  346. avatar: null,
  347. type: null,
  348. gender: null,
  349. remark: null,
  350. description: null,
  351. tagIds: null,
  352. remarkMobiles: null,
  353. remarkCorpName: null,
  354. addWay: null,
  355. operUserid: null,
  356. corpId: null,
  357. companyId: null
  358. };
  359. this.resetForm("form");
  360. },
  361. selectUser(row){
  362. this.form.userId=row.id
  363. // console.log("row",row)
  364. this.nickName=row.nickName
  365. },
  366. /** 搜索按钮操作 */
  367. handleQuery() {
  368. this.queryParams.pageNum = 1;
  369. this.getList();
  370. },
  371. /** 重置按钮操作 */
  372. resetQuery() {
  373. this.resetForm("queryForm");
  374. this.queryParams.corpId= this.myQwCompanyList[0].dictValue
  375. this.handleQuery();
  376. },
  377. // 多选框选中数据
  378. handleSelectionChange(selection) {
  379. this.ids = selection.map(item => item.id)
  380. this.single = selection.length!==1
  381. this.multiple = !selection.length
  382. },
  383. /** 新增按钮操作 */
  384. handleAdd() {
  385. this.form.corpId=this.queryParams.corpId;
  386. addUnassigned(this.form).then(response => {
  387. this.msgSuccess("同步成功");
  388. this.getList();
  389. });
  390. },
  391. handleTransfer(row) {
  392. this.reset();
  393. if(this.ids==null||this.ids==""){
  394. return this.$message('请选择需要分配的客户');
  395. }
  396. setTimeout(() => {
  397. this.$refs.qwUserSelectOne.getDetails(this.queryParams.corpId);
  398. }, 1);
  399. this.open = true;
  400. this.title = "分配客户";
  401. },
  402. /** 提交按钮 */
  403. submitForm() {
  404. this.nickName=null;
  405. this.$refs["form"].validate(valid => {
  406. if (valid) {
  407. var form={
  408. ids:this.ids,
  409. userId:this.form.userId,
  410. corpId:this.queryParams.corpId,
  411. }
  412. resignedTransfer(form).then(response => {
  413. this.msgSuccess(response.msg);
  414. this.open = false;
  415. this.getList();
  416. });
  417. }
  418. });
  419. },
  420. /** 删除按钮操作 */
  421. handleDelete(row) {
  422. const ids = row.id || this.ids;
  423. this.$confirm('是否确认删除企业微信客户编号为"' + ids + '"的数据项?', "警告", {
  424. confirmButtonText: "确定",
  425. cancelButtonText: "取消",
  426. type: "warning"
  427. }).then(function() {
  428. return delExternalContact(ids);
  429. }).then(() => {
  430. this.getList();
  431. this.msgSuccess("删除成功");
  432. }).catch(() => {});
  433. },
  434. /** 导出按钮操作 */
  435. handleExport() {
  436. const queryParams = this.queryParams;
  437. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  438. confirmButtonText: "确定",
  439. cancelButtonText: "取消",
  440. type: "warning"
  441. }).then(() => {
  442. this.exportLoading = true;
  443. return exportExternalContact(queryParams);
  444. }).then(response => {
  445. this.download(response.msg);
  446. this.exportLoading = false;
  447. }).catch(() => {});
  448. }
  449. }
  450. };
  451. </script>