index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="project-box">
  3. <el-row style="padding-bottom: 16px">
  4. <el-input placeholder="请输入关键字" style="width: 240px" clearable @keyup.enter.native="ChangeKeyWord(keyWord)" v-model="keyWord">
  5. <i slot="prefix" class="el-input__icon el-icon-search" style="cursor: pointer" @click="ChangeKeyWord(keyWord)"></i>
  6. </el-input>
  7. <el-button style="float: right" @click="addProject">添加项目</el-button>
  8. </el-row>
  9. <div class="saga-brand-group">
  10. <el-row :gutter="16">
  11. <el-col :span="6" v-for="item in projectList" :key="item.id">
  12. <el-card shadow="always" class="project-card" :body-style="{ padding: '0px' }">
  13. <el-image style="width: 100%; height: 187px" :src="item | getImage">
  14. <div slot="error" class="image-slot">
  15. <i class="iconfont icon-wandajituan"></i>
  16. </div>
  17. </el-image>
  18. <div style="padding: 16px">
  19. <span class="project-name" :title="item.localName">{{ item.localName }}</span>
  20. <span class="iconfont icon-shanchu" @click="deleteProject(item)"></span>
  21. <span class="iconfont icon-bianji" @click="updateProject(item)"></span>
  22. </div>
  23. </el-card>
  24. </el-col>
  25. </el-row>
  26. </div>
  27. <!-- 新增项目 -->
  28. <add-project-dialog
  29. :addProjectVisible.sync="addProjectVisible"
  30. @update:projectList="ChangeKeyWord"
  31. :dialogType="dialogType"
  32. :formData="form"
  33. ></add-project-dialog>
  34. </div>
  35. </template>
  36. <script lang="ts">
  37. import { Component, Vue } from "vue-property-decorator";
  38. import { UserModule } from "../../store/modules/user";
  39. import { projectQuery } from "@/api/datacenter";
  40. import { imageGetUrl } from "@/api/imageservice";
  41. import AddProjectDialog from "./components/AddProjectDialog/index.vue"; //新增项目弹窗
  42. @Component({
  43. name: "index",
  44. components: {
  45. AddProjectDialog,
  46. },
  47. filters: {
  48. getImage(item: any) {
  49. if (item?.infos?.projPic?.[0]?.key) {
  50. return `${imageGetUrl}${item.infos.projPic[0].key}`;
  51. } else {
  52. return "";
  53. }
  54. },
  55. },
  56. })
  57. export default class extends Vue {
  58. private keyWord = "";
  59. private projectList: any = [];
  60. private addProjectVisible = false;
  61. private dialogType = "create";
  62. private form: any = {};
  63. get projectId() {
  64. return UserModule.projectId;
  65. }
  66. /**
  67. * 检索项目
  68. * @param 检索关键字
  69. */
  70. private async ChangeKeyWord(keyWord?: string) {
  71. const params: any = {
  72. pageNumber: 1,
  73. pageSize: 2000,
  74. };
  75. if (keyWord) params.filters = `localName contain '${keyWord}'`;
  76. const res = await projectQuery(params);
  77. if (res.result === "success" && res.content.length) {
  78. this.projectList = res.content;
  79. } else {
  80. this.projectList = [];
  81. }
  82. }
  83. /**
  84. * 添加项目
  85. */
  86. private addProject() {
  87. this.dialogType = "create";
  88. this.form = {};
  89. this.addProjectVisible = true;
  90. }
  91. /**
  92. * 修改项目
  93. */
  94. private updateProject(item: any) {
  95. this.dialogType = "update";
  96. this.form = item;
  97. this.addProjectVisible = true;
  98. }
  99. /**
  100. * 删除项目
  101. */
  102. private deleteProject(item: any) {
  103. this.$message.info("删除接口暂不提供!");
  104. console.log("删除项目", item.id);
  105. }
  106. created() {
  107. this.ChangeKeyWord();
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .project-box {
  113. height: 100%;
  114. padding: 0 16px;
  115. .saga-brand-group {
  116. height: calc(100% - 48px);
  117. overflow-y: auto;
  118. overflow-x: hidden;
  119. ::v-deep .el-col {
  120. margin-bottom: 16px;
  121. }
  122. .project-card {
  123. ::v-deep .image-slot {
  124. display: flex;
  125. width: 100%;
  126. height: 100%;
  127. background-color: #075fa9;
  128. }
  129. .project-name {
  130. display: inline-block;
  131. width: calc(100% - 50px);
  132. cursor: text;
  133. overflow: hidden;
  134. text-overflow: ellipsis;
  135. white-space: nowrap;
  136. }
  137. .icon-bianji {
  138. display: none;
  139. float: right;
  140. cursor: pointer;
  141. margin-right: 12px;
  142. }
  143. .icon-shanchu {
  144. display: none;
  145. float: right;
  146. cursor: pointer;
  147. }
  148. }
  149. .project-card:hover {
  150. .icon-bianji {
  151. display: block;
  152. }
  153. .icon-shanchu {
  154. display: block;
  155. }
  156. }
  157. .saga-brand-list {
  158. display: flex;
  159. flex-direction: row;
  160. flex-wrap: wrap;
  161. justify-content: space-between;
  162. .saga-brand-item {
  163. width: 380px;
  164. height: 247px;
  165. // margin-right: 17px;
  166. margin-bottom: 16px;
  167. cursor: pointer;
  168. box-sizing: border-box;
  169. background-color: #fff;
  170. border-radius: 4px;
  171. border: 1px solid #e4e5e7;
  172. transition: all 0.1s linear 0.01s;
  173. .saga-brand-name {
  174. display: inline-block;
  175. width: 133px;
  176. height: 100%;
  177. margin-right: 5px;
  178. font-size: 14px;
  179. line-height: 22px;
  180. .saga-brand-zhName {
  181. height: 44px;
  182. display: -webkit-box;
  183. -webkit-box-orient: vertical;
  184. -webkit-line-clamp: 2;
  185. overflow: hidden;
  186. }
  187. .saga-brand-enName {
  188. color: #8d9399;
  189. margin-top: 4px;
  190. height: 22px;
  191. overflow: hidden;
  192. white-space: nowrap;
  193. text-overflow: ellipsis;
  194. }
  195. }
  196. .saga-brand-logo {
  197. width: 52px;
  198. height: 52px;
  199. display: inline-block;
  200. vertical-align: top;
  201. ::v-deep .image-slot {
  202. font-size: 30px;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. width: 100%;
  207. height: 100%;
  208. background: #f5f7fa;
  209. color: #909399;
  210. }
  211. }
  212. }
  213. .pick {
  214. width: 380px;
  215. height: 1px;
  216. }
  217. .saga-brand-item.brand-new {
  218. border: 1px solid rgba(58, 141, 222, 0.6);
  219. }
  220. .saga-brand-item:hover {
  221. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  222. transform: translate(0, -5px);
  223. }
  224. .saga-brand-item:nth-child(4n) {
  225. margin-right: 0;
  226. }
  227. }
  228. }
  229. }
  230. ::v-deep .icon-wandajituan {
  231. font-size: 60px;
  232. margin: auto;
  233. color: #ffffff;
  234. }
  235. @media screen and (max-width: 1000px) {
  236. ::v-deep .icon-wandajituan {
  237. font-size: 30px;
  238. }
  239. }
  240. </style>