personnelInformation.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. <template>
  2. <el-row>
  3. <el-col :span="5">
  4. <div class="box">
  5. <el-scrollbar>
  6. <basic-container>
  7. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  8. </basic-container>
  9. </el-scrollbar>
  10. </div>
  11. </el-col>
  12. <el-col :span="19">
  13. <basic-container>
  14. <avue-crud
  15. :option="option"
  16. :search.sync="search"
  17. :table-loading="loading"
  18. :data="data"
  19. ref="crud"
  20. v-model="form"
  21. @row-del="rowDel"
  22. @row-update="rowUpdate"
  23. @row-save="rowSave"
  24. :before-open="beforeOpen"
  25. :page.sync="page"
  26. @search-change="searchChange"
  27. @search-reset="searchReset"
  28. @selection-change="selectionChange"
  29. @current-change="currentChange"
  30. @size-change="sizeChange"
  31. @refresh-change="refreshChange"
  32. @on-load="onLoad"
  33. >
  34. <template slot="menuLeft">
  35. <el-button
  36. type="danger"
  37. size="small"
  38. plain
  39. icon="el-icon-delete"
  40. @click="handleDelete"
  41. >删 除
  42. </el-button>
  43. <!-- <el-button
  44. type="info"
  45. size="small"
  46. plain
  47. icon="el-icon-user"
  48. @click="handleGrant"
  49. >角色配置
  50. </el-button>-->
  51. <el-button
  52. type="info"
  53. size="small"
  54. plain
  55. icon="el-icon-refresh"
  56. @click="handleReset"
  57. >密码重置
  58. </el-button>
  59. <!-- <el-button
  60. type="success"
  61. size="small"
  62. plain
  63. icon="el-icon-upload2"
  64. @click="handleImport"
  65. >导入
  66. </el-button>
  67. <el-button
  68. type="warning"
  69. size="small"
  70. plain
  71. icon="el-icon-download"
  72. @click="handleExport"
  73. >导出
  74. </el-button>-->
  75. </template>
  76. <template slot-scope="{ row }" slot="tenantName">
  77. <el-tag>{{ row.tenantName }}</el-tag>
  78. </template>
  79. <template slot-scope="{ row }" slot="roleName">
  80. <el-tag>{{ row.roleName }}</el-tag>
  81. </template>
  82. <template slot-scope="{ row }" slot="deptName">
  83. <el-tag>{{ row.deptName }}</el-tag>
  84. </template>
  85. <template slot-scope="{ row }" slot="userTypeName">
  86. <el-tag>{{ row.userTypeName }}</el-tag>
  87. </template>
  88. <template slot-scope="{ row }" slot="workingStatus">
  89. <div :style="row.workingStatus == 1 ? 'color: red;' : ''">
  90. {{ row.workingStatus == 0 ? "启用" : "禁用" }}
  91. </div>
  92. </template>
  93. <template slot-scope="{ type, disabled }" slot="accountForm">
  94. <avue-input
  95. :disabled="type == 'view'"
  96. v-model="form.account"
  97. size="small"
  98. placeholder="请输入 登录账号"
  99. @change="accountChange"
  100. ></avue-input>
  101. </template>
  102. </avue-crud>
  103. <el-dialog title="用户角色配置" append-to-body :visible.sync="roleBox" width="345px">
  104. <el-tree
  105. :data="roleGrantList"
  106. show-checkbox
  107. check-strictly
  108. default-expand-all
  109. node-key="id"
  110. ref="treeRole"
  111. :default-checked-keys="roleTreeObj"
  112. :props="props"
  113. >
  114. </el-tree>
  115. <span slot="footer" class="dialog-footer">
  116. <el-button @click="roleBox = false">取 消</el-button>
  117. <el-button type="primary" @click="submitRole">确 定</el-button>
  118. </span>
  119. </el-dialog>
  120. <el-dialog title="用户数据导入" append-to-body :visible.sync="excelBox" width="555px">
  121. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
  122. <template slot="excelTemplate">
  123. <el-button type="primary" @click="handleTemplate">
  124. 点击下载<i class="el-icon-download el-icon--right"></i>
  125. </el-button>
  126. </template>
  127. </avue-form>
  128. </el-dialog>
  129. <!-- 重置密码对话框 -->
  130. <el-dialog title="重置密码" :visible.sync="dialogVisible" width="30%" :append-to-body="true">
  131. <el-form :inline="true">
  132. <el-form-item label="密码重置为:" prop="changeThePassword">
  133. <el-input v-model="newPassword" placeholder="请输入内容"></el-input>
  134. </el-form-item>
  135. </el-form>
  136. <span slot="footer" class="dialog-footer">
  137. <el-button @click="dialogVisible = false">取 消</el-button>
  138. <el-button type="primary" @click="resetPasswordDiy()">确 定</el-button>
  139. </span>
  140. </el-dialog>
  141. <el-dialog title="用户平台配置" append-to-body :visible.sync="platformBox">
  142. <avue-crud
  143. :option="platformOption"
  144. :table-loading="platformLoading"
  145. :data="platformData"
  146. ref="platformCrud"
  147. v-model="platformForm"
  148. :before-open="platformBeforeOpen"
  149. :page.sync="platformPage"
  150. @row-update="platformRowUpdate"
  151. @search-change="platformSearchChange"
  152. @search-reset="platformSearchReset"
  153. @selection-change="platformSelectionChange"
  154. @current-change="platformCurrentChange"
  155. @size-change="platformSizeChange"
  156. @refresh-change="platformRefreshChange"
  157. @on-load="platformOnLoad"
  158. >
  159. <template slot-scope="{ row }" slot="tenantName">
  160. <el-tag>{{ row.tenantName }}</el-tag>
  161. </template>
  162. <template slot-scope="{ row }" slot="userTypeName">
  163. <el-tag>{{ row.userTypeName }}</el-tag>
  164. </template>
  165. </avue-crud>
  166. </el-dialog>
  167. </basic-container>
  168. </el-col>
  169. </el-row>
  170. </template>
  171. <script>
  172. import {
  173. getList,
  174. getUser,
  175. getUserPlatform,
  176. remove,
  177. update,
  178. updatePlatform,
  179. add,
  180. grant,
  181. resetPassword,
  182. addDealer,
  183. } from "@/api/system/user";
  184. import {getDeptTree, getDeptLazyTree} from "@/api/system/dept";
  185. import {getRoleTree} from "@/api/system/role";
  186. import {getPostList} from "@/api/system/post";
  187. import {mapGetters} from "vuex";
  188. import website from "@/config/website";
  189. import {getToken} from "@/util/auth";
  190. export default {
  191. data() {
  192. const validatePass = (rule, value, callback) => {
  193. if (value === "") {
  194. callback(new Error("请输入密码"));
  195. } else {
  196. callback();
  197. }
  198. };
  199. const validatePass2 = (rule, value, callback) => {
  200. if (value === "") {
  201. callback(new Error("请再次输入密码"));
  202. } else if (value !== this.form.password) {
  203. callback(new Error("两次输入密码不一致!"));
  204. } else {
  205. callback();
  206. }
  207. };
  208. return {
  209. form: {},
  210. search: {},
  211. // 密码重置框是否可见
  212. dialogVisible: false,
  213. roleBox: false,
  214. excelBox: false,
  215. platformBox: false,
  216. initFlag: true,
  217. // 需要重置的密码
  218. newPassword: "123456",
  219. selectionList: [],
  220. query: {},
  221. loading: true,
  222. platformLoading: false,
  223. page: {
  224. pageSize: 10,
  225. currentPage: 1,
  226. total: 0,
  227. },
  228. platformPage: {
  229. pageSize: 10,
  230. currentPage: 1,
  231. total: 0,
  232. },
  233. init: {
  234. roleTree: [],
  235. deptTree: [],
  236. },
  237. props: {
  238. label: "title",
  239. value: "key",
  240. },
  241. roleGrantList: [],
  242. roleTreeObj: [],
  243. treeDeptId: "",
  244. treeData: [],
  245. treeOption: {
  246. nodeKey: "id",
  247. lazy: true,
  248. treeLoad: function (node, resolve) {
  249. const parentId = node.level === 0 ? 0 : node.data.id;
  250. getDeptLazyTree(parentId).then((res) => {
  251. resolve(
  252. res.data.data.map((item) => {
  253. return {
  254. ...item,
  255. leaf: !item.hasChildren,
  256. };
  257. })
  258. );
  259. });
  260. },
  261. addBtn: false,
  262. menu: false,
  263. size: "small",
  264. props: {
  265. labelText: "标题",
  266. label: "title",
  267. value: "value",
  268. children: "children",
  269. },
  270. },
  271. option: {
  272. height: "auto",
  273. calcHeight: 80,
  274. tip: false,
  275. searchShow: true,
  276. searchMenuSpan: 24,
  277. border: true,
  278. index: true,
  279. selection: true,
  280. viewBtn: true,
  281. //dialogType: 'drawer',
  282. dialogClickModal: false,
  283. column: [
  284. {
  285. label: "登录账号",
  286. prop: "account",
  287. search: true,
  288. display: false,
  289. },
  290. {
  291. label: "用户姓名",
  292. prop: "realName",
  293. search: true,
  294. display: false,
  295. },
  296. {
  297. label: "所属角色",
  298. prop: "roleName",
  299. slot: true,
  300. display: false,
  301. },
  302. {
  303. label: "所属部门",
  304. prop: "deptName",
  305. slot: true,
  306. display: false,
  307. },
  308. {
  309. label: "手机号",
  310. prop: "phone",
  311. search: true,
  312. slot: true,
  313. display: false,
  314. },
  315. {
  316. label: "用户状态",
  317. prop: "workingStatus",
  318. type: "select",
  319. dicData: [
  320. {
  321. label: "启用",
  322. value: 0,
  323. },
  324. {
  325. label: "禁用",
  326. value: 1,
  327. },
  328. ],
  329. hide: false,
  330. slot: true,
  331. display: false,
  332. },
  333. ],
  334. group: [
  335. {
  336. label: "基础信息",
  337. prop: "baseInfo",
  338. icon: "el-icon-user-solid",
  339. column: [
  340. {
  341. label: "登录账号",
  342. prop: "account",
  343. rules: [
  344. {
  345. required: true,
  346. message: "请输入登录账号",
  347. trigger: "blur",
  348. },
  349. ],
  350. },
  351. {
  352. label: "密码",
  353. prop: "password",
  354. hide: true,
  355. editDisplay: false,
  356. viewDisplay: false,
  357. rules: [{required: true, validator: validatePass, trigger: "blur"}],
  358. },
  359. {
  360. label: "确认密码",
  361. prop: "password2",
  362. hide: true,
  363. editDisplay: false,
  364. viewDisplay: false,
  365. rules: [{required: true, validator: validatePass2, trigger: "blur"}],
  366. },
  367. ],
  368. },
  369. {
  370. label: "详细信息",
  371. prop: "detailInfo",
  372. icon: "el-icon-s-order",
  373. column: [
  374. {
  375. label: "用户昵称",
  376. prop: "name",
  377. hide: true,
  378. rules: [
  379. {
  380. required: true,
  381. message: "请输入用户昵称",
  382. trigger: "blur",
  383. },
  384. ],
  385. },
  386. {
  387. label: "用户姓名",
  388. prop: "realName",
  389. rules: [
  390. {
  391. required: true,
  392. message: "请输入用户姓名",
  393. trigger: "blur",
  394. },
  395. {
  396. min: 2,
  397. max: 20,
  398. message: "姓名长度在2到20个字符",
  399. },
  400. ],
  401. },
  402. {
  403. label: "手机号码",
  404. prop: "phone",
  405. overHidden: true,
  406. rules: [{
  407. required: true,
  408. message: "请输入手机号码",
  409. trigger: "blur"
  410. }, {
  411. pattern: /^1[3-9]\d{9}$/,
  412. message: '请输入正确的手机号码',
  413. trigger: 'blur'
  414. }]
  415. },
  416. {
  417. label: "用户性别",
  418. prop: "sex",
  419. type: "select",
  420. dicData: [
  421. {
  422. label: "男",
  423. value: 1,
  424. },
  425. {
  426. label: "女",
  427. value: 2,
  428. },
  429. {
  430. label: "未知",
  431. value: 3,
  432. },
  433. ],
  434. hide: true,
  435. },
  436. {
  437. label: "用户状态",
  438. prop: "workingStatus",
  439. type: "select",
  440. dicData: [
  441. {
  442. label: "启用",
  443. value: 0,
  444. },
  445. {
  446. label: "禁用",
  447. value: 1,
  448. },
  449. ],
  450. hide: true,
  451. rules: [
  452. {
  453. required: true,
  454. message: "请选择用户状态",
  455. trigger: "blur",
  456. },
  457. ],
  458. },
  459. {
  460. label: "账号状态",
  461. prop: "statusName",
  462. hide: true,
  463. display: false,
  464. },
  465. ],
  466. }
  467. ],
  468. },
  469. data: [],
  470. platformQuery: {},
  471. platformSelectionList: [],
  472. platformData: [],
  473. platformForm: {},
  474. platformOption: {
  475. tip: false,
  476. searchShow: true,
  477. searchMenuSpan: 6,
  478. border: true,
  479. index: true,
  480. selection: true,
  481. viewBtn: true,
  482. dialogClickModal: false,
  483. menuWidth: 120,
  484. editBtnText: "配置",
  485. column: [
  486. {
  487. label: "登录账号",
  488. prop: "account",
  489. search: true,
  490. display: false,
  491. },
  492. {
  493. label: "所属企业",
  494. prop: "tenantName",
  495. slot: true,
  496. display: false,
  497. },
  498. {
  499. label: "用户姓名",
  500. prop: "realName",
  501. search: true,
  502. display: false,
  503. },
  504. {
  505. label: "用户平台",
  506. prop: "userTypeName",
  507. slot: true,
  508. display: false,
  509. },
  510. {
  511. label: "用户平台",
  512. type: "select",
  513. dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
  514. props: {
  515. label: "dictValue",
  516. value: "dictKey",
  517. },
  518. dataType: "number",
  519. search: true,
  520. hide: true,
  521. display: false,
  522. prop: "userType",
  523. rules: [
  524. {
  525. required: true,
  526. message: "请选择用户平台",
  527. trigger: "blur",
  528. },
  529. ],
  530. },
  531. {
  532. label: "用户拓展",
  533. prop: "userExt",
  534. type: "textarea",
  535. minRows: 8,
  536. span: 24,
  537. overHidden: true,
  538. row: true,
  539. hide: true,
  540. },
  541. ],
  542. },
  543. excelForm: {},
  544. excelOption: {
  545. submitBtn: false,
  546. emptyBtn: false,
  547. column: [
  548. {
  549. label: "模板上传",
  550. prop: "excelFile",
  551. type: "upload",
  552. drag: true,
  553. loadText: "模板上传中,请稍等",
  554. span: 24,
  555. propsHttp: {
  556. res: "data",
  557. },
  558. tip: "请上传 .xls,.xlsx 标准格式文件",
  559. action: "/api/blade-user/import-user",
  560. },
  561. {
  562. label: "数据覆盖",
  563. prop: "isCovered",
  564. type: "switch",
  565. align: "center",
  566. width: 80,
  567. dicData: [
  568. {
  569. label: "否",
  570. value: 0,
  571. },
  572. {
  573. label: "是",
  574. value: 1,
  575. },
  576. ],
  577. value: 0,
  578. slot: true,
  579. rules: [
  580. {
  581. required: true,
  582. message: "请选择是否覆盖",
  583. trigger: "blur",
  584. },
  585. ],
  586. },
  587. {
  588. label: "模板下载",
  589. prop: "excelTemplate",
  590. formslot: true,
  591. span: 24,
  592. },
  593. ],
  594. },
  595. };
  596. },
  597. watch: {
  598. "form.tenantId"() {
  599. if (this.form.tenantId !== "" && this.initFlag) {
  600. this.initData(this.form.tenantId);
  601. }
  602. },
  603. "excelForm.isCovered"() {
  604. if (this.excelForm.isCovered !== "") {
  605. const column = this.findObject(this.excelOption.column, "excelFile");
  606. column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
  607. }
  608. },
  609. },
  610. computed: {
  611. ...mapGetters(["userInfo", "permission"]),
  612. permissionList() {
  613. return {
  614. addBtn: this.vaildData(this.permission.user_add, false),
  615. viewBtn: this.vaildData(this.permission.user_view, false),
  616. delBtn: this.vaildData(this.permission.user_delete, false),
  617. editBtn: this.vaildData(this.permission.user_edit, false),
  618. };
  619. },
  620. platformPermissionList() {
  621. return {
  622. // addBtn: false,
  623. // viewBtn: false,
  624. // delBtn: false,
  625. // editBtn: this.vaildData(this.permission.user_edit, false),
  626. };
  627. },
  628. ids() {
  629. let ids = [];
  630. this.selectionList.forEach((ele) => {
  631. ids.push(ele.id);
  632. });
  633. return ids.join(",");
  634. },
  635. },
  636. created() {
  637. // 根据 企业好判断是否要显示 积分余额
  638. // const content = JSON.parse(localStorage.getItem('saber-tenantId')).content
  639. // if (content == 171757) {
  640. // this.$nextTick(()=>{
  641. // this.refsDisplay()
  642. // })
  643. // }
  644. let arr = localStorage.getItem("roleName").split(",");
  645. this.$nextTick(() => {
  646. // 循环这个 实例
  647. for (let item of this.$refs.crud.option.group) {
  648. // 判断是不是详细详细里的
  649. if (item.prop == "detailInfo") {
  650. for (let ite of item.column) {
  651. // 判断是不是积分余额
  652. if (ite.prop == "pointsBalance") {
  653. // 判断是否是admin 权限
  654. if (arr.indexOf("admin") != -1) {
  655. ite.disabled = false;
  656. }
  657. ite.addDisplay = true;
  658. ite.editDisplay = true;
  659. ite.viewDisplay = true;
  660. }
  661. }
  662. }
  663. }
  664. });
  665. },
  666. mounted() {
  667. // 非企业模式默认加载管理组数据
  668. if (!website.tenantMode) {
  669. this.initData(website.tenantId);
  670. }
  671. },
  672. methods: {
  673. accountChange(val) {
  674. this.form.name = val;
  675. this.form.realName = val;
  676. },
  677. // 循环实例 修改积分余额是否显示
  678. refsDisplay() {
  679. let arr = localStorage.getItem("roleName").split(",");
  680. // 循环这个 实例
  681. for (let item of this.$refs.crud.option.group) {
  682. // 判断是不是详细详细里的
  683. if (item.prop == "detailInfo") {
  684. for (let ite of item.column) {
  685. // 判断是不是积分余额
  686. if (ite.prop == "pointsBalance") {
  687. // 判断是否是admin 权限
  688. if (arr.indexOf("admin") != -1) {
  689. ite.disabled = false;
  690. }
  691. ite.addDisplay = true;
  692. ite.editDisplay = true;
  693. ite.viewDisplay = true;
  694. }
  695. }
  696. }
  697. }
  698. },
  699. nodeClick(data) {
  700. this.treeDeptId = data.id;
  701. this.page.currentPage = 1;
  702. this.onLoad(this.page);
  703. },
  704. initData(tenantId) {
  705. getRoleTree(tenantId).then((res) => {
  706. const column = this.findObject(this.option.group, "roleId");
  707. let data = res.data.data;
  708. // 没有提取 sort
  709. // data.sort((a, b)=>{
  710. // return a.sort>b.sort ? 1 : (a.sort<b.sort ? -1 : 0)
  711. // })
  712. // data.forEach(d=>{
  713. // if(Array.isArray(d.children)){
  714. // d.children.sort((a, b)=>{
  715. // return a.sort>b.sort ? 1 : (a.sort<b.sort ? -1 : 0)
  716. // })
  717. // }
  718. // })
  719. column.dicData = [];
  720. if (localStorage.getItem("roleName").indexOf("admin") != -1) {
  721. column.dicData = data;
  722. } else {
  723. for (let item of data) {
  724. if (item.title != "管理员") {
  725. column.dicData.push(item);
  726. }
  727. }
  728. }
  729. });
  730. // getDeptTree(tenantId).then(res => {
  731. // const column = this.findObject(this.option.group, "deptId");
  732. // column.dicData = res.data.data;
  733. // });
  734. getPostList(tenantId).then((res) => {
  735. const column = this.findObject(this.option.group, "postId");
  736. column.dicData = res.data.data;
  737. });
  738. },
  739. submitRole() {
  740. const roleList = this.$refs.treeRole.getCheckedKeys().join(",");
  741. grant(this.ids, roleList).then(() => {
  742. this.roleBox = false;
  743. this.$message({
  744. type: "success",
  745. message: "操作成功!",
  746. });
  747. this.onLoad(this.page);
  748. });
  749. },
  750. rowSave(row, done, loading) {
  751. // row.roleId = row.roleId.join(",");
  752. // row.postId = row.postId.join(",");
  753. addDealer(row).then(
  754. () => {
  755. this.initFlag = false;
  756. this.onLoad(this.page);
  757. this.$message({
  758. type: "success",
  759. message: "操作成功!",
  760. });
  761. done();
  762. },
  763. (error) => {
  764. window.console.log(error);
  765. loading();
  766. }
  767. );
  768. },
  769. rowUpdate(row, index, done, loading) {
  770. // row.deptId = row.deptId.join(",");
  771. row.roleId = row.roleId.join(",");
  772. row.postId = row.postId.join(",");
  773. if (!row.workingStatus) {
  774. row.workingStatus = "0";
  775. }
  776. // 福达写死小程序
  777. let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  778. if (userObj.tenant_id == "577435") {
  779. // row.userType = 4
  780. row.appletsId = "wxa92adb24f1784863";
  781. }
  782. update(row).then(
  783. () => {
  784. this.initFlag = false;
  785. this.onLoad(this.page);
  786. this.$message({
  787. type: "success",
  788. message: "操作成功!",
  789. });
  790. done();
  791. },
  792. (error) => {
  793. window.console.log(error);
  794. loading();
  795. }
  796. );
  797. },
  798. rowDel(row) {
  799. this.$confirm("确定将选择数据删除?", {
  800. confirmButtonText: "确定",
  801. cancelButtonText: "取消",
  802. type: "warning",
  803. })
  804. .then(() => {
  805. return remove(row.id);
  806. })
  807. .then(() => {
  808. this.onLoad(this.page);
  809. this.$message({
  810. type: "success",
  811. message: "操作成功!",
  812. });
  813. });
  814. },
  815. searchReset() {
  816. this.query = {};
  817. this.treeDeptId = "";
  818. this.onLoad(this.page);
  819. },
  820. searchChange(params, done) {
  821. this.query = params;
  822. this.page.currentPage = 1;
  823. this.onLoad(this.page, params);
  824. done();
  825. },
  826. selectionChange(list) {
  827. this.selectionList = list;
  828. },
  829. selectionClear() {
  830. this.selectionList = [];
  831. this.$refs.crud.toggleSelection();
  832. },
  833. handleDelete() {
  834. if (this.selectionList.length === 0) {
  835. this.$message.warning("请选择至少一条数据");
  836. return;
  837. }
  838. this.$confirm("确定将选择数据删除?", {
  839. confirmButtonText: "确定",
  840. cancelButtonText: "取消",
  841. type: "warning",
  842. })
  843. .then(() => {
  844. return remove(this.ids);
  845. })
  846. .then(() => {
  847. this.onLoad(this.page);
  848. this.$message({
  849. type: "success",
  850. message: "操作成功!",
  851. });
  852. this.$refs.crud.toggleSelection();
  853. });
  854. },
  855. handleReset() {
  856. if (this.selectionList.length === 0) {
  857. this.$message.warning("请选择至少一条数据");
  858. return;
  859. }
  860. this.dialogVisible = true;
  861. // this.$confirm("确定将选择账号密码重置为123456?", {
  862. // confirmButtonText: "确定",
  863. // cancelButtonText: "取消",
  864. // type: "warning"
  865. // })
  866. // .then(() => {
  867. // return resetPassword(this.ids);
  868. // })
  869. // .then(() => {
  870. // this.$message({
  871. // type: "success",
  872. // message: "操作成功!"
  873. // });
  874. // this.$refs.crud.toggleSelection();
  875. // });
  876. },
  877. // 重置密码为指定内容
  878. resetPasswordDiy() {
  879. resetPassword(this.ids, this.newPassword).then((res) => {
  880. console.log(res);
  881. if (res.data.code === 200) {
  882. this.$message({
  883. message: "操作成功!",
  884. type: "success",
  885. });
  886. this.dialogVisible = false;
  887. }
  888. });
  889. },
  890. handleGrant() {
  891. if (this.selectionList.length === 0) {
  892. this.$message.warning("请选择至少一条数据");
  893. return;
  894. }
  895. this.roleTreeObj = [];
  896. if (this.selectionList.length === 1) {
  897. this.roleTreeObj = this.selectionList[0].roleId.split(",");
  898. }
  899. getRoleTree().then((res) => {
  900. this.roleGrantList = res.data.data;
  901. this.roleBox = true;
  902. });
  903. },
  904. handlePlatform() {
  905. this.platformBox = true;
  906. },
  907. handleImport() {
  908. this.excelBox = true;
  909. },
  910. uploadAfter(res, done, loading, column) {
  911. window.console.log(column);
  912. this.excelBox = false;
  913. this.refreshChange();
  914. done();
  915. },
  916. handleExport() {
  917. this.$confirm("是否导出用户数据?", "提示", {
  918. confirmButtonText: "确定",
  919. cancelButtonText: "取消",
  920. type: "warning",
  921. }).then(() => {
  922. window.open(
  923. `/api/blade-user/export-user?${this.website.tokenHeader}=${getToken()}&account=${
  924. this.search.account
  925. }&realName=${this.search.realName}`
  926. );
  927. });
  928. },
  929. handleTemplate() {
  930. window.open(`/api/blade-user/export-template?${this.website.tokenHeader}=${getToken()}`);
  931. },
  932. beforeOpen(done, type) {
  933. if (["edit", "view"].includes(type)) {
  934. // if (localStorage.getItem('roleName').indexOf('admin') == -1) {
  935. // this.findObject(this.option.group, "workingStatus").disabled = true;
  936. // }
  937. getUser(this.form.id).then((res) => {
  938. this.form = res.data.data;
  939. // if (this.form.hasOwnProperty("deptId")) {
  940. // this.form.deptId = this.form.deptId.split(",");
  941. // }
  942. if (this.form.hasOwnProperty("roleId")) {
  943. this.form.roleId = this.form.roleId.split(",");
  944. }
  945. if (this.form.hasOwnProperty("postId")) {
  946. this.form.postId = this.form.postId.split(",");
  947. }
  948. });
  949. }
  950. this.initFlag = true;
  951. done();
  952. },
  953. currentChange(currentPage) {
  954. this.page.currentPage = currentPage;
  955. },
  956. sizeChange(pageSize) {
  957. this.page.pageSize = pageSize;
  958. },
  959. refreshChange() {
  960. this.onLoad(this.page, this.query);
  961. },
  962. onLoad(page, params = {}) {
  963. this.loading = true;
  964. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then((res) => {
  965. const data = res.data.data;
  966. this.page.total = data.total;
  967. this.data = data.records;
  968. this.loading = false;
  969. this.selectionClear();
  970. });
  971. },
  972. platformRowUpdate(row, index, done, loading) {
  973. updatePlatform(row.id, row.userType, row.userExt).then(
  974. () => {
  975. this.platformOnLoad(this.platformPage);
  976. this.$message({
  977. type: "success",
  978. message: "操作成功!",
  979. });
  980. done();
  981. },
  982. (error) => {
  983. window.console.log(error);
  984. loading();
  985. }
  986. );
  987. },
  988. platformBeforeOpen(done, type) {
  989. if (["edit", "view"].includes(type)) {
  990. getUserPlatform(this.platformForm.id).then((res) => {
  991. this.platformForm = res.data.data;
  992. });
  993. }
  994. done();
  995. },
  996. platformSearchReset() {
  997. this.platformQuery = {};
  998. this.platformOnLoad(this.platformPage);
  999. },
  1000. platformSearchChange(params, done) {
  1001. this.platformQuery = params;
  1002. this.platformPage.currentPage = 1;
  1003. this.platformOnLoad(this.platformPage, params);
  1004. done();
  1005. },
  1006. platformSelectionChange(list) {
  1007. this.platformSelectionList = list;
  1008. },
  1009. platformSelectionClear() {
  1010. this.platformSelectionList = [];
  1011. this.$refs.platformCrud.toggleSelection();
  1012. },
  1013. platformCurrentChange(currentPage) {
  1014. this.platformPage.currentPage = currentPage;
  1015. },
  1016. platformSizeChange(pageSize) {
  1017. this.platformPage.pageSize = pageSize;
  1018. },
  1019. platformRefreshChange() {
  1020. this.platformOnLoad(this.platformPage, this.platformQuery);
  1021. },
  1022. platformOnLoad(page, params = {}) {
  1023. this.platformLoading = true;
  1024. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then((res) => {
  1025. const data = res.data.data;
  1026. this.platformPage.total = data.total;
  1027. this.platformData = data.records;
  1028. this.platformLoading = false;
  1029. this.selectionClear();
  1030. });
  1031. },
  1032. },
  1033. };
  1034. </script>
  1035. <style>
  1036. .box {
  1037. height: 800px;
  1038. }
  1039. .el-scrollbar {
  1040. height: 100%;
  1041. }
  1042. .box .el-scrollbar__wrap {
  1043. overflow: scroll;
  1044. }
  1045. ::v-deep .el-dialog .el-dialog__body {
  1046. display: flex;
  1047. justify-content: center;
  1048. align-items: center;
  1049. }
  1050. ::v-deep .el-col-md-8 {
  1051. width: 24.33333%;
  1052. }
  1053. .itemTable ::v-deep .el-table {
  1054. margin-left: 50px;
  1055. width: 100%;
  1056. }
  1057. </style>