You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

adminImages.vue 17 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div>
  3. <div class="ui container" style="width: 80%;">
  4. <div class="row" style="border: 1px solid #d4d4d5;margin-top: 15px;padding-top: 0;">
  5. <div class="ui attached segment">
  6. <div class="ui form ignore-dirty">
  7. <div class="ui fluid action input">
  8. <input type="text" placeholder="搜镜像Tag/描述/标签..." v-model="search" @keyup.enter="searchName()">
  9. <button class="ui blue button" @click="searchName()">搜索</button>
  10. </div>
  11. </div>
  12. </div>
  13. <el-row style="padding: 1rem;">
  14. <el-col :span="2" style="margin-right: 1rem;">
  15. <el-checkbox v-model="checked" style="padding: 0.5rem 1rem;">仅显示平台推荐</el-checkbox>
  16. </el-col>
  17. <el-col :span="6">
  18. <el-dropdown @command="handleCommand" trigger="click" style="border: 1px solid rgba(34,36,38,.15);border-radius: 4px;padding: 0.5rem 1rem;">
  19. <span class="el-dropdown-link">
  20. {{dropdownPrivate}}<i class="el-icon-caret-bottom el-icon--right"></i>
  21. </span>
  22. <el-dropdown-menu slot="dropdown">
  23. <el-dropdown-item :command="{label:'全部',private:''}">全部</el-dropdown-item>
  24. <el-dropdown-item :command="{label:'公开',private:false}">公开</el-dropdown-item>
  25. <el-dropdown-item :command="{label:'公开',private:true}">私有</el-dropdown-item>
  26. </el-dropdown-menu>
  27. </el-dropdown>
  28. </el-col>
  29. </el-row>
  30. <el-row>
  31. <el-table
  32. :data="tableDataCustom"
  33. style="width: 100%"
  34. :header-cell-style="tableHeaderStyle"
  35. >
  36. <el-table-column
  37. label="镜像Tag"
  38. min-width="19%"
  39. align="left"
  40. prop="tag"
  41. >
  42. <template slot-scope="scope">
  43. <div style="display: flex;align-items: center;">
  44. <a class="text-over image_title" :title="scope.row.tag">{{ scope.row.tag }}</a>
  45. <i class="ri-lock-2-line" style="color: #fa8c16;padding: 0 1rem;" v-if="scope.row.isPrivate"></i>
  46. <img v-if="scope.row.type==5" src="/img/jian.svg" style="margin-left: 0.5rem;">
  47. </div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column
  51. label="镜像描述"
  52. min-width="28%"
  53. align="left"
  54. prop="description"
  55. >
  56. <template slot-scope="scope">
  57. <div class="image_desc" :title="scope.row.description">{{ scope.row.description}}</div>
  58. <div v-if="!!scope.row.topics">
  59. <span v-for="(topic,index) in scope.row.topics" class="ui repo-topic label topic" style="cursor: default;">{{topic}}</span>
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="cloudbrainType"
  65. label="可用集群"
  66. min-width="10%"
  67. align="center"
  68. >
  69. <template slot-scope="scope">
  70. {{scope.row.cloudbrainType | transformType}}
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. prop="isPrivate"
  75. label="状态"
  76. min-width="8%"
  77. align="center"
  78. >
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.isPrivate" style="color: rgb(250, 140, 22);">私有</span>
  81. <span v-else style="color: rgb(19, 194, 141);">公开</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column
  85. prop="creator"
  86. label="创建者"
  87. min-width="8%"
  88. align="center"
  89. >
  90. <template slot-scope="scope">
  91. <a :href="'/' + scope.row.userName" :title="scope.row.userName">
  92. <img :src="scope.row.relAvatarLink" class="ui avatar image">
  93. </a>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. prop="createdUnix"
  98. label="创建时间"
  99. align="center"
  100. min-width="14%"
  101. >
  102. <template slot-scope="scope">
  103. {{scope.row.createdUnix | transformTimestamp}}
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. align="center"
  108. min-width="21%"
  109. label="操作"
  110. >
  111. <template slot-scope="scope">
  112. <div style="display: flex;justify-content: flex-end;align-items: center;">
  113. <div style="display: flex;align-items: center;cursor: default;;padding: 0 1rem;">
  114. <svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke"><path d="M4.4 6.54c-1.761 1.643-2.6 3.793-2.36 6.056.24 2.263 1.507 4.521 3.663 6.534a29110.9 29110.9 0 0010.296 9.633l10.297-9.633c2.157-2.013 3.424-4.273 3.664-6.536.24-2.264-.599-4.412-2.36-6.056-1.73-1.613-3.84-2.29-6.097-1.955-1.689.25-3.454 1.078-5.105 2.394l-.4.319-.398-.319c-1.649-1.316-3.414-2.143-5.105-2.394a7.612 7.612 0 00-1.113-.081c-1.838 0-3.541.694-4.983 2.038z"></path></svg>
  115. <span style="line-height: 2;margin-left:0.3rem;">{{scope.row.numStars}}</span>
  116. </div>
  117. <template v-if="!scope.row.isPrivate">
  118. <span style="padding: 0 1rem;color: rgb(250, 140, 22);cursor:pointer;" v-if="scope.row.type==5" @click="unSetRecommend(scope.$index,scope.row.id)">取消推荐</span>
  119. <span style="padding: 0 1rem;color: rgb(19, 194, 141);cursor:pointer;" v-else @click="setRecommend(scope.$index,scope.row.id)">设为推荐</span>
  120. </template>
  121. <span style="padding: 0 1rem;color:#0366d6;cursor:pointer;" @click="copyUrl(scope.row.place)">复制地址</span>
  122. <div style="padding-left:1rem;cursor:pointer;">
  123. <el-dropdown size="medium">
  124. <span class="el-dropdown-link">
  125. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  126. </span>
  127. <el-dropdown-menu slot="dropdown">
  128. <el-dropdown-item @click.native="eidtImage(scope.row.id)">编辑</el-dropdown-item>
  129. <el-dropdown-item style="color: red;" @click.native="deleteImage(scope.row.id)">删除</el-dropdown-item>
  130. </el-dropdown-menu>
  131. </el-dropdown>
  132. </div>
  133. </div>
  134. </template>
  135. </el-table-column>
  136. </el-table>
  137. </el-row>
  138. <div class="ui container" style="padding:2rem 0;text-align:center">
  139. <el-pagination
  140. background
  141. @size-change="handleSizeChangeCustom"
  142. @current-change="handleCurrentChangeCustom"
  143. :current-page="currentPageCustom"
  144. :page-size="pageSizeCustom"
  145. :page-sizes="[5,15,20]"
  146. layout="total, sizes, prev, pager, next, jumper"
  147. :total="totalNumCustom">
  148. </el-pagination>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </template>
  154. <script>
  155. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  156. export default {
  157. components: {
  158. },
  159. data() {
  160. return {
  161. search:'',
  162. dropdownPrivate:'全部',
  163. checked:false,
  164. currentPageCustom:1,
  165. pageSizeCustom:15,
  166. totalNumCustom:0,
  167. paramsCustom:{page:1,pageSize:15,q:'',recommend:false},
  168. tableDataCustom: [],
  169. starCustom:[],
  170. loadingCustom:false,
  171. };
  172. },
  173. methods: {
  174. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  175. if(rowIndex===0){
  176. return 'background:#f5f5f6;color:#606266'
  177. }
  178. },
  179. handleSizeChangeCustom(val){
  180. this.paramsCustom.pageSize = val
  181. this.getImageListCustom()
  182. },
  183. handleCurrentChangeCustom(val){
  184. this.paramsCustom.page = val
  185. this.getImageListCustom()
  186. },
  187. getImageListCustom(){
  188. this.loadingCustom = true
  189. this.$axios.get('/admin/images/data',{
  190. params:this.paramsCustom
  191. }).then((res)=>{
  192. console.log("res",res)
  193. this.totalNumCustom = res.data.count
  194. this.tableDataCustom = res.data.images
  195. this.tableDataCustom.forEach(element => {
  196. this.starCustom.push({id:element.id,})
  197. });
  198. this.loadingCustom = false
  199. })
  200. },
  201. deleteImage(id){
  202. console.log("deleteImage")
  203. let flag=1
  204. let _this = this
  205. $('.ui.basic.modal.images')
  206. .modal({
  207. onDeny: function() {
  208. flag = false
  209. },
  210. onApprove: function() {
  211. _this.$axios.delete('/image/'+id).then((res)=>{
  212. console.log(res)
  213. _this.getImageListCustom()
  214. })
  215. flag = true
  216. },
  217. onHidden: function() {
  218. if (flag == false) {
  219. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  220. }else{
  221. $('.alert').html('删除成功').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  222. }
  223. }
  224. })
  225. .modal('show')
  226. },
  227. eidtImage(id){
  228. location.href = `/image/${id}/imageAdmin`
  229. },
  230. imageStar(index,id,isStar){
  231. if(isStar){
  232. this.$axios.put(`/image/${id}/action/unstar`).then((res)=>{
  233. console.log(res)
  234. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars - 1
  235. this.tableDataPublic[index].isStar = false
  236. })
  237. }else{
  238. this.$axios.put(`/image/${id}/action/star`).then((res)=>{
  239. console.log(res)
  240. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars + 1
  241. this.tableDataPublic[index].isStar = true
  242. })
  243. }
  244. },
  245. copyUrl(url){
  246. const cInput = document.createElement('input')
  247. cInput.value = url
  248. document.body.appendChild(cInput)
  249. cInput.select()
  250. document.execCommand('Copy')
  251. cInput.remove()
  252. },
  253. searchName(){
  254. this.paramsCustom.q = this.search
  255. this.paramsCustom.page = 1
  256. this.getImageListCustom()
  257. },
  258. setRecommend(index,id){
  259. this.$axios.put(`/admin/image/${id}/action/recommend`).then((res)=>{
  260. console.log(res)
  261. this.tableDataCustom[index].type = 5
  262. })
  263. },
  264. unSetRecommend(index,id){
  265. this.$axios.put(`/admin/image/${id}/action/unrecommend`).then((res)=>{
  266. console.log(res)
  267. this.tableDataCustom[index].type = 0
  268. })
  269. },
  270. handleCommand(command){
  271. console.log(command)
  272. this.dropdownPrivate = command.label
  273. this.paramsCustom.private = command.private
  274. this.getImageListCustom()
  275. }
  276. },
  277. filters:{
  278. transformType(val){
  279. if(val==0){
  280. return "GPU"
  281. }
  282. },
  283. transformPravite(val){
  284. if(val){
  285. return "私有"
  286. }else{
  287. return "公开"
  288. }
  289. },
  290. transformTimestamp(timestamp){
  291. // let a = new Date(timestamp).getTime();
  292. const date = new Date(parseInt(timestamp) * 1000);
  293. const Y = date.getFullYear() + '-';
  294. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  295. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  296. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  297. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()) + ':' ;
  298. const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  299. const dateString = Y + M + D + h + m + s;
  300. // console.log('dateString', dateString); // > dateString 2021-07-06 14:23
  301. return dateString;
  302. },
  303. },
  304. watch:{
  305. search(val){
  306. this.paramsCustom.q = val
  307. this.getImageListCustom()
  308. },
  309. checked(val){
  310. this.paramsCustom.recommend = val
  311. this.getImageListCustom()
  312. }
  313. },
  314. mounted() {
  315. this.getImageListCustom()
  316. },
  317. created() {
  318. }
  319. };
  320. </script>
  321. <style scoped>
  322. .header-wrapper {
  323. background-color: #f5f5f6;
  324. padding-top: 15px;
  325. }
  326. .image_text{
  327. padding:25px 0 55px 0 ;
  328. }
  329. #header{
  330. position: relative;
  331. top:-40px;
  332. }
  333. .el-dropdown-menu__item--divided{
  334. border-top: 1px solid blue;
  335. }
  336. .el-table thead{
  337. background-color: #f5f5f6;
  338. }
  339. /deep/ .el-tabs__item:hover{
  340. color: #000;
  341. font-weight: 500;
  342. }
  343. /deep/ .el-tabs__item.is-active {
  344. color: #000;
  345. font-weight: 500;
  346. }
  347. /deep/ .el-tabs__active-bar{
  348. background-color:#000
  349. }
  350. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  351. background-color: #5bb973;
  352. color: #FFF;
  353. }
  354. /deep/ .el-pagination.is-background .el-pager li.active {
  355. color: #fff;
  356. cursor: default;
  357. }
  358. /deep/ .el-pagination.is-background .el-pager li:hover {
  359. color: #5bb973;
  360. }
  361. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  362. color: #5bb973;
  363. }
  364. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  365. background-color: #5bb973;
  366. color: #FFF;
  367. }
  368. /deep/ .el-pager li.active {
  369. color: #08C0B9;
  370. cursor: default;
  371. }
  372. /deep/ .el-pagination .el-pager li:hover {
  373. color: #08C0B9;
  374. }
  375. /deep/ .el-pagination .el-pager li:not(.disabled):hover {
  376. color: #08C0B9;
  377. }
  378. /deep/ .el-icon--right{
  379. margin-left: 1.5rem;
  380. }
  381. /* /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{
  382. background-color: #5bb973;
  383. color: #000;
  384. } */
  385. /* /deep/ .el-pager li:hover{
  386. color: #000;
  387. } */
  388. #success{
  389. background-color: #5bb973;
  390. color: white;
  391. }
  392. .text-over{
  393. overflow: hidden;
  394. text-overflow: ellipsis;
  395. vertical-align: middle;
  396. white-space: nowrap;
  397. }
  398. .image_title{
  399. display: inline-block;
  400. cursor: default;
  401. color: rgb(66, 98, 144);
  402. }
  403. .image_desc{
  404. -webkit-line-clamp: 2;
  405. -webkit-box-orient: vertical;
  406. display: -webkit-box;
  407. text-overflow: ellipsis;
  408. overflow: hidden;
  409. }
  410. .heart-stroke{
  411. stroke: #FA8C16;
  412. stroke-width: 2;
  413. fill: #fff
  414. }
  415. .stars_active{
  416. fill: #FA8C16 !important;
  417. stroke:#FA8C16 !important
  418. }
  419. .header-new-drop{
  420. width: 100%;
  421. }
  422. </style>