companyUnassigned.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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="handleSync"
  76. v-hasPermi="['qw:externalContact:addUnassigned']"
  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. :disabled="multiple"
  97. v-hasPermi="['qw:externalContact:companyTransfer']"
  98. >分配客户</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. v-if="isQwUserISNull"
  103. type="primary"
  104. plain
  105. size="mini"
  106. @click="handleTransferAll"
  107. v-hasPermi="['qw:externalContact:companyTransfer']"
  108. >分配此员工所有客户</el-button>
  109. </el-col>
  110. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  111. </el-row>
  112. <el-table v-loading="loading" :data="externalContactList" @selection-change="handleSelectionChange" border>
  113. <el-table-column type="selection" width="55" align="center" />
  114. <el-table-column label="原所属员工" align="center" prop="qwUserName" width="120px"/>
  115. <el-table-column label="原员工部门" align="center" prop="departmentName" width="120px"/>
  116. <el-table-column label="外部联系人账号" align="center" prop="externalUserId" width="120px"/>
  117. <el-table-column label="客户名称" align="center" prop="name" />
  118. <el-table-column label="头像" align="center" prop="avatar" width="120px">
  119. <template slot-scope="scope">
  120. <el-popover
  121. placement="right"
  122. title=""
  123. trigger="hover">
  124. <img slot="reference" :src="scope.row.avatar" width="100px">
  125. <img :src="scope.row.avatar" style="max-width: 150px;">
  126. </el-popover>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="用户类别" align="center" prop="type">
  130. <template slot-scope="scope">
  131. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="性别" align="center" prop="gender">
  135. <template slot-scope="scope">
  136. <dict-tag :options="genderOptions" :value="scope.row.gender"/>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="备注" align="center" prop="remark" />
  140. <el-table-column label="描述信息" align="center" prop="description" />
  141. <el-table-column label="标签" align="center" prop="tagIds" width="150px">
  142. <template slot-scope="scope">
  143. <div class="tag-container">
  144. <div class="tag-list">
  145. <div v-for="i in JSON.parse(scope.row.tagIds)" :key="i" style="display: inline;">
  146. <el-tag type="success" v-for="ii in tagList" :key="ii.id" style="margin: 3px;" v-if="ii.tagId==i">{{ii.name}}</el-tag>
  147. </div>
  148. </div>
  149. </div>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="备注电话号码" align="center" prop="remarkMobiles" width="150px">
  153. <template slot-scope="scope">
  154. <span v-for="i in JSON.parse(scope.row.remarkMobiles)" :key="i">{{i}}</span>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="备注企业名称" align="center" prop="remarkCorpName" />
  158. <el-table-column label="来源" align="center" prop="addWay" width="100px">
  159. <template slot-scope="scope">
  160. <dict-tag :options="addWayOptions" :value="scope.row.addWay"/>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="状态" align="center" prop="status" width="100px">
  164. <template slot-scope="scope">
  165. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="转接状态" align="center" prop="transferStatus" width="100px">
  169. <template slot-scope="scope">
  170. <dict-tag :options="transferStatusOptions" :value="scope.row.transferStatus"/>
  171. </template>
  172. </el-table-column>
  173. <el-table-column label="企业id" align="center" prop="corpId" />
  174. </el-table>
  175. <pagination
  176. v-show="total>0"
  177. :total="total"
  178. :page.sync="queryParams.pageNum"
  179. :limit.sync="queryParams.pageSize"
  180. :page-sizes="[100, 200, 300, 500]"
  181. @pagination="getList"
  182. />
  183. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  184. <el-form ref="form" :model="form" :rules="rules" label-width="100px" style="height: 100%">
  185. <div style="background-color: rgb(239, 250, 255); margin: 10px;padding: 15px;">
  186. <div>原跟进成员离职时间不能超过1年且离职前一年内至少登录过一次企业微信</div>
  187. <div>接替成员最近一年内至少登陆过一次企业微信。</div>
  188. <div>需等待总后台审核才会进行转接</div>
  189. </div>
  190. <el-form-item label="接替员工:" prop="nickName">
  191. <el-input style="width: 150px" disabled>
  192. <template slot="prefix">
  193. <el-button
  194. plain
  195. size="small"
  196. type="success"
  197. v-if="form.nickName">
  198. {{ form.nickName }}
  199. </el-button>
  200. </template>
  201. </el-input>
  202. </el-form-item>
  203. <el-form-item label="清除标签" prop="needClearTag">
  204. <el-radio v-model="form.needClearTag" :label="0">不清除</el-radio>
  205. <el-radio v-model="form.needClearTag" :label="1">清除</el-radio>
  206. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  207. <i class="el-icon-info"></i>
  208. <span v-if="form.needClearTag === 0">不清除标签:客户转接后会保留原标签,不会被清除。</span>
  209. <span v-else>清除标签:客户转接后原标签不会保留,仅会存在自动添加的标签。</span>
  210. </div>
  211. </el-form-item>
  212. <el-card>
  213. <companyTransferQwUserSelect ref="companyTransferSelect" @selectUser="selectUser"/>
  214. </el-card>
  215. </el-form>
  216. <div slot="footer" class="dialog-footer">
  217. <el-button type="primary"
  218. @click="submitForm"
  219. :disabled="submitLoading"
  220. :loading="submitLoading">提交审核</el-button>
  221. <el-button @click="cancel">取 消</el-button>
  222. </div>
  223. </el-dialog>
  224. </div>
  225. </template>
  226. <script>
  227. import { listTag } from '@/api/qw/tag'
  228. import { getMyQwCompanyList, userList } from '@/api/qw/user'
  229. import { addUnassigned, companyExtList, companyTransfer, exportExternalContact } from '@/api/qw/externalContact'
  230. import companyTransferQwUserSelect from '@/views/qw/externalContactTransfer/companyTransferQwUserSelect.vue'
  231. export default {
  232. name: "companyUnassigned",
  233. components: { companyTransferQwUserSelect },
  234. data() {
  235. return {
  236. showSearch: true,
  237. loading: false,
  238. ids: [],
  239. multiple: true,
  240. queryParams: {
  241. pageNum: 1,
  242. pageSize: 10,
  243. corpId: null,
  244. qwUserName: null,
  245. name: null,
  246. type: null,
  247. gender: null,
  248. transferStatus: null,
  249. status: 1
  250. },
  251. total: 0,
  252. externalContactList: [],
  253. myQwCompanyList: [],
  254. typeOptions: [],
  255. genderOptions: [],
  256. addWayOptions: [],
  257. statusOptions: [],
  258. transferStatusOptions: [],
  259. qwUserNameParam: {
  260. qwUserName: null,
  261. },
  262. qwUserNameList: [],
  263. isQwUserISNull: false,
  264. form: {
  265. corpId: null,
  266. qwUserId: null,
  267. nickName: null,
  268. content: null,
  269. type: 0,
  270. oldQwUserId: null,
  271. needClearTag: 0
  272. },
  273. rules: {
  274. nickName: [
  275. { required: true, message: "接替员工不能为空", trigger: "blur" }
  276. ]
  277. },
  278. exportLoading: false,
  279. companyId: null,
  280. submitLoading: false,
  281. tagList: [],
  282. open: false,
  283. title: "",
  284. };
  285. },
  286. created() {
  287. // 从store中获取当前用户的companyId
  288. this.companyId = this.$store.state.user.user?.companyId || null;
  289. this.getQwCompanyList();
  290. this.getDicts("sys_qw_externalContact_type").then(response => {
  291. this.typeOptions = response.data;
  292. });
  293. this.getDicts("sys_sex").then(response => {
  294. this.genderOptions = response.data;
  295. });
  296. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  297. this.addWayOptions = response.data;
  298. });
  299. this.getDicts("sys_qw_external_contact_status").then(response => {
  300. this.statusOptions = response.data;
  301. });
  302. this.getDicts("sys_qw_transfer_status").then(response => {
  303. this.transferStatusOptions = response.data;
  304. });
  305. },
  306. methods: {
  307. handleQuery() {
  308. this.queryParams.pageNum = 1;
  309. this.getList();
  310. },
  311. resetQuery() {
  312. this.queryParams = {
  313. pageNum: 1,
  314. pageSize: 10,
  315. corpId: null,
  316. qwUserName: null,
  317. name: null,
  318. type: null,
  319. gender: null,
  320. transferStatus: null,
  321. status: 1
  322. };
  323. this.qwUserNameList = null
  324. this.isQwUserISNull = false
  325. this.resetForm("queryForm")
  326. this.queryParams.corpId = this.myQwCompanyList?.[0]?.dictValue || null
  327. this.getList()
  328. },
  329. getList() {
  330. this.loading = true
  331. companyExtList(this.queryParams).then(response => {
  332. this.externalContactList = response.rows;
  333. this.total = response.total;
  334. this.loading = false
  335. })
  336. },
  337. getQwCompanyList() {
  338. getMyQwCompanyList().then(response => {
  339. this.myQwCompanyList = response.data;
  340. if(this.myQwCompanyList!=null){
  341. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  342. listTag({corpId:this.queryParams.corpId}).then(response => {
  343. this.tagList = response.rows;
  344. });
  345. this.getList();
  346. }
  347. });
  348. },
  349. updateCorpId() {
  350. listTag({corpId:this.queryParams.corpId}).then(response => {
  351. this.tagList = response.rows;
  352. });
  353. this.getList();
  354. },
  355. handleSelectChange(value) {
  356. if(!value){
  357. this.qwUserNameList=null
  358. this.isQwUserISNull = false;
  359. }else{
  360. this.isQwUserISNull = true;
  361. }
  362. },
  363. qwUserMethod(query) {
  364. if (query) {
  365. this.qwUserNameParam.qwUserName = query;
  366. userList(this.qwUserNameParam).then(response => {
  367. this.qwUserNameList = response.rows;
  368. });
  369. }
  370. },
  371. handleSync() {
  372. this.form.corpId=this.queryParams.corpId;
  373. addUnassigned(this.form).then(() => {
  374. this.msgSuccess("同步成功");
  375. this.getList();
  376. });
  377. },
  378. handleExport() {
  379. const queryParams = this.queryParams;
  380. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  381. confirmButtonText: "确定",
  382. cancelButtonText: "取消",
  383. type: "warning"
  384. }).then(() => {
  385. this.exportLoading = true;
  386. return exportExternalContact(queryParams);
  387. }).then(response => {
  388. this.download(response.msg);
  389. this.exportLoading = false;
  390. }).catch(() => {});
  391. },
  392. handleSelectionChange(selection) {
  393. this.ids = selection.map(item => item.id)
  394. this.multiple = !selection.length
  395. },
  396. reset() {
  397. this.form = {
  398. corpId: null,
  399. qwUserId: null,
  400. nickName: null,
  401. content: null,
  402. type: 0,
  403. oldQwUserId: null,
  404. needClearTag: 0
  405. };
  406. this.resetForm("form");
  407. },
  408. handleTransfer() {
  409. this.reset()
  410. if(!this.ids){
  411. this.$message('请选择需要分配的客户')
  412. return
  413. }
  414. this.submitLoading = false
  415. this.title = "分配客户"
  416. this.open = true
  417. },
  418. handleTransferAll() {
  419. this.reset()
  420. this.form.type = 1
  421. this.form.oldQwUserId = this.qwUserNameList.find(item => item.qwUserName === this.queryParams.qwUserName)?.id || null
  422. this.submitLoading = false
  423. this.title = "分配该员工所有客户"
  424. this.open = true
  425. this.$nextTick(() => {
  426. this.$refs.companyTransferSelect.load(this.queryParams.corpId, this.companyId)
  427. })
  428. },
  429. selectUser(selection) {
  430. this.form.qwUserId = selection.id
  431. this.form.nickName = selection.qwUserName
  432. },
  433. cancel() {
  434. this.open = false;
  435. this.reset();
  436. },
  437. submitForm() {
  438. this.$refs["form"].validate(valid => {
  439. if (valid) {
  440. if (this.submitLoading) {
  441. return;
  442. }
  443. this.submitLoading = true
  444. const params = {
  445. ids: this.ids,
  446. qwUserId: this.form.qwUserId,
  447. content: this.form.content,
  448. type: this.form.type,
  449. transferType: 2,
  450. oldQwUserId: this.form.oldQwUserId,
  451. needClearTag: this.form.needClearTag
  452. }
  453. companyTransfer(params).then(() => {
  454. this.$message.success("审核已提交,等待管理员审核");
  455. this.open = false;
  456. })
  457. }
  458. });
  459. }
  460. },
  461. };
  462. </script>
  463. <style scoped>
  464. </style>