user.vue 47 KB

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