user.vue 39 KB

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