user.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <div class="box-body">
  5. <!-- 搜索 -->
  6. <el-form inline :model="searchForm" label-width="70px">
  7. <el-form-item label="顶级机构">
  8. <el-select
  9. v-model="searchForm.rootOrgId"
  10. placeholder="请选择"
  11. :disabled="!isSuperAdmin"
  12. @change="rootOrgChanged4Search"
  13. class="input_width"
  14. >
  15. <el-option
  16. v-for="item in rootOrgList"
  17. :label="item.name"
  18. :value="item.id"
  19. :key="item.id"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="角色">
  24. <el-select
  25. clearable
  26. v-model="searchForm.roleId"
  27. placeholder="请选择"
  28. class="input_width"
  29. >
  30. <el-option
  31. v-for="item in roleList4Search"
  32. :label="item.roleName"
  33. :value="item.roleId"
  34. :key="item.roleId"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="登录名">
  39. <el-input
  40. placeholder="请输入登录名"
  41. v-model="searchForm.loginName"
  42. class="input_width"
  43. />
  44. </el-form-item>
  45. <el-form-item label="姓名">
  46. <el-input
  47. placeholder="请输入姓名"
  48. v-model="searchForm.name"
  49. class="input_width"
  50. />
  51. </el-form-item>
  52. <div></div>
  53. <el-form-item>
  54. <el-button
  55. size="small"
  56. type="primary"
  57. icon="el-icon-search"
  58. @click="handleSearchBtn"
  59. >
  60. 查询
  61. </el-button>
  62. <el-button
  63. size="small"
  64. icon="el-icon-refresh"
  65. @click="resetEcsFormSearch"
  66. >
  67. 重置
  68. </el-button>
  69. <el-button
  70. size="small"
  71. type="primary"
  72. icon="el-icon-plus"
  73. @click="openAddingDialog"
  74. >
  75. 新增
  76. </el-button>
  77. </el-form-item>
  78. </el-form>
  79. <div class="block-seperator"></div>
  80. <!-- 添加用户信息弹出框 -->
  81. <el-dialog title="新增用户" width="450px" :visible.sync="addingDialog">
  82. <el-form
  83. :inline="true"
  84. inline-message
  85. :model="userForm"
  86. ref="addingForm"
  87. :rules="rules"
  88. label-position="right"
  89. label-width="120px"
  90. >
  91. <el-row>
  92. <el-form-item label="姓名" prop="name">
  93. <el-input
  94. class="input_width_lg"
  95. v-model="userForm.name"
  96. auto-complete="off"
  97. placeholder="请输入姓名"
  98. />
  99. </el-form-item>
  100. </el-row>
  101. <el-row>
  102. <el-form-item label="登录名" prop="loginName">
  103. <el-input
  104. class="input_width_lg"
  105. v-model="userForm.loginName"
  106. auto-complete="off"
  107. placeholder="请输入登录名"
  108. />
  109. </el-form-item>
  110. </el-row>
  111. <el-row>
  112. <el-form-item label="密码" prop="password">
  113. <el-input
  114. class="input_width_lg"
  115. v-model="userForm.password"
  116. auto-complete="off"
  117. placeholder="请输入密码"
  118. />
  119. </el-form-item>
  120. </el-row>
  121. <el-row>
  122. <el-form-item label="联系方式" prop="mobile">
  123. <el-input
  124. class="input_width_lg"
  125. v-model="userForm.mobile"
  126. auto-complete="off"
  127. placeholder="请输入联系方式"
  128. />
  129. </el-form-item>
  130. </el-row>
  131. <el-row>
  132. <el-form-item label="顶级机构" prop="rootOrgId">
  133. <el-select
  134. class="input_width_lg"
  135. v-model="userForm.rootOrgId"
  136. placeholder="请选择"
  137. :disabled="!isSuperAdmin"
  138. @change="rootOrgChanged4InsertOrUpdate"
  139. >
  140. <el-option
  141. v-for="item in rootOrgList"
  142. :label="item.name"
  143. :value="item.id"
  144. :key="item.id"
  145. >
  146. </el-option>
  147. </el-select>
  148. </el-form-item>
  149. </el-row>
  150. <el-row>
  151. <el-form-item label="角色" prop="roleIds">
  152. <el-select
  153. class="input_width_lg"
  154. multiple
  155. v-model="userForm.roleIds"
  156. placeholder="请选择"
  157. @change="rolesChanged"
  158. >
  159. <el-option
  160. v-for="item in roleList4InsertOrUpdateWithoutSuperAdmin"
  161. :label="item.roleName"
  162. :value="item.roleId"
  163. :key="item.roleId"
  164. >
  165. </el-option>
  166. </el-select>
  167. </el-form-item>
  168. </el-row>
  169. <el-row>
  170. <el-form-item label="子机构" prop="orgId">
  171. <el-select
  172. class="input_width_lg"
  173. :remote-method="getOrgList4InsertOrUpdate"
  174. @focus="e => getOrgList4InsertOrUpdate(e.target.value)"
  175. :loading="orgLoading4InsertOrUpdate"
  176. remote
  177. filterable
  178. clearable
  179. v-model="userForm.orgId"
  180. placeholder="请选择"
  181. >
  182. <el-option
  183. v-for="item in orgList4InsertOrUpdate"
  184. :label="item.name"
  185. :value="item.id"
  186. :key="item.id"
  187. >
  188. </el-option>
  189. </el-select>
  190. </el-form-item>
  191. </el-row>
  192. <el-row>
  193. <el-form-item label="状态">
  194. <el-radio-group class="pull_right_sm" v-model="enableStr">
  195. <el-radio label="true">启用</el-radio>
  196. <el-radio label="false">禁用</el-radio>
  197. </el-radio-group>
  198. </el-form-item>
  199. </el-row>
  200. <el-row class="d-flex justify-content-center">
  201. <el-button type="primary" @click="add">保 存</el-button>
  202. <el-button @click="addingDialog = false">取 消</el-button>
  203. </el-row>
  204. </el-form>
  205. </el-dialog>
  206. <!-- 修改用户信息弹出框 -->
  207. <el-dialog title="编辑用户" width="450px" :visible.sync="updateDialog">
  208. <el-form
  209. :inline="true"
  210. :model="userForm"
  211. ref="updateForm"
  212. :rules="rules"
  213. label-position="right"
  214. label-width="120px"
  215. >
  216. <el-row>
  217. <el-form-item label="ID">
  218. <el-input
  219. class="input_width_lg"
  220. v-model="userForm.id"
  221. :disabled="true"
  222. />
  223. </el-form-item>
  224. </el-row>
  225. <el-row>
  226. <el-form-item label="姓名" prop="name">
  227. <el-input
  228. class="input_width_lg"
  229. v-model="userForm.name"
  230. auto-complete="off"
  231. placeholder="请输入姓名"
  232. />
  233. </el-form-item>
  234. </el-row>
  235. <el-row>
  236. <el-form-item label="登录名" prop="loginName">
  237. <el-input
  238. class="input_width_lg"
  239. v-model="userForm.loginName"
  240. auto-complete="off"
  241. placeholder="请输入登录名"
  242. />
  243. </el-form-item>
  244. </el-row>
  245. <el-row>
  246. <el-form-item label="联系方式" prop="mobile">
  247. <el-input
  248. class="input_width_lg"
  249. v-model="userForm.mobile"
  250. auto-complete="off"
  251. placeholder="请输入联系方式"
  252. />
  253. </el-form-item>
  254. </el-row>
  255. <el-row>
  256. <el-form-item label="顶级机构" prop="rootOrgId">
  257. <el-select
  258. class="input_width_lg"
  259. v-model="userForm.rootOrgId"
  260. placeholder="请选择"
  261. :disabled="true"
  262. >
  263. <el-option
  264. v-for="item in rootOrgList"
  265. :label="item.name"
  266. :value="item.id"
  267. :key="item.id"
  268. >
  269. </el-option>
  270. </el-select>
  271. </el-form-item>
  272. </el-row>
  273. <el-row>
  274. <el-form-item label="角色" prop="roleIds">
  275. <el-select
  276. class="input_width_lg"
  277. multiple
  278. v-model="userForm.roleIds"
  279. placeholder="请选择"
  280. :disabled="rowIsSuperAdmin"
  281. @change="rolesChanged"
  282. >
  283. <el-option
  284. v-for="item in roleList4InsertOrUpdate"
  285. :label="item.roleName"
  286. :disabled="item.roleCode == 'SUPER_ADMIN'"
  287. :value="item.roleId"
  288. :key="item.roleId"
  289. >
  290. </el-option>
  291. </el-select>
  292. </el-form-item>
  293. </el-row>
  294. <el-row>
  295. <el-form-item label="子机构" prop="orgId">
  296. <el-select
  297. class="input_width_lg"
  298. :remote-method="getOrgList4InsertOrUpdate"
  299. @focus="e => getOrgList4InsertOrUpdate(e.target.value)"
  300. :loading="orgLoading4InsertOrUpdate"
  301. remote
  302. filterable
  303. clearable
  304. v-model="userForm.orgId"
  305. placeholder="请选择"
  306. >
  307. <el-option
  308. v-for="item in orgList4InsertOrUpdate"
  309. :label="item.name"
  310. :value="item.id"
  311. :key="item.id"
  312. >
  313. </el-option>
  314. </el-select>
  315. </el-form-item>
  316. </el-row>
  317. <el-row>
  318. <el-form-item label="状态">
  319. <el-radio-group
  320. class="pull_right_sm"
  321. v-model="enableStr"
  322. :disabled="rowIsSuperAdmin"
  323. >
  324. <el-radio label="true">启用</el-radio>
  325. <el-radio label="false">禁用</el-radio>
  326. </el-radio-group>
  327. </el-form-item>
  328. </el-row>
  329. <el-row class="d-flex justify-content-center">
  330. <el-button type="primary" @click="update">保 存</el-button>
  331. <el-button @click="updateDialog = false">取 消</el-button>
  332. </el-row>
  333. </el-form>
  334. </el-dialog>
  335. <!-- 页面列表 -->
  336. <el-table
  337. :data="tableData"
  338. border
  339. resizable
  340. stripe
  341. style="width: 100%;"
  342. @selection-change="selectChange"
  343. >
  344. <el-table-column prop="id" width="80" label="ID" />
  345. <el-table-column prop="name" width="120" label="姓名" />
  346. <el-table-column prop="loginName" width="100" label="登录名" />
  347. <el-table-column prop="rootOrgName" label="顶级机构" />
  348. <!-- <el-table-column prop="roleNamesStr" width="110" label="角色" /> -->
  349. <el-table-column width="120" label="角色">
  350. <span
  351. slot-scope="scope"
  352. v-html="scope.row.roleNamesStr.replace(/,/g, '<br />')"
  353. >
  354. </span>
  355. </el-table-column>
  356. <el-table-column prop="updateTime" width="160" label="更新时间" />
  357. <el-table-column width="50" label="状态">
  358. <span slot-scope="scope">
  359. <span v-if="scope.row.enable">
  360. <el-tooltip
  361. class="item"
  362. effect="dark"
  363. content="启用"
  364. placement="left"
  365. >
  366. <i class="el-icon-success" style="color:green;"></i>
  367. </el-tooltip>
  368. </span>
  369. <span v-else>
  370. <el-tooltip
  371. class="item"
  372. effect="dark"
  373. content="禁用"
  374. placement="left"
  375. >
  376. <i class="el-icon-error" style="color:red;"></i>
  377. </el-tooltip>
  378. </span>
  379. </span>
  380. </el-table-column>
  381. <el-table-column width="190" label="操作">
  382. <div slot-scope="scope">
  383. <el-button
  384. v-if="!scope.row.enable"
  385. size="mini"
  386. type="primary"
  387. plain
  388. @click="enableById(scope.row)"
  389. icon="el-icon-check"
  390. >
  391. 启用
  392. </el-button>
  393. <el-button
  394. v-if="scope.row.enable"
  395. size="mini"
  396. type="danger"
  397. @click="disableById(scope.row)"
  398. icon="el-icon-close"
  399. >
  400. 禁用
  401. </el-button>
  402. &nbsp;
  403. <el-dropdown>
  404. <el-button type="primary" plain size="mini">
  405. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  406. </el-button>
  407. <el-dropdown-menu slot="dropdown">
  408. <el-dropdown-item>
  409. <el-button
  410. size="mini"
  411. type="primary"
  412. plain
  413. @click="openUpdateDialog(scope.row)"
  414. icon="el-icon-edit"
  415. >编辑
  416. </el-button>
  417. </el-dropdown-item>
  418. <el-dropdown-item>
  419. <el-button
  420. v-if="false"
  421. size="mini"
  422. type="danger"
  423. @click="deleteById(scope.row)"
  424. icon="el-icon-delete"
  425. >删除
  426. </el-button>
  427. </el-dropdown-item>
  428. <el-dropdown-item>
  429. <el-button
  430. size="mini"
  431. type="danger"
  432. @click="resetPass(scope.row)"
  433. >
  434. <v-icon name="lock" scale="0.7" /> 重置密码
  435. </el-button>
  436. </el-dropdown-item>
  437. </el-dropdown-menu>
  438. </el-dropdown>
  439. </div>
  440. </el-table-column>
  441. </el-table>
  442. <div class="page pull-right">
  443. <el-pagination
  444. @current-change="handleCurrentChange"
  445. :current-page="currentPage"
  446. :page-size="10"
  447. :page-sizes="[10, 20, 50, 100]"
  448. @size-change="handleSizeChange"
  449. layout="total, sizes, prev, pager, next, jumper"
  450. :total="total"
  451. />
  452. </div>
  453. </div>
  454. </div>
  455. </section>
  456. </template>
  457. <script>
  458. import { CORE_API } from "@/constants/constants.js";
  459. import { mapState } from "vuex";
  460. export default {
  461. name: "User",
  462. data() {
  463. var validateRootOrg = (rule, value, callback) => {
  464. if (0 != value && !value) {
  465. callback(new Error("请选择顶级机构"));
  466. } else {
  467. callback();
  468. }
  469. };
  470. var validateRoles = (rule, value, callback) => {
  471. if (value.length == 0) {
  472. callback(new Error("请选择角色"));
  473. } else {
  474. callback();
  475. }
  476. };
  477. return {
  478. orgLoading4InsertOrUpdate: false,
  479. isSuperAdmin: false,
  480. roleList4Search: [],
  481. roleList4InsertOrUpdate: [],
  482. rootOrgList: [],
  483. orgList4InsertOrUpdate: [],
  484. searchForm: {
  485. name: "",
  486. loginName: "",
  487. enable: "",
  488. rootOrgId: "",
  489. roleId: ""
  490. },
  491. userForm: {
  492. id: null,
  493. name: "",
  494. loginName: "",
  495. password: "",
  496. mobile: "",
  497. enable: true,
  498. rootOrgId: null,
  499. orgId: null,
  500. roleIds: []
  501. },
  502. enableStr: "true",
  503. tempOrgList: [],
  504. userId: "",
  505. selectedUserIds: [],
  506. tableData: [],
  507. currentPage: 1,
  508. pageSize: 10,
  509. total: 10,
  510. addingDialog: false,
  511. updateDialog: false,
  512. rowIsSuperAdmin: false,
  513. rules: {
  514. name: [
  515. {
  516. required: true,
  517. message: "请输入姓名",
  518. trigger: "blur"
  519. }
  520. ],
  521. loginName: [
  522. {
  523. required: true,
  524. message: "请输入登录名",
  525. trigger: "blur"
  526. }
  527. ],
  528. password: [
  529. {
  530. required: true,
  531. message: "请输入密码",
  532. trigger: "blur"
  533. }
  534. ],
  535. mobile: [
  536. {
  537. message: "请输入联系方式",
  538. trigger: "blur"
  539. }
  540. ],
  541. rootOrgId: [
  542. {
  543. validator: validateRootOrg,
  544. trigger: "blur,change"
  545. }
  546. ],
  547. orgId: [],
  548. roleIds: [
  549. {
  550. validator: validateRoles,
  551. trigger: "blur,change"
  552. }
  553. ]
  554. }
  555. };
  556. },
  557. computed: {
  558. ...mapState({
  559. user: state => state.user
  560. }),
  561. userIds() {
  562. var userIds = "";
  563. for (let userId of this.selectedUserIds) {
  564. if (!userIds) {
  565. userIds += userId;
  566. } else {
  567. userIds += "," + userId;
  568. }
  569. }
  570. return userIds;
  571. },
  572. roleList4InsertOrUpdateWithoutSuperAdmin() {
  573. return this.roleList4InsertOrUpdate.filter(
  574. item => item.roleCode != "SUPER_ADMIN"
  575. );
  576. }
  577. },
  578. methods: {
  579. resetEcsFormSearch() {
  580. this.searchForm = Object.assign(this.searchForm, {
  581. roleId: "",
  582. loginName: "",
  583. name: ""
  584. });
  585. },
  586. handleSizeChange(val) {
  587. this.currentPage = 1;
  588. this.pageSize = val;
  589. this.search();
  590. },
  591. validateOrg(rule, value, callback) {
  592. if (0 != value && !value) {
  593. callback(new Error("请选择子机构"));
  594. } else {
  595. callback();
  596. }
  597. },
  598. rolesChanged() {
  599. var isLC = false;
  600. for (let cur of this.roleList4InsertOrUpdate) {
  601. if (
  602. cur.roleCode == "LC_USER" &&
  603. this.userForm.roleIds.includes(cur.roleId)
  604. ) {
  605. isLC = true;
  606. break;
  607. }
  608. }
  609. console.log("rolesChanged(); isLC:", isLC);
  610. if (isLC) {
  611. this.rules.orgId = [
  612. {
  613. validator: this.validateOrg,
  614. trigger: "blur,change"
  615. }
  616. ];
  617. } else {
  618. this.rules.orgId = [];
  619. }
  620. },
  621. rootOrgChanged4Search() {
  622. var url =
  623. CORE_API +
  624. "/rolePrivilege/getRoles?includeSuperAdmin=" +
  625. true +
  626. "&rootOrgId=" +
  627. this.searchForm.rootOrgId;
  628. this.$httpWithMsg.post(url).then(response => {
  629. this.roleList4Search = response.data;
  630. });
  631. },
  632. rootOrgChanged4InsertOrUpdate() {
  633. this.orgList4InsertOrUpdate = [];
  634. var url =
  635. CORE_API +
  636. "/rolePrivilege/getRoles?includeSuperAdmin=" +
  637. true +
  638. "&rootOrgId=" +
  639. this.userForm.rootOrgId;
  640. this.$httpWithMsg.post(url).then(response => {
  641. this.roleList4InsertOrUpdate = response.data;
  642. this.rolesChanged();
  643. });
  644. },
  645. getOrgList4InsertOrUpdate(query) {
  646. this.orgLoading4InsertOrUpdate = true;
  647. var url =
  648. CORE_API +
  649. "/org/query?" +
  650. new URLSearchParams({
  651. name: query,
  652. rootOrgId: this.userForm.rootOrgId
  653. });
  654. this.$httpWithMsg
  655. .get(url)
  656. .then(response => {
  657. this.orgList4InsertOrUpdate = response.data;
  658. this.orgLoading4InsertOrUpdate = false;
  659. })
  660. .catch(() => {
  661. this.orgLoading4InsertOrUpdate = false;
  662. });
  663. },
  664. getTag(status) {
  665. if (status == true) {
  666. return "success";
  667. } else if (status == false) {
  668. return "danger";
  669. }
  670. return status;
  671. },
  672. getLevel(level) {
  673. if (level == "ZSB") {
  674. return "专升本";
  675. } else if (level == "GQZ") {
  676. return "高起专";
  677. }
  678. return level;
  679. },
  680. handleSearchBtn() {
  681. this.currentPage = 1;
  682. this.search();
  683. },
  684. search() {
  685. this.loading = true;
  686. var param = new URLSearchParams(this.searchForm);
  687. var url =
  688. CORE_API +
  689. "/user/all/" +
  690. this.currentPage +
  691. "/" +
  692. this.pageSize +
  693. "?" +
  694. param;
  695. this.$httpWithMsg.get(url).then(response => {
  696. console.log(response);
  697. this.tableData = response.data.list;
  698. this.total = response.data.total;
  699. this.loading = false;
  700. });
  701. },
  702. handleCurrentChange(val) {
  703. this.currentPage = val;
  704. this.search();
  705. },
  706. selectChange(row) {
  707. this.selectedUserIds = [];
  708. row.forEach(element => {
  709. this.selectedUserIds.push(element.id);
  710. });
  711. console.log(this.selectedUserIds);
  712. },
  713. //新增
  714. openAddingDialog() {
  715. if (this.$refs.addingForm) {
  716. this.$refs.addingForm.resetFields();
  717. }
  718. if (this.$refs.updateForm) {
  719. this.$refs.updateForm.resetFields();
  720. }
  721. this.addingDialog = true;
  722. this.userForm.name = "";
  723. this.userForm.loginName = "";
  724. this.userForm.password = "";
  725. this.userForm.mobile = "";
  726. this.userForm.roleIds = [];
  727. this.userForm.orgId = null;
  728. this.enableStr = "true";
  729. this.orgList4InsertOrUpdate = [];
  730. this.rolesChanged();
  731. },
  732. //修改
  733. openUpdateDialog(row) {
  734. if (this.$refs.updateForm) {
  735. this.$refs.updateForm.resetFields();
  736. }
  737. if (this.$refs.addingForm) {
  738. this.$refs.addingForm.resetFields();
  739. }
  740. this.updateDialog = true;
  741. this.userForm.id = row.id;
  742. this.userForm.roleIds = row.roleIds;
  743. this.userForm.name = row.name;
  744. this.userForm.loginName = row.loginName;
  745. this.enableStr = row.enable ? "true" : "false";
  746. this.userForm.mobile = row.mobile;
  747. this.userForm.password = null;
  748. this.userForm.rootOrgId = row.rootOrgId;
  749. this.rowIsSuperAdmin = false;
  750. for (let roleCode of row.roleCodes) {
  751. if (roleCode == "SUPER_ADMIN") {
  752. this.rowIsSuperAdmin = true;
  753. break;
  754. }
  755. }
  756. this.rootOrgChanged4InsertOrUpdate();
  757. this.orgList4InsertOrUpdate = [{ id: row.orgId, name: row.orgName }];
  758. this.userForm.orgId = row.orgId;
  759. },
  760. exportUser() {
  761. var param = new URLSearchParams(this.searchForm);
  762. window.open(CORE_API + "/user/export?" + param);
  763. },
  764. //保存
  765. add() {
  766. var url = CORE_API + "/user";
  767. this.$refs.addingForm.validate(valid => {
  768. if (valid) {
  769. this.userForm.enable = this.enableStr == "true";
  770. this.$httpWithMsg.post(url, this.userForm).then(() => {
  771. this.$notify({
  772. type: "success",
  773. message: "添加成功"
  774. });
  775. this.search();
  776. this.addingDialog = false;
  777. });
  778. } else {
  779. return false;
  780. }
  781. });
  782. },
  783. //保存
  784. update() {
  785. var url = CORE_API + "/user";
  786. this.$refs.updateForm.validate(valid => {
  787. if (valid) {
  788. this.userForm.enable = this.enableStr == "true";
  789. this.$httpWithMsg.put(url, this.userForm).then(() => {
  790. this.$notify({
  791. type: "success",
  792. message: "添加成功"
  793. });
  794. this.search();
  795. this.updateDialog = false;
  796. });
  797. } else {
  798. return false;
  799. }
  800. });
  801. },
  802. //重置密码
  803. resetPass(row) {
  804. this.$confirm("是否重置密码?", "提示", {
  805. confirmButtonText: "确定",
  806. cancelButtonText: "取消",
  807. type: "warning"
  808. })
  809. .then(() => {
  810. var url = CORE_API + "/user/resetPass/" + row.id;
  811. this.$httpWithMsg.put(url).then(() => {
  812. this.$notify({
  813. type: "success",
  814. message: "重置成功!"
  815. });
  816. return this.search();
  817. });
  818. })
  819. .catch(e => console.log(e));
  820. },
  821. //删除单个数据
  822. deleteById(row) {
  823. this.$confirm("是否删除该用户?", "提示", {
  824. confirmButtonText: "确定",
  825. cancelButtonText: "取消",
  826. type: "warning"
  827. }).then(() => {
  828. var url = CORE_API + "/user/" + row.id;
  829. this.$httpWithMsg.delete(url).then(() => {
  830. this.$notify({
  831. type: "success",
  832. message: "删除成功!"
  833. });
  834. return this.search();
  835. });
  836. });
  837. },
  838. //删除多条数据
  839. deleteByIds() {
  840. if (this.selectedUserIds.length === 0) {
  841. this.$notify({
  842. type: "warning",
  843. message: "请选择要删除的用户"
  844. });
  845. } else {
  846. this.$confirm("是否删除这些用户?", "提示", {
  847. confirmButtonText: "确定",
  848. cancelButtonText: "取消",
  849. type: "error"
  850. }).then(() => {
  851. var url = CORE_API + "/user/" + this.userIds;
  852. this.$httpWithMsg.delete(url).then(() => {
  853. this.$notify({
  854. type: "success",
  855. message: "删除成功!"
  856. });
  857. this.search();
  858. });
  859. });
  860. }
  861. },
  862. //启用
  863. enableByIds() {
  864. if (this.selectedUserIds.length === 0) {
  865. this.$notify({
  866. type: "warning",
  867. message: "请选择要开启的用户"
  868. });
  869. } else {
  870. this.$confirm("是否启用这些用户?", "提示", {
  871. confirmButtonText: "确定",
  872. cancelButtonText: "取消",
  873. type: "warning"
  874. }).then(() => {
  875. var url = CORE_API + "/user/enable/" + this.userIds;
  876. this.$httpWithMsg.put(url, {}).then(() => {
  877. this.$notify({
  878. type: "success",
  879. message: "开启成功!"
  880. });
  881. return this.search();
  882. });
  883. });
  884. }
  885. },
  886. enableById(row) {
  887. this.$confirm("是否启用该用户?", "提示", {
  888. confirmButtonText: "确定",
  889. cancelButtonText: "取消",
  890. type: "warning"
  891. }).then(() => {
  892. var url = CORE_API + "/user/enable/" + row.id;
  893. this.$httpWithMsg.put(url, {}).then(() => {
  894. this.$notify({
  895. type: "success",
  896. message: "开启成功!"
  897. });
  898. this.search();
  899. });
  900. });
  901. },
  902. //禁用
  903. disableByIds() {
  904. if (this.selectedUserIds.length === 0) {
  905. this.$notify({
  906. type: "warning",
  907. message: "请选择要禁用的用户"
  908. });
  909. } else {
  910. this.$confirm("是否禁用这些用户?", "提示", {
  911. confirmButtonText: "确定",
  912. cancelButtonText: "取消",
  913. type: "error"
  914. }).then(() => {
  915. var url = CORE_API + "/user/disable/" + this.userIds;
  916. this.$httpWithMsg.put(url, {}).then(() => {
  917. this.$notify({
  918. type: "success",
  919. message: "禁用成功!"
  920. });
  921. this.search();
  922. });
  923. });
  924. }
  925. },
  926. //禁用
  927. disableById(row) {
  928. this.$confirm("是否禁用该用户?", "提示", {
  929. confirmButtonText: "确定",
  930. cancelButtonText: "取消",
  931. type: "error"
  932. }).then(() => {
  933. var url = CORE_API + "/user/disable/" + row.id;
  934. this.$httpWithMsg.put(url, {}).then(() => {
  935. this.$notify({
  936. type: "success",
  937. message: "禁用成功!"
  938. });
  939. this.search();
  940. });
  941. });
  942. },
  943. /*初始化*/
  944. init() {
  945. for (let role of this.user.roleList) {
  946. if (role.roleCode == "SUPER_ADMIN") {
  947. this.isSuperAdmin = true;
  948. break;
  949. }
  950. }
  951. this.searchForm.rootOrgId = this.user.rootOrgId;
  952. this.userForm.rootOrgId = this.user.rootOrgId;
  953. var url1 = CORE_API + "/org/getRootOrgList";
  954. var url2 =
  955. CORE_API +
  956. "/rolePrivilege/getRoles?includeSuperAdmin=true&rootOrgId=" +
  957. this.user.rootOrgId;
  958. Promise.all([
  959. this.$httpWithMsg.get(url1),
  960. this.$httpWithMsg.post(url2)
  961. ]).then(([resp1, resp2]) => {
  962. this.rootOrgList = resp1.data;
  963. this.roleList4Search = resp2.data;
  964. this.roleList4InsertOrUpdate = resp2.data;
  965. this.search();
  966. });
  967. }
  968. },
  969. //初始化查询
  970. created() {
  971. this.init();
  972. }
  973. };
  974. </script>
  975. <style scoped>
  976. .page {
  977. margin-top: 10px;
  978. }
  979. .input_width_lg {
  980. width: 180px;
  981. }
  982. .input_width {
  983. width: 150px;
  984. }
  985. </style>