user.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. <template>
  2. <el-row>
  3. <el-col :span="5">
  4. <div class="box">
  5. <el-scrollbar>
  6. <basic-container>
  7. <avue-tree
  8. :option="treeOption"
  9. :data="treeData"
  10. @node-click="nodeClick"
  11. />
  12. </basic-container>
  13. </el-scrollbar>
  14. </div>
  15. </el-col>
  16. <el-col :span="19">
  17. <basic-container>
  18. <avue-crud
  19. :option="option"
  20. :search.sync="search"
  21. :table-loading="loading"
  22. :data="data"
  23. ref="crud"
  24. :before-close="beforeClose"
  25. v-model="form"
  26. :permission="permissionList"
  27. @row-del="rowDel"
  28. @row-update="rowUpdate"
  29. @row-save="rowSave"
  30. :before-open="beforeOpen"
  31. :page.sync="page"
  32. @search-change="searchChange"
  33. @search-reset="searchReset"
  34. @selection-change="selectionChange"
  35. @current-change="currentChange"
  36. @size-change="sizeChange"
  37. @refresh-change="refreshChange"
  38. @on-load="onLoad"
  39. >
  40. <!-- 自 定义按钮 -->
  41. <template
  42. slot-scope="{row,index}"
  43. slot="menu"
  44. >
  45. <el-link
  46. :underline="false"
  47. type="primary"
  48. icon="el-icon-edit"
  49. size="small"
  50. @click="$refs.crud.rowView(row,index)"
  51. >查看</el-link>
  52. <el-link
  53. class="marleft10"
  54. :underline="false"
  55. type="primary"
  56. icon="el-icon-edit"
  57. size="small"
  58. @click="editKJ(row, index)"
  59. >编辑</el-link>
  60. <el-link
  61. class="marleft10"
  62. :underline="false"
  63. type="primary"
  64. icon="el-icon-delete"
  65. size="small"
  66. @click="$refs.crud.rowDel(row,index)"
  67. >删除</el-link>
  68. </template>
  69. <!-- 参建项目 -->
  70. <template
  71. slot-scope="{type}"
  72. slot="projectAndUserListForm"
  73. >
  74. <div
  75. class="flexStar martop10"
  76. v-for="(item,key) in fromss.projectAndUserList"
  77. :key='key'
  78. >
  79. <el-input
  80. v-model="fromss.projectAndUserList[key].projectName"
  81. :disabled="true"
  82. ></el-input>
  83. <el-input
  84. class="marleft10"
  85. v-model="fromss.projectAndUserList[key].contractName"
  86. :disabled="true"
  87. ></el-input>
  88. <el-input
  89. class="marleft10"
  90. v-model="fromss.projectAndUserList[key].roleName"
  91. :disabled="true"
  92. ></el-input>
  93. <el-button
  94. @click="deleteProject(key,type)"
  95. class="marleft10"
  96. type="danger"
  97. icon="el-icon-delete"
  98. circle
  99. ></el-button>
  100. </div>
  101. </template>
  102. <!-- 参与项目自定义表单 -->
  103. <template slot="projectIdForm">
  104. <el-select
  105. v-model="fromss.projectId"
  106. placeholder="请选择"
  107. >
  108. <el-option
  109. v-for="item in projectData"
  110. :key="item.id"
  111. :label="item.projectName"
  112. :value="item.id"
  113. >
  114. </el-option>
  115. </el-select>
  116. </template>
  117. <!-- 合同段自定义表单 -->
  118. <template slot="contractIdForm">
  119. <el-select
  120. v-model="fromss.contractId"
  121. placeholder="请选择"
  122. >
  123. <el-option
  124. v-for="item in contractData"
  125. :key="item.id"
  126. :label="item.projectName"
  127. :value="item.id"
  128. >
  129. </el-option>
  130. </el-select>
  131. </template>
  132. <!-- 用户类型自定义表单 -->
  133. <template
  134. slot-scope="{type}"
  135. slot="roleIdsForm"
  136. >
  137. <div class="flexStar">
  138. <el-select
  139. v-model="fromss.roleIds"
  140. placeholder="请选择"
  141. >
  142. <el-option
  143. v-for="item in roleIdsData"
  144. :key="item.id"
  145. :label="item.roleName"
  146. :value="item.roleId"
  147. >
  148. </el-option>
  149. </el-select>
  150. <el-button
  151. v-show="type!=='view'"
  152. class="marleft10"
  153. type="warning"
  154. size="mini"
  155. @click="addProject(type)"
  156. >确认添加</el-button>
  157. </div>
  158. </template>
  159. <template slot="menuLeft">
  160. <el-button
  161. type="primary"
  162. size="small"
  163. icon="el-icon-plus"
  164. @click="addKJ()"
  165. >新 增
  166. </el-button>
  167. <el-button
  168. type="danger"
  169. size="small"
  170. plain
  171. icon="el-icon-delete"
  172. v-if="permission.user_delete"
  173. @click="handleDelete"
  174. >删 除
  175. </el-button>
  176. <el-button
  177. type="info"
  178. size="small"
  179. plain
  180. v-if="permission.user_role"
  181. icon="el-icon-user"
  182. @click="handleGrant"
  183. >角色配置
  184. </el-button>
  185. <el-button
  186. type="info"
  187. size="small"
  188. plain
  189. v-if="permission.user_reset"
  190. icon="el-icon-refresh"
  191. @click="handleReset"
  192. >密码重置
  193. </el-button>
  194. <el-button
  195. type="info"
  196. size="small"
  197. plain
  198. v-if="userInfo.role_name.includes('admin')"
  199. icon="el-icon-setting"
  200. @click="handlePlatform"
  201. >平台配置
  202. </el-button>
  203. <el-button
  204. type="info"
  205. size="small"
  206. plain
  207. v-if="userInfo.role_name.includes('admin')"
  208. icon="el-icon-coordinate"
  209. @click="handleLock"
  210. >账号解封
  211. </el-button>
  212. <el-button
  213. type="success"
  214. size="small"
  215. plain
  216. v-if="userInfo.role_name.includes('admin')"
  217. icon="el-icon-upload2"
  218. @click="handleImport"
  219. >导入
  220. </el-button>
  221. <el-button
  222. type="warning"
  223. size="small"
  224. plain
  225. v-if="userInfo.role_name.includes('admin')"
  226. icon="el-icon-download"
  227. @click="handleExport"
  228. >导出
  229. </el-button>
  230. </template>
  231. <template
  232. slot-scope="{row}"
  233. slot="tenantName"
  234. >
  235. <el-tag>{{row.tenantName}}</el-tag>
  236. </template>
  237. <template
  238. slot-scope="{row}"
  239. slot="roleName"
  240. >
  241. <el-tag>{{row.roleName}}</el-tag>
  242. </template>
  243. <template
  244. slot-scope="{row}"
  245. slot="deptName"
  246. >
  247. <el-tag>{{row.deptName}}</el-tag>
  248. </template>
  249. <template
  250. slot-scope="{row}"
  251. slot="userTypeName"
  252. >
  253. <el-tag>{{row.userTypeName}}</el-tag>
  254. </template>
  255. </avue-crud>
  256. <el-dialog
  257. title="用户角色配置"
  258. append-to-body
  259. :visible.sync="roleBox"
  260. width="345px"
  261. >
  262. <el-tree
  263. :data="roleGrantList"
  264. show-checkbox
  265. check-strictly
  266. default-expand-all
  267. node-key="id"
  268. ref="treeRole"
  269. :default-checked-keys="roleTreeObj"
  270. :props="props"
  271. >
  272. </el-tree>
  273. <span
  274. slot="footer"
  275. class="dialog-footer"
  276. >
  277. <el-button @click="roleBox = false">取 消</el-button>
  278. <el-button
  279. type="primary"
  280. @click="submitRole"
  281. >确 定</el-button>
  282. </span>
  283. </el-dialog>
  284. <el-dialog
  285. title="用户数据导入"
  286. append-to-body
  287. :visible.sync="excelBox"
  288. width="555px"
  289. >
  290. <avue-form
  291. :option="excelOption"
  292. v-model="excelForm"
  293. :upload-after="uploadAfter"
  294. >
  295. <template slot="excelTemplate">
  296. <el-button
  297. type="primary"
  298. @click="handleTemplate"
  299. >
  300. 点击下载<i class="el-icon-download el-icon--right"></i>
  301. </el-button>
  302. </template>
  303. </avue-form>
  304. </el-dialog>
  305. <el-dialog
  306. title="用户平台配置"
  307. append-to-body
  308. :visible.sync="platformBox"
  309. >
  310. <avue-crud
  311. :option="platformOption"
  312. :table-loading="platformLoading"
  313. :data="platformData"
  314. ref="platformCrud"
  315. v-model="platformForm"
  316. :before-open="platformBeforeOpen"
  317. :page.sync="platformPage"
  318. :permission="platformPermissionList"
  319. @row-update="platformRowUpdate"
  320. @search-change="platformSearchChange"
  321. @search-reset="platformSearchReset"
  322. @selection-change="platformSelectionChange"
  323. @current-change="platformCurrentChange"
  324. @size-change="platformSizeChange"
  325. @refresh-change="platformRefreshChange"
  326. @on-load="platformOnLoad"
  327. >
  328. <template
  329. slot-scope="{row}"
  330. slot="tenantName"
  331. >
  332. <el-tag>{{row.tenantName}}</el-tag>
  333. </template>
  334. <template
  335. slot-scope="{row}"
  336. slot="userTypeName"
  337. >
  338. <el-tag>{{row.userTypeName}}</el-tag>
  339. </template>
  340. </avue-crud>
  341. </el-dialog>
  342. </basic-container>
  343. </el-col>
  344. </el-row>
  345. </template>
  346. <script>
  347. import {
  348. getList,
  349. getUser,
  350. getUserPlatform,
  351. remove,
  352. update,
  353. updatePlatform,
  354. add,
  355. grant,
  356. resetPassword, unlock
  357. } from "@/api/system/user";
  358. import { getProjectList } from "@/api/manager/projectinfo";
  359. import { findContractByProjectId, removeUsersByIds } from "@/api/manager/contractinfo";
  360. import { exportBlob } from "@/api/common";
  361. import { getDeptTree, getDeptLazyTree } from "@/api/system/dept";
  362. import { roletree, treeUser, findProjectAndContractList, saveUserInfoByProjectTow } from "@/api/system/role";
  363. // import { getPostList } from "@/api/system/post";
  364. import { mapGetters } from "vuex";
  365. import website from '@/config/website';
  366. import { getToken } from '@/util/auth';
  367. import { downloadXls } from "@/util/util";
  368. import { dateNow } from "@/util/date";
  369. import NProgress from 'nprogress';
  370. import 'nprogress/nprogress.css';
  371. export default {
  372. data () {
  373. const validatePass = (rule, value, callback) => {
  374. if (value === '') {
  375. callback(new Error('请输入密码'));
  376. } else {
  377. callback();
  378. }
  379. };
  380. const validatePass2 = (rule, value, callback) => {
  381. if (value === '') {
  382. callback(new Error('请再次输入密码'));
  383. } else if (value !== this.form.password) {
  384. callback(new Error('两次输入密码不一致!'));
  385. } else {
  386. callback();
  387. }
  388. };
  389. return {
  390. addData: {
  391. tenantId: '',
  392. deptId: ''
  393. },
  394. form: {},
  395. search: {},
  396. roleBox: false,
  397. excelBox: false,
  398. platformBox: false,
  399. initFlag: true,
  400. selectionList: [],
  401. query: {},
  402. loading: true,
  403. platformLoading: false,
  404. page: {
  405. pageSize: 10,
  406. currentPage: 1,
  407. total: 0
  408. },
  409. platformPage: {
  410. pageSize: 10,
  411. currentPage: 1,
  412. total: 0
  413. },
  414. init: {
  415. roleTree: [],
  416. deptTree: [],
  417. },
  418. props: {
  419. label: "title",
  420. value: "key"
  421. },
  422. roleGrantList: [],
  423. roleTreeObj: [],
  424. treeDeptId: '',
  425. treeData: [],
  426. treeOption: {
  427. nodeKey: 'id',
  428. lazy: true,
  429. treeLoad: function (node, resolve) {
  430. const parentId = (node.level === 0) ? 0 : node.data.id;
  431. getDeptLazyTree(parentId).then(res => {
  432. resolve(res.data.data.map(item => {
  433. return {
  434. ...item,
  435. leaf: !item.hasChildren
  436. }
  437. }))
  438. });
  439. },
  440. addBtn: false,
  441. menu: false,
  442. size: 'small',
  443. props: {
  444. labelText: '标题',
  445. label: 'title',
  446. value: 'value',
  447. children: 'children'
  448. }
  449. },
  450. fromss: {
  451. userId: '',//
  452. projectAndUserList: [],
  453. projectId: '',//参与项项目
  454. contractId: '',//合同段
  455. roleIds: '',//用户类型
  456. },
  457. projectData: [],//参与项项目
  458. contractData: [],//合同段
  459. roleIdsData: [],//用户类型
  460. option: {
  461. height: 'auto',
  462. calcHeight: 80,
  463. tip: false,
  464. searchShow: true,
  465. searchMenuSpan: 6,
  466. border: true,
  467. index: true,
  468. selection: true,
  469. addBtn: false,
  470. // viewBtn: true,
  471. editBtn: false,
  472. delBtn: false,
  473. dialogType: 'drawer',
  474. dialogClickModal: false,
  475. column: [
  476. {
  477. label: "登录账号",
  478. prop: "account",
  479. search: true,
  480. display: false
  481. },
  482. {
  483. label: "所属租户",
  484. prop: "tenantName",
  485. slot: true,
  486. display: false
  487. },
  488. {
  489. label: "用户姓名",
  490. prop: "realName",
  491. search: true,
  492. display: false
  493. },
  494. {
  495. label: "所属角色",
  496. prop: "roleName",
  497. slot: true,
  498. display: false,
  499. },
  500. {
  501. label: "所属部门",
  502. prop: "deptName",
  503. slot: true,
  504. display: false
  505. },
  506. {
  507. label: "用户平台",
  508. prop: "userTypeName",
  509. slot: true,
  510. display: false
  511. },
  512. {
  513. label: "用户平台",
  514. type: "select",
  515. dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
  516. props: {
  517. label: "dictValue",
  518. value: "dictKey"
  519. },
  520. dataType: "number",
  521. search: true,
  522. hide: true,
  523. display: false,
  524. prop: "userType",
  525. rules: [{
  526. required: true,
  527. message: "请选择用户平台",
  528. trigger: "blur"
  529. }]
  530. },
  531. ],
  532. group: [
  533. {
  534. label: '基础信息',
  535. prop: 'baseInfo',
  536. icon: 'el-icon-user-solid',
  537. column: [
  538. {
  539. label: "所属租户",
  540. prop: "tenantId",
  541. type: "tree",
  542. dicUrl: "/api/blade-system/tenant/select",
  543. props: {
  544. label: "tenantName",
  545. value: "tenantId"
  546. },
  547. hide: !website.tenantMode,
  548. addDisplay: website.tenantMode,
  549. editDisplay: website.tenantMode,
  550. viewDisplay: website.tenantMode,
  551. rules: [{
  552. required: true,
  553. message: "请输入所属租户",
  554. trigger: "change"
  555. }],
  556. span: 24,
  557. },
  558. {
  559. label: "登录账号",
  560. prop: "account",
  561. rules: [{
  562. required: true,
  563. message: "请输入登录账号",
  564. trigger: "blur"
  565. }],
  566. },
  567. {
  568. label: '密码',
  569. prop: 'password',
  570. hide: true,
  571. editDisplay: false,
  572. viewDisplay: false,
  573. rules: [{ required: true, validator: validatePass, trigger: 'blur' }]
  574. },
  575. {
  576. label: '确认密码',
  577. prop: 'password2',
  578. hide: true,
  579. editDisplay: false,
  580. viewDisplay: false,
  581. rules: [{ required: true, validator: validatePass2, trigger: 'blur' }]
  582. },
  583. ]
  584. },
  585. {
  586. label: '详细信息',
  587. prop: 'detailInfo',
  588. icon: 'el-icon-s-order',
  589. column: [
  590. {
  591. label: "用户姓名",
  592. prop: "realName",
  593. rules: [{
  594. required: true,
  595. message: "请输入用户姓名",
  596. trigger: "blur"
  597. }, {
  598. min: 2,
  599. max: 5,
  600. message: '姓名长度在2到5个字符'
  601. }]
  602. },
  603. {
  604. label: "手机号码",
  605. prop: "phone",
  606. rules: [{
  607. required: true,
  608. message: "请输入手机号",
  609. trigger: "blur",
  610. }],
  611. },
  612. {
  613. label: "身份证号",
  614. prop: "idNumber",
  615. },
  616. {
  617. label: "所属部门",
  618. prop: "deptId",
  619. type: "tree",
  620. multiple: true,
  621. dicData: [],
  622. props: {
  623. label: "title"
  624. },
  625. checkStrictly: true,
  626. slot: true,
  627. rules: [{
  628. required: true,
  629. message: "请选择所属部门",
  630. trigger: "change"
  631. }]
  632. },
  633. ]
  634. },
  635. {
  636. label: '职能描述',
  637. prop: 'dutyInfo',
  638. icon: 'el-icon-s-custom',
  639. column: [
  640. {
  641. label: "参建项目",
  642. prop: "projectAndUserList",
  643. span: 24,
  644. // rules: [{
  645. // required: true,
  646. // message: "请先添加参加项目",
  647. // trigger: "change"
  648. // }],
  649. },
  650. {
  651. label: "参与项目",
  652. prop: "projectId",
  653. span: 16,
  654. },
  655. {
  656. label: "合同段",
  657. prop: "contractId",
  658. span: 16,
  659. }, {
  660. label: "用户类型",
  661. prop: "roleIds",
  662. span: 16,
  663. }, {
  664. label: "单位名称",
  665. prop: "companyName",
  666. span: 16,
  667. }, {
  668. label: "职位",
  669. prop: "position",
  670. span: 16,
  671. },
  672. {
  673. label: "允许登录",
  674. type: "select",
  675. span: 16,
  676. prop: "status",
  677. dicData: [
  678. { value: 1, label: '是' },
  679. { value: 0, label: '否' }],
  680. rules: [{
  681. required: true,
  682. message: "请选择是否允许登录",
  683. trigger: "change"
  684. }],
  685. },
  686. ]
  687. },
  688. ]
  689. },
  690. data: [],
  691. platformQuery: {},
  692. platformSelectionList: [],
  693. platformData: [],
  694. platformForm: {},
  695. platformOption: {
  696. tip: false,
  697. searchShow: true,
  698. searchMenuSpan: 6,
  699. border: true,
  700. index: true,
  701. selection: true,
  702. viewBtn: true,
  703. dialogClickModal: false,
  704. menuWidth: 120,
  705. editBtnText: '配置',
  706. column: [
  707. {
  708. label: "登录账号",
  709. prop: "account",
  710. search: true,
  711. display: false
  712. },
  713. {
  714. label: "所属租户",
  715. prop: "tenantName",
  716. slot: true,
  717. display: false
  718. },
  719. {
  720. label: "用户姓名",
  721. prop: "realName",
  722. search: true,
  723. display: false
  724. },
  725. {
  726. label: "用户平台",
  727. prop: "userTypeName",
  728. slot: true,
  729. display: false
  730. },
  731. {
  732. label: "用户平台",
  733. type: "select",
  734. dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
  735. props: {
  736. label: "dictValue",
  737. value: "dictKey"
  738. },
  739. dataType: "number",
  740. search: true,
  741. hide: true,
  742. display: false,
  743. prop: "userType",
  744. rules: [{
  745. required: true,
  746. message: "请选择用户平台",
  747. trigger: "blur"
  748. }]
  749. },
  750. {
  751. label: "用户拓展",
  752. prop: "userExt",
  753. type: "textarea",
  754. minRows: 8,
  755. span: 24,
  756. overHidden: true,
  757. row: true,
  758. hide: true,
  759. },
  760. ],
  761. },
  762. excelForm: {},
  763. excelOption: {
  764. submitBtn: false,
  765. emptyBtn: false,
  766. column: [
  767. {
  768. label: '模板上传',
  769. prop: 'excelFile',
  770. type: 'upload',
  771. drag: true,
  772. loadText: '模板上传中,请稍等',
  773. span: 24,
  774. propsHttp: {
  775. res: 'data'
  776. },
  777. tip: '请上传 .xls,.xlsx 标准格式文件',
  778. action: "/api/blade-user/import-user"
  779. },
  780. {
  781. label: "数据覆盖",
  782. prop: "isCovered",
  783. type: "switch",
  784. align: "center",
  785. width: 80,
  786. dicData: [
  787. {
  788. label: "否",
  789. value: 0
  790. },
  791. {
  792. label: "是",
  793. value: 1
  794. }
  795. ],
  796. value: 0,
  797. slot: true,
  798. rules: [
  799. {
  800. required: true,
  801. message: "请选择是否覆盖",
  802. trigger: "blur"
  803. }
  804. ]
  805. },
  806. {
  807. label: '模板下载',
  808. prop: 'excelTemplate',
  809. formslot: true,
  810. span: 24,
  811. }
  812. ]
  813. }
  814. };
  815. },
  816. watch: {
  817. 'form.tenantId' () {
  818. if (this.form.tenantId !== '' && this.initFlag) {
  819. this.initData(this.form.tenantId);
  820. }
  821. },
  822. 'excelForm.isCovered' () {
  823. if (this.excelForm.isCovered !== '') {
  824. const column = this.findObject(this.excelOption.column, "excelFile");
  825. column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
  826. }
  827. },
  828. 'fromss.projectId': function () {
  829. this.fromss.contractId = ''
  830. if (this.fromss.projectId) {
  831. this.findContractByProjectId(this.fromss.projectId)
  832. } else {
  833. this.contractData = []
  834. }
  835. },
  836. },
  837. computed: {
  838. ...mapGetters(["userInfo", "permission"]),
  839. permissionList () {
  840. return {
  841. addBtn: this.vaildData(this.permission.user_add, false),
  842. viewBtn: this.vaildData(this.permission.user_view, false),
  843. delBtn: this.vaildData(this.permission.user_delete, false),
  844. editBtn: this.vaildData(this.permission.user_edit, false)
  845. };
  846. },
  847. platformPermissionList () {
  848. return {
  849. addBtn: false,
  850. viewBtn: false,
  851. delBtn: false,
  852. editBtn: this.vaildData(this.permission.user_edit, false)
  853. };
  854. },
  855. ids () {
  856. let ids = [];
  857. this.selectionList.forEach(ele => {
  858. ids.push(ele.id);
  859. });
  860. return ids.join(",");
  861. },
  862. },
  863. mounted () {
  864. // 非租户模式默认加载管理组数据
  865. if (!website.tenantMode) {
  866. this.initData(website.tenantId);
  867. }
  868. if (this.$route.query.tankai) {
  869. this.$refs.crud.rowAdd()
  870. }
  871. },
  872. methods: {
  873. //#region 弹框事件及方法
  874. addKJ () {
  875. this.getProjectList()
  876. this.treeUser()
  877. this.fromss.projectAndUserList = []
  878. this.fromss.projectId = ''
  879. this.fromss.userId = ''
  880. this.fromss.contractId = ''
  881. this.fromss.roleIds = '' //合同段Id
  882. this.contractData = [] //合同段枚举
  883. this.$refs.crud.rowAdd()
  884. },
  885. addProject (type) {//确定添加参建项目
  886. if (type == 'add') {
  887. this.addfangfa()
  888. } else {
  889. const tag = true
  890. if (!this.fromss.projectId) {
  891. this.$message({
  892. type: "error",
  893. message: "请选择参与项目!"
  894. })
  895. return tag = false
  896. }
  897. if (!this.fromss.contractId) {
  898. this.$message({
  899. type: "error",
  900. message: "请选择合同段!"
  901. })
  902. return tag = false
  903. }
  904. if (!this.fromss.roleIds) {
  905. this.$message({
  906. type: "error",
  907. message: "请选择用户类型!"
  908. })
  909. return tag = false
  910. }
  911. if (tag) {
  912. this.saveUserInfoByProjectTow([{
  913. projectId: this.fromss.projectId,
  914. contractId: this.fromss.contractId,
  915. roleId: this.fromss.roleIds,
  916. userId: this.fromss.userId
  917. }])
  918. }
  919. }
  920. },
  921. addfangfa () {//添加时确定添加按钮方法处理
  922. let tag = true
  923. if (!this.fromss.projectId) {
  924. this.$message({
  925. type: "error",
  926. message: "请选择参与项目!"
  927. })
  928. tag = false
  929. return
  930. }
  931. if (!this.fromss.contractId) {
  932. this.$message({
  933. type: "error",
  934. message: "请选择合同段!"
  935. })
  936. tag = false
  937. return
  938. }
  939. if (!this.fromss.roleIds) {
  940. this.$message({
  941. type: "error",
  942. message: "请选择用户类型!"
  943. })
  944. tag = false
  945. return
  946. }
  947. this.fromss.projectAndUserList.forEach((val) => {
  948. if (val.projectId == this.fromss.projectId && val.contractId == this.fromss.contractId) {
  949. this.$message({
  950. type: "error",
  951. message: "参与项目的合同段不能相同!"
  952. })
  953. tag = false
  954. return
  955. }
  956. if (tag == false) return
  957. })
  958. if (tag == false) return
  959. let tas = {
  960. projectName: '',
  961. contractName: '',
  962. roleType: '',
  963. roleName: ''
  964. }
  965. this.projectData.forEach(val => {
  966. if (val.id === this.fromss.projectId) {
  967. tas.projectName = val.projectName
  968. }
  969. })
  970. this.contractData.forEach(val => {
  971. if (val.id === this.fromss.contractId) {
  972. tas.contractName = val.projectName
  973. }
  974. })
  975. this.roleIdsData.forEach(val => {
  976. if (val.roleId === this.fromss.roleIds) {
  977. tas.roleName = val.roleName
  978. }
  979. })
  980. this.fromss.projectAndUserList.push({
  981. projectId: this.fromss.projectId,
  982. contractId: this.fromss.contractId,
  983. roleId: this.fromss.roleIds,
  984. projectName: tas.projectName,
  985. contractName: tas.contractName,
  986. roleName: tas.roleName
  987. })
  988. this.fromss.projectId = ''
  989. this.fromss.contractId = ''
  990. this.fromss.roleIds = ''
  991. },
  992. editKJ (row, index) {//编辑用户
  993. console.log(row);
  994. this.fromss.userId = row.id //用户ID
  995. this.fromss.contractId = '' //合同段Id
  996. this.contractData = [] //合同段枚举
  997. this.getProjectList()
  998. this.treeUser()
  999. this.findProjectAndContractList(row.id)
  1000. this.$refs.crud.rowEdit(row, index)
  1001. },
  1002. deleteProject (key, type) {//删除参建项目按钮
  1003. if (type == 'add') {
  1004. this.fromss.projectAndUserList.splice(this.fromss.projectAndUserList[key], 1)
  1005. } else {
  1006. this.removeUsersByIds(this.fromss.projectAndUserList[key].id)
  1007. }
  1008. },
  1009. beforeClose (done) {//弹框关闭事件
  1010. this.fromss = {
  1011. userId: '',//
  1012. projectAndUserList: [],
  1013. projectId: '',//参与项项目
  1014. contractId: '',//合同段
  1015. roleIds: '',//用户类型
  1016. },
  1017. done()
  1018. },
  1019. async removeUsersByIds (ids) {//删除参建项目
  1020. const { data: res } = await removeUsersByIds(ids)
  1021. console.log(res);
  1022. if (res.code == 200) {
  1023. this.findProjectAndContractList(this.fromss.userId)
  1024. }
  1025. },
  1026. async getProjectList () {//项目类型
  1027. const { data: res } = await getProjectList()
  1028. console.log(res);
  1029. if (res.code === 200) {
  1030. this.projectData = res.data.records
  1031. }
  1032. },
  1033. async findContractByProjectId (pId) {//合同段
  1034. const { data: res } = await findContractByProjectId(pId)
  1035. console.log(res);
  1036. if (res.code === 200) {
  1037. this.contractData = res.data
  1038. }
  1039. },
  1040. async treeUser () {//获取用户类型枚举
  1041. const { data: res } = await treeUser()
  1042. console.log(res);
  1043. if (res.code === 200) {
  1044. this.roleIdsData = res.data
  1045. }
  1046. },
  1047. async findProjectAndContractList (userId) {//编辑获取参建项目
  1048. const { data: res } = await findProjectAndContractList({ userId })
  1049. console.log(res);
  1050. if (res.code === 200) {
  1051. res.data.forEach(val => {
  1052. if (val.roleType) {
  1053. val.roleName = val.roleType + ' | ' + val.roleName
  1054. }
  1055. })
  1056. this.fromss.projectAndUserList = res.data
  1057. }
  1058. },
  1059. async saveUserInfoByProjectTow (da) {//编辑添加参建项目
  1060. const { data: res } = await saveUserInfoByProjectTow(da)
  1061. console.log(res);
  1062. if (res.code == 200) {
  1063. this.fromss.projectId = '' //参与项项目
  1064. this.fromss.contractId = '' //合同段
  1065. this.fromss.roleIds = '' //用户类型
  1066. this.findProjectAndContractList(this.fromss.userId)
  1067. }
  1068. },
  1069. //#endregion
  1070. //#region 甘云杰
  1071. nodeClick (data) {
  1072. this.addData = {
  1073. tenantId: data.tenantId,
  1074. deptId: data.id
  1075. }
  1076. this.treeDeptId = data.id;
  1077. this.page.currentPage = 1;
  1078. this.onLoad(this.page);
  1079. },
  1080. initData (tenantId) {
  1081. // roletree(tenantId).then(res => {
  1082. // const column = this.findObject(this.option.group, "roleId");
  1083. // column.dicData = res.data.data;
  1084. // });
  1085. //所属部门
  1086. getDeptTree(tenantId).then(res => {
  1087. const column = this.findObject(this.option.group, "deptId");
  1088. column.dicData = res.data.data;
  1089. });
  1090. // 所属岗位
  1091. // getPostList(tenantId).then(res => {
  1092. // const column = this.findObject(this.option.group, "postId");
  1093. // column.dicData = res.data.data;
  1094. // });
  1095. },
  1096. submitRole () {
  1097. const roleList = this.$refs.treeRole.getCheckedKeys().join(",");
  1098. grant(this.ids, roleList).then(() => {
  1099. this.roleBox = false;
  1100. this.$message({
  1101. type: "success",
  1102. message: "操作成功!"
  1103. });
  1104. this.onLoad(this.page);
  1105. });
  1106. },
  1107. rowSave (row, done, loading) { //新增保存
  1108. add({ ...row, projectAndUserList: this.fromss.projectAndUserList }).then(() => {
  1109. this.initFlag = false;
  1110. this.onLoad(this.page);
  1111. this.$message({
  1112. type: "success",
  1113. message: "操作成功!"
  1114. });
  1115. done();
  1116. }, () => {
  1117. loading();
  1118. });
  1119. },
  1120. rowUpdate (row, index, done, loading) {//修改按钮
  1121. row.deptId = row.deptId.join(",");
  1122. row.roleId = row.roleId.join(",");
  1123. row.postId = row.postId.join(",");
  1124. update({ ...row, projectAndUserList: this.fromss.projectAndUserList }).then(() => {
  1125. this.initFlag = false;
  1126. this.onLoad(this.page);
  1127. this.$message({
  1128. type: "success",
  1129. message: "操作成功!"
  1130. });
  1131. done();
  1132. }, () => {
  1133. loading();
  1134. });
  1135. },
  1136. rowDel (row) {
  1137. this.$confirm("确定将选择数据删除?", {
  1138. confirmButtonText: "确定",
  1139. cancelButtonText: "取消",
  1140. type: "warning"
  1141. })
  1142. .then(() => {
  1143. return remove(row.id);
  1144. })
  1145. .then(() => {
  1146. this.onLoad(this.page);
  1147. this.$message({
  1148. type: "success",
  1149. message: "操作成功!"
  1150. });
  1151. });
  1152. },
  1153. searchReset () {
  1154. this.query = {};
  1155. this.treeDeptId = '';
  1156. this.onLoad(this.page);
  1157. },
  1158. searchChange (params, done) {
  1159. this.query = params;
  1160. this.page.currentPage = 1;
  1161. this.onLoad(this.page, params);
  1162. done();
  1163. },
  1164. selectionChange (list) {
  1165. this.selectionList = list;
  1166. },
  1167. selectionClear () {
  1168. this.selectionList = [];
  1169. this.$refs.crud.toggleSelection();
  1170. },
  1171. handleDelete () {
  1172. if (this.selectionList.length === 0) {
  1173. this.$message.warning("请选择至少一条数据");
  1174. return;
  1175. }
  1176. this.$confirm("确定将选择数据删除?", {
  1177. confirmButtonText: "确定",
  1178. cancelButtonText: "取消",
  1179. type: "warning"
  1180. })
  1181. .then(() => {
  1182. return remove(this.ids);
  1183. })
  1184. .then(() => {
  1185. this.onLoad(this.page);
  1186. this.$message({
  1187. type: "success",
  1188. message: "操作成功!"
  1189. });
  1190. this.$refs.crud.toggleSelection();
  1191. });
  1192. },
  1193. handleReset () {
  1194. if (this.selectionList.length === 0) {
  1195. this.$message.warning("请选择至少一条数据");
  1196. return;
  1197. }
  1198. this.$confirm("确定将选择账号密码重置为123456?", {
  1199. confirmButtonText: "确定",
  1200. cancelButtonText: "取消",
  1201. type: "warning"
  1202. })
  1203. .then(() => {
  1204. return resetPassword(this.ids);
  1205. })
  1206. .then(() => {
  1207. this.$message({
  1208. type: "success",
  1209. message: "操作成功!"
  1210. });
  1211. this.$refs.crud.toggleSelection();
  1212. });
  1213. },
  1214. handleGrant () {
  1215. if (this.selectionList.length === 0) {
  1216. this.$message.warning("请选择至少一条数据");
  1217. return;
  1218. }
  1219. this.roleTreeObj = [];
  1220. if (this.selectionList.length === 1) {
  1221. this.roleTreeObj = this.selectionList[0].roleId.split(",");
  1222. }
  1223. roletree().then(res => {
  1224. this.roleGrantList = res.data.data;
  1225. this.roleBox = true;
  1226. });
  1227. },
  1228. handlePlatform () {
  1229. this.platformBox = true;
  1230. },
  1231. handleLock () {
  1232. if (this.selectionList.length === 0) {
  1233. this.$message.warning("请选择至少一条数据");
  1234. return;
  1235. }
  1236. this.$confirm("确定将选择账号解封?", {
  1237. confirmButtonText: "确定",
  1238. cancelButtonText: "取消",
  1239. type: "warning"
  1240. })
  1241. .then(() => {
  1242. return unlock(this.ids);
  1243. })
  1244. .then(() => {
  1245. this.$message({
  1246. type: "success",
  1247. message: "操作成功!"
  1248. });
  1249. });
  1250. },
  1251. handleImport () {
  1252. this.excelBox = true;
  1253. },
  1254. uploadAfter (res, done, loading, column) {
  1255. window.console.log(column);
  1256. this.excelBox = false;
  1257. this.refreshChange();
  1258. done();
  1259. },
  1260. handleExport () {
  1261. this.$confirm("是否导出用户数据?", "提示", {
  1262. confirmButtonText: "确定",
  1263. cancelButtonText: "取消",
  1264. type: "warning"
  1265. }).then(() => {
  1266. NProgress.start();
  1267. exportBlob(`/api/blade-user/export-user?${this.website.tokenHeader}=${getToken()}&account=${this.search.account}&realName=${this.search.realName}`).then(res => {
  1268. downloadXls(res.data, `用户数据表${dateNow()}.xlsx`);
  1269. NProgress.done();
  1270. })
  1271. });
  1272. },
  1273. handleTemplate () {
  1274. exportBlob(`/api/blade-user/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
  1275. downloadXls(res.data, "用户数据模板.xlsx");
  1276. })
  1277. },
  1278. beforeOpen (done, type) {
  1279. if (["edit", "view"].includes(type)) {
  1280. getUser(this.form.id).then(res => {
  1281. this.form = res.data.data;
  1282. if (this.form.hasOwnProperty("deptId")) {
  1283. this.form.deptId = this.form.deptId.split(",");
  1284. }
  1285. if (this.form.hasOwnProperty("roleId")) {
  1286. this.form.roleId = this.form.roleId.split(",");
  1287. }
  1288. if (this.form.hasOwnProperty("postId")) {
  1289. this.form.postId = this.form.postId.split(",");
  1290. }
  1291. });
  1292. } else {
  1293. this.form.tenantId = this.addData.tenantId
  1294. this.form.deptId = this.addData.deptId
  1295. }
  1296. this.initFlag = true;
  1297. done();
  1298. },
  1299. currentChange (currentPage) {
  1300. this.page.currentPage = currentPage;
  1301. },
  1302. sizeChange (pageSize) {
  1303. this.page.pageSize = pageSize;
  1304. },
  1305. refreshChange () {
  1306. this.onLoad(this.page, this.query);
  1307. },
  1308. onLoad (page, params = {}) {
  1309. this.loading = true;
  1310. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  1311. const data = res.data.data;
  1312. this.page.total = data.total;
  1313. this.data = data.records;
  1314. this.loading = false;
  1315. this.selectionClear();
  1316. });
  1317. },
  1318. platformRowUpdate (row, index, done, loading) {
  1319. updatePlatform(row.id, row.userType, row.userExt).then(() => {
  1320. this.platformOnLoad(this.platformPage);
  1321. this.$message({
  1322. type: "success",
  1323. message: "操作成功!"
  1324. });
  1325. done();
  1326. }, error => {
  1327. window.console.log(error);
  1328. loading();
  1329. });
  1330. },
  1331. platformBeforeOpen (done, type) {
  1332. if (["edit", "view"].includes(type)) {
  1333. getUserPlatform(this.platformForm.id).then(res => {
  1334. this.platformForm = res.data.data;
  1335. });
  1336. }
  1337. done();
  1338. },
  1339. platformSearchReset () {
  1340. this.platformQuery = {};
  1341. this.platformOnLoad(this.platformPage);
  1342. },
  1343. platformSearchChange (params, done) {
  1344. this.platformQuery = params;
  1345. this.platformPage.currentPage = 1;
  1346. this.platformOnLoad(this.platformPage, params);
  1347. done();
  1348. },
  1349. platformSelectionChange (list) {
  1350. this.platformSelectionList = list;
  1351. },
  1352. platformSelectionClear () {
  1353. this.platformSelectionList = [];
  1354. this.$refs.platformCrud.toggleSelection();
  1355. },
  1356. platformCurrentChange (currentPage) {
  1357. this.platformPage.currentPage = currentPage;
  1358. },
  1359. platformSizeChange (pageSize) {
  1360. this.platformPage.pageSize = pageSize;
  1361. },
  1362. platformRefreshChange () {
  1363. this.platformOnLoad(this.platformPage, this.platformQuery);
  1364. },
  1365. platformOnLoad (page, params = {}) {
  1366. this.platformLoading = true;
  1367. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  1368. const data = res.data.data;
  1369. this.platformPage.total = data.total;
  1370. this.platformData = data.records;
  1371. this.platformLoading = false;
  1372. this.selectionClear();
  1373. });
  1374. },
  1375. //#endregion
  1376. },
  1377. };
  1378. </script>
  1379. <style>
  1380. .box {
  1381. height: 800px;
  1382. }
  1383. .el-scrollbar {
  1384. height: 100%;
  1385. }
  1386. .box .el-scrollbar__wrap {
  1387. overflow: scroll;
  1388. }
  1389. </style>