index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <Dialog draggable custom-show type="lg" title="通讯录" height="720px" @close="handleClose" @confirm="handleConfirm">
  3. <div class="content">
  4. <div class="left-content">
  5. <el-input v-model="queryParams1.deptName" class="custom-input" placeholder="组织架构搜索">
  6. <template #prefix>
  7. <el-icon class="el-input__icon"><search /></el-icon>
  8. </template>
  9. </el-input>
  10. <div class="tree-container">
  11. <div class="tree-box">
  12. <el-tree :data="treeData" :props="{ value: 'deptId', label: 'deptName', children: 'children' }" accordion @node-click="handleNodeClick" />
  13. </div>
  14. </div>
  15. </div>
  16. <div class="middle-content">
  17. <div class="user-box">
  18. <div class="user-table">
  19. <div class="tr">
  20. <div class="td2">
  21. <div :class="getCheckedClass()" @click="handleChecked"></div>
  22. </div>
  23. <div class="td">姓名</div>
  24. <div class="td3">职务</div>
  25. </div>
  26. <div class="table-content">
  27. <div v-for="(item, index) in userList" :key="index" class="tr2">
  28. <div class="td2">
  29. <div :class="item.checked ? 'common-checked-active' : 'common-checked'" @click="handleChecked2(item)"></div>
  30. </div>
  31. <div class="td">{{ item.nickName }}</div>
  32. <div class="td3">
  33. {{ item.deptName }}
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="select-box2">
  41. <div class="select-header">
  42. <div class="left-item">
  43. <div>已选择:</div>
  44. <div class="text">{{ selectList.length }}</div>
  45. <div>人</div>
  46. </div>
  47. <div class="clear-btn" @click="clearSelect">清空</div>
  48. </div>
  49. <div class="select-content">
  50. <div v-for="(item, index) in selectList" :key="index" class="box-item">
  51. <div class="box-left">
  52. <div class="line">
  53. <div class="text1">{{ item.nickName }}</div>
  54. <div class="text2">{{ item.duty }}</div>
  55. </div>
  56. <div class="line" style="margin-top: 6px">
  57. <div class="text2">{{ item.deptName }}</div>
  58. </div>
  59. </div>
  60. <div class="close-btn" @click="deleteItem(item)"></div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </Dialog>
  66. </template>
  67. <script lang="ts" setup name="Contact">
  68. import { Search } from '@element-plus/icons-vue';
  69. import { listDept } from '@/api/system/dept';
  70. import { DeptVO } from '@/api/system/dept/types';
  71. import { listUser } from '@/api/system/user';
  72. defineProps({
  73. modelValue: Boolean
  74. });
  75. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  76. const emits = defineEmits(['update:modelValue', 'close', 'confirm']);
  77. let queryParams1 = ref({
  78. pageNum: 1,
  79. pageSize: 10,
  80. deptName: undefined,
  81. deptCategory: undefined,
  82. status: undefined
  83. });
  84. let queryParams2 = ref({
  85. pageNum: 1,
  86. pageSize: 100,
  87. deptId: ''
  88. });
  89. const treeData = ref([]);
  90. const userList = ref([]);
  91. const selectList = ref([]);
  92. const getCheckedClass = () => {
  93. let res = 'common-checked';
  94. const len = userList.value.length;
  95. const len2 = selectList.value.length;
  96. if (len2 > 0 && len2 === len) {
  97. res = 'common-checked-active';
  98. } else if (len2 > 0) {
  99. res = 'common-checked-half';
  100. }
  101. return res;
  102. };
  103. const handleNodeClick = (data) => {
  104. queryParams2.value.deptId = data.deptId;
  105. getPerson();
  106. };
  107. const getPerson = () => {
  108. listUser(queryParams2.value).then((res) => {
  109. const data = res.rows;
  110. data.forEach((item) => {
  111. for (let i = 0; i < selectList.value.length; i++) {
  112. if (selectList.value[i].nickName === item.nickName) {
  113. item.checked = true;
  114. break;
  115. }
  116. }
  117. });
  118. userList.value = data;
  119. });
  120. };
  121. // 全选、全取消
  122. const handleChecked = () => {
  123. const checkedClass = getCheckedClass();
  124. let flag = true;
  125. if (checkedClass === 'common-checked-active') {
  126. flag = false;
  127. }
  128. userList.value.forEach((item) => {
  129. item.checked = flag;
  130. });
  131. computedSelectList();
  132. };
  133. // 单个选中、取消选中
  134. const handleChecked2 = (item) => {
  135. item.checked = !item.checked;
  136. computedSelectList();
  137. };
  138. const computedSelectList = () => {
  139. userList.value.forEach((item2) => {
  140. let index = 0;
  141. for (let i = 0; i < selectList.value.length; i++) {
  142. if (!!item2.checked && selectList.value[i].userId !== item2.userId) {
  143. index++;
  144. } else if (!item2.checked && selectList.value[i].userId === item2.userId) {
  145. selectList.value.splice(i, 1);
  146. break;
  147. }
  148. }
  149. if (!!item2.checked && selectList.value.length === index) {
  150. selectList.value.push(item2);
  151. }
  152. });
  153. };
  154. // 清空
  155. const clearSelect = () => {
  156. userList.value.forEach((item) => {
  157. if (item.checked) {
  158. item.checked = false;
  159. }
  160. });
  161. selectList.value = [];
  162. };
  163. // 清空指定项
  164. const deleteItem = (item) => {
  165. for (let i = 0; i < userList.value.length; i++) {
  166. if (item.userId === userList.value[i].userId) {
  167. userList.value[i].checked = false;
  168. break;
  169. }
  170. }
  171. computedSelectList();
  172. };
  173. // 弹窗关闭后
  174. const handleClose = () => {
  175. emits('update:modelValue', false);
  176. emits('close');
  177. };
  178. //
  179. const handleConfirm = () => {
  180. emits('confirm', selectList.value);
  181. emits('update:modelValue', false);
  182. };
  183. const initData = () => {
  184. listDept(queryParams1.value).then((res: any) => {
  185. const data = proxy?.handleTree<DeptVO>(res.data, 'deptId');
  186. treeData.value = data;
  187. });
  188. };
  189. onMounted(() => {
  190. initData();
  191. });
  192. </script>
  193. <style lang="scss" scoped>
  194. .content {
  195. display: flex;
  196. margin-top: 12px;
  197. .left-content {
  198. width: 303px;
  199. padding-right: 10px;
  200. border-right: 1px solid #2187ff;
  201. }
  202. .middle-content {
  203. width: 303px;
  204. padding: 0 10px;
  205. border-right: 1px solid #2187ff;
  206. .search-box {
  207. display: flex;
  208. .select-box {
  209. flex-shrink: 0;
  210. width: 176px !important;
  211. height: 56px;
  212. line-height: 56px;
  213. margin: 0 10px;
  214. color: #83a3be;
  215. font-size: 14px;
  216. }
  217. }
  218. .user-box {
  219. width: 100%;
  220. height: 100%;
  221. .user-table {
  222. padding: 15px 0;
  223. display: flex;
  224. flex-direction: column;
  225. font-size: 16px;
  226. color: #fbffff;
  227. .tr {
  228. background-color: #102e76;
  229. }
  230. .tr,
  231. .tr2 {
  232. display: flex;
  233. padding: 6px 0;
  234. .td {
  235. flex: 1;
  236. display: flex;
  237. align-items: center;
  238. }
  239. .td2 {
  240. width: 30px;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. }
  245. .td3 {
  246. flex: 2;
  247. display: flex;
  248. align-items: center;
  249. }
  250. }
  251. .table-content {
  252. height: 520px;
  253. overflow-y: auto;
  254. }
  255. .tr2 {
  256. margin-top: 10px;
  257. background-color: #122868;
  258. }
  259. .phone-icon {
  260. width: 31px;
  261. height: 31.5px;
  262. background: url('@/assets/images/emergencyCommandMap/communication/phone.png');
  263. background-size: 100% 100%;
  264. cursor: pointer;
  265. }
  266. }
  267. }
  268. }
  269. .custom-select-popper {
  270. .el-scrollbar {
  271. .el-select-dropdown__item {
  272. color: #b1cae0;
  273. font-size: 14px;
  274. height: 56px;
  275. line-height: 56px;
  276. }
  277. }
  278. }
  279. .input {
  280. background: transparent;
  281. color: #83a3be;
  282. font-size: 14px;
  283. outline: none;
  284. appearance: none;
  285. height: 100%;
  286. border: none;
  287. &::placeholder {
  288. color: #83a3be;
  289. }
  290. }
  291. .tree-container {
  292. display: flex;
  293. .tree-box {
  294. width: 100%;
  295. height: 555px;
  296. overflow-y: auto;
  297. padding: 15px 8px;
  298. :deep(.el-tree) {
  299. height: 100%;
  300. background-color: transparent;
  301. color: #fbffff;
  302. font-size: 16px;
  303. .el-tree-node__content {
  304. height: auto;
  305. padding-top: 10px;
  306. padding-bottom: 10px;
  307. white-space: normal;
  308. word-break: break-all;
  309. }
  310. .el-tree-node__expand-icon {
  311. color: #297cfc;
  312. }
  313. .el-tree-node:focus > .el-tree-node__content,
  314. .el-tree-node__content:hover {
  315. background-color: transparent !important;
  316. }
  317. }
  318. }
  319. }
  320. .select-box2 {
  321. margin-left: 30px;
  322. width: 303px;
  323. height: 100%;
  324. .select-header {
  325. display: flex;
  326. justify-content: space-between;
  327. align-items: center;
  328. color: #fbffff;
  329. font-size: 14px;
  330. border-bottom: 1px solid #247dff;
  331. padding: 20px;
  332. .left-item {
  333. display: flex;
  334. align-items: center;
  335. .text {
  336. margin: 0 10px;
  337. color: #00e8ff;
  338. font-family: 'BEBAS-1';
  339. }
  340. }
  341. .clear-btn {
  342. color: #00e8ff;
  343. cursor: pointer;
  344. }
  345. }
  346. .select-content {
  347. height: 520px;
  348. overflow-y: auto;
  349. .box-item {
  350. border-bottom: 1px solid #247dff;
  351. padding: 7px;
  352. position: relative;
  353. display: flex;
  354. .box-left {
  355. flex: 1;
  356. margin-right: 5px;
  357. }
  358. .line {
  359. color: #fff;
  360. font-size: 16px;
  361. display: flex;
  362. .text1 {
  363. margin-right: 35px;
  364. }
  365. .text2 {
  366. color: #a7ccdf;
  367. }
  368. }
  369. .close-btn {
  370. flex-shrink: 0;
  371. cursor: pointer;
  372. width: 20px;
  373. height: 20px;
  374. background: url('@/assets/images/emergencyCommandMap/communication/close.png') no-repeat;
  375. background-size: 100% 100%;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. </style>