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.

1045 lines
33 KiB

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