move.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="cl-dept-move"></div>
  3. </template>
  4. <script>
  5. import { deepTree } from "cl-admin/utils";
  6. export default {
  7. name: "cl-dept-move",
  8. methods: {
  9. async getDeptList() {
  10. return await this.$service.system.dept.list().then(deepTree);
  11. },
  12. async toMove(ids) {
  13. let list = await this.getDeptList();
  14. this.$crud.openForm({
  15. title: "部门转移",
  16. width: "600px",
  17. props: {
  18. "label-width": "80px"
  19. },
  20. items: [
  21. {
  22. label: "选择部门",
  23. prop: "dept",
  24. component: {
  25. name: "system-user__dept-move",
  26. methods: {
  27. selectRow(e) {
  28. this.$emit("input", e);
  29. }
  30. },
  31. render() {
  32. return (
  33. <div
  34. style={{
  35. border: "1px solid #eee",
  36. "border-radius": "3px",
  37. padding: "2px"
  38. }}>
  39. <el-tree
  40. data={list}
  41. {...{
  42. props: {
  43. props: {
  44. label: "name"
  45. }
  46. }
  47. }}
  48. node-key="id"
  49. highlight-current
  50. on-node-click={this.selectRow}></el-tree>
  51. </div>
  52. );
  53. }
  54. }
  55. }
  56. ],
  57. on: {
  58. submit: (data, { done, close }) => {
  59. if (!data.dept) {
  60. this.$message.warning("请选择部门");
  61. return done();
  62. }
  63. const { name, id } = data.dept;
  64. this.$confirm(`是否将用户转移到部门 ${name} 下`, "提示", {
  65. type: "warning"
  66. })
  67. .then(() => {
  68. this.$service.system.user
  69. .move({
  70. departmentId: id,
  71. userIds: ids
  72. })
  73. .then((res) => {
  74. this.$message.success("转移成功");
  75. this.$emit("success", res);
  76. close();
  77. })
  78. .catch((err) => {
  79. this.$message.error(err);
  80. this.$emit("error", err);
  81. done();
  82. });
  83. })
  84. .catch(() => {});
  85. }
  86. }
  87. });
  88. }
  89. }
  90. };
  91. </script>