MyJoin.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div class="bigBox">
  3. <!-- 功能 -->
  4. <div class="tabBox">
  5. <el-tabs v-model="activeName" v-el-table-infinite-scroll="setPackScroll" :infinite-scroll-distance="30" :infinite-scroll-disabled="packTotal" class="demo-tabs" @tab-click="handleClick" tab-position="top">
  6. <el-tab-pane label="我发起的" name="first" style="min-height:300px">
  7. <div>
  8. <!-- <el-button @click="newFileAdd">新建文件</el-button> -->
  9. </div>
  10. <div>
  11. <el-table @row-contextmenu="handleRowClick" height="calc(100vh - 40px - 15px)" :data="myPack" style="width: 100%;cursor: pointer;" @row-click="rowJoinClickFN">
  12. <!-- <el-table-column type="selection" width="55" /> -->
  13. <el-table-column label="名称" width="280">
  14. <template #default="scope">
  15. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="juzhong">
  16. <img :src="getImage(scope.row.fileType)" alt="" class="juli">
  17. <el-tooltip class="box-item" effect="dark" placement="top"
  18. :show-after="1000" :content="scope.row.fileName">
  19. <span>{{ scope.row.fileName }}</span>
  20. </el-tooltip>
  21. </span>
  22. </template>
  23. </el-table-column>
  24. <el-table-column prop="createTime" label="时间" sortable width="280" />
  25. <el-table-column prop="fileType" label="类型" />
  26. <el-table-column label="大小">
  27. <template #default="scope">
  28. <span>
  29. {{ formatFileSize(scope.row.fileSize) }}
  30. </span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="是否归档">
  34. <template #default="scope">
  35. <span>
  36. {{ scope.row.isFiled === "Y"?'已归档':'未归档' }}
  37. </span>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. <div class="setCli" v-if="cliCC" :style="{ left: xz - 100+ 'px', top: yz -150 + 'px' }">
  42. <template v-for="(item, index) in rightMenuData" :key="index">
  43. <p @click="chooseSet(item, index, 1)" class="chooseSet">
  44. <img :src="item.img" alt="">
  45. {{ item.name }}
  46. </p>
  47. </template>
  48. </div>
  49. </div>
  50. </el-tab-pane>
  51. <el-tab-pane label="我参与的" name="second">
  52. <el-table :data="myEjoy" style="width: 100%;cursor: pointer;" @row-click="rowJoinClickFN">
  53. <!-- <el-table-column type="selection" width="55" /> -->
  54. <el-table-column label="名称" width="280">
  55. <template #default="scope">
  56. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="juzhong">
  57. <img :src="getImage(scope.row.fileType)" alt="" class="juli">
  58. <el-tooltip class="box-item" effect="dark" placement="top"
  59. :show-after="1000" :content="scope.row.fileName">
  60. <span>{{ scope.row.fileName }}</span>
  61. </el-tooltip>
  62. </span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="createTime" label="时间" sortable width="280" />
  66. <el-table-column prop="fileType" label="类型" />
  67. <el-table-column label="大小">
  68. <template #default="scope">
  69. <span>
  70. {{ formatFileSize(scope.row.fileSize) }}
  71. </span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="是否归档">
  75. <template #default="scope">
  76. <span>
  77. {{ scope.row.isFiled === "Y"?'已归档':'未归档' }}
  78. </span>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. </el-tab-pane>
  83. </el-tabs>
  84. </div>
  85. <!-- 新增文件盒子 -->
  86. <div>
  87. <AddFile v-if="newAdd" :newAdd="newAdd" @threeBe="threeBe"></AddFile>
  88. </div>
  89. </div>
  90. </template>
  91. <script>
  92. import { ref, onMounted ,inject} from 'vue'
  93. import fileCount from '../../api/fileCount/fileCount';
  94. import ImgFile from '../myfile/jsComponents/ImgFile';
  95. import { toRaw } from "@vue/reactivity";
  96. import AddFile from './components/AddFile.vue'
  97. import FileEdit from "@/views/myfile/components/FileEdit.vue";
  98. import { ElMessage } from 'element-plus';
  99. import archiveTray from "@/assets/images/archiveTray.png";
  100. import {documentation}from "@/api/biz/actor.js"
  101. import {getInfo}from "@/api/biz/info.js"
  102. import elTableInfiniteScroll from 'el-table-infinite-scroll'
  103. import { setIcon } from "@/utils/index.js";
  104. export default {
  105. directives: {
  106. 'el-table-infinite-scroll': elTableInfiniteScroll
  107. },
  108. setup() {
  109. const activeName = ref('first')
  110. let collectImg = ref(true)
  111. let myEjoy = ref([])
  112. let myPack = ref([])
  113. let newAdd = ref(false)
  114. const historycopyRow = ref(false);
  115. const historyPrew = ref();
  116. const clickRowId = ref();
  117. const copyRow = ref();
  118. const onlyView = ref(false);
  119. const showEdit = ref(false)
  120. const thisLClickRow = ref()//当前左键的文件
  121. const addFileTab = inject("addFileTab");
  122. const ejoyPageNum = ref(1)
  123. const packPageNum = ref(1)
  124. const ejoyTotal = ref(true)
  125. const packTotal = ref(true)
  126. const clickRow = ref()
  127. let xz = ref(0)
  128. let yz = ref(0)
  129. const cliCC = ref(false)
  130. const rightMenuData = ref([
  131. {
  132. name:'归档',
  133. img:archiveTray
  134. }
  135. ])
  136. const rowClickFN = (row,col,e)=>{
  137. // console.log('row',row);
  138. thisLClickRow.value = row
  139. clickRowId.value = row.docId
  140. copyRow.value = toRaw(row)
  141. const itemData = {
  142. name: copyRow.value.fileName,
  143. path: `${window.location.origin}/fileEdit?clickRowId=${copyRow.value.docId}&canEdit=1&canCopy=1&history=0&fileId=0`
  144. }
  145. // sessionStorage.setItem('newTab',JSON.stringify(itemData))
  146. window.parent.$setOpenTab(itemData)
  147. // addFileTab(copyRow.value,1);
  148. // showEdit.value = true
  149. }
  150. const rowJoinClickFN = (row,col,e)=>{
  151. getInfo(row.docId).then((res)=>{
  152. // console.log('res',res);
  153. row = res.data
  154. if(row.isFiled === "Y"){
  155. return ElMessage({ message: '该文件已归档 不可再次编辑', type: 'error' })
  156. }
  157. thisLClickRow.value = row
  158. clickRowId.value = row.docId
  159. copyRow.value = toRaw(row)
  160. const itemData = {
  161. name: copyRow.value.fileName,
  162. path: `${window.location.origin}/fileEdit?clickRowId=${copyRow.value.docId}&canEdit=1&canCopy=1&history=0&fileId=0`
  163. }
  164. // sessionStorage.setItem('newTab',JSON.stringify(itemData))
  165. window.parent.$setOpenTab(itemData)
  166. // addFileTab(copyRow.value,1);
  167. })
  168. }
  169. function getCountPeople() {
  170. packTotal.value = true
  171. packPageNum.value = 1
  172. const query = `pageSize=20&pageNum=${packPageNum.value}`
  173. fileCount.myCount(query).then(res => {
  174. myPack.value = res.rows
  175. if(res.rows.length <res.total){
  176. packTotal.value = false
  177. }
  178. })
  179. }
  180. function getMyJoin() {
  181. ejoyTotal.value = true
  182. ejoyPageNum.value = 1
  183. const query = `pageSize=20&pageNum=${ejoyPageNum.value}`
  184. fileCount.myJoin(query).then(res => {
  185. myEjoy.value = res.rows
  186. if(res.rows.length <res.total){
  187. ejoyTotal.value = false
  188. }
  189. })
  190. }
  191. const setJoinScroll = ()=>{
  192. // console.log('btm');
  193. ejoyPageNum.value = ejoyPageNum.value + 1
  194. const query = `pageSize=20&pageNum=${ejoyPageNum.value}`
  195. // -------------先禁止掉事件 定时器1秒钟后才能再次触发
  196. ejoyTotal.value = true
  197. fileCount.myJoin(query).then(res => {
  198. const newarr = toRaw(myEjoy.value).concat(res.rows)
  199. myEjoy.value = JSON.parse(JSON.stringify(newarr))
  200. if(newarr.length <res.total){
  201. //获取后的数量<total就可以再次获取
  202. setTimeout(()=>{
  203. ejoyTotal.value = false
  204. },1000)
  205. }
  206. })
  207. }
  208. const setPackScroll = ()=>{
  209. // console.log('btm');
  210. packPageNum.value = packPageNum.value + 1
  211. const query = `pageSize=20&pageNum=${packPageNum.value}`
  212. // -------------先禁止掉事件 定时器1秒钟后才能再次触发
  213. packTotal.value = true
  214. fileCount.myCount(query).then(res => {
  215. const newarr = toRaw(myPack.value).concat(res.rows)
  216. myPack.value = JSON.parse(JSON.stringify(newarr))
  217. if(newarr.length <res.total){
  218. //获取后的数量<total就可以再次获取
  219. setTimeout(()=>{
  220. packTotal.value = false
  221. },1000)
  222. }
  223. })
  224. }
  225. function handleClick(data, e) {
  226. // console.log(data, e, 'tab');
  227. }
  228. function getImage(file) {
  229. return setIcon(file);
  230. }
  231. function formatFileSize(fileSize) {
  232. if (fileSize >= 1024 * 1024 * 1024) {
  233. // 大于等于1GB,显示GB
  234. return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
  235. } else if (fileSize >= 1024 * 1024) {
  236. // 大于等于1MB,显示MB
  237. return (fileSize / (1024 * 1024)).toFixed(2) + 'MB';
  238. } else if (fileSize >= 1024) {
  239. // 大于等于1KB,显示KB
  240. return (fileSize / 1024).toFixed(2) + 'KB';
  241. } else {
  242. // 小于1KB,显示字节
  243. return fileSize + 'B';
  244. }
  245. }
  246. function newFileAdd(){
  247. newAdd.value = true
  248. }
  249. function threeBe(data){
  250. newAdd.value = data
  251. }
  252. // 我发起的右键事件
  253. // 文件名表格每一行点击事件
  254. function handleRowClick(row, col, e) {
  255. clickRow.value = row
  256. e.preventDefault();
  257. e.stopPropagation();
  258. xz.value = e.pageX
  259. yz.value = e.pageY
  260. if (cliCC.value === true) {
  261. cliCC.value = false
  262. } else {
  263. cliCC.value = true
  264. }
  265. }
  266. // 关闭文件夹右键菜单
  267. const closeRMenu = () => {
  268. // console.log("close");
  269. cliCC.value = false;
  270. };
  271. const chooseSet =async (row, index, num)=>{
  272. if (row.name == '归档') {
  273. if(clickRow.value.isFiled == 'Y'){
  274. return ElMessage({
  275. type: "error",
  276. message: "文件已归档,请勿重复操作"
  277. })
  278. }
  279. const res = await documentation(clickRow.value.docId)
  280. if(res.code == 200){
  281. ElMessage({
  282. type: "success",
  283. message: "成功归档"
  284. })
  285. getCountPeople()
  286. }
  287. cliCC.value = false
  288. }
  289. }
  290. onMounted(() => {
  291. getCountPeople()
  292. getMyJoin()
  293. window.addEventListener("click", closeRMenu, true);
  294. })
  295. return {
  296. activeName,
  297. handleClick,
  298. myEjoy,
  299. myPack,
  300. getCountPeople,
  301. getMyJoin,
  302. collectImg,
  303. getImage,
  304. formatFileSize,
  305. newAdd,
  306. newFileAdd,
  307. threeBe,
  308. historycopyRow,
  309. historyPrew,
  310. onlyView,
  311. rowClickFN,
  312. thisLClickRow,
  313. copyRow,
  314. clickRowId,
  315. showEdit,
  316. addFileTab,
  317. handleRowClick,
  318. clickRow,
  319. xz,
  320. yz,
  321. rightMenuData,
  322. archiveTray,
  323. closeRMenu,
  324. cliCC,
  325. chooseSet,
  326. rowJoinClickFN,
  327. ejoyPageNum,
  328. packPageNum,
  329. ejoyTotal,
  330. packTotal,
  331. setJoinScroll,
  332. setPackScroll
  333. }
  334. },
  335. components:{
  336. AddFile,
  337. FileEdit
  338. }
  339. }
  340. </script>
  341. <style scoped lang="scss">
  342. @import "@/assets/styles/my-common.scss";
  343. .bigBox {
  344. width: 100%;
  345. height: 100vh;
  346. margin: 0 auto;
  347. background-color: white;
  348. }
  349. .tabBox {
  350. width: 100%;
  351. height: 40px;
  352. margin: 0 auto;
  353. background-color: #F5F7F9;
  354. position: relative;
  355. }
  356. .juli{
  357. width: 22px;
  358. height: 22px;
  359. }
  360. .preview {
  361. width: 100%;
  362. height: 100%;
  363. background-color: #fff;
  364. overflow: hidden;
  365. }
  366. .setCli {
  367. width: 156px;
  368. max-height: auto;
  369. position: absolute;
  370. // top: -70px;
  371. // left: 300px;
  372. flex-wrap: 400;
  373. background-color: white;
  374. border: 1px solid gray;
  375. border-radius: 4px;
  376. z-index: 300000000;
  377. overflow-y: auto;
  378. // font-size: 16px;
  379. }
  380. .chooseSet {
  381. width: 140px;
  382. height: 30px;
  383. line-height: 30px;
  384. margin: 5px auto;
  385. font-size: 13px;
  386. cursor: pointer;
  387. // display: flex;
  388. // align-items: center;
  389. // position: relative;
  390. img {
  391. margin-right: 4px;
  392. vertical-align: middle;
  393. }
  394. }
  395. .chooseSet:hover {
  396. width: 140px;
  397. height: 30px;
  398. line-height: 30px;
  399. margin: 5px auto;
  400. font-size: 13px;
  401. background-color: #F5F7F9;
  402. /* color: white; */
  403. }
  404. :deep(.el-tabs__nav) {
  405. margin: 0 calc(100% - 55%);
  406. }
  407. </style>