user.vue 29 KB

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