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 15 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
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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="7%"
  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="13%"
  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="23%"
  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. this.totalNumCustom = res.data.count
  193. this.tableDataCustom = res.data.images
  194. this.tableDataCustom.forEach(element => {
  195. this.starCustom.push({id:element.id,})
  196. });
  197. this.loadingCustom = false
  198. })
  199. },
  200. deleteImage(id){
  201. let flag=1
  202. let _this = this
  203. $('.ui.basic.modal.images')
  204. .modal({
  205. onDeny: function() {
  206. flag = false
  207. },
  208. onApprove: function() {
  209. _this.$axios.delete('/image/'+id).then((res)=>{
  210. _this.getImageListCustom()
  211. })
  212. flag = true
  213. },
  214. onHidden: function() {
  215. if (flag == false) {
  216. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  217. }else{
  218. $('.alert').html('删除成功').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  219. }
  220. }
  221. })
  222. .modal('show')
  223. },
  224. eidtImage(id){
  225. location.href = `/image/${id}/imageAdmin`
  226. },
  227. imageStar(index,id,isStar){
  228. if(isStar){
  229. this.$axios.put(`/image/${id}/action/unstar`).then((res)=>{
  230. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars - 1
  231. this.tableDataPublic[index].isStar = false
  232. })
  233. }else{
  234. this.$axios.put(`/image/${id}/action/star`).then((res)=>{
  235. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars + 1
  236. this.tableDataPublic[index].isStar = true
  237. })
  238. }
  239. },
  240. copyUrl(url){
  241. const cInput = document.createElement('input')
  242. cInput.value = url
  243. document.body.appendChild(cInput)
  244. cInput.select()
  245. document.execCommand('Copy')
  246. cInput.remove()
  247. },
  248. searchName(){
  249. this.paramsCustom.q = this.search
  250. this.paramsCustom.page = 1
  251. this.getImageListCustom()
  252. },
  253. setRecommend(index,id){
  254. this.$axios.put(`/admin/image/${id}/action/recommend`).then((res)=>{
  255. this.tableDataCustom[index].type = 5
  256. })
  257. },
  258. unSetRecommend(index,id){
  259. this.$axios.put(`/admin/image/${id}/action/unrecommend`).then((res)=>{
  260. this.tableDataCustom[index].type = 0
  261. })
  262. },
  263. handleCommand(command){
  264. this.dropdownPrivate = command.label
  265. this.paramsCustom.private = command.private
  266. this.getImageListCustom()
  267. }
  268. },
  269. filters:{
  270. transformType(val){
  271. if(val==0){
  272. return "GPU"
  273. }
  274. },
  275. transformPravite(val){
  276. if(val){
  277. return "私有"
  278. }else{
  279. return "公开"
  280. }
  281. },
  282. transformTimestamp(timestamp){
  283. const date = new Date(parseInt(timestamp) * 1000);
  284. const Y = date.getFullYear() + '-';
  285. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  286. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  287. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  288. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()) + ':' ;
  289. const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  290. const dateString = Y + M + D + h + m + s;
  291. return dateString;
  292. },
  293. },
  294. watch:{
  295. checked(val){
  296. this.paramsCustom.page = 1
  297. this.paramsCustom.recommend = val
  298. this.getImageListCustom()
  299. }
  300. },
  301. mounted() {
  302. this.getImageListCustom()
  303. },
  304. created() {
  305. }
  306. };
  307. </script>
  308. <style scoped>
  309. .header-wrapper {
  310. background-color: #f5f5f6;
  311. padding-top: 15px;
  312. }
  313. .image_text{
  314. padding:25px 0 55px 0 ;
  315. }
  316. #header{
  317. position: relative;
  318. top:-40px;
  319. }
  320. .el-dropdown-menu__item--divided{
  321. border-top: 1px solid blue;
  322. }
  323. .el-table thead{
  324. background-color: #f5f5f6;
  325. }
  326. /deep/ .el-tabs__item:hover{
  327. color: #000;
  328. font-weight: 500;
  329. }
  330. /deep/ .el-tabs__item.is-active {
  331. color: #000;
  332. font-weight: 500;
  333. }
  334. /deep/ .el-tabs__active-bar{
  335. background-color:#000
  336. }
  337. #success{
  338. background-color: #5bb973;
  339. color: white;
  340. }
  341. .text-over{
  342. overflow: hidden;
  343. text-overflow: ellipsis;
  344. vertical-align: middle;
  345. white-space: nowrap;
  346. }
  347. .image_title{
  348. display: inline-block;
  349. cursor: default;
  350. color: rgb(66, 98, 144);
  351. }
  352. .image_desc{
  353. -webkit-line-clamp: 2;
  354. -webkit-box-orient: vertical;
  355. display: -webkit-box;
  356. text-overflow: ellipsis;
  357. overflow: hidden;
  358. }
  359. .heart-stroke{
  360. stroke: #FA8C16;
  361. stroke-width: 2;
  362. fill: #fff
  363. }
  364. .stars_active{
  365. fill: #FA8C16 !important;
  366. stroke:#FA8C16 !important
  367. }
  368. .header-new-drop{
  369. width: 100%;
  370. }
  371. </style>