index.vue 19 KB

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