MyJoin.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div v-if="!showEdit">
  3. <div class="bigBox">
  4. <!-- 功能 -->
  5. <div class="tabBox">
  6. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" tab-position="top">
  7. <el-tab-pane label="我发起的" name="first">
  8. <div>
  9. <!-- <el-button @click="newFileAdd">新建文件</el-button> -->
  10. </div>
  11. <div>
  12. <el-table :data="myEjoy" style="width: 100%;cursor: pointer;" @row-click="rowClickFN">
  13. <!-- <el-table-column type="selection" width="55" /> -->
  14. <el-table-column label="名称" width="200">
  15. <template #default="scope">
  16. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="juzhong">
  17. <el-icon v-if="collectImg" class="juli">
  18. <Star />
  19. </el-icon>
  20. <img v-else src="../../assets/images/yellowstar.png" alt="" class="juli">
  21. <img :src="getImage(scope.row.fileType)" alt="" class="juli">
  22. <span>{{ scope.row.fileName }}</span>
  23. </span>
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="createTime" label="时间" sortable width="180" />
  27. <el-table-column prop="fileType" label="类型" />
  28. <el-table-column label="大小">
  29. <template #default="scope">
  30. <span>
  31. {{ formatFileSize(scope.row.fileSize) }}
  32. </span>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. </el-tab-pane>
  38. <el-tab-pane label="我参与的" name="second">
  39. <el-table :data="myPack" style="width: 100%;cursor: pointer;" @row-click="rowClickFN">
  40. <!-- <el-table-column type="selection" width="55" /> -->
  41. <el-table-column label="名称" width="200">
  42. <template #default="scope">
  43. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="juzhong">
  44. <el-icon v-if="collectImg" class="juli">
  45. <Star />
  46. </el-icon>
  47. <img v-else src="../../assets/images/yellowstar.png" alt="" class="juli">
  48. <img :src="getImage(scope.row.fileType)" alt="" class="juli">
  49. <span>{{ scope.row.fileName }}</span>
  50. </span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="createTime" label="时间" sortable width="180" />
  54. <el-table-column prop="fileType" label="类型" />
  55. <el-table-column label="大小">
  56. <template #default="scope">
  57. <span>
  58. {{ formatFileSize(scope.row.fileSize) }}
  59. </span>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. </el-tab-pane>
  64. </el-tabs>
  65. </div>
  66. <!-- 新增文件盒子 -->
  67. <div>
  68. <AddFile v-if="newAdd" :newAdd="newAdd" @threeBe="threeBe"></AddFile>
  69. </div>
  70. </div>
  71. </div>
  72. <div v-else class="preview">
  73. <FileEdit
  74. :docId="clickRowId"
  75. :copyRow="copyRow"
  76. :historyPrew="historyPrew"
  77. :historycopyRow="historycopyRow"
  78. :onlyView="onlyView"
  79. ></FileEdit>
  80. </div>
  81. </template>
  82. <script>
  83. import { ref, onMounted ,inject} from 'vue'
  84. import fileCount from '../../api/fileCount/fileCount';
  85. import ImgFile from '../myfile/jsComponents/ImgFile';
  86. import { toRaw } from "@vue/reactivity";
  87. import AddFile from './components/AddFile.vue'
  88. import FileEdit from "@/views/myfile/components/FileEdit.vue";
  89. import { ElMessage } from 'element-plus';
  90. export default {
  91. setup() {
  92. const activeName = ref('first')
  93. let collectImg = ref(true)
  94. let myEjoy = ref([])
  95. let myPack = ref([])
  96. let newAdd = ref(false)
  97. const historycopyRow = ref(false);
  98. const historyPrew = ref();
  99. const clickRowId = ref();
  100. const copyRow = ref();
  101. const onlyView = ref(false);
  102. const showEdit = ref(false)
  103. const thisLClickRow = ref()//当前左键的文件
  104. const addFileTab = inject("addFileTab");
  105. const rowClickFN = (row,col,e)=>{
  106. console.log('row',row);
  107. thisLClickRow.value = row
  108. clickRowId.value = row.docId
  109. copyRow.value = toRaw(row)
  110. addFileTab(copyRow.value,1);
  111. // showEdit.value = true
  112. }
  113. function getCountPeople() {
  114. fileCount.myCount({}).then(res => {
  115. myEjoy.value = res.rows
  116. })
  117. }
  118. function getMyJoin() {
  119. fileCount.myJoin({}).then(res => {
  120. myPack.value = res.rows
  121. })
  122. }
  123. function handleClick(data, e) {
  124. console.log(data, e, 'tab');
  125. }
  126. function getImage(file) {
  127. if (file === '.txt') {
  128. return ImgFile.txt
  129. } else if (file === '.xlxs' || file === '.docx') {
  130. return ImgFile.xlxs
  131. } else if (file === '.pptx') {
  132. return ImgFile.pptx
  133. } else if (file === '.word') {
  134. return ImgFile.word
  135. } else if (file === '.pdf') {
  136. return ImgFile.pdf
  137. }
  138. }
  139. function formatFileSize(fileSize) {
  140. if (fileSize >= 1024 * 1024 * 1024) {
  141. // 大于等于1GB,显示GB
  142. return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
  143. } else if (fileSize >= 1024 * 1024) {
  144. // 大于等于1MB,显示MB
  145. return (fileSize / (1024 * 1024)).toFixed(2) + 'MB';
  146. } else if (fileSize >= 1024) {
  147. // 大于等于1KB,显示KB
  148. return (fileSize / 1024).toFixed(2) + 'KB';
  149. } else {
  150. // 小于1KB,显示字节
  151. return fileSize + 'B';
  152. }
  153. }
  154. function newFileAdd(){
  155. newAdd.value = true
  156. }
  157. function threeBe(data){
  158. newAdd.value = data
  159. }
  160. onMounted(() => {
  161. getCountPeople()
  162. getMyJoin()
  163. })
  164. return {
  165. activeName,
  166. handleClick,
  167. myEjoy,
  168. myPack,
  169. getCountPeople,
  170. getMyJoin,
  171. collectImg,
  172. getImage,
  173. formatFileSize,
  174. newAdd,
  175. newFileAdd,
  176. threeBe,
  177. historycopyRow,
  178. historyPrew,
  179. onlyView,
  180. rowClickFN,
  181. thisLClickRow,
  182. copyRow,
  183. clickRowId,
  184. showEdit,
  185. addFileTab
  186. }
  187. },
  188. components:{
  189. AddFile,
  190. FileEdit
  191. }
  192. }
  193. </script>
  194. <style scoped lang="scss">
  195. @import "@/assets/styles/my-common.scss";
  196. .bigBox {
  197. width: 100%;
  198. height: 88vh;
  199. margin: 0 auto;
  200. background-color: white;
  201. }
  202. .tabBox {
  203. width: 100%;
  204. height: 40px;
  205. margin: 0 auto;
  206. background-color: #F5F7F9;
  207. }
  208. .preview {
  209. width: 100%;
  210. height: 100%;
  211. background-color: #fff;
  212. overflow: hidden;
  213. }
  214. :deep(.el-tabs__nav) {
  215. margin: 0 calc(100% - 55%);
  216. }
  217. </style>