companyUnassigned.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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-card>
  204. <companyTransferQwUserSelect :corpId="queryParams.corpId" :companyId="companyId" @selectUser="selectUser"/>
  205. </el-card>
  206. </el-form>
  207. <div slot="footer" class="dialog-footer">
  208. <el-button type="primary"
  209. @click="submitForm"
  210. :disabled="submitLoading"
  211. :loading="submitLoading">提交审核</el-button>
  212. <el-button @click="cancel">取 消</el-button>
  213. </div>
  214. </el-dialog>
  215. </div>
  216. </template>
  217. <script>
  218. import { listTag } from '@/api/qw/tag'
  219. import { getMyQwCompanyList, userList } from '@/api/qw/user'
  220. import { addUnassigned, companyExtList, companyTransfer, exportExternalContact } from '@/api/qw/externalContact'
  221. import companyTransferQwUserSelect from '@/views/qw/externalContactTransfer/companyTransferQwUserSelect.vue'
  222. export default {
  223. name: "companyUnassigned",
  224. components: { companyTransferQwUserSelect },
  225. data() {
  226. return {
  227. showSearch: true,
  228. loading: false,
  229. ids: [],
  230. multiple: true,
  231. queryParams: {
  232. pageNum: 1,
  233. pageSize: 10,
  234. corpId: null,
  235. qwUserName: null,
  236. name: null,
  237. type: null,
  238. gender: null,
  239. transferStatus: null,
  240. status: 1
  241. },
  242. total: 0,
  243. externalContactList: [],
  244. myQwCompanyList: [],
  245. typeOptions: [],
  246. genderOptions: [],
  247. addWayOptions: [],
  248. statusOptions: [],
  249. transferStatusOptions: [],
  250. qwUserNameParam: {
  251. qwUserName: null,
  252. },
  253. qwUserNameList: [],
  254. isQwUserISNull: false,
  255. form: {
  256. corpId: null,
  257. qwUserId: null,
  258. nickName: null,
  259. content: null,
  260. type: 0,
  261. oldQwUserId: null
  262. },
  263. rules: {
  264. nickName: [
  265. { required: true, message: "接替员工不能为空", trigger: "blur" }
  266. ]
  267. },
  268. exportLoading: false,
  269. companyId: null,
  270. submitLoading: false,
  271. tagList: [],
  272. open: false,
  273. title: "",
  274. };
  275. },
  276. created() {
  277. // 从store中获取当前用户的companyId
  278. this.companyId = this.$store.state.user.user?.companyId || null;
  279. this.getQwCompanyList();
  280. this.getDicts("sys_qw_externalContact_type").then(response => {
  281. this.typeOptions = response.data;
  282. });
  283. this.getDicts("sys_sex").then(response => {
  284. this.genderOptions = response.data;
  285. });
  286. this.getDicts("sys_qw_externalContact_addWay").then(response => {
  287. this.addWayOptions = response.data;
  288. });
  289. this.getDicts("sys_qw_external_contact_status").then(response => {
  290. this.statusOptions = response.data;
  291. });
  292. this.getDicts("sys_qw_transfer_status").then(response => {
  293. this.transferStatusOptions = response.data;
  294. });
  295. },
  296. methods: {
  297. handleQuery() {
  298. this.queryParams.pageNum = 1;
  299. this.getList();
  300. },
  301. resetQuery() {
  302. this.queryParams = {
  303. pageNum: 1,
  304. pageSize: 10,
  305. corpId: null,
  306. qwUserName: null,
  307. name: null,
  308. type: null,
  309. gender: null,
  310. transferStatus: null,
  311. status: 1
  312. };
  313. this.qwUserNameList = null
  314. this.isQwUserISNull = false
  315. this.resetForm("queryForm")
  316. this.queryParams.corpId = this.myQwCompanyList?.[0]?.dictValue || null
  317. this.getList()
  318. },
  319. getList() {
  320. this.loading = true
  321. companyExtList(this.queryParams).then(response => {
  322. this.externalContactList = response.rows;
  323. this.total = response.total;
  324. this.loading = false
  325. })
  326. },
  327. getQwCompanyList() {
  328. getMyQwCompanyList().then(response => {
  329. this.myQwCompanyList = response.data;
  330. if(this.myQwCompanyList!=null){
  331. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  332. listTag({corpId:this.queryParams.corpId}).then(response => {
  333. this.tagList = response.rows;
  334. });
  335. this.getList();
  336. }
  337. });
  338. },
  339. updateCorpId() {
  340. listTag({corpId:this.queryParams.corpId}).then(response => {
  341. this.tagList = response.rows;
  342. });
  343. this.getList();
  344. },
  345. handleSelectChange(value) {
  346. if(!value){
  347. this.qwUserNameList=null
  348. this.isQwUserISNull = false;
  349. }else{
  350. this.isQwUserISNull = true;
  351. }
  352. },
  353. qwUserMethod(query) {
  354. if (query) {
  355. this.qwUserNameParam.qwUserName = query;
  356. userList(this.qwUserNameParam).then(response => {
  357. this.qwUserNameList = response.rows;
  358. });
  359. }
  360. },
  361. handleSync() {
  362. this.form.corpId=this.queryParams.corpId;
  363. addUnassigned(this.form).then(() => {
  364. this.msgSuccess("同步成功");
  365. this.getList();
  366. });
  367. },
  368. handleExport() {
  369. const queryParams = this.queryParams;
  370. this.$confirm('是否确认导出所有企业微信客户数据项?', "警告", {
  371. confirmButtonText: "确定",
  372. cancelButtonText: "取消",
  373. type: "warning"
  374. }).then(() => {
  375. this.exportLoading = true;
  376. return exportExternalContact(queryParams);
  377. }).then(response => {
  378. this.download(response.msg);
  379. this.exportLoading = false;
  380. }).catch(() => {});
  381. },
  382. handleSelectionChange(selection) {
  383. this.ids = selection.map(item => item.id)
  384. this.multiple = !selection.length
  385. },
  386. reset() {
  387. this.form = {
  388. corpId: null,
  389. qwUserId: null,
  390. nickName: null,
  391. content: null,
  392. type: 0,
  393. oldQwUserId: null
  394. };
  395. this.resetForm("form");
  396. },
  397. handleTransfer() {
  398. this.reset()
  399. if(!this.ids){
  400. this.$message('请选择需要分配的客户')
  401. return
  402. }
  403. this.submitLoading = false
  404. this.title = "分配客户"
  405. this.open = true
  406. },
  407. handleTransferAll() {
  408. this.reset()
  409. this.form.type = 1
  410. this.form.oldQwUserId = this.qwUserNameList.find(item => item.qwUserName === this.queryParams.qwUserName)?.id || null
  411. this.submitLoading = false
  412. this.title = "分配该员工所有客户"
  413. this.open = true
  414. },
  415. selectUser(selection) {
  416. this.form.qwUserId = selection.id
  417. this.form.nickName = selection.qwUserName
  418. },
  419. cancel() {
  420. this.open = false;
  421. this.reset();
  422. },
  423. submitForm() {
  424. this.$refs["form"].validate(valid => {
  425. if (valid) {
  426. if (this.submitLoading) {
  427. return;
  428. }
  429. this.submitLoading = true
  430. const params = {
  431. ids: this.ids,
  432. qwUserId: this.form.qwUserId,
  433. content: this.form.content,
  434. type: this.form.type,
  435. transferType: 2,
  436. oldQwUserId: this.form.oldQwUserId
  437. }
  438. companyTransfer(params).then(() => {
  439. this.$message.success("审核已提交,等待管理员审核");
  440. this.open = false;
  441. })
  442. }
  443. });
  444. }
  445. },
  446. };
  447. </script>
  448. <style scoped>
  449. </style>