index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <div class="file-details">
  3. <customHeader>文件共享中心</customHeader>
  4. <div class="content">
  5. <div class="left-box">
  6. <!-- 左侧树菜单 -->
  7. <fileSystem :selected="selected" :list="listArr" :draggable="true" @delete-node="onDeltet" @on-click="onClick"
  8. @change-name="onChangeName" @addNode="onAddNode" @downloadNode="downloadNode">
  9. <template #icon="{ item }">
  10. <template v-if="item.isFolder">
  11. <SvgIcon v-if="item.expanded" size="18" name="file-open" />
  12. <SvgIcon v-else size="18" name="file-close" />
  13. </template>
  14. <treeIcon class="iconfont" :title="item.title" v-else />
  15. </template>
  16. <template #operation="{ type }">
  17. <a-tooltip placement="top" :color="'rgba(28, 72, 105,.5)'">
  18. <template #title>
  19. <span>添加</span>
  20. </template>
  21. <i class="iconfont icon-xinzeng" v-if="type == 'addDocument'"></i>
  22. </a-tooltip>
  23. <a-tooltip placement="top" :color="'rgba(28, 72, 105,.5)'">
  24. <template #title>
  25. <span>编辑</span>
  26. </template>
  27. <i class="iconfont icon-bianji" v-if="type == 'Editable'"></i>
  28. </a-tooltip>
  29. <a-tooltip placement="top" :color="'rgba(28, 72, 105,.5)'">
  30. <template #title>
  31. <span>删除</span>
  32. </template>
  33. <a-popconfirm v-if="type == 'deleteNode'" title="是否确认删除!" ok-text="确定" cancel-text="取消"
  34. @confirm="confirmDel">
  35. <i class="iconfont icon-guanbi"></i>
  36. </a-popconfirm>
  37. </a-tooltip>
  38. <a-tooltip placement="top" :color="'rgba(28, 72, 105,.5)'">
  39. <template #title>
  40. <span>下载目录</span>
  41. </template>
  42. <i class="iconfont icon-shangchuan1" v-if="type == 'downloadNode'"></i>
  43. </a-tooltip>
  44. </template>
  45. </fileSystem>
  46. </div>
  47. <div class="right-box">
  48. <div class="search">
  49. <span style="color: #fff">文件名称:</span>
  50. <a-input v-model:value="searchForm.fileName" placeholder="请输入文件名称" :disabled="activeKey != '1'" />
  51. <span style="color: #fff">文件类型:</span>
  52. <a-select v-model:value="searchForm.fileType" placeholder="请选择..." style="width: 220px; margin-right: 20px"
  53. :disabled="activeKey != '1'">
  54. <a-select-option v-for="item in filetypeList" :value="item.value">{{ item.label }}</a-select-option>
  55. </a-select>
  56. <a-button type="primary" preIcon="ant-design:search-outlined" @click="onSearch"
  57. :disabled="activeKey != '1'">查询</a-button>
  58. <a-button type="primary" style="float: right;" @click="reportSum">汇总报表</a-button>
  59. <a-button type="primary" style="float: right; margin-right: 20px" @click="openModal(true)">文件上传</a-button>
  60. </div>
  61. <div class="list">
  62. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  63. <a-tab-pane key="1" tab="全部">
  64. <NormalTable :key="alive" :submitInfo="submitInfo" :selfParam="selfParam" :searchParam="searchForm"
  65. :nodeParam="nodeParam" :columns="columns" :list="getTree" :deleteById="deleteById" :downLoad="downLoad"
  66. designScope="file-detail" title="文件详情" />
  67. </a-tab-pane>
  68. <a-tab-pane key="2" tab="待审批">
  69. <approvalPend :key="alive2" :selected="selected" />
  70. </a-tab-pane>
  71. <a-tab-pane key="3" tab="已审批">
  72. <endEd :key="alive3" :selected="selected" />
  73. </a-tab-pane>
  74. </a-tabs>
  75. </div>
  76. </div>
  77. </div>
  78. <!-- 上传谈弹窗 -->
  79. <a-modal v-model:visible="visible" centered :width="600" title="上传文件" @ok="handleOk" @cancel="handleCancel">
  80. <a-form :model="formState" labelAlign="right" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
  81. <a-form-item label="是否审批" :rules="[{ required: true, message: '请选择是否审批' }]">
  82. <a-radio-group v-model:value="formState.isApprove" @change="changeRadio">
  83. <a-radio :value="true">是</a-radio>
  84. <a-radio :value="false">否</a-radio>
  85. </a-radio-group>
  86. </a-form-item>
  87. <a-form-item label="文件类型">
  88. <JDictSelectTag v-model:value="formState.fileType" placeholder="请选择文件类型" dictCode="file_type"
  89. style="width: 260px" />
  90. </a-form-item>
  91. <a-form-item label="文件上传">
  92. <a-upload :before-upload="beforeUpload" @remove="handleRemove" :multiple="false" :file-list="fileList">
  93. <a-button type="primary" preIcon="ant-design:cloud-upload-outlined">选择文件</a-button>
  94. </a-upload>
  95. </a-form-item>
  96. </a-form>
  97. </a-modal>
  98. <!-- 汇总报表弹窗 -->
  99. <a-modal v-model:visible="visiblehHz" centered :width="600" title="报表汇总" :footer="null" @cancel="handleCancelHz">
  100. <div
  101. style="height:240px;overflow-y: auto;display: flex;flex-direction: column;align-items: center; padding: 10px;box-sizing: border-box">
  102. <vue3-seamless-scroll hover-stop="true" :list="reportHzList" :hover="true" :step="0.06" class="seamless-warp1">
  103. <div v-for="(item, index) in reportHzList" :key="index"
  104. style="width:100%;height:40px;display: flex;justify-content: space-between;align-items: center">
  105. <span>{{ item.time }}</span>
  106. <span>{{ item.msg }}</span>
  107. </div>
  108. </vue3-seamless-scroll>
  109. </div>
  110. </a-modal>
  111. </div>
  112. </template>
  113. <script lang="ts" setup name="system-user">
  114. import { Vue3SeamlessScroll } from 'vue3-seamless-scroll';
  115. import customHeader from '/@/components/vent/customHeader.vue';
  116. import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
  117. import fileSystem from './commen/fileSystem.vue';
  118. import treeIcon from './commen/Icon/treeIcon.vue';
  119. import NormalTable from '../comment/NormalTable.vue';
  120. import approvalPend from '../approvalPend/index.vue';
  121. import endEd from '../endEd/index.vue';
  122. import { useRouter } from 'vue-router';
  123. import { useMessage } from '/@/hooks/web/useMessage';
  124. import { SvgIcon } from '/@/components/Icon';
  125. import { ref, onMounted, reactive, nextTick, watch,onUnmounted } from 'vue';
  126. import { columns } from './fileDetail.data';
  127. import { getTree, createFile, editMenu, delMenu, uploadApi, downLoad, deleteById, listData, getNowUserAgencyData,sumVentReport, queryVentMonReportJd, zipdownload } from './fileDetail.api';
  128. let visiblehHz = ref(false)
  129. let reportHzList = ref<any[]>([])
  130. let timer: null | NodeJS.Timeout = null;
  131. let activeKey = ref('1');
  132. let selfParam = reactive({
  133. //各矿参数
  134. sysOrgCode: '',
  135. bpmStatus: null,
  136. flag: false,
  137. });
  138. let router = useRouter(); //路由
  139. const { createMessage } = useMessage();
  140. let searchForm = reactive({
  141. fileName: '',
  142. fileType: '',
  143. });
  144. let filetypeList = reactive<any[]>([
  145. { label: 'txt', value: 'txt' },
  146. { label: 'doc', value: 'doc' },
  147. { label: 'docx', value: 'docx' },
  148. { label: 'xls', value: 'xls' },
  149. { label: 'xlsx', value: 'xlsx' },
  150. { label: 'ppt', value: 'ppt' },
  151. { label: 'pptx', value: 'pptx' },
  152. { label: 'jpg', value: 'jpg' },
  153. { label: 'png', value: 'png' },
  154. { label: 'pdf', value: 'pdf' },
  155. ]);
  156. let fileList = reactive<any[]>([]); //上传文件列表
  157. // let uploadParam = reactive({}); //上传文件参数
  158. let nodeParam = reactive({}); //点击树节点时传递的参数
  159. let alive = ref(0); //点击树节点刷新表格数据
  160. let alive2 = ref(0);
  161. let alive3 = ref(0);
  162. let visible = ref(false); //控制上传弹窗的显示
  163. let formState = reactive({
  164. //上传文件类型,是否审批
  165. isApprove: null,
  166. fileType: '',
  167. });
  168. //文件审批-提交信息
  169. let submitInfo = ref<any[]>([]);
  170. //lxh 当前选中树节点
  171. let selected = reactive<any>({
  172. id: null,
  173. pid: null,
  174. title: '',
  175. isFolder: false,
  176. });
  177. let flag = ref('');
  178. //左侧菜单列表
  179. let listArr = reactive<any[]>([]);
  180. //获取要删除的节点数据
  181. let delNode = reactive({});
  182. //下载目录
  183. function downloadNode(data) {
  184. console.log(data, '999000=============================================')
  185. zipdownload({ id: data.id, ifMine: false }).then((res) => {
  186. let filename = `${data.fileName}`;
  187. downFilePublic(res, filename);
  188. });
  189. }
  190. // 下载公用方法
  191. function downFilePublic(content, fileName) {
  192. const blob = new Blob([content], { type: 'application/zip;charset=UTF-8' }); // 构造一个blob对象来处理数据
  193. // 对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
  194. // IE10以上支持blob但是依然不支持download
  195. if ('download' in document.createElement('a')) {
  196. // 支持a标签download的浏览器
  197. const link = document.createElement('a'); // 创建a标签
  198. link.download = fileName; // a标签添加属性
  199. link.style.display = 'none';
  200. link.href = URL.createObjectURL(blob);
  201. document.body.appendChild(link);
  202. link.click(); // 执行下载
  203. URL.revokeObjectURL(link.href); // 释放url
  204. document.body.removeChild(link); // 释放标签
  205. } else {
  206. // 其他浏览器
  207. navigator.msSaveBlob(blob, fileName);
  208. }
  209. }
  210. //汇总报表
  211. function reportSum() {
  212. visiblehHz.value = true
  213. sumVentReport()
  214. timer = setInterval(async () => {
  215. let res = await queryVentMonReportJd()
  216. reportHzList.value = res.jdList
  217. if (res.flag) {
  218. visiblehHz.value = false
  219. clearTimeout(timer);
  220. reportHzList.value.length=0
  221. alive.value = new Date().getTime();
  222. } else {
  223. visiblehHz.value = true
  224. }
  225. }, 3000)
  226. }
  227. //关闭汇总弹窗
  228. function handleCancelHz(){
  229. reportHzList.value.length=0
  230. visiblehHz.value = false
  231. clearTimeout(timer);
  232. alive.value = new Date().getTime();
  233. }
  234. //上传文件
  235. let openModal = (val) => {
  236. formState.isApprove = null;
  237. formState.fileType = '';
  238. fileList.length = 0;
  239. visible.value = val;
  240. };
  241. //tabs选项切换
  242. let tabChange = (activeKeyVal) => {
  243. activeKey.value = activeKeyVal;
  244. switch (activeKeyVal) {
  245. case '1':
  246. alive.value = new Date().getTime();
  247. break;
  248. case '2':
  249. alive2.value = new Date().getTime();
  250. break;
  251. case '3':
  252. alive3.value = new Date().getTime();
  253. break;
  254. }
  255. };
  256. //文件审批状态切换
  257. let changeRadio = (val) => {
  258. formState.isApprove = val.target.value;
  259. };
  260. //开始上传
  261. let handleOk = () => {
  262. if (formState.isApprove === null) {
  263. createMessage.warning('请选择文件审批状态!');
  264. } else {
  265. const formData = new FormData();
  266. formData.append('file', fileList[0]);
  267. formData.append('parentId', selected.id);
  268. formData.append('isApprove', formState.isApprove);
  269. formData.append('fileType', formState.fileType);
  270. uploadApi(formData).then((res) => {
  271. console.log(res, '上传返回');
  272. alive.value = new Date().getTime();
  273. visible.value = false;
  274. });
  275. }
  276. };
  277. //取消上传
  278. let handleCancel = () => {
  279. visible.value = false;
  280. };
  281. let list2trees = (data) => {
  282. // 删除 所有 children,以防止多次调用
  283. data.forEach(function (item) {
  284. delete item.children;
  285. });
  286. // 将数据存储为 以 id 为 KEY 的 map 索引数据列
  287. let map = {};
  288. data.forEach(function (item) {
  289. map[item.id] = item;
  290. });
  291. var val = [];
  292. data.forEach(function (item) {
  293. item.isFolder = true;
  294. item.title = item.fileName;
  295. item.pid = item.parentId;
  296. // 以当前遍历项,的pid,去map对象中找到索引的id
  297. var parent = map[item.pid];
  298. // 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
  299. if (parent) {
  300. (parent.children || (parent.children = [])).push(item);
  301. } else {
  302. //如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
  303. val.push(item);
  304. }
  305. });
  306. return val;
  307. };
  308. let getTypeTableList = async () => {
  309. let parentId = nodeParam.id || '';
  310. let selectFlag = nodeParam.id ? false : true;
  311. let likeFileName = searchForm.fileName || '';
  312. let fileSuffix = searchForm.fileType || '';
  313. let bpmStatus = selfParam.bpmStatus || '';
  314. let sysOrgCode = selfParam.sysOrgCode || '';
  315. let res = await getTree({
  316. parentId: parentId,
  317. selectFlag: selectFlag,
  318. likeFileName: likeFileName,
  319. fileSuffix: '.' + fileSuffix,
  320. bpmStatus: bpmStatus,
  321. sysOrgCode: sysOrgCode,
  322. });
  323. console.log(res, 'tableList--------------------');
  324. };
  325. //获取左侧菜单树数据
  326. let getTreeList = async () => {
  327. listArr.length = 0;
  328. let data = await getTree({ parentId: '' });
  329. let datas = data.records.filter((v) => v.fileType == null);
  330. let list = list2trees(datas);
  331. listArr.push(...list);
  332. console.log(listArr, '树节点数据');
  333. selected.id = listArr[0].id;
  334. selected.pid = listArr[0].pid;
  335. selected.title = listArr[0].title;
  336. selected.isFolder = listArr[0].isFolder;
  337. };
  338. //点击目录
  339. const onClick = (node) => {
  340. selected.id = node.id;
  341. selected.pid = node.pid;
  342. selected.title = node.title;
  343. selected.isFolder = node.isFolder;
  344. console.log(selected, 'selec----------');
  345. if (flag.value != node.title) {
  346. alive.value = new Date().getTime();
  347. nodeParam = node;
  348. flag.value = node.title;
  349. }
  350. };
  351. //添加文件
  352. const onAddNode = async (node) => {
  353. let data = await createFile({ fileName: node.newName, type: 'FOL', parentId: node.id });
  354. console.log(data, '新增文件返回');
  355. getTreeList();
  356. };
  357. // 修改名字
  358. const onChangeName = (node) => {
  359. editMenu({
  360. id: node.id,
  361. fileName: node.newName,
  362. parentId: node.pid,
  363. }).then((res) => {
  364. getTreeList();
  365. });
  366. };
  367. // 删除
  368. let onDeltet = (node) => {
  369. delNode = { ...node };
  370. };
  371. //确定删除
  372. let confirmDel = () => {
  373. if (delNode.pid == 'root') {
  374. createMessage.warning('根节点不能被删除!');
  375. } else if (delNode.children) {
  376. createMessage.warning('该节点无法被删除,请先删除该节点下的子节点!');
  377. } else {
  378. delMenu({ id: delNode.id }).then((res) => {
  379. console.log(res, '删除文件');
  380. getTreeList();
  381. });
  382. }
  383. };
  384. //查询列表
  385. let onSearch = () => {
  386. alive.value = new Date().getTime();
  387. };
  388. //上传文件
  389. let beforeUpload = (file) => {
  390. console.log(file, '选中文件');
  391. fileList.length = 0;
  392. let index = file.name.indexOf('.');
  393. let name = file.name.substring(index + 1);
  394. if (name == 'png' || name == 'jpg' || name == 'gif' || name == 'psd' || name == 'webp') {
  395. createMessage.warning('禁止上传图片类型的文件!');
  396. } else {
  397. fileList.push(file);
  398. }
  399. };
  400. // 文件移除
  401. let handleRemove = (file) => {
  402. const index = fileList.indexOf(file);
  403. const newFileList = fileList.slice();
  404. newFileList.splice(index, 1);
  405. fileList.length = 0;
  406. };
  407. //文件-提交
  408. async function getListData() {
  409. let res = await listData({ zx: true, column: 'createTime', order: 'desc', status: 1 });
  410. console.log(res, '审批提交-----------');
  411. submitInfo.value = res;
  412. }
  413. watch(
  414. () => router.currentRoute.value,
  415. (val) => {
  416. console.log('各矿传参', val);
  417. selfParam.bpmStatus = val.query.bpmStatus;
  418. selfParam.sysOrgCode = val.query.sysOrgCode;
  419. selfParam.flag = val.query.flag;
  420. },
  421. { immediate: true }
  422. );
  423. onMounted(() => {
  424. getTreeList();
  425. getListData();
  426. getTypeTableList();
  427. });
  428. onUnmounted(() => {
  429. if (timer) {
  430. clearTimeout(timer);
  431. timer = undefined;
  432. }
  433. });
  434. </script>
  435. <style lang="less" scoped>
  436. @ventSpace: zxm;
  437. .file-details {
  438. width: calc(100% - 10px);
  439. height: calc(100% - 100px);
  440. padding: 0px 15px 15px 15px;
  441. position: relative;
  442. margin-top: 100px;
  443. // background: url(../../../../assets/images/files/homes/bd.png) no-repeat center;
  444. // background-size: contain;
  445. &::after {
  446. display: block;
  447. content: '';
  448. height: 200px;
  449. width: 100%;
  450. position: absolute;
  451. background-image: linear-gradient(#2eb2ff05, #2ea2ff00);
  452. border-top: 1px solid #2eb2ff20;
  453. top: 0px;
  454. left: 0px;
  455. }
  456. .content {
  457. width: 100%;
  458. height: 100%;
  459. display: flex;
  460. flex-direction: row;
  461. justify-content: space-between;
  462. align-items: flex-start;
  463. position: relative;
  464. z-index: 999;
  465. .left-box {
  466. width: 18%;
  467. height: 100%;
  468. padding: 10px;
  469. border: 1px solid #99e8ff66;
  470. background: #27546e1a;
  471. box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  472. -moz-box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  473. -webkit-box-shadow: 0px 0px 50px 1px rgb(149 235 255 / 5%) inset;
  474. // lxh
  475. .iconfont {
  476. color: #fff;
  477. font-size: 12px;
  478. margin-left: 5px;
  479. }
  480. }
  481. .right-box {
  482. width: 82%;
  483. height: 100%;
  484. padding: 0px 0px 0px 10px;
  485. box-sizing: border-box;
  486. .search {
  487. height: 34px;
  488. line-height: 34px;
  489. margin-bottom: 15px;
  490. }
  491. }
  492. .list {
  493. height: calc(100% - 49px);
  494. position: relative;
  495. }
  496. }
  497. .zxm-form {
  498. padding: 10px !important;
  499. }
  500. }
  501. .seamless-warp1 {
  502. width: 100%;
  503. height: 100%;
  504. overflow: hidden;
  505. }
  506. ::v-deep .jeecg-svg-icon {
  507. margin-right: 5px;
  508. }
  509. ::v-deep .jeecg-basic-table-form-container {
  510. padding: 0px 0px;
  511. }
  512. ::v-deep .zxm-btn-primary {
  513. background-color: transparent;
  514. border: none;
  515. background: url(../../../../assets/images/files/details/btn.png) no-repeat !important;
  516. background-size: 100% 100% !important;
  517. }
  518. ::v-deep .zxm-tree-switcher {
  519. background: transparent;
  520. }
  521. ::v-deep .zxm-input {
  522. width: 220px;
  523. height: 30px;
  524. background: transparent;
  525. border: 1px solid #31bccc;
  526. color: #fff;
  527. margin-right: 20px;
  528. border-radius: 5px;
  529. }
  530. ::v-deep .zxm-select:not(.zxm-select-customize-input) .zxm-select-selector {
  531. height: 30px !important;
  532. background: transparent !important;
  533. border: 1px solid #31bccc !important;
  534. border-radius: 5px !important;
  535. color: #fff !important;
  536. }
  537. ::v-deep .zxm-select-single.zxm-select-show-arrow .zxm-select-selection-item {
  538. color: #fff !important;
  539. }
  540. ::v-deep .zxm-btn-group {
  541. margin-right: 25px;
  542. }
  543. ::v-deep .zxm-upload-list-item-name {
  544. color: #fff;
  545. }
  546. ::v-deep .zxm-upload-list-item:hover .zxm-upload-list-item-info {
  547. background-color: transparent;
  548. }
  549. :deep(.@{ventSpace}-table-cell-row-hover) {
  550. background: #264d8833 !important;
  551. }
  552. :deep(.@{ventSpace}-table-row-selected) {
  553. background: #268bc522 !important;
  554. }
  555. :deep(.@{ventSpace}-select-dropdown) {
  556. border: 1px solid #ececec66;
  557. .@{ventSpace}-select-item-option-selected,
  558. .@{ventSpace}-select-item-option-active {
  559. background-color: #ffffff33 !important;
  560. }
  561. .@{ventSpace}-select-item:hover {
  562. background-color: #ffffff33 !important;
  563. }
  564. }
  565. ::v-deep .zxm-form-item-control-input {
  566. width: 90%;
  567. }
  568. </style>