index.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <el-card shadow="never">
  3. <yun-table
  4. :columns="columns"
  5. tabs="category"
  6. search="filename"
  7. toolbar="refresh,add,del,guilei"
  8. :auth="auth"
  9. :extend="extend">
  10. <template #toolbar="{tool,selections}">
  11. <el-dropdown trigger="click" v-if="tool=='guilei'">
  12. <el-button type="warning" :disabled="selections.length?false:true"><i class="fa fa-arrow-right"></i>&nbsp;归类</el-button>
  13. <template #dropdown>
  14. <el-dropdown-menu>
  15. {foreach name="categoryList" id="item"}
  16. <el-dropdown-item @click.stop="changeCategory(selections,'{$key}')"><i class="fa fa-eye"></i> {$item}</el-dropdown-item>
  17. {/foreach}
  18. </el-dropdown-menu>
  19. </template>
  20. </el-dropdown>
  21. </template>
  22. <template #formatter="{field,rows}">
  23. <div v-if="field=='filename'">
  24. <el-tooltip
  25. effect="dark"
  26. :content="rows.filename"
  27. placement="top">
  28. <el-tag style="cursor: pointer;">{{formateName(rows.filename)}}</el-tag>
  29. </el-tooltip>
  30. </div>
  31. </template>
  32. </yun-table>
  33. </el-card>
  34. </template>
  35. <script>
  36. import table from "@components/Table.js";
  37. export default{
  38. components:{'YunTable':table},
  39. data:{
  40. auth:{
  41. del:Yunqi.auth.check('app\\admin\\controller\\general\\Attachment','del'),
  42. add:Yunqi.auth.check('app\\admin\\controller\\general\\Attachment','add'),
  43. multi:Yunqi.auth.check('app\\admin\\controller\\general\\Attachment','multi'),
  44. },
  45. //列表页面
  46. extend:{
  47. index_url: 'general/attachment/index',
  48. add_url: 'general/attachment/add',
  49. del_url: 'general/attachment/del',
  50. multi_url: 'general/attachment/multi'
  51. },
  52. columns:[
  53. {checkbox: true},
  54. {field: 'id',title:'ID',operate:false,edit:'hidden'},
  55. {field: 'category', title: __('类别'),visible:false,operate: false, formatter: Yunqi.formatter.tag, searchList:Yunqi.data.categoryList},
  56. {field: 'admin_id', title: __('管理员ID'), visible: false,operate:false},
  57. {field: 'user_id', title: __('会员ID'), visible: false,operate:false},
  58. {field: 'thumburl', title: __('缩略图'), operate: false,formatter: Yunqi.formatter.image},
  59. {field: 'filename', title: __('文件名'),align:'left',operate: 'like',formatter: Yunqi.formatter.slot},
  60. {field: 'fullurl', title: __('源文件'),align:'left',operate: false,formatter: Yunqi.formatter.link},
  61. {
  62. field: 'filesize', title: __('文件大小'),operate: false, sortable: true, formatter: function (value, row) {
  63. var size = parseFloat(value);
  64. var i = Math.floor(Math.log(size) / Math.log(1024));
  65. return (size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
  66. }
  67. },
  68. {field: 'is_image', title: __('图片'), operate: false,searchList: {1: __('是'), 0: __('否')},formatter: function(data,row){
  69. let tag=Yunqi.formatter.tag;
  70. if(row.is_image){
  71. tag.value='是';
  72. tag.type='success';
  73. }else{
  74. tag.value='否';
  75. tag.type='danger';
  76. }
  77. return tag;
  78. }},
  79. {field: 'imagetype', title: __('图片类型'), operate: false},
  80. {field: 'imagewidth', title: __('宽度'), operate: false},
  81. {field: 'imageheight', title: __('高度'), operate: false},
  82. {field: 'storage', title: __('存储方式'), operate: false,searchList: Yunqi.data.disksList,formatter: Yunqi.formatter.tag},
  83. {
  84. field: 'createtime',
  85. title: __('创建时间'),
  86. formatter: Yunqi.formatter.datetime,
  87. operate: {form:'date-picker',type:'daterange'},
  88. sortable: true
  89. },
  90. {
  91. field: 'operate',
  92. fixed: 'right',
  93. title: __('操作'),
  94. width:50,
  95. action:{
  96. del:true
  97. }
  98. }
  99. ]
  100. },
  101. methods: {
  102. changeCategory:function (selections,key){
  103. if(selections.length==0){
  104. return;
  105. }
  106. let ids=[];
  107. selections.forEach(res=>{
  108. ids.push(res.id);
  109. });
  110. Yunqi.api.multi(this.extend.multi_url,{ids:ids,field:'category',value:key},function(){
  111. location.reload();
  112. });
  113. },
  114. formateName:function (data){
  115. //获取data的后缀名
  116. let ext=data.substring(data.lastIndexOf('.')+1);
  117. let name=data.substring(0,data.lastIndexOf('.'));
  118. if(name.length>8){
  119. //取末尾5个字符
  120. return name.substring(0,3)+'...'+name.substring(name.length-5)+'.'+ext;
  121. }
  122. return data;
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. </style>