index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  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="qwUserId">
  15. <el-input
  16. v-model="queryParams.qwUserId"
  17. placeholder="请输入企微账号"
  18. clearable
  19. size="small"
  20. @keyup.enter.native="handleQuery"
  21. />
  22. </el-form-item>
  23. <el-form-item label="企微昵称" prop="qwUserName">
  24. <el-input
  25. v-model="queryParams.qwUserName"
  26. placeholder="请输入企微昵称"
  27. clearable
  28. size="small"
  29. @keyup.enter.native="handleQuery"
  30. />
  31. </el-form-item>
  32. <el-form-item label="授权码" prop="appKey">
  33. <el-input
  34. v-model="queryParams.appKey"
  35. placeholder="请输入授权码"
  36. clearable
  37. size="small"
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <el-row :gutter="10" class="mb8">
  47. <el-col :span="1.5">
  48. <el-button
  49. type="warning"
  50. plain
  51. icon="el-icon-download"
  52. size="mini"
  53. :loading="exportLoading"
  54. @click="handleExport"
  55. v-hasPermi="['qw:user:export']"
  56. >导出</el-button>
  57. </el-col>
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. <el-table border v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
  61. <el-table-column label="企微成员ID" align="center" prop="id" />
  62. <el-table-column label="企微账号" align="center" prop="qwUserId" />
  63. <el-table-column label="企微昵称" align="center" prop="qwUserName" />
  64. <el-table-column label="员工称呼" align="center" prop="welcomeText" />
  65. <el-table-column label="所属部门" align="center" prop="isDel">
  66. <template slot-scope="scope">
  67. <el-tag v-if="scope.row.isDel == 0" type="success">正常</el-tag>
  68. <el-tag v-else type="error">离职</el-tag>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="联系我二维码" align="center" prop="contactWay" >
  72. <template slot-scope="scope">
  73. <el-image
  74. v-if="scope.row.contactWay!=null"
  75. style="width: 100px; height: 100px"
  76. :src="scope.row.contactWay"
  77. fit="contain"
  78. @click="openImageViewer(scope.row.contactWay)"/>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="绑定的AI客服" align="center" prop="fastGptRoleName" />
  82. <el-table-column label="授权码" align="center" prop="appKey" />
  83. <el-table-column label="ai状态" align="center" prop="loginStatus">
  84. <template slot-scope="scope">
  85. <el-tag v-if="scope.row.ipadStatus == 1" type="success">在线</el-tag>
  86. <el-tag v-else type="danger">离线</el-tag>
  87. </template>
  88. </el-table-column>
  89. <!-- <el-table-column label="插件状态" align="center" prop="toolStatus">-->
  90. <!-- <template slot-scope="scope">-->
  91. <!-- <el-tag v-if="scope.row.toolStatus == 1" type="success">在线</el-tag>-->
  92. <!-- <el-tag v-else type="danger">离线</el-tag>-->
  93. <!-- </template>-->
  94. <!-- </el-table-column>-->
  95. <!-- <el-table-column label="插件版本" align="center" prop="version"/>-->
  96. <el-table-column label="服务器地址" align="center" prop="loginCodeUrl">
  97. <template slot-scope="scope">
  98. <el-tooltip class="item" effect="dark" :content="scope.row.loginCodeUrl" placement="top">
  99. <div style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis;">
  100. <span>{{ scope.row.loginCodeUrl }}</span>
  101. </div>
  102. </el-tooltip>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
  106. <template slot-scope="scope">
  107. <el-button
  108. size="mini"
  109. type="text"
  110. icon="el-icon-user-solid"
  111. plain
  112. @click="handleAppellation(scope.row)"
  113. >
  114. 修改员工称呼
  115. </el-button>
  116. <el-button
  117. v-if="scope.row.serverStatus==1&&scope.row.ipadStatus!=1"
  118. size="mini"
  119. type="text"
  120. icon="el-icon-sunny"
  121. plain
  122. @click="handleLoginQwCode(scope.row)"
  123. v-hasPermi="['qw:user:login']"
  124. >
  125. 登录企微
  126. </el-button>
  127. <el-button
  128. v-if="scope.row.serverStatus==1&&scope.row.ipadStatus==1"
  129. size="mini"
  130. type="text"
  131. icon="el-icon-moon"
  132. plain
  133. @click="handleLoginOutQwStatus(scope.row)"
  134. v-hasPermi="['qw:user:login']"
  135. >
  136. 退出企微
  137. </el-button>
  138. <el-button
  139. v-if="scope.row.ipadStatus==1"
  140. size="mini"
  141. type="text"
  142. icon="el-icon-moon"
  143. plain
  144. @click="handleTwoCode(scope.row)"
  145. v-hasPermi="['qw:user:login']">
  146. 二次验证
  147. </el-button>
  148. <el-button
  149. v-if="scope.row.serverStatus!=1"
  150. size="mini"
  151. type="text"
  152. icon="el-icon-moon"
  153. plain
  154. @click="handleGetQwIpad(scope.row)"
  155. v-hasPermi="['qw:user:login']"
  156. >
  157. 获取Ai主机
  158. </el-button>
  159. <el-button
  160. v-if="scope.row.serverStatus==1 && scope.row.ipadStatus!=1"
  161. size="mini"
  162. type="text"
  163. icon="el-icon-moon"
  164. plain
  165. @click="handleDelQwIpad(scope.row)"
  166. v-hasPermi="['qw:user:login']"
  167. >
  168. 解绑Ai主机
  169. </el-button>
  170. </template>
  171. </el-table-column>
  172. <el-table-column label="主机" align="center" class-name="small-padding fixed-width" width="110px" fixed="right">
  173. <template slot-scope="scope">
  174. <el-button
  175. v-if="scope.row.appKey==null"
  176. size="mini"
  177. type="text"
  178. icon="el-icon-s-check"
  179. plain
  180. v-hasPermi="['qw:user:authAppKey']"
  181. @click="uploadAuthorizeKey2(scope.row)"
  182. >授权key
  183. </el-button>
  184. <el-button
  185. v-if="scope.row.loginCodeUrl==null && scope.row.appKey !=null"
  186. size="mini"
  187. type="text"
  188. icon="el-icon-sunny"
  189. plain
  190. @click="handleBindCloudHost(scope.row)"
  191. v-hasPermi="['qw:user:loginIp']"
  192. >
  193. 绑定主机
  194. </el-button>
  195. <!-- <el-button-->
  196. <!-- v-if="scope.row.loginCodeUrl!=null"-->
  197. <!-- size="mini"-->
  198. <!-- type="text"-->
  199. <!-- icon="el-icon-video-camera-solid"-->
  200. <!-- plain-->
  201. <!-- @click="handleCloudAP(scope.row.loginCodeUrl)"-->
  202. <!-- v-hasPermi="['qw:user:cloudAP']"-->
  203. <!-- >-->
  204. <!-- 获取主机帐密-->
  205. <!-- </el-button>-->
  206. <el-button
  207. v-if="scope.row.loginCodeUrl!=null"
  208. size="mini"
  209. type="text"
  210. icon="el-icon-moon"
  211. plain
  212. @click="handleUnbindCloudHost(scope.row)"
  213. v-hasPermi="['qw:user:loginIpOut']"
  214. >
  215. 解除主机
  216. </el-button>
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="AI客服" align="center" class-name="small-padding fixed-width" width="100px" fixed="right">
  220. <template slot-scope="scope">
  221. <el-button
  222. size="mini"
  223. type="text"
  224. icon="el-icon-connection"
  225. plain
  226. v-if="scope.row.fastGptRoleName!=null"
  227. @click="bindFastGptRole(scope.row)"
  228. >换绑AI客服</el-button>
  229. <el-button
  230. size="mini"
  231. type="text"
  232. plain
  233. icon="el-icon-link"
  234. v-else
  235. @click="bindFastGptRole(scope.row)"
  236. >绑定AI客服</el-button>
  237. <el-button
  238. size="mini"
  239. type="text"
  240. icon="el-icon-unlock"
  241. plain
  242. v-if="scope.row.fastGptRoleName!=null"
  243. @click="relieveFastGptRole(scope.row)"
  244. >解绑AI客服</el-button>
  245. </template>
  246. </el-table-column>
  247. </el-table>
  248. <pagination
  249. v-show="total>0"
  250. :total="total"
  251. :page.sync="queryParams.pageNum"
  252. :limit.sync="queryParams.pageSize"
  253. @pagination="getList"
  254. />
  255. <!-- 绑定AI客服-->
  256. <el-dialog :title="bindAiTitle" :visible.sync="bindAiOpen" width="1200px" append-to-body>
  257. <fast-gpt-role ref="fastGptRole" @refreshFastGptList="refreshFastGptList" ></fast-gpt-role>
  258. </el-dialog>
  259. <!-- <el-dialog :visible.sync="updateIp.open" width="600px" append-to-body>-->
  260. <!-- <el-form ref="updateIpForm" :model="updateIpForm" :rules="updateIpRule" label-width="100px">-->
  261. <!-- <el-form-item label="新云主机IP" prop="Ip">-->
  262. <!-- <el-input v-model="updateIpForm.newIp" placeholder="请输入新IP" />-->
  263. <!-- </el-form-item>-->
  264. <!-- </el-form>-->
  265. <!-- <div slot="footer" class="dialog-footer" >-->
  266. <!-- <el-button type="primary" @click="submitUpdateIpForm">确 定</el-button>-->
  267. <!-- </div>-->
  268. <!-- </el-dialog>-->
  269. <el-dialog title="云主机信息" :visible.sync="cloudAPOpen.open" append-to-body>
  270. <el-card class="box-card">
  271. <div slot="header" class="clearfix">
  272. <span>账号:{{cloudAPOpen.admin}}</span>
  273. </div>
  274. <div slot="header" class="clearfix">
  275. <span>密码:{{cloudAPOpen.passWord}}</span>
  276. </div>
  277. </el-card>
  278. </el-dialog>
  279. <el-dialog :title="callOpen.title" :visible.sync="callOpen.open" width="500px" append-to-body>
  280. <el-form ref="callOpenFrom" :model="callOpenFrom" :rules="callOpenRule" label-width="110px">
  281. <el-form-item label="员工称呼" prop="welcomeText">
  282. <el-input v-model="callOpenFrom.welcomeText" placeholder="请输入员工称呼" />
  283. </el-form-item>
  284. </el-form>
  285. <div slot="footer" class="dialog-footer" >
  286. <el-button type="primary" @click="submitCallOpenFrom">确 定</el-button>
  287. </div>
  288. </el-dialog>
  289. <el-dialog title="授权key" :visible.sync="authorizeKeyOpen" width="500px" append-to-body>
  290. <el-form ref="authorizeKeyFrom" :model="authorizeKeyFrom" :rules="authorizeKeyRule" label-width="110px">
  291. <el-form-item label="授权的key值" prop="appKey">
  292. <el-input v-model="authorizeKeyFrom.appKey" placeholder="请输入授权key" type="Number"/>
  293. </el-form-item>
  294. </el-form>
  295. <div slot="footer" class="dialog-footer" >
  296. <el-button type="primary" @click="submitAuthorizeKeyForm">确 定</el-button>
  297. </div>
  298. </el-dialog>
  299. <!--二维码 -->
  300. <el-dialog
  301. title="企微二次认证"
  302. :visible.sync="qwLoginTwo.open"
  303. width="600px"
  304. append-to-body
  305. custom-class="qr-login-dialog"
  306. >
  307. <div class="qr-login-container">
  308. <div class="image-wrapper" v-loading="imageLoading" >
  309. <el-image
  310. :src="'data:image/png;base64,' +qwLoginTwo.codeUrl"
  311. style="display: block; margin: 0 auto; width: 300px; height: 300px;"
  312. />
  313. </div>
  314. <p class="qr-login-instructions">二次验证二维码</p>
  315. </div>
  316. <div slot="footer" class="dialog-footer" >
  317. <el-button type="primary" @click="qwLoginTwo.open=false">确 定</el-button>
  318. </div>
  319. </el-dialog>
  320. <el-dialog
  321. :title="qwLogin.title"
  322. :visible.sync="qwLogin.open"
  323. width="600px"
  324. append-to-body
  325. custom-class="qr-login-dialog"
  326. >
  327. <div class="qr-login-container">
  328. <div class="image-wrapper" v-loading="imageLoading" >
  329. <el-image
  330. :src="'data:image/png;base64,' +qwLogin.codeUrl"
  331. style="display: block; margin: 0 auto; width: 300px; height: 300px;"
  332. />
  333. </div>
  334. <p class="qr-login-instructions">使用企业微信扫码授权登录</p>
  335. </div>
  336. </el-dialog>
  337. <el-dialog
  338. title="输入企微验证码"
  339. :visible.sync="qwCode.open"
  340. width="600px"
  341. append-to-body>
  342. <el-form :model="qwCode" label-width="80px" @submit.native.prevent="handleSubmit">
  343. <el-form-item label="验证码" prop="companyName">
  344. <el-input v-model="qwCode.code" placeholder="输入企微6位验证码" />
  345. </el-form-item>
  346. </el-form>
  347. <div slot="footer" class="dialog-footer">
  348. <el-button type="primary" @click="submitCodeForm">确 定</el-button>
  349. </div>
  350. </el-dialog>
  351. <!-- 大图预览对话框 -->
  352. <el-dialog
  353. :visible.sync="dialogVisible"
  354. :modal="false"
  355. width="1200"
  356. append-to-body>
  357. <img
  358. :src="this.dialogImageUrl"
  359. style="display: block; max-width: 100%; margin: 0 auto"
  360. />
  361. </el-dialog>
  362. </div>
  363. </template>
  364. <script>
  365. import {
  366. listUser,
  367. getUser,
  368. delUser,
  369. addUser,
  370. updateUser,
  371. exportUser,
  372. updateUserWeclome,
  373. getMyQwCompanyList,
  374. relieveFastGptRoleById,
  375. staffListUser,
  376. loginQwCode,
  377. loginQwIpad,
  378. modifyLoginQwStatus,
  379. loginQwCodeMsg,
  380. getQwCodeUrl,
  381. twoCode,
  382. twoCodeStatus,
  383. qrCodeStatus,
  384. getQwIpad,
  385. delQwIpad,
  386. logoutQwLogout,
  387. qrCodeVerify,
  388. outLoginQwIpad,
  389. loginQwCodeUrl,
  390. getLoginQwStatus,
  391. handleAllocateRemoteHost,
  392. qwBindCloudHost, qwUnbindCloudHost, handleAuthAppKey, handleInputAuthAppKey, selectCloudAP
  393. } from '@/api/qw/user'
  394. import fastGptRole from "@/views/fastGpt/fastGptRole/fastGptRole";
  395. import {updateSop, updateSopQwUser} from "@/api/qw/sop";
  396. export default {
  397. name: "User",
  398. components: { fastGptRole},
  399. data() {
  400. return {
  401. updateIp:{
  402. open:false,
  403. title: "修改云主机IP"
  404. },
  405. updateIpForm:{
  406. id:null,
  407. newIp:null,
  408. },
  409. authorizeKeyOpen:false,
  410. authorizeKeyFrom:{
  411. id:null,
  412. appKey:null,
  413. qwUserId:null,
  414. qwUserName:null
  415. },
  416. updateIpRule:{},
  417. newIp:null,
  418. //放大图片
  419. dialogImageUrl:null,
  420. dialogVisible:false,
  421. // 遮罩层
  422. loading: true,
  423. // 导出遮罩层
  424. exportLoading: false,
  425. // 选中数组
  426. ids: [],
  427. // 非单个禁用
  428. single: true,
  429. // 非多个禁用
  430. multiple: true,
  431. // 显示搜索条件
  432. showSearch: true,
  433. // 总条数
  434. total: 0,
  435. //公司列表
  436. myQwCompanyList:[],
  437. // 企微用户表格数据
  438. userList: [],
  439. allowSelectOptions:[],
  440. // 弹出层标题
  441. bindAiTitle: "",
  442. bindAiOpen: false,
  443. qwLogin:{
  444. title:"",
  445. open:false,
  446. codeUrl:null,
  447. code:null,
  448. appKey:null,
  449. },
  450. qwLoginTwo:{
  451. title:"",
  452. open:false,
  453. codeUrl:null,
  454. code:null,
  455. appKey:null,
  456. },
  457. qwCode:{
  458. title:"",
  459. open:false,
  460. code:null,
  461. },
  462. cloudAPOpen:{
  463. open:false,
  464. admin:null,
  465. passWord:null,
  466. },
  467. callOpen:{
  468. open:false,
  469. title: '修改员工称呼',
  470. },
  471. callOpenFrom:{
  472. id:null,
  473. welcomeText:null,
  474. },
  475. twoCodeInterval:null,
  476. loginQwInterval:null,
  477. imageLoading: true, // 控制加载状态
  478. // 查询参数
  479. queryParams: {
  480. pageNum: 1,
  481. pageSize: 10,
  482. qwUserId: null,
  483. corpId: null,
  484. qwUserName: null,
  485. },
  486. qwUserId:null,
  487. companyUserList:[],
  488. // 表单参数
  489. form: {
  490. isSendMsg: '2',
  491. },
  492. authorizeKeyRule:{
  493. appKey:[{required:true,message:"授权码不能为空",trigger:"blur"}]
  494. },
  495. callOpenRule:{
  496. welcomeText:[{required:true,message:"员工称呼不能为空",trigger:"blur"}]
  497. },
  498. // 表单校验
  499. rules: {
  500. },
  501. //欢迎语表单校验
  502. weclomeRules:{
  503. welcomeText:[{required:true,message:"消息文本不能为空",trigger:"blur"}]
  504. },
  505. };
  506. },
  507. created() {
  508. getMyQwCompanyList().then(response => {
  509. this.myQwCompanyList = response.data;
  510. if(this.myQwCompanyList!=null){
  511. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  512. this.getList();
  513. }
  514. });
  515. },
  516. watch: {
  517. // 监听弹窗的可见性变化
  518. 'qwLogin.open'(newVal) {
  519. if (!newVal) {
  520. // 如果弹窗关闭,清除定时器
  521. clearInterval(this.loginQwInterval);
  522. }
  523. },
  524. },
  525. methods: {
  526. getList() {
  527. this.loading = true;
  528. staffListUser(this.queryParams).then(response => {
  529. this.userList = response.rows;
  530. this.total = response.total;
  531. this.loading = false;
  532. });
  533. },
  534. updateCorpId(){
  535. this.reset();
  536. this.getList();
  537. },
  538. //绑定AI客服
  539. bindFastGptRole(row){
  540. this.bindAiTitle="绑定AI客服";
  541. this.bindAiOpen=true;
  542. setTimeout(() => {
  543. this.$refs.fastGptRole.handleBindAiData(row)
  544. }, 200);
  545. },
  546. handleAppellation(val){
  547. this.callOpen.open=true;
  548. this.callOpenFrom.welcomeText=val.welcomeText;
  549. this.callOpenFrom.id=val.id;
  550. },
  551. //登录
  552. handleLoginQwCode(val){
  553. if (val.appKey==null || val.appKey===''){
  554. return this.$message.warning("没有授权码,无法登录企业微信,请授权");
  555. }
  556. loginQwIpad({qwUserId:val.id}).then(res => {
  557. this.qwUserId=val.id;
  558. this.qwLogin.code=null;
  559. this.imageLoading=false;
  560. console.log(res)
  561. if(res.msg=="success"){
  562. this.qwLogin.codeUrl=res.qrCode64
  563. this.qwLogin.open=true;
  564. this.loginQwPolling();
  565. }else{
  566. this.$message.success(res.msg);
  567. this.getList()
  568. }
  569. })
  570. },
  571. handleTwoCode(val){
  572. twoCode({ qwUserId: val.id }).then(res => {
  573. console.log(res)
  574. this.qwLoginTwo.open=true;
  575. this.qwLoginTwo.codeUrl=res.qrCode
  576. });
  577. },
  578. twoCodePolling() {
  579. this.twoCodeInterval = setInterval(() => {
  580. twoCodeStatus({ qwUserId: this.qwUserId }).then(res => {
  581. console.log(res)
  582. if (res.msg==104001) {
  583. this.$message.success('登录成功');
  584. this.clearDl()
  585. clearInterval(this.loginQwInterval);
  586. }else if(res.msg==100004){
  587. this.clearDl()
  588. }
  589. });
  590. }, 3000);
  591. },
  592. loginQwPolling() {
  593. this.loginQwInterval = setInterval(() => {
  594. qrCodeStatus({ qwUserId: this.qwUserId }).then(res => {
  595. console.log(res)
  596. if (res.msg==22) {
  597. this.$message.success('账号企业不一致请重新扫码登录');
  598. this.clearDl();
  599. }
  600. if (res.msg==104001) {
  601. this.$message.success('登录成功');
  602. this.clearDl()
  603. }else if(res.msg==100004){
  604. this.qwCode.open=true;
  605. clearInterval(this.loginQwInterval);
  606. }
  607. });
  608. }, 3000);
  609. },
  610. submitCodeForm(){
  611. qrCodeVerify({ code: this.qwCode.code,qwUserId: this.qwUserId }).then(res => {
  612. console.log(res)
  613. this.$message.success('验证成功账号信息确认中。。。。');
  614. this.qwCode.open=false;
  615. this.loginQwInterval = setTimeout(() => {
  616. qrCodeStatus({ qwUserId: this.qwUserId }).then(res => {
  617. console.log(res);
  618. if (res.msg == 23) {
  619. this.$message.error('账号不一致请重新扫码登录');
  620. this.clearDl();
  621. }
  622. if (res.msg == 22) {
  623. this.$message.error('账号企业不一致请重新扫码登录');
  624. this.clearDl();
  625. }
  626. if (res.msg == 104001) {
  627. this.$message.success('登录成功');
  628. this.clearDl();
  629. }
  630. });
  631. }, 4000);
  632. });
  633. },
  634. clearDl(){
  635. this.qwCode.open=false;
  636. this.qwLogin.open=false;
  637. clearInterval(this.loginQwInterval);
  638. this.getList()
  639. },
  640. //退出
  641. handleLoginOutQwStatus(val){
  642. outLoginQwIpad({qwUserId: val.id}).then(res => {
  643. this.$message.success("退出登录成功");
  644. this.getList()
  645. })
  646. },
  647. handleGetQwIpad(val){
  648. getQwIpad({ qwUserId: val.id }).then(res => {
  649. this.$message.success("获取主机成功");
  650. this.getList();
  651. }).catch(error => {
  652. console.log(error);
  653. if (error.code === 501) {
  654. this.$confirm(
  655. '当前区域没有多余的名额,将为你分配异地名额,会导致企业微信需要扫脸重新登录,并且半个小时后需要进行验证',
  656. '提示',
  657. {
  658. confirmButtonText: '确定',
  659. cancelButtonText: '取消',
  660. type: 'warning',
  661. dangerouslyUseHTMLString: true
  662. }
  663. ).then(() => {
  664. return handleAllocateRemoteHost({ qwUserId: val.id });
  665. }).then(res => {
  666. this.$message.success('异地主机分配成功');
  667. this.getList();
  668. }).catch(() => {
  669. this.$message.info('已取消异地主机分配');
  670. });
  671. } else {
  672. this.$message.error('获取主机失败');
  673. }
  674. });
  675. },
  676. handleDelQwIpad(val){
  677. delQwIpad({qwUserId: val.id}).then(res => {
  678. this.$message.success("解绑主机成功");
  679. this.getList()
  680. })
  681. },
  682. //传验证码
  683. handleLoginQwCodeMsg(){
  684. loginQwCodeMsg({appKey: this.qwLogin.appKey,code:this.qwLogin.code}).then(res => {
  685. this.qwLogin.open=false;
  686. this.$message.success("登录成功");
  687. })
  688. },
  689. validateCode() {
  690. // 只允许输入数字并限制长度为6
  691. this.qwLogin.code = this.qwLogin.code.replace(/\D/g, "").slice(0, 6);
  692. },
  693. handleCloudAP(urlAP){
  694. selectCloudAP({ipAddress:urlAP}).then(res => {
  695. this.cloudAPOpen.open=true
  696. this.cloudAPOpen.admin=res.data.apAdmin;
  697. this.cloudAPOpen.passWord=res.data.apPassword;
  698. })
  699. },
  700. handleUnbindCloudHost(val){
  701. const appKey=val.appKey;
  702. this.$confirm(
  703. '确定要给企微账号:<span style="color: green;">' +val.qwUserId + '' +
  704. '</span><br>企微昵称:<span style="color: red;">【' + val.qwUserName + '】</span>' +
  705. '</span><br><span style="color: orange;">解绑【Ps:解绑后此云主机可能会分配给他人】</span></span>',
  706. "警告",
  707. {
  708. confirmButtonText: "确定",
  709. cancelButtonText: "取消",
  710. type: "warning",
  711. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  712. }
  713. ).then(() => {
  714. return qwUnbindCloudHost(appKey);
  715. }).then(response => {
  716. this.$message.success('解绑成功');
  717. }).finally(res=>{
  718. this.getList();
  719. })
  720. },
  721. handleAuthorizeKey(val){
  722. this.authorizeKeyFrom.id=val.id;
  723. this.authorizeKeyFrom.qwUserId=val.qwUserId;
  724. this.authorizeKeyFrom.qwUserName=val.qwUserName;
  725. this.authorizeKeyOpen=true;
  726. },
  727. submitAuthorizeKeyForm(){
  728. this.$refs["authorizeKeyFrom"].validate(valid => {
  729. if (valid) {
  730. if (this.authorizeKeyFrom.id != null && this.authorizeKeyFrom.appKey != null) {
  731. this.uploadAuthorizeKey();
  732. }
  733. }
  734. });
  735. },
  736. submitCallOpenFrom(){
  737. this.$refs["callOpenFrom"].validate(valid => {
  738. if (valid) {
  739. if (this.callOpenFrom.id != null && this.callOpenFrom.welcomeText != null) {
  740. updateUser(this.callOpenFrom).then(res=>{
  741. this.$message.success('修改成功');
  742. this.callOpen.open=false;
  743. this.getList();
  744. });
  745. }
  746. }
  747. });
  748. },
  749. uploadAuthorizeKey(){
  750. this.$confirm(
  751. '确定要给企微账号:<span style="color: green;">' + this.authorizeKeyFrom.qwUserId + '' +
  752. '</span><br>企微昵称:<span style="color: red;">【' + this.authorizeKeyFrom.qwUserName + '】</span>' +
  753. '</span><br>授权key:<span style="color: #04adf6;">【' + this.authorizeKeyFrom.appKey + '】</span>?',
  754. "警告",
  755. {
  756. confirmButtonText: "确定",
  757. cancelButtonText: "取消",
  758. type: "warning",
  759. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  760. }
  761. ).then(() => {
  762. this.authorizeKeyOpen=false;
  763. return handleInputAuthAppKey(this.authorizeKeyFrom);
  764. }).then(response => {
  765. this.msgSuccess("授权key完成");
  766. }).finally(res=>{
  767. this.resetAuthorizeKeyFrom();
  768. this.getList();
  769. })
  770. },
  771. uploadAuthorizeKey2(val){
  772. const id=val.id;
  773. this.$confirm(
  774. '确定要给企微账号:<span style="color: green;">' +val.qwUserId + '' +
  775. '</span><br>企微昵称:<span style="color: red;">【' + val.qwUserName + '】</span>' +
  776. '</span><br>授权key</span>?',
  777. "警告",
  778. {
  779. confirmButtonText: "确定",
  780. cancelButtonText: "取消",
  781. type: "warning",
  782. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  783. }
  784. ).then(() => {
  785. return handleAuthAppKey({id:id});
  786. }).then(response => {
  787. this.msgSuccess("授权key完成");
  788. }).finally(res=>{
  789. this.resetAuthorizeKeyFrom();
  790. this.getList();
  791. })
  792. },
  793. handleBindCloudHost(val){
  794. if (val.appKey == null || val.appKey == '') {
  795. return this.$message.warning('没有授权码,无法绑定主机,请联系管理员');
  796. }
  797. const appKey=val.appKey;
  798. this.$confirm(
  799. '确定要给企微账号:<span style="color: green;">' +val.qwUserId + '' +
  800. '</span><br>企微昵称:<span style="color: red;">【' + val.qwUserName + '】</span>' +
  801. '</span><br><span style="color: dodgerblue;">绑定云主机?</span></span>',
  802. "警告",
  803. {
  804. confirmButtonText: "确定",
  805. cancelButtonText: "取消",
  806. type: "warning",
  807. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  808. }
  809. ).then(() => {
  810. return qwBindCloudHost(appKey);
  811. }).then(response => {
  812. this.$message.success('绑定成功,请登录云主机进行配置~~');
  813. }).finally(res=>{
  814. this.getList();
  815. })
  816. },
  817. openImageViewer(url) {
  818. // 打开大图预览对话框
  819. this.dialogImageUrl=url
  820. this.dialogVisible = true;
  821. },
  822. //刷新页面
  823. refreshFastGptList(){
  824. this.bindAiOpen=false;
  825. this.getList();
  826. },
  827. // 取消按钮
  828. cancel() {
  829. this.open = false;
  830. this.reset();
  831. },
  832. // 表单重置
  833. reset() {
  834. this.form = {
  835. id: null,
  836. qwUserId: null,
  837. corpId: null,
  838. qwUserName: null,
  839. };
  840. this.resetForm("form");
  841. },
  842. //重置授权
  843. resetAuthorizeKeyFrom(){
  844. this.authorizeKeyFrom={
  845. id:null,
  846. appKey:null,
  847. qwUserId:null,
  848. qwUserName:null
  849. };
  850. },
  851. //重置登录
  852. resetQwLogin(){
  853. this.qwLogin={
  854. title:"",
  855. open:false,
  856. codeUrl:null,
  857. code:null,
  858. corpId:null,
  859. qwUserId:null,
  860. }
  861. this.qwLogin.open=false;
  862. this.loading=false;
  863. this.getList();
  864. },
  865. //解绑AI客服
  866. relieveFastGptRole(row){
  867. this.$confirm('是否确认解绑AI客服?', "警告", {
  868. confirmButtonText: "确定",
  869. cancelButtonText: "取消",
  870. type: "warning"
  871. }).then(function() {
  872. return relieveFastGptRoleById(row.id);
  873. }).then(() => {
  874. this.getList();
  875. this.msgSuccess("解绑成功");
  876. })
  877. },
  878. /** 搜索按钮操作 */
  879. handleQuery() {
  880. this.queryParams.pageNum = 1;
  881. this.getList();
  882. },
  883. /** 重置按钮操作 */
  884. resetQuery() {
  885. this.resetForm("queryForm");
  886. this.queryParams.corpId=this.myQwCompanyList[0].dictValue;
  887. this.handleQuery();
  888. },
  889. // 多选框选中数据
  890. handleSelectionChange(selection) {
  891. this.ids = selection.map(item => item.id)
  892. this.single = selection.length!==1
  893. this.multiple = !selection.length
  894. },
  895. /** 提交按钮 */
  896. submitForm() {
  897. this.$refs["form"].validate(valid => {
  898. if (valid) {
  899. if (this.form.id != null) {
  900. // updateUser(this.form).then(response => {
  901. // this.msgSuccess("绑定成功");
  902. // this.open = false;
  903. // this.getList();
  904. //
  905. // });
  906. } else {
  907. // addUser(this.form).then(response => {
  908. // this.msgSuccess("新增成功");
  909. // this.open = false;
  910. // this.getList();
  911. // });
  912. }
  913. }
  914. });
  915. },
  916. /** 导出按钮操作 */
  917. handleExport() {
  918. const queryParams = this.queryParams;
  919. this.$confirm('是否确认导出所有企微用户数据项?', "警告", {
  920. confirmButtonText: "确定",
  921. cancelButtonText: "取消",
  922. type: "warning"
  923. }).then(() => {
  924. this.exportLoading = true;
  925. return exportUser(queryParams);
  926. }).then(response => {
  927. this.download(response.msg);
  928. this.exportLoading = false;
  929. }).catch(() => {});
  930. }
  931. }
  932. };
  933. </script>
  934. <style>
  935. .text-container {
  936. max-height: 7.5em; /* 设置最大高度为6行,根据字体大小调整 */
  937. overflow-y: auto; /* 内容超出时显示滚动条 */
  938. line-height: 1.5em; /* 行高设置,确保每行高度一致 */
  939. }
  940. .qr-login-dialog .el-dialog__body {
  941. display: flex;
  942. flex-direction: column;
  943. align-items: center;
  944. text-align: center;
  945. padding: 20px;
  946. }
  947. .qr-login-container {
  948. width: 100%;
  949. }
  950. .qr-login-instructions {
  951. font-size: 14px;
  952. color: #666;
  953. margin: 10px 0;
  954. }
  955. .verification-code-input {
  956. margin-top: 15px;
  957. width: 80%;
  958. }
  959. </style>