user.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="hui-flex hui-content work-user">
  3. <div class="hui-content-title">
  4. <div class="hui-title-item active">成员管理</div>
  5. </div>
  6. <div class="hui-flex-box yui-tree-box">
  7. <div class="hui-left-tree">
  8. <div class="hui-left-tree-title">
  9. <div class="tree-logo">
  10. <el-image v-if="organization.logoUrl" :src="organization.logoUrl" fit="cover"></el-image>
  11. <div class="el-image" v-else>
  12. <div class="image-slot"><i class="el-icon-picture-outline"></i></div>
  13. </div>
  14. </div>
  15. <span class="hui-left-tree-sub hui-ellipsis">{{organization.name}}</span>
  16. </div>
  17. <div class="hui-left-tree-content">
  18. <el-collapse>
  19. <el-collapse-item v-for="item in treeData" :key="item.id" :name="item.id">
  20. <template slot="title">
  21. <div class="collapse-title" @click="changeCollapse(item)">
  22. <i class="iconfont huifont-bumen"></i>
  23. <span class="el-collapse-name">{{item.name}}</span>
  24. </div>
  25. </template>
  26. <div>
  27. <el-tree :data="item.children" :props="defaultProps" :expand-on-click-node="false"
  28. @node-click="selectPart">
  29. </el-tree>
  30. </div>
  31. </el-collapse-item>
  32. </el-collapse>
  33. </div>
  34. </div>
  35. <div class="hui-tree-content">
  36. <div class="hui-flex hui-table">
  37. <div class="hui-content-insert">
  38. <el-button v-permission="'/work/organization/user/add'" type="primary" size="small"
  39. @click="insertUser" :disabled="!part.id">
  40. 新增成员
  41. </el-button>
  42. </div>
  43. <div class="hui-flex-box">
  44. <el-table :data="tableData" row-key="id" height="100%">
  45. <el-table-column label="序号" width="50">
  46. <template slot-scope="scope">
  47. <div style="text-align: center;">{{scope.$index + 1}}</div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="姓名">
  51. <template slot-scope="scope">
  52. <div class="hui-table-user">
  53. <div class="hui-table-avatar">
  54. <avatar :user="scope.row"></avatar>
  55. </div>
  56. <div>{{scope.row.name}}</div>
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="电话" prop="phone"></el-table-column>
  61. <el-table-column label="部门">
  62. <template slot-scope="scope">
  63. <span>{{part.name}}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="权限">
  67. <template slot-scope="scope">
  68. <el-button v-permission="'/work/organization/user/set'" size="mini" type="primary"
  69. @click="updateUser(scope.row,2,'设置权限')">
  70. 设置
  71. </el-button>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" width="150" align="center">
  75. <template slot-scope="scope">
  76. <div class="hui-table-operation">
  77. <span v-permission="'/work/organization/user/detail'" class="table-operation"
  78. @click="lookUser(scope.row)">
  79. 详情
  80. </span>
  81. <span v-permission="'/work/organization/user/update'" class="table-operation"
  82. v-if="!scope.row.projectFlowId" @click="updateUser(scope.row,3,'修改用户')">
  83. 编辑
  84. </span>
  85. <span v-permission="'/work/organization/user/delete'" class="table-operation"
  86. v-if="!scope.row.projectFlowId" @click="deleteUser(scope.row)">
  87. 删除
  88. </span>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <template slot="empty">
  93. <el-empty description="当前部门没有直属成员"></el-empty>
  94. </template>
  95. </el-table>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="visible" width="900px"
  101. :append-to-body="true">
  102. <edit v-if="visible && type === 1" :part="part" @callback="callback"></edit>
  103. <role v-if="visible && type === 2" :user="user" @callback="callback"></role>
  104. </el-dialog>
  105. <el-drawer title="用户详情" :visible.sync="drawer" :size="400" :append-to-body="true">
  106. <detail v-if="drawer" :user="user"></detail>
  107. </el-drawer>
  108. </div>
  109. </template>
  110. <script>
  111. import {
  112. getPartList,
  113. getUserListByPart,
  114. deleteUser
  115. } from '@/api/organization'
  116. import role from '@/components/work/organization/user/role'
  117. import detail from '@/components/work/organization/user/detail'
  118. import edit from '@/components/work/organization/user/edit'
  119. export default {
  120. data() {
  121. return {
  122. treeData: [],
  123. organization: {},
  124. project: {},
  125. tableData: [],
  126. defaultProps: {
  127. children: 'children',
  128. label: 'name'
  129. },
  130. part: {},
  131. visible: false,
  132. user: {},
  133. drawer: false,
  134. type: 1,
  135. title: '',
  136. oldCollapse: []
  137. }
  138. },
  139. mounted() {
  140. this.organization = this.$store.getters.organization;
  141. this.project = this.$store.getters.project;
  142. let logo = !this.organization.logo ? {} : JSON.parse(this.organization.logo);
  143. this.organization['logoUrl'] = logo.url;
  144. this.init()
  145. },
  146. methods: {
  147. init() {
  148. if (!this.auth('/work/organization/user/list')) return;
  149. getPartList(this.organization.id, this.project.id).then(res => {
  150. if (res.state) {
  151. this.treeData = res.data;
  152. }
  153. })
  154. },
  155. changeCollapse(part) {
  156. setTimeout(() => {
  157. this.selectPart(part)
  158. }, 300)
  159. },
  160. selectPart(part) {
  161. this.part = part;
  162. getUserListByPart({
  163. projectId: this.project.id,
  164. organizationId: this.organization.id,
  165. partId: part.id
  166. }).then(
  167. res => {
  168. if (res.state) {
  169. this.tableData = res.data;
  170. }
  171. })
  172. },
  173. insertUser() {
  174. this.type = 1;
  175. this.title = '新增成员';
  176. this.visible = true;
  177. },
  178. updateUser(user, type, title) {
  179. this.user = user;
  180. this.type = type;
  181. this.title = title;
  182. this.visible = true;
  183. },
  184. lookUser(user) {
  185. this.user = user;
  186. this.user['partName'] = this.part.name;
  187. this.drawer = true;
  188. },
  189. deleteUser(user) {
  190. this.$confirm('确定要删除该员工?', () => {
  191. deleteUser(this.organization.id, user.id).then(res => {
  192. if (res.state) {
  193. this.selectPart(this.part);
  194. this.$message.success('操作成功');
  195. }
  196. })
  197. });
  198. },
  199. callback(type) {
  200. this.visible = false;
  201. if (type === 'init') this.selectPart(this.part);
  202. }
  203. },
  204. components: {
  205. edit,
  206. role,
  207. detail
  208. }
  209. }
  210. </script>
  211. <style lang="scss">
  212. .work-user {
  213. .yui-tree-box {
  214. background: transparent;
  215. .hui-left-tree {
  216. border-right: 1px solid $--border-color-base;
  217. }
  218. .hui-tree-content {
  219. padding: 0;
  220. }
  221. }
  222. .hui-left-tree-title {
  223. .tree-logo {
  224. width: 24px;
  225. height: 24px;
  226. border-radius: 4px;
  227. overflow: hidden;
  228. .el-image {
  229. width: 100%;
  230. height: 100%;
  231. .image-slot {
  232. width: 100%;
  233. height: 100%;
  234. text-align: center;
  235. line-height: 24px;
  236. }
  237. }
  238. }
  239. .hui-left-tree-sub {
  240. font-weight: 400;
  241. }
  242. }
  243. }
  244. </style>