index.vue 5.9 KB

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