topologyPop.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div class="ne--topology--pop">
  3. <div class="v-common-dialog-wrapper custom-dialog">
  4. <div class="modal-tit">NE Topology</div>
  5. <div class="v-common-dialog-content">
  6. <div class="dialog-tree">
  7. <div class="tree-area">
  8. <div class="tree-depth1">
  9. <ul>
  10. <li class="depth1-item" v-for="(tenant, index) in myTreeView" :key="index">
  11. <div class="depth-item-tit depth1-item-tit" :class="[tenant.fold ? '' : 'down']">
  12. <button class="arr" :class="[tenant.neGroupList.length == 0 ? 'nor' : '']" @click="tenant.neGroupList.length > 0 && (tenant.fold = !tenant.fold)"></button>
  13. <i class="ico"></i>
  14. <strong>{{ tenant.tenantName }}{{tenant.neGroupList.length > 0 ? '('+tenant.neGroupList.length+')': ''}}</strong>
  15. <!-- <button class="btn-tree btn-add" @click="addTree2(item1, index)"></button> -->
  16. </div>
  17. <div class="tree-depth2" v-if="tenant.fold">
  18. <ul>
  19. <li class="depth2-item" v-if="tenant.add">
  20. <div class="depth-item-tit depth2-item-tit depth-item-reg">
  21. <button class="arr"></button>
  22. <i class="ico"></i>
  23. <v-text-field
  24. class="custom-input mini"
  25. placeholder=""
  26. v-model="addGroupTitle"
  27. ></v-text-field>
  28. <button class="btn-tree btn-save" @click="saveTree2(tenant)"></button>
  29. </div>
  30. </li>
  31. <li class="depth2-item" v-for="(neGroup, index2) in tenant.neGroupList" :key="index2">
  32. <div class="depth-item-tit depth2-item-tit" :class="[neGroup.fold ? '' : 'down']">
  33. <button class="arr" @click="neGroup.fold = !neGroup.fold"></button>
  34. <i class="ico"></i>
  35. <v-checkbox
  36. class="custom-check type2"
  37. hide-details
  38. v-model="neGroup.isAllCheck"
  39. @update:modelValue="fnAllCheck($event, neGroup)">
  40. <template v-slot:label>{{neGroup.neGroup}}{{neGroup.neList.length > 0 ? '('+neGroup.neList.length+')': ''}}</template>
  41. </v-checkbox>
  42. <!-- <button class="btn-ne-add" @click="neRegPop = true"><i class="plus"></i>NE</button>
  43. <button class="btn-tree btn-pos"></button> -->
  44. </div>
  45. <div class="tree-depth3" v-if="neGroup.fold">
  46. <ul>
  47. <li class="depth3-item" v-for="(ne, index3) in neGroup.neList" :key="index3">
  48. <div class="depth-item-tit depth3-item-tit">
  49. <i class="ico" :class="getNeType(ne.neType)"></i>
  50. <v-checkbox
  51. class="custom-check type2"
  52. hide-details
  53. v-model="neGroup.selectNeList"
  54. :value="ne.neId"
  55. :id="neGroup.neGroup+ne.neId"
  56. @update:modelValue="fnCheckNeBox($event, neGroup)">
  57. <template v-slot:label v-if="ne.modify == false">{{ ne.neName }}</template>
  58. </v-checkbox>
  59. <!-- <v-text-field
  60. v-if="ne.modify"
  61. class="custom-input mini"
  62. v-model="treeName3"
  63. ></v-text-field> -->
  64. <!-- <button class="btn-tree btn-mod" v-if="ne.modify == false" @click="txtModify(ne)" ></button>
  65. <button class="btn-tree btn-save" v-if="ne.modify" @click="txtSave(ne)"></button> -->
  66. </div>
  67. </li>
  68. </ul>
  69. </div>
  70. </li>
  71. </ul>
  72. </div>
  73. </li>
  74. </ul>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="btn-wrap">
  80. <v-btn
  81. class="custom-btn btn-white mini"
  82. @click="$emit('closePop')"
  83. >
  84. 취소
  85. </v-btn>
  86. <v-btn
  87. class="custom-btn btn-blue mini"
  88. @click="fnSave"
  89. >
  90. 선택
  91. </v-btn>
  92. </div>
  93. </div>
  94. </div>
  95. </template>
  96. <script setup>
  97. /***********************
  98. * import
  99. ************************/
  100. import { useI18n } from "vue-i18n"
  101. import useUtil from "@/composables/useUtil"
  102. import useValid from "@/composables/useValid"
  103. /***********************
  104. * plugins inject
  105. ************************/
  106. const { $toast, $log, $dayjs, $eventBus } = useNuxtApp();
  107. // props
  108. const props = defineProps({
  109. isTopologyPop: Boolean,
  110. })
  111. // 참조가능 데이터 설정
  112. defineExpose({
  113. fnInit,
  114. })
  115. // 발신 이벤트 선언
  116. const emit = defineEmits(["closePop", "selectTarget"])
  117. /***********************
  118. * data & created
  119. ************************/
  120. const coreList = ['AMF', 'SMF', 'UDC', 'MEC', 'UPF']
  121. const ranList = ['CU', 'DU', 'RU', 'AU']
  122. const myTreeView = ref([])
  123. const userLevel = ref('')
  124. const userTenant = ref('')
  125. /***********************
  126. * Watch & computed
  127. ************************/
  128. const getNeType = computed(() => {
  129. return (val) => {
  130. if(!useUtil.isNull(val)) {
  131. if(coreList.includes(val)) return 'core'
  132. else if(ranList.includes(val)) return 'ran'
  133. }else return ''
  134. }
  135. })
  136. /***********************
  137. * Methods
  138. ************************/
  139. onMounted(() =>{
  140. userTenant.value = useAuthStore().getTenantName
  141. userLevel.value = useAuthStore().getAccountLevel
  142. /*
  143. userlevel구분
  144. {title: 'superAdmin', value: -1},
  145. {title: 'adminSds', value: 0},
  146. {title: 'managerBusiness', value: 1},
  147. {title: 'operatorBusiness', value: 2}
  148. */
  149. fnInit()
  150. })
  151. function fnInit(){
  152. fnGetNeTopology()
  153. }
  154. /**
  155. * NE Topology 트리뷰 데이터 조회
  156. */
  157. function fnGetNeTopology(){
  158. useAxios().post(useApi.getTopology).then((res) => {
  159. $log.debug("[neMgmt][fnGetNeTopology][success]")
  160. let list = res.data.data
  161. let temp = []
  162. list.forEach((item, idx) => {
  163. let depth1 = {}
  164. depth1.tenantName = item.tenantName
  165. depth1.fold = true
  166. depth1.neGroupList = []
  167. if(item.neGroupList){
  168. item.neGroupList.forEach((neGroup, idx2) => {
  169. let depth2 = {}
  170. depth2.neGroup = neGroup.neGroup
  171. depth2.fold = true
  172. depth2.add = false
  173. depth2.neList = []
  174. depth2.isAllCheck = false
  175. depth2.selectNeList = []
  176. if(neGroup.neList && neGroup.neList.length > 0){
  177. neGroup.neList.forEach((ne, idx3)=> {
  178. let depth3 = {}
  179. depth3.neName = ne.neName
  180. depth3.neId = ne.neId
  181. depth3.neType = ne.neType
  182. depth3.upfNum = ne.upfNum
  183. depth3.customerType = ne.customerType
  184. depth3.modify = false
  185. depth2.neList.push(depth3)
  186. })
  187. if(depth2.neList.length > 0){
  188. depth1.neGroupList.push(depth2)
  189. }
  190. }
  191. })
  192. }
  193. if(userLevel.value == 0 || userLevel.value == -1){
  194. if(depth1.neGroupList.length > 0){
  195. temp.push(depth1)
  196. }
  197. } else{
  198. if(depth1.neGroupList.length > 0 && userTenant.value == depth1.tenantName){
  199. temp.push(depth1)
  200. }
  201. }
  202. })
  203. myTreeView.value = _cloneDeep(temp)
  204. }).catch((error)=>{
  205. $log.debug("[neMgmt][fnGetNeTopology][error]")
  206. useErrorHandler().fnSetCommErrorHandle(error, fnGetNeTopology)
  207. }).finally(()=>{
  208. $log.debug("[neMgmt][fnGetNeTopology][finished]")
  209. })
  210. }
  211. const checkList = ref([])
  212. function fnAllCheck(event, obj) {
  213. if(event) {
  214. obj.neList.forEach((item) => {
  215. obj.selectNeList.push(item.neId)
  216. })
  217. }else{
  218. obj.selectNeList = []
  219. }
  220. }
  221. function fnCheckNeBox(event, group){
  222. group.isAllCheck = group.selectNeList.length === group.neList.length
  223. }
  224. function fnSave(){
  225. let selectItems = {
  226. tenantName: [],
  227. groupName: [],
  228. neName: [],
  229. singleData: []
  230. }
  231. myTreeView.value.forEach((tenant)=>{
  232. let successfulNeGroups = []
  233. let failedNeGroups = []
  234. tenant.neGroupList.forEach((neGroup)=>{
  235. let neGroupChk = neGroup.neList.every((ne,idx)=>{
  236. let neChk = neGroup.selectNeList.includes(ne.neId)
  237. return neChk
  238. })
  239. if(neGroupChk){
  240. successfulNeGroups.push(neGroup)
  241. } else{
  242. failedNeGroups.push(neGroup)
  243. }
  244. })
  245. //전부선택시 테넌트명 전달
  246. if(failedNeGroups.length == 0){
  247. if(tenant.neGroupList.length > 0){
  248. if(tenant.neGroupList[0].neList.length > 0){
  249. selectItems.tenantName.push(tenant.tenantName)
  250. }
  251. }
  252. } else if(successfulNeGroups.length > 0){ //전부 선택하지 않았을시 그룹명 전달
  253. successfulNeGroups.forEach(item=>{
  254. selectItems.groupName.push(item.neGroup)
  255. })
  256. }
  257. //전부선택이 아닌값중 선택한값
  258. failedNeGroups.forEach(group=>{
  259. group.neList.forEach((ne) => {
  260. if(group.selectNeList.includes(ne.neId)) {
  261. let obj = {}
  262. obj.tenantName = tenant.tenantName
  263. obj.neGroup = group.neGroup
  264. obj.neName = ne.neName
  265. obj.neId = ne.neId
  266. selectItems.neName.push(obj)
  267. }
  268. })
  269. })
  270. //이벤트 이력 개별 neName값
  271. tenant.neGroupList.forEach((neGroup)=>{
  272. neGroup.neList.forEach((ne) => {
  273. if(neGroup.selectNeList.includes(ne.neId)) {
  274. let obj = {}
  275. obj.tenantName = tenant.tenantName
  276. obj.neGroup = neGroup.neGroup
  277. obj.neName = ne.neName
  278. obj.neId = ne.neId
  279. selectItems.singleData.push(obj)
  280. }
  281. })
  282. })
  283. })
  284. emit('selectTarget', selectItems)
  285. }
  286. </script>
  287. <style lang="scss" scoped>
  288. .checked-text{
  289. color:#7ba1c5;
  290. }
  291. .label-text{
  292. font-size: 0.75rem;
  293. margin-left: 0.63rem;
  294. line-height: 1.06rem;
  295. white-space: nowrap;
  296. text-overflow: ellipsis;
  297. overflow: hidden;
  298. display: block;
  299. }
  300. </style>