admin.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <div>
  6. <el-button
  7. type="primary"
  8. size="small"
  9. icon="el-icon-circle-plus-outline"
  10. style="float:left"
  11. @click="openForm(0)">新增</el-button>
  12. <el-button
  13. type="primary"
  14. size="small"
  15. @click="BatchDelete"
  16. >医药师登记</el-button>
  17. <!-- <el-button
  18. type="primary"
  19. size="small"
  20. icon="el-icon-circle-plus-outline"
  21. style="float:left"
  22. @click="toTest">短信</el-button> -->
  23. <!-- <el-button
  24. type="primary"
  25. size="small"
  26. icon="el-icon-circle-plus-outline"
  27. style="float:left"
  28. @click="toTestOne">创建个人用户实名</el-button> -->
  29. <!-- <el-button
  30. type="primary"
  31. size="small"
  32. icon="el-icon-circle-plus-outline"
  33. style="float:left"
  34. @click="toTestFive">创建企业用户并实名</el-button> -->
  35. <!-- <el-button
  36. type="primary"
  37. size="small"
  38. icon="el-icon-circle-plus-outline"
  39. style="float:left"
  40. @click="toTestFour">添加企业成员</el-button> -->
  41. <!-- <el-button
  42. type="primary"
  43. size="small"
  44. icon="el-icon-circle-plus-outline"
  45. style="float:left"
  46. @click="toTestTwo">创建个人印章</el-button> -->
  47. <!-- <el-button
  48. type="primary"
  49. size="small"
  50. icon="el-icon-circle-plus-outline"
  51. style="float:left"
  52. @click="toTestThree">创建合同</el-button> -->
  53. <!-- <el-button
  54. type="primary"
  55. size="small"
  56. icon="el-icon-circle-plus-outline"
  57. style="float:left"
  58. @click="toTestSeven">添加合同签署人</el-button> -->
  59. </div>
  60. </div>
  61. <div class="app-container">
  62. <el-table
  63. :row-style="{ color: '#303133' }"
  64. :header-cell-style="{
  65. backgroundColor: 'rgb(245, 247, 250)',
  66. color: '#606266'
  67. }"
  68. style="width:100%;"
  69. ref="table"
  70. border
  71. :data="admins"
  72. v-loading="is_loading_admins"
  73. @selection-change="handleSelectionChange"
  74. >
  75. <el-table-column
  76. align="center"
  77. type="selection"
  78. width="55">
  79. </el-table-column>
  80. <el-table-column
  81. label="用户名"
  82. prop="user_name"
  83. min-width="160"
  84. align="center"
  85. ></el-table-column>
  86. <el-table-column label="医保医师编码" prop="doctor_number" min-width="160" align="center">
  87. <template slot-scope="scope">
  88. <span v-if="scope.row.doctor_number== 0"></span>
  89. <span v-if="scope.row.doctor_number!= 0">{{scope.row.doctor_number}}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. label="最后登录IP"
  94. prop="ip"
  95. min-width="150"
  96. align="center"
  97. ></el-table-column>
  98. <el-table-column
  99. label="最后登录时间"
  100. prop="last_login_time"
  101. min-width="170"
  102. align="center"
  103. >
  104. <template slot-scope="scope">
  105. <span>{{
  106. scope.row.last_login_time == 0
  107. ? ""
  108. : _parseTime(scope.row.last_login_time, "{y}-{m}-{d} {h}:{i}")
  109. }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column
  113. label="角色"
  114. prop="role_name"
  115. min-width="160"
  116. align="center"
  117. ></el-table-column>
  118. <el-table-column label="状态" min-width="100" align="center">
  119. <template slot-scope="scope">
  120. <div
  121. v-if="scope.row.status == 1"
  122. style="color: #67C23A; font-size:20px;"
  123. >
  124. <li class="el-icon-success"></li>
  125. </div>
  126. <div v-else style="color: #F56C6C; font-size:20px;">
  127. <li class="el-icon-error"></li>
  128. </div>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="操作" width="240" align="center">
  132. <template slot-scope="scope">
  133. <!-- <router-link :to="{ path:'/role/admin/edit', query:{ id:scope.row.user_id }}"> -->
  134. <el-tooltip
  135. class="item"
  136. effect="dark"
  137. content="编辑"
  138. placement="top"
  139. >
  140. <el-button
  141. type="primary"
  142. icon="el-icon-edit-outline"
  143. size="small"
  144. @click="openForm(scope.row.user_id)"
  145. ></el-button>
  146. </el-tooltip>
  147. <!-- </router-link> -->
  148. <el-tooltip
  149. class="item"
  150. effect="dark"
  151. content="移除"
  152. placement="top"
  153. >
  154. <el-button
  155. type="danger"
  156. size="small"
  157. icon="el-icon-delete"
  158. v-if="
  159. scope.row.status == 1 &&
  160. org.creator != scope.row.user_id &&
  161. scope.row.user_id != local_user_id
  162. "
  163. @click="disableAdminAction(scope.row)"
  164. ></el-button>
  165. </el-tooltip>
  166. <el-tooltip
  167. class="item"
  168. effect="dark"
  169. content="恢复"
  170. placement="top"
  171. >
  172. <el-button
  173. size="small"
  174. type="info"
  175. icon="el-icon-refresh"
  176. v-if="
  177. scope.row.status == 0 &&
  178. org.creator != scope.row.user_id &&
  179. scope.row.user_id != local_user_id
  180. "
  181. @click="recoverAdminAction(scope.row)"
  182. ></el-button>
  183. </el-tooltip>
  184. <span v-if="scope.row.user_type == 2">
  185. <el-button type="primary" size="small" icon="el-icon-refresh-left" @click="toReturn(scope.row.user_id,scope.row.is_mark)">
  186. <span v-if="scope.row.is_mark ==0">登记</span>
  187. <span v-if="scope.row.is_mark ==1">撤销</span>
  188. </el-button>
  189. </span>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. <el-row style="margin-top: 15px;" v-if="admin_total_count > 10">
  194. <el-col :span="24">
  195. <el-pagination
  196. :total="admin_total_count"
  197. :current-page.sync="current_page"
  198. @current-change="pageChange"
  199. :page-size="10"
  200. layout="total, prev, pager, next, jumper"
  201. ></el-pagination>
  202. </el-col>
  203. </el-row>
  204. <admin-info-form ref="admininfoform"></admin-info-form>
  205. </div>
  206. </div>
  207. </template>
  208. <script>
  209. import { adminMainView, getAdmins, setAdminStatus,toSign,toTestOne,toTestTwo,toTestThree,toTestFour,toTestFive } from "@/api/role/admin";
  210. import { getRoles } from "@/api/role/role";
  211. import { parseTime } from "@/utils";
  212. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  213. import AdminInfoForm from "./components/AdminInfoForm";
  214. import axios from 'axios'
  215. export default {
  216. name: "adminManage",
  217. data() {
  218. return {
  219. crumbs: [
  220. { path: false, name: "管理中心" },
  221. { path: false, name: "员工管理" }
  222. ],
  223. is_loading_admins: true,
  224. admins: [], // [{user_id, user_name, role_name, title_name, ip, last_login_time, status}]
  225. admin_total_count: 0,
  226. current_page: 1,
  227. roles: [],
  228. is_exist_role: false,
  229. org: null,
  230. isSubSuperAdmin: false,
  231. local_user_id: 0,
  232. selectDrug:[]
  233. };
  234. },
  235. components: {
  236. BreadCrumb,
  237. AdminInfoForm
  238. },
  239. created: function() {
  240. this.local_user_id = this.$store.getters.xt_user.user.id;
  241. let page = 1;
  242. this.getRoles(page);
  243. adminMainView()
  244. .then(rs => {
  245. this.is_loading_admins = false;
  246. var resp = rs.data;
  247. if (resp.state === 1) {
  248. var adminData = resp.data.admins
  249. console.log("数据",adminData)
  250. this.admins.push(...adminData);
  251. this.admin_total_count = resp.data.total_count;
  252. this.is_exist_role = resp.data.is_exist_role;
  253. this.current_page = 1;
  254. this.org = resp.data.org;
  255. this.isSubSuperAdmin = resp.data.isSubSuperAdmin;
  256. //能进入当前页面的角色只有超级管理员和子管理员,如果当前角色是子管理员,需要把超级管理员和其他子管理员的信息去除,子管理员不能编辑超级管理员和其他子管理员信息,
  257. if (this.isSubSuperAdmin) {
  258. //去除管理员信息
  259. for (let i = 0; i < this.admins.length; i++) {
  260. if (this.admins[i].user_id == this.org.creator) {
  261. this.admins.splice(i, 1);
  262. i--;
  263. }
  264. }
  265. //去除其他子管理员信息
  266. for (let i = 0; i < this.admins.length; i++) {
  267. if (
  268. this.admins[i].user_id != this.local_user_id &&
  269. this.admins[i].is_sub_super_admin
  270. ) {
  271. //将自己排除在外
  272. console.log(this.admins[i]);
  273. this.admins.splice(i, 1);
  274. i--;
  275. }
  276. }
  277. }
  278. } else {
  279. this.$message.error(resp.msg);
  280. }
  281. })
  282. .catch(err => {
  283. this.is_loading_admins = false;
  284. this.$message.error(err);
  285. });
  286. },
  287. computed: {
  288. should_update_admins() {
  289. return this.$store.getters.xt_role_temps.did_admins_changed;
  290. }
  291. },
  292. methods: {
  293. getRoles(page) {
  294. getRoles(page)
  295. .then(rs => {
  296. this.loading_roles = false;
  297. const resp = rs.data;
  298. if (resp.state === 1) {
  299. this.roles.push(...resp.data.roles);
  300. } else {
  301. this.$message.error(resp.msg);
  302. }
  303. })
  304. .catch(err => {
  305. this.loading_roles = false;
  306. this.$message.error(err);
  307. });
  308. },
  309. openForm(adminId) {
  310. this.$refs["admininfoform"].open(adminId, this.roles);
  311. },
  312. _parseTime(time, format) {
  313. return parseTime(time, format);
  314. },
  315. requestAdminsWithPage: function(page) {
  316. this.admins.splice(0, this.admins.length);
  317. this.is_loading_admins = true;
  318. getAdmins(page)
  319. .then(rs => {
  320. this.is_loading_admins = false;
  321. const resp = rs.data;
  322. console.log(resp);
  323. if (resp.state === 1) {
  324. var admindata = resp.data.admins
  325. this.admins.push(...admindata);
  326. this.admin_total_count = resp.data.total_count;
  327. } else {
  328. this.$message.error(resp.msg);
  329. }
  330. })
  331. .catch(err => {
  332. this.is_loading_admins = false;
  333. this.$message.error(err);
  334. });
  335. },
  336. addAdminAction: function() {
  337. this.$router.push({ path: "/role/admin/create" });
  338. },
  339. disableAdminAction: function(row) {
  340. this.$msgbox({
  341. title: "提示",
  342. message: "是否确定要移除该用户",
  343. showCancelButton: true,
  344. confirmButtonText: "确定",
  345. cancelButtonText: "取消",
  346. type: "warning",
  347. beforeClose: (action, instance, done) => {
  348. if (action === "confirm") {
  349. instance.confirmButtonLoading = true;
  350. instance.confirmButtonText = "删除中...";
  351. setAdminStatus(row.user_id, false)
  352. .then(rs => {
  353. done();
  354. instance.confirmButtonLoading = false;
  355. const resp = rs.data;
  356. if (resp.state === 1) {
  357. row.status = 0;
  358. } else {
  359. this.$message.error(resp.msg);
  360. }
  361. })
  362. .catch(err => {
  363. done();
  364. instance.confirmButtonLoading = false;
  365. this.$message.error(err);
  366. });
  367. } else {
  368. done();
  369. }
  370. }
  371. });
  372. },
  373. recoverAdminAction: function(row) {
  374. const loading = this.$loading({
  375. lock: true,
  376. text: "正在恢复管理员...",
  377. spinner: "el-icon-loading",
  378. background: "rgba(0, 0, 0, 0.7)"
  379. });
  380. setAdminStatus(row.user_id, true)
  381. .then(rs => {
  382. loading.close();
  383. const resp = rs.data;
  384. if (resp.state === 1) {
  385. row.status = 1;
  386. } else {
  387. this.$message.error(resp.msg);
  388. }
  389. })
  390. .catch(err => {
  391. loading.close();
  392. this.$message.error(err);
  393. });
  394. },
  395. pageChange: function(nextPage) {
  396. this.requestAdminsWithPage(nextPage);
  397. },
  398. // toLogin(){
  399. // var that = this
  400. // axios.get('http://127.0.0.1:9532/sz/api/doctor/get').then(function(response) {
  401. // if (response.data.state == 0) {
  402. // that.$message.error(response.data.msg)
  403. // return false
  404. // } else {
  405. // that.$message({ message: '登记成功', type: 'success' })
  406. // }
  407. // }).catch(function(error) {
  408. // })
  409. // },
  410. BatchDelete() {
  411. if (this.selectDrug.length == 0) {
  412. this.$message.error("请选择要登记的信息");
  413. return false;
  414. }
  415. this.$confirm(
  416. "确认要登记所选记录吗? <br>",
  417. "备案提示",
  418. {
  419. dangerouslyUseHTMLString: true,
  420. confirmButtonText: "确定",
  421. cancelButtonText: "取消",
  422. type: "warning"
  423. }
  424. ).then(() => {
  425. var ids = [];
  426. var idMap = {};
  427. console.log("3333333",this.selectDrug)
  428. for (const index in this.selectDrug) {
  429. ids.push(this.selectDrug[index].user_id);
  430. idMap[this.selectDrug[index].user_id] = this.selectDrug[index].user_id;
  431. }
  432. var idss = ids.join(',')
  433. let params = {
  434. ids:idss,
  435. admin_user_id:this.$store.getters.xt_user.user.id
  436. }
  437. console.log("prams222",params)
  438. var that = this
  439. axios.get('http://127.0.0.1:9532/sz/api/doctor/get',{ params: params }).then(function(response) {
  440. if (response.data.state == 0) {
  441. that.$message.error(response.data.data.msg)
  442. return false
  443. } else {
  444. that.$message.error(response.data.data.msg)
  445. if(response.data.data.msg == ""){
  446. that.$message.success("登记成功!")
  447. that.adminMainView()
  448. }
  449. if(response.data.data.msg!=""){
  450. that.$message.error(response.data.data.msg)
  451. that.adminMainView()
  452. }
  453. }
  454. }).catch(function(error) {
  455. })
  456. });
  457. },
  458. toReturn(id,is_mark){
  459. var that = this
  460. let params = {
  461. 'id':id,
  462. "is_mark":is_mark,
  463. "admin_user_id":this.$store.getters.xt_user.user.id
  464. }
  465. axios.get('http://127.0.0.1:9532/sz/api/medical/get',{params:params}).then(function(response) {
  466. if (response.data.state == 0) {
  467. that.$message.error(response.data.data.msg)
  468. return false
  469. } else {
  470. if(response.data.data.msg == ""){
  471. that.$message.success("登记成功!")
  472. that.adminMainView()
  473. }
  474. if(response.data.data.msg!=""){
  475. that.$message.error(response.data.data.msg)
  476. that.adminMainView()
  477. }
  478. }
  479. }).catch(function(error) {
  480. })
  481. },
  482. handleSelectionChange(val) {
  483. this.selectDrug = val;
  484. },
  485. toTest(){
  486. toSign().then(response=>{
  487. if(response.data.state ==1){
  488. var sign = response.data.data.sign
  489. console.log("sign",sign)
  490. }
  491. })
  492. },
  493. toTestOne(){
  494. toTestOne().then(response=>{
  495. if(response.data.state==1){
  496. var sign = response.data.data.sign
  497. console.log("sign",sign)
  498. }
  499. })
  500. },
  501. toTestTwo(){
  502. toTestTwo().then(response=>{
  503. if(response.data.state ==1){
  504. var sign = response.data.data.sign
  505. console.log("sign",sign)
  506. }
  507. })
  508. },
  509. toTestThree(){
  510. toTestThree().then(response=>{
  511. if(response.data.state ==1){
  512. var sign = response.data.data.sign
  513. console.log("sign",sign)
  514. }
  515. })
  516. },
  517. toTestFour(){
  518. toTestFour().then(response=>{
  519. if(response.data.state==1){
  520. var sign = response.data.data.sign
  521. console.log("sign",sign)
  522. }
  523. })
  524. },
  525. toTestFive(){
  526. toTestFive().then(response=>{
  527. if(response.data.state==1){
  528. var sign = response.data.data.sign
  529. console.log("sign",sign)
  530. }
  531. })
  532. },
  533. toTestSeven(){
  534. toTestSeven().then(response=>{
  535. if(response.data.state ==1){
  536. var sign = response.data.data.sign
  537. console.log("sign",sign)
  538. }
  539. })
  540. }
  541. },
  542. watch: {
  543. should_update_admins(should_change) {
  544. if (should_change) {
  545. this.requestAdminsWithPage(this.current_page);
  546. }
  547. }
  548. }
  549. };
  550. </script>
  551. <style rel="stylesheet/scss" lang="scss" scoped>
  552. .el-button + .el-button {
  553. margin-left: 0 !important;
  554. }
  555. </style>
  556. <style>
  557. .el-table td,
  558. .el-table th.is-leaf,
  559. .el-table--border,
  560. .el-table--group {
  561. border-color: #d0d3da;
  562. }
  563. .el-table--border::after,
  564. .el-table--group::after,
  565. .el-table::before {
  566. background-color: #d0d3da;
  567. }
  568. </style>