index.vue 14 KB

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