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.

1157 lines
38 KiB

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