departManage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <script setup>
  2. import { ref,reactive } from 'vue'
  3. import {useDepart} from './hooks/use-depart'
  4. import { departInterence } from '@/api/api.js'
  5. import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
  6. import { Search } from '@element-plus/icons-vue'
  7. const {
  8. defaultDepart,defaultGroup,departArr,tableParams,tableData,groupTeamId,
  9. getDepartArr,getTableUser,
  10. useTreeMove,useTreeEvent,useDepartTable
  11. } = useDepart()
  12. const {checkAllowDrag,checkAllowDrop,handleDropOver} = useTreeMove()
  13. const {act_node,clickNode,initDepart,openNodeDialog,removeNode} = useTreeEvent()
  14. const {
  15. changeStatus,getUserDetail,
  16. openUserDialog,openResetPassDialog,openMoveDepartDialog
  17. } = useDepartTable()
  18. const defaultProp = {label:'DepartmentName',children:'Child'}
  19. const tableColumns = [
  20. { label:"姓名", key:"RealName" },{ label:"账号", key:"AdminName" },{ label:"手机号", key:"Mobile"},
  21. { label:"角色", key:"RoleName" },{ label:"部门/分组", key:"DepartmentGroup" },{ label:"状态", key:"Enabled"}
  22. ]
  23. let isShowloadding = ref('')
  24. //切换表格页码
  25. function handleCurrentChange(page){
  26. tableParams.pageNo = page
  27. getTableUser()
  28. }
  29. let shareCustomDepartmentId = ref(0)
  30. function setShareCustomDepartId(){
  31. // 不同环境下 共享客户组的DepartmentId不一样
  32. if(process.env.NODE_ENV == 'development'||process.env.NODE_ENV == 'test'){
  33. shareCustomDepartmentId.value = 61
  34. }else if(process.env.NODE_ENV == 'production'){
  35. shareCustomDepartmentId.value = 37
  36. }
  37. }
  38. //同步每刻
  39. function synchronizationMEIKE(){}
  40. //获取用户数据
  41. getTableUser()
  42. //获取部门结构
  43. getDepartArr()
  44. //设置shareCustomDepartmentId的值
  45. setShareCustomDepartId()
  46. </script>
  47. <template>
  48. <div class="depart_container">
  49. <div class="left_cont">
  50. <div class="company_top" @click="initDepart">
  51. <img src="@/assets/img/set_m/home_ico.png" alt="" style="width:30px;height:30px;">
  52. <span :class="(!defaultGroup&&!defaultDepart)?'act':''">部门信息</span>
  53. </div>
  54. <el-tree
  55. ref="departTree"
  56. class="depart_tree"
  57. style="margin-top:27px;"
  58. :data="departArr"
  59. node-key="unicodeKey"
  60. :props="defaultProp"
  61. draggable
  62. :allow-drag="checkAllowDrag"
  63. :allow-drop="checkAllowDrop"
  64. check-strictly
  65. empty-text="暂无部门"
  66. @node-drop="handleDropOver">
  67. <template #default="{node,data}">
  68. <span class="custom-tree-node" @click="clickNode(node,data)">
  69. <span>{{ node.label }}</span>
  70. <span style="display:flex;align-items:center;" v-show="act_node===data.unicodeKey">
  71. <img src="~@/assets/img/data_m/move_ico.png" alt="" class="icon-img" @click.stop>
  72. <img src="~@/assets/img/set_m/add.png" alt="" class="icon-img" @click.stop="openNodeDialog('add',data,node)" v-if="data.IsDepartment">
  73. <img src="~@/assets/img/set_m/add.png" alt="" class="icon-img" @click.stop="openNodeDialog('add',data,node)" v-if="data.IsGroup">
  74. <img src="~@/assets/img/set_m/edit.png" alt="" class="icon-img" @click.stop="openNodeDialog('edit',data,node)">
  75. <el-popconfirm
  76. @onConfirm="removeNode(node,data)"
  77. confirmButtonText='删除'
  78. cancelButtonText='取消'
  79. confirmButtonType="text"
  80. icon="el-icon-info"
  81. iconColor="red"
  82. title="确定删除吗"
  83. v-if="data.DepartmentId!=shareCustomDepartmentId"
  84. >
  85. <!-- 共享客户组不允许删除 -->
  86. <template #reference>
  87. <img src="~@/assets/img/set_m/del.png" alt="" style="width:12px;height:12px;margin-top:4px">
  88. </template>
  89. </el-popconfirm>
  90. </span>
  91. </span>
  92. </template>
  93. </el-tree>
  94. <div class="noDepart" @click="openNodeDialog('add',{},{level:0})">
  95. <img src="~@/assets/img/set_m/add_ico.png" alt="" style="width:16px;height:16px;margin-right:10px;">
  96. <span>新建部门</span>
  97. </div>
  98. </div>
  99. <div class="right_cont">
  100. <div class="right_cont_top">
  101. <div>
  102. <el-button type="primary" @click="openUserDialog('add',{})">添加用户</el-button>
  103. <el-button type="primary" @click="synchronizationMEIKE" style="margin-left: 26px;">同步每刻</el-button>
  104. </div>
  105. <el-input
  106. placeholder="姓名/账号/手机号搜索"
  107. v-model="tableParams.searchTxt"
  108. :prefix-icon="Search"
  109. clearable
  110. @input="initDepart"
  111. style="max-width:359px">
  112. </el-input>
  113. </div>
  114. <div class="right_cont_bot">
  115. <el-table
  116. :data="tableData"
  117. @row-click="getUserDetail"
  118. v-loading="isShowloadding"
  119. element-loading-text="数据加载中..."
  120. highlight-current-row border
  121. >
  122. <el-table-column v-for="column in tableColumns" :key="column.key"
  123. :prop="column.key"
  124. :label="column.label"
  125. align="center"
  126. >
  127. <template #default="{row}">
  128. <span v-if="column.key==='Enabled'"
  129. :style="{color:row.Enabled===0?'#FF0000':null}"
  130. >{{row.Enabled===0?'禁用':'启用'}}</span>
  131. <span v-else-if="column.key==='RealName'">
  132. <el-tag
  133. v-if="row.LabelVal"
  134. :style="row.LabelVal==1||row.LabelVal==2?'color:#fff;background:#409EFF':'color:#409EFF;background:#ECF5FF'"
  135. style="position:absolute;left:10px"
  136. >{{
  137. row.LabelVal==1?'超管'
  138. :row.LabelVal==2?'管理员'
  139. :row.LabelVal==3?'部门经理'
  140. :row.LabelVal==4?'组长':'主管'
  141. }}</el-tag>
  142. <span style="position: relative;">{{row.RealName}}</span>
  143. </span>
  144. <span v-else>{{row[column.key]}}</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="操作" align="center" width="260">
  148. <template #default="{row}">
  149. <div style="color:#4099ef; font-size:24px;display: flex;gap:0 10px;">
  150. <span class="editsty" @click.stop="openUserDialog('edit',row)">编辑</span>
  151. <span class="editsty" @click.stop="openResetPassDialog(row)">重置密码</span>
  152. <span class="editsty" @click.stop="openMoveDepartDialog(row)">移动分组</span>
  153. <span
  154. class="editsty"
  155. @click.stop="changeStatus(row)"
  156. >{{row.Enabled===0?'启用':'禁用'}}</span>
  157. <!-- <span class="deletesty" @click.stop="delUser(row)">删除</span> -->
  158. </div>
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <el-config-provider :locale="zhCn">
  163. <el-pagination background layout="total,prev,pager,next,jumper" :current-page="tableParams.pageNo"
  164. :page-size="tableParams.pageSize" :total="tableParams.total"
  165. @current-change="handleCurrentChange" style="margin-top: 60px; justify-content: flex-end;">
  166. </el-pagination>
  167. </el-config-provider>
  168. <!-- 用户详情右侧弹窗 -->
  169. </div>
  170. </div>
  171. </div>
  172. </template>
  173. <style scoped lang="scss">
  174. .depart_container {
  175. * {
  176. box-sizing: border-box;
  177. }
  178. .el-popper {
  179. padding: 20px !important;
  180. }
  181. .fade {
  182. transition: all 0.5s;
  183. }
  184. display: flex;
  185. background: #f5f7f9;
  186. // reset
  187. .el-form-item__label {
  188. font-size: 16px;
  189. padding-right: 20px !important;
  190. }
  191. .el-tag {
  192. font-size: 12px !important;
  193. }
  194. .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before {
  195. content: '';
  196. }
  197. .el-tag {
  198. margin-right: 10px;
  199. }
  200. .el-cascader .el-input {
  201. width: 100%;
  202. }
  203. .left_cont {
  204. width: 16%;
  205. min-width: 200px;
  206. margin-right: 20px;
  207. height: calc(100vh - 120px);
  208. overflow-y: auto;
  209. border-radius: 4px;
  210. background: #fff;
  211. padding: 20px;
  212. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  213. .company_top {
  214. display: flex;
  215. align-items: flex-end;
  216. font-size: 16px;
  217. color: #333;
  218. cursor: pointer;
  219. span {
  220. width: 100%;
  221. padding: 4px 10px 0;
  222. &:hover {
  223. background: #F5F7FA;
  224. }
  225. }
  226. .act {
  227. background: #F0F4FF;
  228. }
  229. }
  230. :deep(.depart_tree) {
  231. font-size: 15px;
  232. color: #333;
  233. .custom-tree-node {
  234. display: flex !important;
  235. justify-content: space-between;
  236. align-items: center;
  237. display: block;
  238. flex: 1;
  239. .icon-img{
  240. width:12px;
  241. height:12px;
  242. margin-right:10px;
  243. }
  244. }
  245. .el-tree-node__content {
  246. margin-bottom: 15px !important;
  247. }
  248. .el-tree-node__children {
  249. .el-tree-node {
  250. margin-bottom: 8px !important;
  251. padding-left: 18px;
  252. }
  253. .el-tree-node__content {
  254. margin-bottom: 5px !important;
  255. padding-left: 0 !important;
  256. }
  257. }
  258. .el-icon.el-tree-node__expand-icon{
  259. svg{
  260. display: none;
  261. }
  262. &::before{
  263. content: url("@/assets/img/set_m/slide.png") !important;
  264. }
  265. &.expanded::before{
  266. content: url("@/assets/img/set_m/down.png") !important;
  267. }
  268. }
  269. .el-tree-node__expand-icon.expanded {
  270. -webkit-transform: rotate(0deg);
  271. transform: rotate(0deg);
  272. }
  273. .el-tree-node.is-current>.el-tree-node__content {
  274. background-color: #F0F4FF !important;
  275. }
  276. .el-tree-node__content {
  277. padding-right: 10px !important;
  278. }
  279. }
  280. .noDepart {
  281. margin-top: 50px;
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. color: #409EFF;
  286. font-size: 16px;
  287. cursor: pointer;
  288. }
  289. }
  290. .right_cont {
  291. width: 82%;
  292. background: #F5F7F9;
  293. height: calc(100vh - 120px);
  294. // box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  295. border-radius: 4px;
  296. display: flex;
  297. flex-direction: column;
  298. .right_cont_top {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. border: 1px solid #ECECEC;
  303. padding: 20px 30px;
  304. background: #fff;
  305. border-radius: 4px;
  306. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  307. }
  308. .right_cont_bot {
  309. flex: 1;
  310. overflow-y: auto;
  311. padding: 20px 30px;
  312. background: #fff;
  313. margin-top: 20px;
  314. position: relative;
  315. border: 1px solid #ECECEC;
  316. border-radius: 4px;
  317. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  318. .right_shadow {
  319. width: 350px;
  320. background: #fff;
  321. position: absolute;
  322. right: 0;
  323. top: 0;
  324. bottom: 0;
  325. overflow-y: hidden;
  326. z-index: 2;
  327. box-shadow: -3px 0 6px rgba(0, 0, 0, 0.1);
  328. border: 1px solid #ececec;
  329. padding: 60px 30px;
  330. .shadow_top {
  331. display: flex;
  332. align-items: center;
  333. }
  334. .shadow_info {
  335. margin-top: 30px;
  336. margin-bottom: 40px;
  337. font-size: 16px;
  338. color: #333;
  339. height: calc(100% - 120px);
  340. overflow-y: auto;
  341. .info_item {
  342. margin-bottom: 20px;
  343. .item_tit {
  344. margin-bottom: 10px;
  345. }
  346. }
  347. }
  348. .close_btn {
  349. width: 16px;
  350. height: 16px;
  351. position: absolute;
  352. right: 20px;
  353. top: 20px;
  354. }
  355. }
  356. }
  357. }
  358. }
  359. </style>