topoImageCard.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <!--拓扑图缩略图卡片-->
  2. <template>
  3. <el-card :class="{'box-card': true, 'active': data.checked}" shadow="hover" :body-style="{ padding: '0px' }">
  4. <div class="image" v-if="!data.pic" style="line-height: 120px;text-align: center;">
  5. <img :src="require('@/assets/images/noImg.png')" style="height:60px;">
  6. </div>
  7. <img class="image" v-else :src="`${imgBaseUrl}${data.pic}`">
  8. <div class="shadow image" v-if="!isRecycle" @click.stop="toEdit">
  9. <el-checkbox v-model="data.checked" class="shadowCheck" @change="changeCheck"></el-checkbox>
  10. </div>
  11. <div class="content">
  12. <div>
  13. <span class="title" :title="data.name">{{data.name}}</span>
  14. <div class="func">
  15. <el-popover placement="top" width="200" trigger="hover" popper-class="customPop">
  16. <p>版本 : {{data.version}}</p>
  17. <p>更新时间 : {{data.lastUpdate}}</p>
  18. <!-- <p>更新人 : {{data.putUser || '张三'}}</p> -->
  19. <span slot="reference"><img :src="require('@/assets/images/tips.png')" style="width: 20px;height:20px" /></span>
  20. </el-popover>
  21. <el-dropdown :hide-on-click="false" placement="bottom-start" trigger="click" @command="handleCommand">
  22. <span class="el-dropdown-link">
  23. <img :src="require('@/assets/images/more.png')" style="width: 20px;height:20px" />
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <template v-for="t in moreList">
  27. <el-dropdown-item :key="t.name" :command="t.name" v-if="dropdownItemShow(t)">{{t.label}}</el-dropdown-item>
  28. </template>
  29. </el-dropdown-menu>
  30. </el-dropdown>
  31. </div>
  32. </div>
  33. <div class="tags">
  34. <span v-for="(t,i) in data.label" :key="data.name + i">{{t}}</span>
  35. </div>
  36. </div>
  37. </el-card>
  38. </template>
  39. <script>
  40. const imgBaseUrl = window.__systemConf.imgServeUri
  41. import { publishGraph } from "@/api/home"
  42. export default {
  43. props: {
  44. data: {
  45. type: Object,
  46. default: () => {
  47. return {}
  48. }
  49. },
  50. isRecycle: {
  51. type: Boolean,
  52. default: false
  53. },
  54. isPub: {
  55. type: Number,
  56. default: 0
  57. }
  58. },
  59. data() {
  60. return {
  61. moreList: [
  62. { name: 'rename', label: '重命名', show: 'any' }, // 类型为 未发布/已发布 时出现
  63. { name: 'publish', label: '发布', show: 0 }, // 类型为 未发布 时出现
  64. { name: 'download', label: '下载', show: 1 }, // 类型为 已发布 时出现
  65. { name: 'editTag', label: '修改标签', show: 1 }, // 类型为 已发布 时出现
  66. { name: 'moveTo', label: '移动到', show: 'any' }, // 类型为 未发布/已发布 时出现
  67. { name: 'delete', label: '删除', show: 'any' }, // 类型为 未发布/已发布 时出现
  68. { name: 'recover', label: '恢复', show: 'isRecycle' }, // 类型为 回收站 时出现
  69. { name: 'deleteRecycle', label: '永久删除', show: 'isRecycle' }, // 类型为 回收站 时出现
  70. ],
  71. checked: false,
  72. imgBaseUrl,
  73. };
  74. },
  75. methods: {
  76. // 显示下拉框内容选项判断
  77. dropdownItemShow(item) {
  78. return (!this.isRecycle && (item.show == 'any' || item.show == this.isPub)) || (this.isRecycle && item.show == "isRecycle")
  79. },
  80. // 复选框改变时
  81. changeCheck() {
  82. this.$emit('changeCheck', this.data);
  83. },
  84. // 点击更多中的命令时
  85. handleCommand(command) {
  86. const pa = {
  87. graphId: this.data.graphId,
  88. id: this.data.id
  89. };
  90. switch (command) {
  91. case "rename":
  92. case "download":
  93. case "editTag":
  94. case "moveTo":
  95. case "delete":
  96. case "recover":
  97. case "deleteRecycle":
  98. this.$emit(command, this.data)
  99. break;
  100. case "publish":
  101. publishGraph(pa).then(res => {
  102. if (res.result == "success") {
  103. this.$message.success("发布成功");
  104. this.$emit('publishSuc')
  105. } else {
  106. this.$message.success("发布失败");
  107. }
  108. });
  109. break;
  110. }
  111. },
  112. // 进入编辑页面
  113. toEdit(e) {
  114. const targetName = e.target.nodeName.toLowerCase();
  115. if (targetName == 'div') {
  116. this.$emit("toEdit", this.data)
  117. }
  118. }
  119. },
  120. };
  121. </script>
  122. <style lang="less" scoped>
  123. .box-card {
  124. position: relative;
  125. width: 260px;
  126. height: 193px;
  127. border-radius: 8px;
  128. margin-right: 20px;
  129. margin-bottom: 20px;
  130. cursor: pointer;
  131. &:hover,
  132. &.active {
  133. border-color: #0091ff80;
  134. box-shadow: 0px 8px 16px 0px rgba(195, 199, 203, 0.4);
  135. .shadow {
  136. display: block;
  137. }
  138. .content {
  139. .func {
  140. display: block;
  141. }
  142. }
  143. }
  144. .image {
  145. display: block;
  146. width: 100%;
  147. height: 120px;
  148. background-color: #f7f9fa;
  149. }
  150. .shadow {
  151. display: none;
  152. position: absolute;
  153. top: 0;
  154. left: 0;
  155. background-color: #8d939926;
  156. .shadowCheck {
  157. position: absolute;
  158. top: 8px;
  159. left: 12px;
  160. }
  161. }
  162. .content {
  163. padding: 8px 12px;
  164. vertical-align: middle;
  165. .title {
  166. display: inline-block;
  167. color: #1f2429;
  168. margin: 0;
  169. max-width: 182px;
  170. white-space: nowrap;
  171. overflow: hidden;
  172. text-overflow: ellipsis;
  173. }
  174. .func {
  175. & > * + * {
  176. margin-left: 8px;
  177. }
  178. display: none;
  179. float: right;
  180. vertical-align: middle;
  181. i {
  182. font-size: 20px;
  183. }
  184. }
  185. .tags {
  186. margin-top: 4px;
  187. span {
  188. display: inline-block;
  189. padding: 1px 6px;
  190. font-size: 12px;
  191. color: #8d9399;
  192. line-height: 18px;
  193. border: 1px solid #8d9399;
  194. border-radius: 3px;
  195. margin-bottom: 11px;
  196. & + span {
  197. margin-left: 4px;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. .customPop {
  204. p {
  205. font-size: 12px;
  206. & + p {
  207. margin-top: 10px;
  208. }
  209. }
  210. }
  211. </style>