user.vue 37 KB

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