1
0

index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div class="organiza">
  3. <div class="title">组织架构</div>
  4. <div class="organiza-body">
  5. <div class="but">
  6. <el-button v-pdpath="'add'" type="primary" @click="addHandler">
  7. 新增组织架构
  8. </el-button>
  9. </div>
  10. <div class="tree">
  11. <div class="treeTile">
  12. <span>组织架构</span>
  13. <span style="padding-right: 100px">操作</span>
  14. </div>
  15. <div class="treeList">
  16. <el-tree
  17. style="width: 100%"
  18. :props="{ children: 'children', label: 'name' }"
  19. :data="organTrees"
  20. node-key="id"
  21. :current-node-key="user.info.id"
  22. accordion
  23. default-expand-all
  24. >
  25. <template #default="{ node, data }">
  26. <span class="custom-tree-node">
  27. <span>{{ data.name }}</span>
  28. <div
  29. class="butList oper-span"
  30. v-if="!topDeptIds.includes(Number(data.id))"
  31. >
  32. <a
  33. @click.stop="showOrganizationDetail({ dept: data })"
  34. v-pdpath="['view']"
  35. >
  36. 查看
  37. </a>
  38. <a
  39. @click.stop="setHandler(data)"
  40. :class="{ disable: user.info.deptId === data.id }"
  41. v-pdpath="['edit']"
  42. >
  43. 编辑
  44. </a>
  45. <a
  46. :class="{ disable: user.info.deptId === data.id }"
  47. style="color: var(--primaryColor)"
  48. @click.stop="delHandler(data.id)"
  49. v-pdpath="['del']"
  50. >
  51. 删除
  52. </a>
  53. </div>
  54. </span>
  55. </template>
  56. </el-tree>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script setup lang="ts">
  63. import { user } from "@/store/user";
  64. import { Organization, delOrganization, getOrganizationTree } from "@/store/organization";
  65. import { markRaw, onMounted, ref } from "vue";
  66. import { addOrganization, showOrganizationDetail, editOrganization } from "./quisk";
  67. import { confirm } from "@/helper/message";
  68. import { ElMessage, ElMessageBox } from "element-plus";
  69. import { RouteName, router } from "@/router";
  70. import { SuccessFilled } from "@element-plus/icons-vue";
  71. import { topDeptIds } from "@/constant/appDeptId";
  72. const organTrees = ref<Organization[]>([]);
  73. const addHandler = async () => {
  74. const data = await addOrganization({});
  75. if (data) {
  76. await refresh();
  77. const config = {
  78. icon: markRaw(SuccessFilled),
  79. confirmButtonText: "去创建",
  80. showClose: true,
  81. cancelButtonText: "我知道了",
  82. };
  83. if (await ElMessageBox.confirm("组织创建成功,快去创建用户吧", "温馨提示", config)) {
  84. router.push({ name: RouteName.user });
  85. }
  86. }
  87. };
  88. const setHandler = async (dept: Organization) => {
  89. if (await editOrganization({ dept })) {
  90. await refresh();
  91. ElMessage.success("操作成功");
  92. }
  93. };
  94. const delHandler = async (deptId: Organization["id"]) => {
  95. if (await confirm("确认要删除组织吗?")) {
  96. await delOrganization(deptId);
  97. ElMessage.success({ message: "删除成功", type: "success" });
  98. refresh();
  99. }
  100. };
  101. const refresh = async () => {
  102. organTrees.value = await getOrganizationTree("1");
  103. };
  104. onMounted(refresh);
  105. </script>
  106. <style lang="scss" scoped>
  107. .organiza {
  108. .title {
  109. height: 56px;
  110. padding: 0 24px;
  111. color: #303133;
  112. font-size: 16px;
  113. line-height: 56px;
  114. height: 56px;
  115. font-weight: 500;
  116. background-color: #fff;
  117. border-bottom: 1px solid #e4e7ed;
  118. }
  119. }
  120. .but {
  121. padding: 0 16px 16px 16px;
  122. background-color: #fff;
  123. text-align: right;
  124. }
  125. .title {
  126. height: 56px;
  127. padding: 0 24px;
  128. color: #303133;
  129. font-size: 16px;
  130. line-height: 56px;
  131. height: 56px;
  132. font-weight: 500;
  133. background-color: #fff;
  134. border-bottom: 1px solid #e4e7ed;
  135. }
  136. .organiza-body {
  137. margin-top: 15px;
  138. background-color: #fff;
  139. padding: 15px;
  140. .tree {
  141. border: 1px solid #ebeef5;
  142. // margin-top: 24px;
  143. .treeTile {
  144. display: flex;
  145. justify-content: space-between;
  146. border-bottom: 1px solid #ebeef5;
  147. background-color: #fafafa;
  148. padding: 12px 20px;
  149. }
  150. .treeList {
  151. max-height: 500px;
  152. overflow-y: auto;
  153. display: flex;
  154. justify-content: space-between;
  155. .custom-tree-node {
  156. flex: 1;
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. font-size: 14px;
  161. padding-right: 8px;
  162. .butList {
  163. width: 140px;
  164. a {
  165. margin: 0 8px;
  166. }
  167. .disable {
  168. color: #bfbfbf !important;
  169. pointer-events: none;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. }
  176. .table-ctrl-right {
  177. .search-scene {
  178. margin: 0 20px 0 26px;
  179. }
  180. i {
  181. margin-left: 20px;
  182. font-size: 1.7rem;
  183. vertical-align: middle;
  184. cursor: pointer;
  185. &.active {
  186. color: var(--primaryColor);
  187. }
  188. }
  189. }
  190. .camera-from {
  191. margin: 0 50px;
  192. }
  193. .share-from {
  194. width: 500px;
  195. margin: 0 auto;
  196. }
  197. .maker {
  198. font-weight: 400;
  199. color: #969799;
  200. line-height: 20px;
  201. }
  202. .oper-user {
  203. height: 40px;
  204. overflow: hidden; //超出的文本隐藏
  205. text-overflow: ellipsis; //溢出用省略号显示
  206. white-space: nowrap; //溢出不换行
  207. cursor: pointer;
  208. }
  209. </style>
  210. <style>
  211. .organiza .el-tree-node__content {
  212. padding: 12px 10px;
  213. border-bottom: 1px solid #ebeef5;
  214. }
  215. .camera-from .el-select,
  216. .dispatch-file-from .el-select {
  217. width: 100%;
  218. }
  219. .el-textarea__inner {
  220. font-family: "Microsoft YaHei";
  221. }
  222. .dispatch-detial .el-form-item__content {
  223. color: #323233;
  224. }
  225. .dispatch-detial .el-form-item__label {
  226. color: #646566;
  227. }
  228. </style>