relationEditor.vue.bak 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!-- 实体类-关系属性 -->
  2. <template>
  3. <div class="flex-row">
  4. <div class="flex1" style="padding-right:24px;min-width:340px; ">
  5. <!--<h2>relationList</h2>-->
  6. <div class="ant-tabs-nav-wrap">
  7. <div class="ant-tabs-nav-scroll">
  8. <div class="ant-tabs-nav ant-tabs-nav-animated">
  9. <div @click="handleTabChange">
  10. <div
  11. role="tab"
  12. accessKey="1"
  13. class="ant-tabs-tab"
  14. :class="{'ant-tabs-tab-active': accesskey === '1'}"
  15. >
  16. 以此为起点
  17. </div>
  18. <div
  19. role="tab"
  20. accessKey="2"
  21. class=" ant-tabs-tab"
  22. :class="{'ant-tabs-tab-active':accesskey === '2'}"
  23. >以此为终点
  24. </div>
  25. </div>
  26. <div
  27. id="move"
  28. class="ant-tabs-ink-bar ant-tabs-ink-bar-animated"
  29. style="display: block; transform: translate3d(0px, 0px, 0px); width: 88px;"
  30. />
  31. </div>
  32. </div>
  33. </div>
  34. <a-button class="openAddRelationSty" @click="AddRelationClass">添加 </a-button>
  35. <a-spin :spinning="spinning">
  36. <a-list
  37. item-layout="horizontal"
  38. :data-source="relationListData"
  39. class="flex1"
  40. style="max-height: 515px; min-height: 300px; overflow: auto;"
  41. >
  42. <a-list-item slot="renderItem" slot-scope="item">
  43. <a-list-item-meta style="position: relative; padding-right: 70px;" @click="handleChangeEntityRouter(item.relClsID)">
  44. <p slot="title" :class="$route.params.relationId===item.relClsID ? 'selected' : '' " style="display: flex;position: relative">
  45. <a-tooltip v-if="entClsType === 'START' " placement="topLeft">
  46. <template slot="title">
  47. <span>{{ item.startEntClsName }}->{{ item.relClsName }} ->{{ item.endEntCls&&item.endEntCls.entClsName }}</span>
  48. </template>
  49. <a class="rela-box">{{ item.startEntClsName }}->{{ item.relClsName }} ->{{ item.endEntCls&&item.endEntCls.entClsName }}</a>
  50. </a-tooltip>
  51. <a-tooltip v-else placement="topLeft">
  52. <template slot="title">
  53. <span>{{ item.endEntCls&&item.endEntCls.entClsName }}->{{ item.relClsName }} ->{{ item.startEntClsName }}</span>
  54. </template>
  55. <a class="rela-box">{{ item.endEntCls&&item.endEntCls.entClsName }}->{{ item.relClsName }} ->{{ item.startEntClsName }}</a>
  56. </a-tooltip>
  57. <span
  58. class="eddit-box"
  59. @click.stop="handleDelRelationClass(item.relClsID)"
  60. >
  61. <a-icon type="minus-circle" /></span>
  62. <span class="cancel-box" @click.stop="handleEditRelationClassName(item)">
  63. <a-icon type="edit" /></span>
  64. </p>
  65. </a-list-item-meta>
  66. </a-list-item>
  67. </a-list>
  68. </a-spin>
  69. </div>
  70. <router-view :key="key" class="flex2" />
  71. </div>
  72. </template>
  73. <script>
  74. const api = require('@/api/index')
  75. const relationListData = []
  76. var odiv
  77. export default {
  78. name: 'RelationEditor',
  79. props: ['entClsName'],
  80. data() {
  81. return {
  82. relationListData,
  83. accesskey: '1',
  84. entClsType: 'START', // 默认是实体类为起点
  85. spinning: false,
  86. backGroundColor: ''
  87. }
  88. },
  89. computed: {
  90. key: function() {
  91. return this.$route.params ? this.$route.params.relationId : ''
  92. }
  93. },
  94. created() {
  95. const id = this.$route.params.classId
  96. this.refreshRelationClassList(id, this.entClsType)
  97. },
  98. mounted() {
  99. odiv = document.getElementById('move')
  100. },
  101. methods: {
  102. /**
  103. * 删除关系类
  104. * @param id
  105. */
  106. handleDelRelationClass(id) {
  107. const vm = this
  108. this.$confirm({
  109. title: '你确定要删除吗?',
  110. onOk() {
  111. api.relationClass.deleteRelationClass(id).then((data) => {
  112. if (data !== false) {
  113. vm.$trigger('relationClass:nodeDestroyed', id)
  114. vm.refreshRelationClassList(vm.$route.params.classId, vm.entClsType)// 刷新关系类列表
  115. vm.$message.success('删除关系类删除成功')
  116. }
  117. })
  118. },
  119. onCancel() {
  120. console.log('取消删除')
  121. }
  122. })
  123. },
  124. /**
  125. * 新增关系类
  126. * @param id
  127. */
  128. AddRelationClass() {
  129. this.$open('createRelationClassModal', {
  130. pramsId: this.$route.params.classId,
  131. entClsName: this.entClsName,
  132. entClsType: this.entClsType,
  133. backGroundColor: this.backGroundColor
  134. }, function(data) {
  135. if (data) {
  136. this.$message.success('添加关系类成功')
  137. this.refreshRelationClassList(this.$route.params.classId, data.entClsType) // 刷新关系类列表
  138. }
  139. })
  140. console.log('backGroundColor' + '1111')
  141. },
  142. /**
  143. * 实体路由跳转
  144. * @param id
  145. */
  146. handleChangeEntityRouter(id) {
  147. this.isActive = id
  148. this.$router.push({ name: 'relation_edit', params: { relationId: id }})
  149. },
  150. /**
  151. * 刷新关系类列表
  152. * @param id
  153. */
  154. refreshRelationClassList(id, entClsType) {
  155. this.spinning = true
  156. api.relationClass.getAllRelationClassList(id, entClsType).then((data) => {
  157. this.spinning = false
  158. this.relationListData = data
  159. })
  160. },
  161. /**
  162. * 修改关系类名称
  163. */
  164. handleEditRelationClassName(opt) {
  165. console.log(opt)
  166. this.$open('editRelationClassNameModal', {
  167. params: opt
  168. }, function(data) {
  169. if (data) {
  170. this.refreshRelationClassList(this.$route.params.classId, this.entClsType) // 刷新关系类列表
  171. this.$message.success('修改关系类名称成功')
  172. }
  173. })
  174. },
  175. handleTabChange(e) {
  176. switch (e.target.accessKey) {
  177. case '1':
  178. odiv.style.transform = `translate3d(5px, 0px, 0px)`,
  179. this.accesskey = '1'
  180. this.entClsType = 'START' // 以此实体类为起点
  181. this.refreshRelationClassList(this.$route.params.classId, this.entClsType)
  182. break
  183. case '2':
  184. odiv.style.transform = `translate3d(${140}px, 0px, 0px)`
  185. this.accesskey = '2'
  186. this.entClsType = 'ENT' // 以此实体类为终点
  187. this.refreshRelationClassList(this.$route.params.classId, this.entClsType)
  188. break
  189. }
  190. }
  191. }
  192. }
  193. </script>
  194. <style scoped>
  195. .eddit-box,
  196. .cancel-box { position: absolute; top: 0; width: 35px; height: 35px; text-indent: 0; text-align: center; }
  197. .cancel-box { right: 0; }
  198. .eddit-box { right: 35px; }
  199. .rela-box { display: block; width: 235px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  200. </style>