index.vue 16 KB

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