You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1120 lines
36 KiB

3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div>
  3. <el-card class="orgindcard">
  4. <div class="publiccss">用户管理</div>
  5. <!-- <el-button type="primary" @click="newlyincreased" style="margin-top: 20px"
  6. >新增</el-button
  7. > -->
  8. <el-row style="margin-top: 10px">
  9. <el-form ref="form" :model="form">
  10. <el-col :span="4">
  11. <el-form-item label="用户查询">
  12. <el-input
  13. v-model="pages.Filter"
  14. clearable
  15. @clear="getlist"
  16. style="width: 200px"
  17. ></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <!-- <el-col :span="6">
  21. <el-form-item label="手机号">
  22. <el-input
  23. v-model="pages.Filter"
  24. style="width: 200px"
  25. ></el-input>
  26. </el-form-item>
  27. </el-col> -->
  28. <!-- <el-col :span="6">
  29. <el-form-item label="姓名">
  30. <el-input
  31. v-model="pages.Filter"
  32. style="width: 200px"
  33. ></el-input>
  34. </el-form-item>
  35. </el-col> -->
  36. <el-col :span="6">
  37. <el-button type="primary" @click="inquireabout">查询</el-button>
  38. </el-col>
  39. </el-form>
  40. </el-row>
  41. <div style="display: flex">
  42. <div style="width: 10%; margin-top: 30px">
  43. <el-tree
  44. :data="treedata"
  45. :props="defaultProps"
  46. @node-click="handleNodeClick"
  47. ></el-tree>
  48. </div>
  49. <div style="width: 90%">
  50. <el-table
  51. height="500"
  52. :data="tableData"
  53. style="width: 100%; margin-top: 20px"
  54. border=""
  55. >
  56. <el-table-column type="index" label="#"></el-table-column>
  57. <el-table-column prop="userName" label="用户名" width="">
  58. </el-table-column>
  59. <el-table-column prop="email" label="邮箱" width="">
  60. </el-table-column>
  61. <!-- <el-table-column prop="email" label="所属角色" width=""> </el-table-column> -->
  62. <el-table-column prop="phoneNumber" label="手机号" width="">
  63. </el-table-column>
  64. <el-table-column prop="surname" label="姓名" width="">
  65. </el-table-column>
  66. <!-- <el-table-column prop="name" label="名称" width=""> </el-table-column> -->
  67. <!-- <el-table-column prop="lastModificationTime" label="开始时间">
  68. <template slot-scope="scope">
  69. {{ scope.row.creationTime | dateFormat }}
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="lastModificationTime" label="结束时间">
  73. <template slot-scope="scope">
  74. {{ scope.row.lastModificationTime | dateFormat }}
  75. </template>
  76. </el-table-column> -->
  77. <el-table-column label="操作" width="480">
  78. <template slot-scope="scope">
  79. <el-button
  80. type="primary"
  81. @click="newlyincreased"
  82. style="margin-top: 20px"
  83. >新增</el-button
  84. >
  85. <el-button type="primary" @click="editmony(scope.row)"
  86. >编辑</el-button
  87. >
  88. <el-button type="primary" @click="deleates(scope.row)"
  89. >删除</el-button
  90. >
  91. <!-- <el-button type="primary" @click="binding(scope.row)"
  92. >绑定组织</el-button
  93. > -->
  94. <el-button type="primary" @click="bandinuser(scope.row)"
  95. >绑定角色</el-button
  96. >
  97. <el-button type="primary" @click="editpassword(scope.row)"
  98. >修改密码</el-button
  99. >
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. </div>
  104. </div>
  105. <!-- <el-pagination
  106. @size-change="handleSizeChange"
  107. @current-change="handleCurrentChange"
  108. :page-sizes="[2, 10, 20, 30]"
  109. :page-size="5"
  110. layout="total, sizes, prev, pager, next, jumper"
  111. :total="total - 1"
  112. >
  113. </el-pagination> -->
  114. <!-- 编辑 -->
  115. <el-dialog
  116. :title="title == 1 ? '新增用户' : '修改用户'"
  117. :visible.sync="dialogVisible"
  118. width="40%"
  119. :close-on-click-modal="false"
  120. >
  121. <el-tabs
  122. v-model="activeName"
  123. v-if="title == 2 ? true : false"
  124. @tab-click="handleClick"
  125. >
  126. <el-tab-pane label="用户信息" name="first">
  127. <el-form
  128. v-if="dialogVisible"
  129. ref="form"
  130. :model="form"
  131. label-width="80px"
  132. :rules="rules"
  133. >
  134. <el-row>
  135. <el-col :span="12">
  136. <el-form-item label="姓名" prop="surname">
  137. <el-input v-model="form.surname"></el-input> </el-form-item
  138. ></el-col>
  139. <el-col :span="12">
  140. <el-form-item label="用户名" prop="userName">
  141. <el-input v-model="form.userName"></el-input> </el-form-item
  142. ></el-col>
  143. <!-- <el-col :span="12">
  144. <el-form-item label="名称" prop="name">
  145. <el-input v-model="form.name"></el-input> </el-form-item
  146. ></el-col> -->
  147. <el-col :span="12">
  148. <el-form-item label="手机号" prop="phoneNumber">
  149. <el-input
  150. v-model="form.phoneNumber"
  151. ></el-input> </el-form-item
  152. ></el-col>
  153. <el-col :span="12">
  154. <el-form-item label="组织架构">
  155. <div style="margin-top: -30px">
  156. 当前选中的组织<span> {{ orgIds }}</span>
  157. </div>
  158. <el-cascader
  159. v-model="orgId"
  160. :options="organizationalstructure"
  161. :show-all-levels="false"
  162. @change="cascaderchang"
  163. :props="{
  164. label: 'displayName',
  165. children: 'treeChildren',
  166. checkStrictly: true,
  167. value: 'id',
  168. }"
  169. ></el-cascader>
  170. </el-form-item>
  171. </el-col>
  172. <!-- <el-col :span="12">
  173. <el-form-item label="邮箱" >
  174. <el-input v-model="form.email"></el-input> </el-form-item
  175. ></el-col> -->
  176. <el-col>
  177. <el-form-item label="是否激活">
  178. <el-checkbox v-model="form.isActive"></el-checkbox>
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="12">
  182. <el-form-item
  183. label="密码"
  184. prop="password"
  185. v-if="title == 1 ? true : false"
  186. >
  187. <el-input v-model="form.password"></el-input> </el-form-item
  188. ></el-col>
  189. <!-- <el-col :span="12">
  190. <el-form-item label="所属角色" prop="roleNames">
  191. <el-select
  192. v-model="form.roleNames"
  193. placeholder="请选择"
  194. @change="onchang"
  195. >
  196. <el-option
  197. v-for="item in options"
  198. :key="item.id"
  199. :label="item.name"
  200. :value="item.name"
  201. >
  202. </el-option>
  203. </el-select>
  204. </el-form-item>
  205. </el-col> -->
  206. </el-row>
  207. </el-form>
  208. </el-tab-pane>
  209. <!-- 选择角色 -->
  210. <el-tab-pane label="角色">
  211. <el-checkbox-group v-model="form.roleNames">
  212. <el-checkbox
  213. v-model="item.id"
  214. :label="item.name"
  215. v-for="(item, index) in checkList"
  216. :key="index"
  217. @change="handleCheckAllChange"
  218. >
  219. </el-checkbox>
  220. </el-checkbox-group>
  221. </el-tab-pane>
  222. <!-- <el-tab-pane label="组织架构"> -->
  223. <!-- :default-checked-keys="defaultKeys" -->
  224. <!-- <el-tree
  225. :props="{
  226. label: 'displayName',
  227. children: 'treeChildren',
  228. }"
  229. :default-checked-keys="defaultKeys"
  230. :default-expand-all="true"
  231. show-checkbox
  232. :data="organizationalstructure"
  233. node-key="id"
  234. @check="iscrentd"
  235. ref="trees"
  236. >
  237. </el-tree> -->
  238. <!-- <div>
  239. 当前选中的组织<span> {{ orgIds }}</span>
  240. </div>
  241. <el-cascader
  242. v-model="orgId"
  243. :options="organizationalstructure"
  244. :show-all-levels="false"
  245. @change="cascaderchang"
  246. :props="{
  247. label: 'displayName',
  248. children: 'treeChildren',
  249. checkStrictly: true,
  250. value: 'id',
  251. }"
  252. ></el-cascader> -->
  253. <!-- </el-tab-pane> -->
  254. <el-tab-pane label="科室操作权限">
  255. <el-tree
  256. :props="{
  257. label: 'displayName',
  258. children: 'treeChildren',
  259. }"
  260. :default-checked-keys="defaultchekedKeys"
  261. :default-expand-all="true"
  262. show-checkbox
  263. :data="setupdepartments"
  264. node-key="id"
  265. @check="iscrentddepartment"
  266. ref="department"
  267. >
  268. </el-tree>
  269. </el-tab-pane>
  270. </el-tabs>
  271. <!-- //新增 -->
  272. <el-form
  273. v-show="title == 1 ? true : false"
  274. v-if="dialogVisible"
  275. ref="form"
  276. :model="form"
  277. label-width="80px"
  278. :rules="rules"
  279. >
  280. <el-tabs>
  281. <el-tab-pane label="用户信息">
  282. <el-row>
  283. <el-col :span="12">
  284. <el-form-item label="姓名" prop="surname">
  285. <el-input v-model="form.surname"></el-input> </el-form-item
  286. ></el-col>
  287. <el-col :span="12">
  288. <el-form-item label="用户名" prop="userName">
  289. <el-input v-model="form.userName"></el-input> </el-form-item
  290. ></el-col>
  291. <!-- <el-col :span="12">
  292. <el-form-item label="名称" prop="userName">
  293. <el-input
  294. v-model="form.usesurnamerName"
  295. ></el-input> </el-form-item
  296. ></el-col> -->
  297. <!-- <el-col :span="12">
  298. <el-form-item label="名称" prop="name">
  299. <el-input v-model="form.name"></el-input> </el-form-item
  300. ></el-col> -->
  301. <el-col :span="12">
  302. <el-form-item label="手机号" prop="phoneNumber">
  303. <el-input
  304. v-model="form.phoneNumber"
  305. ></el-input> </el-form-item
  306. ></el-col>
  307. <!-- <el-col :span="12">
  308. <el-form-item label="邮箱" >
  309. <el-input v-model="form.email"></el-input> </el-form-item
  310. ></el-col> -->
  311. <el-col :span="12">
  312. <el-form-item
  313. label="密码"
  314. prop="password"
  315. v-if="title == 1 ? true : false"
  316. >
  317. <el-input
  318. show-password
  319. v-model="form.password"
  320. type="password"
  321. autocomplete="new-password"
  322. ></el-input> </el-form-item
  323. ></el-col>
  324. <!-- <el-col :span="12">
  325. <el-form-item label="所属角色" prop="roleNames">
  326. <el-select
  327. v-model="form.roleNames"
  328. placeholder="请选择"
  329. @change="onchang"
  330. >
  331. <el-option
  332. v-for="item in options"
  333. :key="item.id"
  334. :label="item.name"
  335. :value="item.name"
  336. >
  337. </el-option>
  338. </el-select>
  339. </el-form-item>
  340. </el-col> -->
  341. <el-col :span="12">
  342. <el-form-item label="是否激活">
  343. <el-checkbox
  344. v-model="form.isActive"
  345. :checked="true"
  346. ></el-checkbox>
  347. </el-form-item>
  348. </el-col>
  349. </el-row>
  350. </el-tab-pane>
  351. <!-- 角色111 -->
  352. <el-tab-pane label="角色">
  353. <el-checkbox-group v-model="roleNames">
  354. <el-checkbox
  355. v-model="item.id"
  356. :label="item.name"
  357. v-for="(item, index) in options"
  358. :key="index"
  359. >
  360. </el-checkbox>
  361. </el-checkbox-group>
  362. </el-tab-pane>
  363. <!-- 组织11 -->
  364. <el-tab-pane label="组织">
  365. <el-cascader
  366. :options="organizationalstructure"
  367. :show-all-levels="false"
  368. :props="{
  369. label: 'displayName',
  370. children: 'treeChildren',
  371. checkStrictly: true,
  372. value: 'id',
  373. }"
  374. ></el-cascader>
  375. <!-- <el-tree
  376. :data="newachitecture"
  377. show-checkbox
  378. :default-expand-all="true"
  379. @check="ischesc"
  380. node-key="id"
  381. ref="tree"
  382. :default-expanded-keys="nodekes"
  383. :default-checked-keys="[5]"
  384. :props="{ label: 'displayName', children: 'treeChildren' }"
  385. >
  386. </el-tree> -->
  387. </el-tab-pane>
  388. <el-tab-pane label="科室操作权限">
  389. <el-tree
  390. :data="newdepartment"
  391. show-checkbox
  392. :default-expand-all="true"
  393. @check="ischesc"
  394. node-key="id"
  395. ref="tree"
  396. :default-expanded-keys="nodekes"
  397. :default-checked-keys="[5]"
  398. :props="{ label: 'displayName', children: 'treeChildren' }"
  399. >
  400. </el-tree>
  401. </el-tab-pane>
  402. </el-tabs>
  403. </el-form>
  404. <span slot="footer" class="dialog-footer">
  405. <el-button @click="dialogVisible = false"> </el-button>
  406. <el-button type="primary" @click="addlsit" class="bulletcommit"
  407. > </el-button
  408. >
  409. </span>
  410. </el-dialog>
  411. <!-- 绑定用户组织弹框 -->
  412. <el-dialog
  413. title="绑定组织"
  414. :visible.sync="bindingdialogVisible"
  415. width="30%"
  416. :close-on-click-modal="false"
  417. >
  418. <el-row>
  419. <el-col :span="8">当前组织:</el-col>
  420. <!-- <el-col :span="16" v-for="(item, index) in values" :key="index">{{
  421. item.displayName
  422. }}</el-col> -->
  423. <el-col :span="8" v-for="(item, index) in values" :key="index">{{
  424. item
  425. }}</el-col>
  426. </el-row>
  427. <el-cascader
  428. style="margin-top: 10px"
  429. v-model="values"
  430. :options="option"
  431. :props="{
  432. value: 'displayName',
  433. label: 'displayName',
  434. children: 'treeChildren',
  435. checkStrictly: true,
  436. }"
  437. @change="handleChange"
  438. ></el-cascader>
  439. <span slot="footer" class="dialog-footer">
  440. <el-button @click="bindingdialogVisible = false"> </el-button>
  441. <el-button type="primary" @click="binduser"> </el-button>
  442. </span>
  443. </el-dialog>
  444. <!-- 用户绑定管理弹框 -->
  445. <el-dialog
  446. title="绑定角色"
  447. :visible.sync="useerdialogVisible"
  448. width="30%"
  449. :close-on-click-modal="false"
  450. >
  451. <el-row>
  452. <el-col :span="8">所属角色:</el-col>
  453. <el-col :span="16" v-for="(item, index) in bingdusers" :key="index">{{
  454. item.name
  455. }}</el-col>
  456. </el-row>
  457. <el-select
  458. v-model="uservalue"
  459. multiple
  460. placeholder="请选择"
  461. style="margin-top: 15px"
  462. >
  463. <el-option
  464. v-for="item in useroptions"
  465. :key="item.id"
  466. :label="item.name"
  467. :value="item.name"
  468. >
  469. </el-option>
  470. </el-select>
  471. <span slot="footer" class="dialog-footer">
  472. <el-button @click="useerdialogVisible = false"> </el-button>
  473. <el-button type="primary" @click="Identifyusers" class="bulletcommit"
  474. > </el-button
  475. >
  476. </span>
  477. </el-dialog>
  478. <!-- 修改密码弹框 -->
  479. <el-dialog
  480. :title="'修改密码' + '用户' + usersName"
  481. :visible.sync="editpassworddialogVisible"
  482. width="30%"
  483. :close-on-click-modal="false"
  484. >
  485. <el-form ref="form" :model="form" label-width="80px">
  486. <el-form-item label="新密码">
  487. <el-input v-model="newPassWord" max="16" min="6"></el-input>
  488. </el-form-item>
  489. </el-form>
  490. <el-form ref="form" :model="form" label-width="80px">
  491. <el-form-item label="确认密码">
  492. <el-input v-model="confarmPassWord" max="16" min="6"></el-input>
  493. </el-form-item>
  494. </el-form>
  495. <span slot="footer" class="dialog-footer">
  496. <el-button @click="editpassworddialogVisible = false"
  497. > </el-button
  498. >
  499. <el-button type="primary" @click="Changepassword" class="bulletcommit"
  500. > </el-button
  501. >
  502. </span>
  503. </el-dialog>
  504. </el-card>
  505. </div>
  506. </template>
  507. <script>
  508. import {
  509. usreslist,
  510. newlists,
  511. delestsid,
  512. editmodify,
  513. getbook,
  514. userorganizat,
  515. organizationtree,
  516. userbind,
  517. usersroles,
  518. useraffiliation,
  519. reverseselection,
  520. usersinits,
  521. selectbinding,
  522. lognis,
  523. } from "../../request/ruquset";
  524. import { mapState } from "vuex";
  525. import { isValid } from "@/utlis/validate";
  526. import { getapi, postapi } from "@/api/api";
  527. // let validatePassword = (rule, value, callback) => {
  528. // var reg1 =
  529. // /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{6,}$/; //密码必须是8位以上、必须含有字母、数字、特殊符号
  530. // var reg2 = /(123|234|345|456|567|678|789|012)/; //不能有3个连续数字
  531. // if (!reg1.test(value)) {
  532. // callback(new Error("密码必须是6位以上、必须含有字母、数字、特殊符号"));
  533. // } else if (reg2.test(value)) {
  534. // callback(new Error("不能有3个连续数字"));
  535. // } else {
  536. // callback();
  537. // }
  538. // };
  539. let validatePassword = /^[a-zA-Z0-9@\$\^\.\*\\?]\{6,15}$/;
  540. export default {
  541. data() {
  542. return {
  543. treedata: [],
  544. defaultProps: {
  545. children: "treeChildren",
  546. label: "displayName",
  547. },
  548. orgIds: "",
  549. orgId: [],
  550. confarmPassWord: "", //确认密码
  551. usersName: "", //用户名
  552. defaultchekedKeys: [], //默认选中的科室
  553. department: [], //选中的科室
  554. setupdepartments: [], //设置科室
  555. newPassWord: "", //新密码
  556. editpassworddialogVisible: false, //修改密码
  557. nodekes: [],
  558. activeName: "first",
  559. chaxunform: {
  560. surname: "",
  561. phoneNumber: "",
  562. userName: "",
  563. },
  564. useroptions: [],
  565. options: [],
  566. uservalue: [],
  567. useerdialogVisible: false,
  568. bindingdialogVisible: false,
  569. values: [],
  570. option: [],
  571. crdetcascader: [], //绑定组织显示
  572. //表单校验
  573. rules: {
  574. password: [
  575. {
  576. required: true,
  577. trigger: "blur",
  578. message: "密码不能为空",
  579. },
  580. {
  581. min: 6,
  582. max: 15,
  583. message: "长度在 6 到 15 个字符",
  584. trigger: "blur",
  585. },
  586. // {
  587. // required: true,
  588. // trigger: "blur",
  589. // validator: validatePassword,
  590. // },
  591. ],
  592. email: [
  593. {
  594. required: true,
  595. message: "请输入邮箱地址",
  596. trigger: "blur",
  597. },
  598. {
  599. type: "email",
  600. message: "请输入正确的邮箱地址",
  601. trigger: ["blur", "change"],
  602. },
  603. ],
  604. phoneNumber: [
  605. { required: true, message: "请输入手机号", trigger: "blur" },
  606. ],
  607. userName: [
  608. { required: true, message: "请输入用户名", trigger: "blur" },
  609. ],
  610. surname: [
  611. { required: true, message: "请输入用户名称", trigger: "change" },
  612. ],
  613. roleNames: [
  614. { required: true, message: "请选择所属用户", trigger: "change" },
  615. ],
  616. nam: [{ required: true, message: "请输入名", trigger: "change" }],
  617. },
  618. tableData: [],
  619. optionsArr: [],
  620. dialogVisible: false,
  621. modetype: "",
  622. total: 0,
  623. form: {
  624. surname: "fas",
  625. name: "ww",
  626. email: "45148415@qq.com",
  627. surname: "",
  628. phoneNumber: "",
  629. password: "1q2w3E*",
  630. roleNames: [],
  631. userName: "",
  632. password: "1q2w3E*",
  633. isActive: true,
  634. },
  635. roleNames: [],
  636. are: [],
  637. checkList: [], //多选框
  638. pages: {
  639. SkipCount: 0,
  640. MaxResultCount: 100,
  641. Filter: "",
  642. // Filter:{
  643. // userName:this.form.userName,
  644. // phoneNumber:this.form.phoneNumber,
  645. // surname: this.form.surname,
  646. // }
  647. },
  648. title: 1,
  649. rowid: "",
  650. userid: "",
  651. bingdusers: [], //s所属用户角色
  652. organizationalstructure: [], //组织架构
  653. defaultKeys: [], //选中的
  654. newachitecture: [], //新增弹框获取组织数据
  655. // customer:[]
  656. password: "",
  657. passwordid: "",
  658. newdepartment: [], //新增科室
  659. };
  660. },
  661. computed: {
  662. ...mapState(["changepassword"]),
  663. },
  664. created() {
  665. this.password = this.changepassword;
  666. console.log(this.password);
  667. this.getlist();
  668. this.gettreedata();
  669. this.idkes = localStorage.getItem("dataidkes");
  670. },
  671. methods: {
  672. cascaderchang(v) {
  673. console.log(v);
  674. },
  675. gettreedata() {
  676. getapi("/api/app/organization-units/by-code-all").then((res) => {
  677. this.treedata = res.data;
  678. console.log(res);
  679. });
  680. },
  681. handleNodeClick(data) {
  682. this.department = data.displayName;
  683. console.log(this.department);
  684. getapi(
  685. `/api/identity/users/getlistinorganizationunit?OrganizationUnitId=${data.id}`
  686. ).then((res) => {
  687. console.log(res);
  688. this.tableData = res.data;
  689. });
  690. },
  691. iscrentddepartment() {
  692. this.department = this.$refs.department.getCheckedKeys(true);
  693. console.log(this.department, "wwww");
  694. },
  695. //修改密码确定按钮
  696. Changepassword() {
  697. if (this.newPassWord == "") {
  698. this.$message.warning("请输入新密码");
  699. } else if (this.confarmPassWord == "") {
  700. this.$message.warning("请输入确认密码");
  701. } else if (this.newPassWord != this.confarmPassWord) {
  702. this.$message.warning("二次输入密码不一致");
  703. } else {
  704. postapi("/api/identity/users/resetpassword", {
  705. userId: this.passwordid,
  706. newPassWord: this.newPassWord,
  707. }).then((res) => {
  708. this.$message.success("修改成功");
  709. this.editpassworddialogVisible = false;
  710. });
  711. }
  712. console.log(this.newPassWord);
  713. },
  714. //修改密码
  715. editpassword(row) {
  716. this.editpassworddialogVisible = true;
  717. this.passwordid = row.id;
  718. this.usersName = row.userName;
  719. },
  720. //新增选择的
  721. ischesc() {
  722. console.log("333", this.$refs.tree.getCheckedKeys(true));
  723. this.nodekes = this.$refs.tree.getCheckedKeys(true);
  724. },
  725. //选中的组织
  726. iscrentd() {
  727. console.log("222", this.$refs.trees.getCheckedKeys(true));
  728. this.defaultKeys = this.$refs.trees.getCheckedKeys(true);
  729. // console.log("222", this.$refs.tree.defaultKeys(true));
  730. },
  731. //选中适合的值
  732. handleCheckAllChange() {
  733. // this.form.roleNames = this.roleNames;
  734. // console.log(this.activeName);
  735. console.log(this.form.roleNames);
  736. },
  737. //table页切换
  738. handleClick() {
  739. console.log(this.activeName);
  740. if (this.activeName == "1") {
  741. //获取当前绑定用户
  742. useraffiliation(this.form.id).then((res) => {
  743. console.log(res.data.items);
  744. if (res.data.items && res.data.items.length > 0) {
  745. let val = res.data.items.map((item) => {
  746. return item.name;
  747. });
  748. this.$set(this.form, "roleNames", val);
  749. } else {
  750. this.$set(this.form, "roleNames", []);
  751. }
  752. });
  753. }
  754. },
  755. //用户列表查询
  756. inquireabout() {
  757. this.getlist();
  758. // usreslist()
  759. },
  760. onchang(v) {
  761. // this.form.roleNames[0] = v;
  762. console.log(v);
  763. },
  764. //级联选择器
  765. handleChange(value) {
  766. this.values = value;
  767. console.log(value);
  768. },
  769. getlist() {
  770. usreslist(this.pages).then((res) => {
  771. this.tableData = res.data.items;
  772. this.total = res.data.totalCount;
  773. console.log(res);
  774. });
  775. },
  776. //绑定
  777. binding(row) {
  778. this.bindingdialogVisible = true;
  779. console.log(row);
  780. this.rowid = row.id;
  781. organizationtree().then((res) => {
  782. this.option = res.data;
  783. console.log(this.option);
  784. });
  785. // reverseselection(row.id).then((res) => {
  786. // this.crdetcascader = res.data;
  787. // console.log(res);
  788. // });
  789. // userorganizat(row.id, this.idkes ).then((res) => {
  790. // console.log(res);
  791. // });
  792. },
  793. //绑定用户角色
  794. bandinuser(row) {
  795. this.useerdialogVisible = true;
  796. this.userid = row.id;
  797. usersroles().then((res) => {
  798. this.useroptions = res.data.items;
  799. console.log(res);
  800. });
  801. useraffiliation(row.id).then((res) => {
  802. res.data.items.forEach((element) => {
  803. console.log(element);
  804. this.uservalue = element[name];
  805. });
  806. // this.uservalue=res.data.items[name]
  807. this.bingdusers = res.data.items;
  808. // console.log(res);
  809. });
  810. // this.form.roleNames.push(row.userName)
  811. // userbind(row.id,{roleNames:this.form.roleNames}).then(res=>{
  812. // console.log(res)
  813. // })
  814. // console.log(row);
  815. },
  816. //确定绑定
  817. Identifyusers() {
  818. // let are = [];
  819. // console.log(this.uservalue);
  820. // are.push(this.uservalue);
  821. // this.uservalue = are;
  822. if (this.uservalue !== "") {
  823. userbind(this.userid, { roleNames: this.uservalue }).then((res) => {
  824. this.$message.success("绑定成功");
  825. this.getlist();
  826. this.useerdialogVisible = false;
  827. });
  828. } else {
  829. this.$message.success("请选择用户");
  830. }
  831. },
  832. //绑定
  833. binduser() {
  834. console.log(this.values);
  835. console.log(this.rowid);
  836. console.log(this.idkes);
  837. if (this.values.length == 0) {
  838. this.$message.success("请选中");
  839. } else {
  840. userorganizat(this.rowid, this.idkes).then((res) => {
  841. this.bindingdialogVisible = false;
  842. this.getlist();
  843. this.$message.success("操作成功");
  844. // this.values = [];
  845. // console.log(res);
  846. });
  847. }
  848. },
  849. //新增用户
  850. newlyincreased() {
  851. this.dialogVisible = true;
  852. this.title = 1;
  853. if (this.title == 1) {
  854. this.form = {};
  855. this.orgId = this.department;
  856. console.log(this.orgId);
  857. console.log(this.department, "1111111111111");
  858. }
  859. getbook().then((res) => {
  860. // res.data.items.forEach((element) => {
  861. // this.form.roleNames = element.name;
  862. // console.log(element);
  863. // });
  864. this.options = res.data.items;
  865. console.log(res, "====>>>>>res");
  866. });
  867. organizationtree().then((res) => {
  868. this.newachitecture = res.data;
  869. this.newdepartment = res.data;
  870. this.organizationalstructure = res.data;
  871. console.log(res, "1w");
  872. });
  873. console.log(this.title);
  874. },
  875. //确定添加或修改
  876. addlsit() {
  877. console.log(this.roleNames);
  878. this.$refs.form.validate((valid) => {
  879. if (valid) {
  880. if (this.title == 1) {
  881. let arrs = [];
  882. // arrs.push(this.roleNames);
  883. // console.log(arrs)
  884. let obj = {
  885. userName: this.form.userName,
  886. name: this.form.name,
  887. surname: this.form.surname,
  888. email: this.form.email,
  889. usesurnamerName: this.form.usesurnamerName,
  890. phoneNumber: this.form.phoneNumber,
  891. password: this.form.password,
  892. roleNames: this.roleNames,
  893. isActive: true,
  894. };
  895. if (this.roleNames.length == 0) {
  896. this.$message.success("请选择角色");
  897. } else {
  898. newlists(obj).then((res) => {
  899. if (res.code == 1) {
  900. this.dialogVisible = false;
  901. this.$message.success("新增成功");
  902. // selectbinding({orgId:this.nodekes}).then(r=>{
  903. // this.$message.success('绑定成功')
  904. // })
  905. }
  906. this.roleNames = [];
  907. this.getlist();
  908. console.log(res);
  909. });
  910. }
  911. } else if (this.title == 2) {
  912. console.log(this.orgId);
  913. // this.roleNames=arrs
  914. let obj = {
  915. userName: this.form.userName,
  916. name: this.form.name,
  917. surname: this.form.surname,
  918. email: this.form.email,
  919. usesurnamerName: this.form.usesurnamerName,
  920. phoneNumber: this.form.phoneNumber,
  921. password: this.form.password,
  922. roleNames: this.form.roleNames,
  923. isActive: true,
  924. // roleNames: this.form.roleNames,
  925. };
  926. if (this.form.roleNames.length != 0) {
  927. console.log(this.form.roleNames);
  928. // let tempArr=[]
  929. editmodify(this.form.id, obj).then((res) => {
  930. if (res.code == 1) {
  931. this.$message.success("修改成功");
  932. this.dialogVisible = false;
  933. this.getlist();
  934. }
  935. console.log(res);
  936. if (res.code == 1) {
  937. selectbinding({
  938. userId: this.form.id,
  939. orgId: this.orgId[0],
  940. }).then((res) => {
  941. console.log(res);
  942. postapi(
  943. `/api/app/abpuserdepartment/createmany?UserId=${this.form.id}`,
  944. this.orgId
  945. ).then((res) => {
  946. console.log(this.orgId);
  947. // this.$message.success("操作成功");
  948. });
  949. // this.$message.success("修改绑定组织成功");
  950. });
  951. // postapi(
  952. // `/api/app/abpuserdepartment/createmany?UserId=${this.form.id}`,
  953. // this.department
  954. // ).then((res) => {
  955. // // this.$message.success("操作成功");
  956. // });
  957. console.log("aaaaaa");
  958. }
  959. });
  960. } else {
  961. this.$message.success("请选则用户");
  962. }
  963. }
  964. }
  965. });
  966. },
  967. //删除方法
  968. deleates(row) {
  969. let id = row.id;
  970. // delestsid(id).then((res) => {
  971. // console.log(res);
  972. // this.getlist();
  973. // this.$message.success("删除成功");
  974. // });
  975. this.$confirm("是否确定删除, 是否继续?", "提示", {
  976. confirmButtonText: "确定",
  977. cancelButtonText: "取消",
  978. type: "warning",
  979. })
  980. .then(() => {
  981. postapi(`/api/identity/users/delete?id=${row.id}`).then((res) => {
  982. this.getlist();
  983. this.$message.success("删除成功");
  984. });
  985. })
  986. .catch(() => {});
  987. console.log(row);
  988. },
  989. //编辑修改
  990. editmony(row) {
  991. console.log(row, "======>>>>>>editmony");
  992. this.dialogVisible = true;
  993. // this.form.roleNames = row.roleNames;
  994. console.log(this.form.roleNames);
  995. this.title = 2;
  996. // this.form.roleNames = this.roleNames;
  997. if (this.title == 2) {
  998. // row里面没有roleNames字段
  999. const form = JSON.parse(JSON.stringify(row));
  1000. console.log(form, "form");
  1001. this.form = {
  1002. ...form,
  1003. roleNames: [],
  1004. };
  1005. this.form.roleNames = [];
  1006. //获取组织架构
  1007. organizationtree().then((res) => {
  1008. this.organizationalstructure = res.data;
  1009. this.setupdepartments = res.data;
  1010. console.log(res, "sssssss");
  1011. });
  1012. // postapi(`/api/app/abpuserdepartment/createmany?UserId=${this.form.id}`,{orgId:this.orgId[0]}).then(res=>{
  1013. // console.log(res,'wwwwwwwwwwwww');
  1014. // })
  1015. useraffiliation(this.form.id).then((res) => {
  1016. console.log(res.data.items);
  1017. if (res.data.items && res.data.items.length > 0) {
  1018. let val = res.data.items.map((item) => {
  1019. return item.name;
  1020. });
  1021. this.$set(this.form, "roleNames", val);
  1022. } else {
  1023. this.$set(this.form, "roleNames", []);
  1024. }
  1025. });
  1026. //科室编辑
  1027. getapi(
  1028. `/api/app/abpuserdepartment/getuserdepartment?UserId=${row.id}`
  1029. ).then((res) => {
  1030. // default-checked-keys
  1031. this.defaultchekedKeys = res.data;
  1032. console.log(res, "科室");
  1033. });
  1034. }
  1035. // useraffiliation(row.id).then((res) => {
  1036. // this.form.roleNames = res.data.items[0].name;
  1037. // // res.data.items.forEach(item=>{
  1038. // // this.form.roleNames=item.name
  1039. // // console.log(item)
  1040. // // })
  1041. // console.log("form", this.form);
  1042. // // console.log(res);
  1043. // console.log(res, "=====10010");
  1044. // this.$forceUpdate();
  1045. // });
  1046. console.log(this.title);
  1047. getbook().then((res) => {
  1048. console.log(res, "===>>>res");
  1049. const { code, data } = res;
  1050. if (code == 1) {
  1051. let options = data.items;
  1052. this.checkList = options;
  1053. // console.log(this.checkList, "checkList");
  1054. this.options = options;
  1055. // this.options = options.map((item, index) => {
  1056. // return {
  1057. // id: item.name,
  1058. // name: item.name,
  1059. // };
  1060. // });
  1061. console.log("options", this.options);
  1062. }
  1063. });
  1064. console.log(row);
  1065. usersinits(row.id).then((res) => {
  1066. this.orgId = res.data[res.data.length - 1].displayName;
  1067. this.orgIds = res.data[0].displayName;
  1068. let list = res.data;
  1069. this.defaultKeys = list.map((item) => {
  1070. return item.id;
  1071. });
  1072. console.log("defaultKeys", this.defaultKeys);
  1073. });
  1074. },
  1075. //分页
  1076. handleSizeChange(v) {
  1077. this.pages.MaxResultCount = v;
  1078. this.getlist();
  1079. },
  1080. handleCurrentChange(v) {
  1081. this.pages.SkipCount = v;
  1082. this.getlist();
  1083. },
  1084. },
  1085. };
  1086. </script>
  1087. <style scoped>
  1088. ::v-deep .el-card {
  1089. margin-top: -15px;
  1090. /* background-color: #000; */
  1091. border-radius: 15px;
  1092. }
  1093. /* ::v-deep .el-card__body {
  1094. margin-top: -15px;
  1095. border-radius: 15px;
  1096. } */
  1097. </style>