MyJoin.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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(88vh - 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. addFileTab(copyRow.value,1);
  142. // showEdit.value = true
  143. }
  144. const rowJoinClickFN = (row,col,e)=>{
  145. console.log('row',row);
  146. getInfo(row.docId).then((res)=>{
  147. // console.log('res',res);
  148. row = res.data
  149. if(row.isFiled === "Y"){
  150. return ElMessage({ message: '该文件已归档 不可再次编辑', type: 'error' })
  151. }
  152. thisLClickRow.value = row
  153. clickRowId.value = row.docId
  154. copyRow.value = toRaw(row)
  155. addFileTab(copyRow.value,1);
  156. })
  157. }
  158. function getCountPeople() {
  159. packTotal.value = true
  160. packPageNum.value = 1
  161. const query = `pageSize=20&pageNum=${packPageNum.value}`
  162. fileCount.myCount(query).then(res => {
  163. myPack.value = res.rows
  164. if(res.rows.length <res.total){
  165. packTotal.value = false
  166. }
  167. })
  168. }
  169. function getMyJoin() {
  170. ejoyTotal.value = true
  171. ejoyPageNum.value = 1
  172. const query = `pageSize=20&pageNum=${ejoyPageNum.value}`
  173. console.log('query',query);
  174. fileCount.myJoin(query).then(res => {
  175. myEjoy.value = res.rows
  176. if(res.rows.length <res.total){
  177. ejoyTotal.value = false
  178. }
  179. })
  180. }
  181. const setJoinScroll = ()=>{
  182. // console.log('btm');
  183. ejoyPageNum.value = ejoyPageNum.value + 1
  184. const query = `pageSize=20&pageNum=${ejoyPageNum.value}`
  185. // -------------先禁止掉事件 定时器1秒钟后才能再次触发
  186. ejoyTotal.value = true
  187. fileCount.myJoin(query).then(res => {
  188. const newarr = toRaw(myEjoy.value).concat(res.rows)
  189. console.log('newarr', newarr);
  190. myEjoy.value = JSON.parse(JSON.stringify(newarr))
  191. if(newarr.length <res.total){
  192. //获取后的数量<total就可以再次获取
  193. setTimeout(()=>{
  194. ejoyTotal.value = false
  195. },1000)
  196. }
  197. })
  198. }
  199. const setPackScroll = ()=>{
  200. // console.log('btm');
  201. packPageNum.value = packPageNum.value + 1
  202. const query = `pageSize=20&pageNum=${packPageNum.value}`
  203. // -------------先禁止掉事件 定时器1秒钟后才能再次触发
  204. packTotal.value = true
  205. fileCount.myCount(query).then(res => {
  206. const newarr = toRaw(myPack.value).concat(res.rows)
  207. console.log('newarr', newarr);
  208. myPack.value = JSON.parse(JSON.stringify(newarr))
  209. if(newarr.length <res.total){
  210. //获取后的数量<total就可以再次获取
  211. setTimeout(()=>{
  212. packTotal.value = false
  213. },1000)
  214. }
  215. })
  216. }
  217. function handleClick(data, e) {
  218. // console.log(data, e, 'tab');
  219. }
  220. function getImage(file) {
  221. return setIcon(file);
  222. }
  223. function formatFileSize(fileSize) {
  224. if (fileSize >= 1024 * 1024 * 1024) {
  225. // 大于等于1GB,显示GB
  226. return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
  227. } else if (fileSize >= 1024 * 1024) {
  228. // 大于等于1MB,显示MB
  229. return (fileSize / (1024 * 1024)).toFixed(2) + 'MB';
  230. } else if (fileSize >= 1024) {
  231. // 大于等于1KB,显示KB
  232. return (fileSize / 1024).toFixed(2) + 'KB';
  233. } else {
  234. // 小于1KB,显示字节
  235. return fileSize + 'B';
  236. }
  237. }
  238. function newFileAdd(){
  239. newAdd.value = true
  240. }
  241. function threeBe(data){
  242. newAdd.value = data
  243. }
  244. // 我发起的右键事件
  245. // 文件名表格每一行点击事件
  246. function handleRowClick(row, col, e) {
  247. console.log('row', row);
  248. clickRow.value = row
  249. e.preventDefault();
  250. e.stopPropagation();
  251. xz.value = e.pageX
  252. yz.value = e.pageY
  253. if (cliCC.value === true) {
  254. cliCC.value = false
  255. } else {
  256. cliCC.value = true
  257. }
  258. }
  259. // 关闭文件夹右键菜单
  260. const closeRMenu = () => {
  261. // console.log("close");
  262. cliCC.value = false;
  263. };
  264. const chooseSet =async (row, index, num)=>{
  265. if (row.name == '归档') {
  266. if(clickRow.value.isFiled == 'Y'){
  267. return ElMessage({
  268. type: "error",
  269. message: "文件已归档,请勿重复操作"
  270. })
  271. }
  272. const res = await documentation(clickRow.value.docId)
  273. console.log('res',res);
  274. if(res.code == 200){
  275. ElMessage({
  276. type: "success",
  277. message: "成功归档"
  278. })
  279. getCountPeople()
  280. }
  281. cliCC.value = false
  282. }
  283. }
  284. onMounted(() => {
  285. getCountPeople()
  286. getMyJoin()
  287. window.addEventListener("click", closeRMenu, true);
  288. })
  289. return {
  290. activeName,
  291. handleClick,
  292. myEjoy,
  293. myPack,
  294. getCountPeople,
  295. getMyJoin,
  296. collectImg,
  297. getImage,
  298. formatFileSize,
  299. newAdd,
  300. newFileAdd,
  301. threeBe,
  302. historycopyRow,
  303. historyPrew,
  304. onlyView,
  305. rowClickFN,
  306. thisLClickRow,
  307. copyRow,
  308. clickRowId,
  309. showEdit,
  310. addFileTab,
  311. handleRowClick,
  312. clickRow,
  313. xz,
  314. yz,
  315. rightMenuData,
  316. archiveTray,
  317. closeRMenu,
  318. cliCC,
  319. chooseSet,
  320. rowJoinClickFN,
  321. ejoyPageNum,
  322. packPageNum,
  323. ejoyTotal,
  324. packTotal,
  325. setJoinScroll,
  326. setPackScroll
  327. }
  328. },
  329. components:{
  330. AddFile,
  331. FileEdit
  332. }
  333. }
  334. </script>
  335. <style scoped lang="scss">
  336. @import "@/assets/styles/my-common.scss";
  337. .bigBox {
  338. width: 100%;
  339. height: 88vh;
  340. margin: 0 auto;
  341. background-color: white;
  342. }
  343. .tabBox {
  344. width: 100%;
  345. height: 40px;
  346. margin: 0 auto;
  347. background-color: #F5F7F9;
  348. position: relative;
  349. }
  350. .juli{
  351. width: 22px;
  352. height: 22px;
  353. }
  354. .preview {
  355. width: 100%;
  356. height: 100%;
  357. background-color: #fff;
  358. overflow: hidden;
  359. }
  360. .setCli {
  361. width: 156px;
  362. max-height: auto;
  363. position: absolute;
  364. // top: -70px;
  365. // left: 300px;
  366. flex-wrap: 400;
  367. background-color: white;
  368. border: 1px solid gray;
  369. border-radius: 4px;
  370. z-index: 300000000;
  371. overflow-y: auto;
  372. // font-size: 16px;
  373. }
  374. .chooseSet {
  375. width: 140px;
  376. height: 30px;
  377. line-height: 30px;
  378. margin: 5px auto;
  379. font-size: 13px;
  380. cursor: pointer;
  381. // display: flex;
  382. // align-items: center;
  383. // position: relative;
  384. img {
  385. margin-right: 4px;
  386. vertical-align: middle;
  387. }
  388. }
  389. .chooseSet:hover {
  390. width: 140px;
  391. height: 30px;
  392. line-height: 30px;
  393. margin: 5px auto;
  394. font-size: 13px;
  395. background-color: #F5F7F9;
  396. /* color: white; */
  397. }
  398. :deep(.el-tabs__nav) {
  399. margin: 0 calc(100% - 55%);
  400. }
  401. </style>