user.vue 47 KB

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