file-table-list.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. <template>
  2. <div>
  3. <fileSearch @search="reload"></fileSearch>
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="datasource"
  9. height="calc(45vh)"
  10. tool-class="ele-toolbar-form"
  11. :initLoad="false"
  12. row-key="id"
  13. :current.sync="current"
  14. :selection.sync="selection"
  15. highlight-current-row
  16. :cache-key="cacheKeyUrl"
  17. @columns-change="onColumnsChange"
  18. @row-click="rowClick"
  19. @selection-change="selectionClick"
  20. @done="done"
  21. :toolbar="!isPop"
  22. >
  23. <!-- 表头工具栏 -->
  24. <template v-slot:toolbar>
  25. <!-- <div style="display: contents;"> -->
  26. <el-dropdown trigger="click" v-if="lcyStatus == 1">
  27. <el-button type="primary">
  28. 新建<i class="el-icon-arrow-down el-icon--right"></i>
  29. </el-button>
  30. <el-dropdown-menu slot="dropdown">
  31. <el-dropdown-item
  32. @click.native="
  33. parenOpen('add', {
  34. power: 'add',
  35. dataKey: 'parentData',
  36. isArr: false
  37. })
  38. "
  39. >新建文件夹</el-dropdown-item
  40. >
  41. <el-dropdown-item
  42. @click.native="
  43. openEdit('add', '', {
  44. power: 'add',
  45. dataKey: 'parentData',
  46. isArr: false
  47. })
  48. "
  49. >新建文档</el-dropdown-item
  50. >
  51. </el-dropdown-menu>
  52. </el-dropdown>
  53. <el-dropdown trigger="click" v-if="lcyStatus == 1">
  54. <el-button type="primary">
  55. 编辑<i class="el-icon-arrow-down el-icon--right"></i>
  56. </el-button>
  57. <el-dropdown-menu slot="dropdown">
  58. <el-dropdown-item
  59. @click.native="
  60. parenOpen('edit', {
  61. power: 'revise',
  62. dataKey: 'parentData',
  63. isArr: false
  64. })
  65. "
  66. >修改</el-dropdown-item
  67. >
  68. <el-dropdown-item
  69. @click.native="
  70. parenOpen('del', {
  71. power: 'del',
  72. dataKey: 'parentData',
  73. isArr: false
  74. })
  75. "
  76. >删除</el-dropdown-item
  77. >
  78. </el-dropdown-menu>
  79. </el-dropdown>
  80. <el-button
  81. v-if="lcyStatus == 1"
  82. type="primary"
  83. @click.native="
  84. openEditAll({
  85. power: 'add',
  86. dataKey: 'parentData',
  87. isArr: false
  88. })
  89. "
  90. >
  91. 批量上传
  92. </el-button>
  93. <el-button
  94. type="primary"
  95. @click.native="
  96. checkEnter({
  97. power: 'checkEnter',
  98. dataKey: 'current',
  99. isArr: true
  100. })
  101. "
  102. :disabled="
  103. !!(selection.filter((item) => item.checkOutStatus != 1).length)
  104. "
  105. v-if="lcyStatus == 1"
  106. >
  107. 检入
  108. </el-button>
  109. <el-button
  110. type="primary"
  111. @click.native="
  112. checkOut({
  113. power: 'checkOut',
  114. dataKey: 'current',
  115. isArr: true
  116. })
  117. "
  118. :disabled="
  119. !!(selection.filter((item) => item.checkOutStatus == 1).length)
  120. "
  121. v-if="lcyStatus == 1"
  122. >
  123. 检出
  124. </el-button>
  125. <el-popconfirm
  126. class="ele-action"
  127. v-if="lcyStatus == 1 && fileType === 0"
  128. title="归档后文档无法修改,是否确认归档"
  129. @confirm="
  130. updateLcyStatus({
  131. power: 'archive',
  132. dataKey: 'current',
  133. isArr: true
  134. })
  135. "
  136. >
  137. <template v-slot:reference>
  138. <el-button type="primary"> 归档 </el-button>
  139. </template>
  140. </el-popconfirm>
  141. <el-button
  142. type="primary"
  143. v-if="lcyStatus == 2"
  144. @click="
  145. noUpdateLcyStatus({
  146. power: 'cancelArchive',
  147. dataKey: 'current',
  148. isArr: true
  149. })
  150. "
  151. >
  152. <!-- {
  153. power: 'cancelArchive',
  154. dataKey: 'current',
  155. isArr: true
  156. } -->
  157. 取消归档
  158. </el-button>
  159. <el-button
  160. type="primary"
  161. v-if="
  162. (lcyStatus == 1 || lcyStatus == 2) &&
  163. (fileType == 0 || fileType == 1)
  164. "
  165. @click="
  166. openSendEdit({
  167. power: 'release',
  168. dataKey: 'current',
  169. isArr: true
  170. })
  171. "
  172. >
  173. 发布
  174. </el-button>
  175. <el-button
  176. v-if="fileType == 2"
  177. type="primary"
  178. @click="processSubmit_template"
  179. >
  180. 发布
  181. </el-button>
  182. <el-button
  183. v-if="fileType === 0 && lcyStatus != 4"
  184. type="primary"
  185. :disabled="selection.length > 1"
  186. @click="
  187. processSubmit({
  188. power: 'abolish',
  189. dataKey: 'current',
  190. isArr: true
  191. })
  192. "
  193. >
  194. 废止
  195. </el-button>
  196. <el-popconfirm
  197. class="ele-action"
  198. title="确定要删除选中的文档吗?"
  199. @confirm="
  200. removeAll({
  201. power: 'del',
  202. dataKey: 'current',
  203. isArr: true
  204. })
  205. "
  206. >
  207. <template v-slot:reference>
  208. <el-button type="danger">批量删除</el-button>
  209. </template>
  210. </el-popconfirm>
  211. <el-button
  212. v-if="fileType === 0 && lcyStatus != 4"
  213. type="primary"
  214. @click="powerOpen"
  215. >
  216. 批量设置权限
  217. </el-button>
  218. <el-button
  219. type="primary"
  220. @click.native="
  221. getFile({
  222. power: 'download',
  223. dataKey: 'current',
  224. isArr: true
  225. })
  226. "
  227. >
  228. 下载
  229. </el-button>
  230. <el-button
  231. :disabled="selection.length > 1"
  232. type="primary"
  233. v-if="fileType == 1"
  234. @click.native="move"
  235. >
  236. 移动
  237. </el-button>
  238. <el-button
  239. type="primary"
  240. v-if="lcyStatus == 1 && fileType === 0"
  241. @click.native="
  242. moveAll({
  243. power: 'edit',
  244. dataKey: 'current',
  245. isArr: true
  246. })
  247. "
  248. >
  249. 批量移动
  250. </el-button>
  251. <!-- </div> -->
  252. </template>
  253. <template v-slot:directoryId="{ row }">
  254. <el-cascader
  255. style="width: 100%"
  256. v-model="row.directoryId"
  257. class="my-cascader"
  258. :disabled="true"
  259. :options="folderList"
  260. :props="{
  261. value: 'id',
  262. label: 'name',
  263. children: 'sonDirectoryList',
  264. emitPath: false,
  265. checkStrictly: true
  266. }"
  267. ></el-cascader>
  268. </template>
  269. <!-- 操作列 -->
  270. <template v-slot:action="{ row }">
  271. <el-link
  272. v-if="
  273. lcyStatus == 1 &&
  274. (row.reviewStatus == 0 || row.reviewStatus == 3) &&
  275. row.status == 0
  276. "
  277. type="primary"
  278. :underline="false"
  279. icon="el-icon-edit"
  280. @click.native="
  281. openEdit('edit', row, {
  282. power: 'revise',
  283. dataKey: 'current',
  284. isArr: false
  285. })
  286. "
  287. >
  288. 修改
  289. </el-link>
  290. <el-popconfirm
  291. v-if="
  292. lcyStatus == 1 &&
  293. (row.reviewStatus == 0 || row.reviewStatus == 3) &&
  294. row.status == 0
  295. "
  296. class="ele-action"
  297. title="确定要删除此文档吗?"
  298. @confirm="
  299. remove(row, {
  300. power: 'del',
  301. dataKey: 'current',
  302. isArr: false
  303. })
  304. "
  305. >
  306. <template v-slot:reference>
  307. <el-link type="danger" :underline="false"> 删除 </el-link>
  308. </template>
  309. </el-popconfirm>
  310. </template>
  311. </ele-pro-table>
  312. <el-tabs
  313. type="border-card"
  314. v-show="!current?.id && parentData?.id"
  315. style="height: calc(55vh - 260px)"
  316. >
  317. <el-tab-pane label="常规">
  318. <folderInfo :parentId="parentData?.id" :folderList="folderList" />
  319. </el-tab-pane>
  320. <el-tab-pane label="操作日志"></el-tab-pane>
  321. </el-tabs>
  322. <el-tabs
  323. v-model="activeName"
  324. type="border-card"
  325. v-show="current.id && isPower(current, 'check')"
  326. style="height: calc(55vh - 260px)"
  327. @tab-click="tabClick"
  328. >
  329. <el-tab-pane label="常规" name="常规">
  330. <Info :parentId="current.id" :folderList="folderList" />
  331. </el-tab-pane>
  332. <el-tab-pane
  333. label="浏览"
  334. name="浏览"
  335. :disabled="!isPower(current, 'browse')"
  336. >
  337. <browse ref="browseRef"></browse>
  338. </el-tab-pane>
  339. <el-tab-pane label="历史版本" name="VersionRef">
  340. <Version :parentId="current.id" ref="VersionRef" />
  341. </el-tab-pane>
  342. <el-tab-pane label="发布记录" name="IssueRef">
  343. <Issue :parentId="current.id" ref="IssueRef" />
  344. </el-tab-pane>
  345. <el-tab-pane label="回收记录" name="ReceiveRef"
  346. ><Receive :parentId="current.id" ref="ReceiveRef"></Receive
  347. ></el-tab-pane>
  348. <el-tab-pane label="变更记录" name="变更记录" v-if="fileType === 0"
  349. ><Change :parentId="current.id"
  350. /></el-tab-pane>
  351. <!-- <el-tab-pane label="打印记录" name="打印记录"
  352. ><print></print
  353. ></el-tab-pane> -->
  354. <el-tab-pane label="工作流" name="bpmRef"
  355. ><bpm :parentId="current.id" ref="bpmRef"></bpm
  356. ></el-tab-pane>
  357. <el-tab-pane
  358. label="权限"
  359. name="权限"
  360. v-if="isCreateUserId(current) && !isCheckOut(current) && fileType === 0"
  361. >
  362. <Power style="" @powerSave="powerSave" ref="PowerRef" />
  363. </el-tab-pane>
  364. <el-tab-pane label="操作日志" name="ActionRef"
  365. ><Action :parentId="current.id" ref="ActionRef"
  366. /></el-tab-pane>
  367. </el-tabs>
  368. <!-- 编辑弹窗 -->
  369. <file-edit
  370. ref="fileEditRef"
  371. :parentId="parentData?.id"
  372. @done="reload"
  373. :lcyStatus="lcyStatus"
  374. :fileType="fileType"
  375. />
  376. <move ref="moveRef" @done="reload" />
  377. <moveAll ref="moveAllRef" @done="reload"></moveAll>
  378. <file-editAll
  379. ref="fileEditAllRef"
  380. :parentId="parentData?.id"
  381. @done="reload"
  382. :fileType="fileType"
  383. :lcyStatus="lcyStatus"
  384. />
  385. <sendEdit ref="sendEditRef" @done="reload" :isAdd="false"></sendEdit>
  386. <process-submit-dialog
  387. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  388. v-if="processSubmitDialogFlag"
  389. ref="processSubmitDialogRef"
  390. @reload="reload"
  391. ></process-submit-dialog>
  392. <ele-modal
  393. width="70vw"
  394. :visible.sync="powerOpenShow"
  395. :close-on-click-modal="false"
  396. custom-class="ele-dialog-form"
  397. :maxable="true"
  398. append-to-body
  399. >
  400. <Power style="" @powerSave="powerSave" ref="PowerRefAll" />
  401. </ele-modal>
  402. </div>
  403. </template>
  404. <script>
  405. import fileSearch from './file-search.vue';
  406. import fileEdit from './file-edit.vue';
  407. import fileEditAll from './file-editAll.vue';
  408. import move from './move.vue';
  409. import moveAll from './moveAll.vue';
  410. import Info from './info.vue';
  411. import folderInfo from './folderInfo.vue';
  412. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  413. import Version from './version.vue';
  414. import Power from './power/index.vue';
  415. import Issue from './issue.vue';
  416. import Action from './action.vue';
  417. import Change from './change.vue';
  418. import Receive from './receive.vue';
  419. import print from './print.vue';
  420. import bpm from './bpm.vue';
  421. import browse from './browse.vue';
  422. import sendEdit from '@/views/doc/issue_doc/components/edit.vue';
  423. import { isPower, isCheckOut, fileStatus, isCreateUserId } from '../util.js';
  424. import { getFile } from '@/api/system/file/index.js';
  425. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  426. import {
  427. fileDeleteAPI,
  428. filePageAPI,
  429. checkEnter,
  430. checkOut,
  431. fileUpdateAPI,
  432. updateLcyStatus,
  433. noUpdateLcyStatus,
  434. fileUpdateAllAPI
  435. } from '@/api/doc-manage';
  436. export default {
  437. mixins: [tableColumnsMixin],
  438. components: {
  439. fileSearch,
  440. fileEdit,
  441. Info,
  442. Version,
  443. Power,
  444. Issue,
  445. Action,
  446. Change,
  447. folderInfo,
  448. processSubmitDialog,
  449. Receive,
  450. print,
  451. fileEditAll,
  452. bpm,
  453. sendEdit,
  454. browse,
  455. move,moveAll
  456. },
  457. props: {
  458. // 上级
  459. parentData: {
  460. type: Object,
  461. default: () => {}
  462. },
  463. // 文件夹数据
  464. folderList: {
  465. type: Array,
  466. default: () => []
  467. },
  468. lcyStatus: {
  469. default: 1
  470. },
  471. fileType: '', //0:公共文档 1:个人文档 2:文档模板
  472. isPop: '',
  473. disabledTableList: {
  474. //已选择列表
  475. default: () => []
  476. },
  477. // 列配置远端同步 key:仅在调用方显式传入时启用同步,其他路由不传则完全关闭
  478. cacheKeyUrl: {
  479. type: String,
  480. default: ''
  481. }
  482. },
  483. //add:新建 fileEdit:修改 filePigeonhole:归档 fileUnPigeonhole:取消归档 fileIssue:发布 fileChange:变更 fileDel:删除
  484. data() {
  485. return {
  486. // 关闭 mixin 默认的 getTabColumns(与 ele-pro-table 工具栏共享同一 localStorage key,
  487. // 混用会破坏缓存结构,由本组件自行接管"远端拉取 + 应用"流程)。
  488. // 仅在 cacheKeyUrl 非空时才会真正发起同步(见 loadColumnsFromServer / onColumnsChange 的守卫)
  489. tabMixinsInit: false,
  490. isPower,
  491. isCheckOut,
  492. isCreateUserId,
  493. powerOpenShow: false,
  494. selection: [],
  495. processSubmitDialogFlag: false,
  496. current: {},
  497. fileUrl: '',
  498. activeName: '常规',
  499. // 表格列配置
  500. columns: [
  501. {
  502. width: 45,
  503. type: 'selection',
  504. columnKey: 'selection',
  505. align: 'center',
  506. fixed: 'left',
  507. selectable: (row, index) => {
  508. return (
  509. !this.disabledTableList
  510. .map((item) => item.id)
  511. .includes(row.id) &&
  512. row.reviewStatus != 1 &&
  513. row.status != 1
  514. );
  515. }
  516. },
  517. {
  518. label: '文档位置',
  519. prop: 'directoryId',
  520. slot: 'directoryId',
  521. width: 220,
  522. align: 'center',
  523. fixed: 'left',
  524. showOverflowTooltip: true
  525. },
  526. {
  527. label: '编码',
  528. prop: 'code',
  529. width: 180,
  530. align: 'center',
  531. fixed: 'left',
  532. showOverflowTooltip: true
  533. },
  534. {
  535. prop: 'name',
  536. label: '文档名称',
  537. align: 'center',
  538. slot: 'name',
  539. showOverflowTooltip: true,
  540. minWidth: 200
  541. },
  542. {
  543. prop: 'storagePath',
  544. label: '文件名称',
  545. align: 'center',
  546. showOverflowTooltip: true,
  547. minWidth: 200,
  548. formatter: (_row, _column, cellValue) => {
  549. return cellValue[0]?.name;
  550. }
  551. },
  552. {
  553. prop: 'version',
  554. label: '版本',
  555. align: 'center',
  556. showOverflowTooltip: true,
  557. minWidth: 100
  558. },
  559. {
  560. prop: 'checkOutUserName',
  561. label: '检出人',
  562. align: 'center',
  563. showOverflowTooltip: true,
  564. minWidth: 100
  565. },
  566. {
  567. prop: 'checkOutStatus',
  568. label: '检出状态',
  569. align: 'center',
  570. showOverflowTooltip: true,
  571. minWidth: 100,
  572. formatter: (_row, _column, cellValue) => {
  573. return cellValue == 1 ? '已检出' : '';
  574. }
  575. },
  576. {
  577. prop: 'checkOutTime',
  578. label: '检出时间',
  579. align: 'center',
  580. showOverflowTooltip: true,
  581. minWidth: 160
  582. },
  583. {
  584. prop: 'createUserName',
  585. label: '创建人',
  586. align: 'center',
  587. showOverflowTooltip: true,
  588. minWidth: 100
  589. },
  590. {
  591. prop: 'createTime',
  592. label: '创建时间',
  593. align: 'center',
  594. showOverflowTooltip: true,
  595. minWidth: 160
  596. },
  597. {
  598. prop: 'updateUserName',
  599. label: '修改人',
  600. align: 'center',
  601. showOverflowTooltip: true,
  602. minWidth: 100
  603. },
  604. {
  605. prop: 'updateTime',
  606. label: '修改时间',
  607. align: 'center',
  608. showOverflowTooltip: true,
  609. minWidth: 160
  610. },
  611. {
  612. prop: 'sizeUnit',
  613. label: '文档大小',
  614. align: 'center',
  615. showOverflowTooltip: true,
  616. minWidth: 100
  617. },
  618. {
  619. prop: 'status',
  620. label: '状态',
  621. align: 'center',
  622. showOverflowTooltip: true,
  623. minWidth: 100,
  624. formatter: (_row, _column, cellValue) => {
  625. return fileStatus(cellValue);
  626. }
  627. },
  628. {
  629. align: 'center',
  630. label: '审核状态',
  631. prop: 'reviewStatus',
  632. width: 100,
  633. formatter: (_row, _column, cellValue) => {
  634. return cellValue == 0
  635. ? '未提交'
  636. : cellValue == 1
  637. ? '审核中'
  638. : cellValue == 2
  639. ? '已审核'
  640. : '审核不通过';
  641. }
  642. },
  643. {
  644. columnKey: 'action',
  645. label: '操作',
  646. width: 200,
  647. align: 'center',
  648. resizable: false,
  649. slot: 'action',
  650. showOverflowTooltip: true,
  651. fixed: 'right'
  652. }
  653. ],
  654. // 是否显示编辑弹窗
  655. showEditFlag: false
  656. };
  657. },
  658. created() {
  659. this.loadColumnsFromServer();
  660. },
  661. methods: {
  662. // ele-pro-table 列变化 → 转换为 slim 格式后同步到后端
  663. // slim 格式与 ele-pro-table 工具栏写入 localStorage 的结构一致,避免缓存互相覆盖
  664. // 注意:type 为 selection/index/expand 的列被 ele-pro-table 排除在 ⚙️ 工具栏外(见 HIDE_SETTING_TYPES),
  665. // 不应写入后端和 localStorage,否则下次加载会被 getSettingCols 当作缓存返回,污染工具栏列表
  666. onColumnsChange(visibleColumns) {
  667. if (!this.cacheKeyUrl) return;
  668. // 用户在 ⚙️ 工具栏里改最新 fixed 值(按 columnKey / prop 索引)
  669. // 源 columns 里的 fixed 是页面初始值,必须以这里为准,否则刷新后丢失
  670. const fixedMap = new Map();
  671. visibleColumns.forEach((c) => {
  672. const key = c.prop || c.columnKey;
  673. if (key) fixedMap.set(key, c.fixed);
  674. });
  675. const visibleIds = new Set(
  676. visibleColumns.map((c) => c.prop || c.columnKey)
  677. );
  678. const merged = this.columns
  679. .filter(
  680. (c) =>
  681. (c.prop || c.columnKey || c.label === '操作') &&
  682. !['selection', 'index', 'expand'].includes(c.type)
  683. )
  684. .map((c) => {
  685. const key = c.prop || c.columnKey;
  686. return {
  687. id: key,
  688. prop: c.prop,
  689. columnKey: c.columnKey,
  690. label: c.label,
  691. checked: visibleIds.has(key),
  692. fixed: fixedMap.has(key) ? fixedMap.get(key) : c.fixed
  693. };
  694. });
  695. this.saveColumns(merged);
  696. },
  697. // 拉取后端列配置,写入与 ele-pro-table 共享的 localStorage,触发表格重渲染
  698. // 过滤掉 HIDE_SETTING_TYPES 的列(selection/index/expand),避免污染 ⚙️ 工具栏列表
  699. async loadColumnsFromServer() {
  700. if (!this.cacheKeyUrl) return;
  701. try {
  702. const res = await this.getByTableId(this.cacheKeyUrl);
  703. if (res?.columnConfig?.length > 0) {
  704. const sanitized = res.columnConfig.filter(
  705. (c) => !['selection', 'index', 'expand'].includes(c.type)
  706. );
  707. this.setStorage(this.cacheKeyUrl + 'Cols', sanitized);
  708. // 触发 ele-pro-table 的 columns watcher 重读缓存
  709. this.columns = [...this.columns];
  710. }
  711. } catch (e) {
  712. console.error('加载列配置失败:', e);
  713. }
  714. },
  715. /* 表格数据源 */
  716. datasource({ page, limit, where, order }) {
  717. if (this.lcyStatus) {
  718. this.current = {};
  719. return filePageAPI({
  720. ...where,
  721. ...order,
  722. pageNum: page,
  723. size: limit,
  724. directoryId: this.parentData?.id,
  725. lcyStatus: this.lcyStatus,
  726. fileType: this.fileType,
  727. isQueryAll: this.$hasPermission('fm:doc:viewAll') ? 1 : ''
  728. });
  729. }
  730. },
  731. /* 刷新表格 */
  732. reload(where) {
  733. this.$refs.table &&
  734. this.$refs.table.reload({ pageNum: 1, where: where });
  735. },
  736. processSubmit(powerData) {
  737. if (this.selection.length == 0 || this.selection.length > 1) {
  738. this.$message.warning('请选择一条数据');
  739. return;
  740. }
  741. if (this.selection[0].checkOutUserName) {
  742. this.$message.warning(
  743. this.selection[0].name +
  744. '已被' +
  745. this.selection[0].checkOutUserName +
  746. '检出 无法废止'
  747. );
  748. return;
  749. }
  750. if (this.powerFn(powerData)) {
  751. return;
  752. }
  753. if (isCheckOut(this.selection[0])) {
  754. this.$message.warning(
  755. this.selection[0].name +
  756. '已被' +
  757. this.selection[0].checkOutUserName +
  758. '检出 无法发起流程'
  759. );
  760. return;
  761. }
  762. this.processSubmitDialogFlag = true;
  763. this.$nextTick(() => {
  764. this.selection[0]['businessKey'] = 'fm_file_repeal_approve';
  765. this.$refs.processSubmitDialogRef.init(this.selection[0]);
  766. });
  767. },
  768. //发布模板
  769. processSubmit_template() {
  770. if (this.selection.length == 0 || this.selection.length > 1) {
  771. this.$message.warning('请选择一条数据');
  772. return;
  773. }
  774. if (this.selection[0].checkOutUserName) {
  775. this.$message.warning(
  776. this.selection[0].name +
  777. '已被' +
  778. this.selection[0].checkOutUserName +
  779. '检出 无法发布'
  780. );
  781. return;
  782. }
  783. if (this.selection[0].status == 2) {
  784. this.$message.warning('模板已发布');
  785. return;
  786. }
  787. this.processSubmitDialogFlag = true;
  788. this.$nextTick(() => {
  789. this.selection[0]['businessKey'] = 'fm_file_template_approve';
  790. this.$refs.processSubmitDialogRef.init(this.selection[0]);
  791. });
  792. },
  793. selectionClick(data) {
  794. this.current = data.reverse()[0] || {};
  795. this.rowClick(this.current);
  796. this.$refs.table.setCurrentRow(this.current);
  797. },
  798. rowClick(row) {
  799. this.$nextTick(() => {
  800. this.$refs.browseRef && this.$refs.browseRef.setFileUrl(row);
  801. this.$refs.PowerRef &&
  802. this.$refs.PowerRef.setTableList(row.userAuthority);
  803. });
  804. },
  805. /* 显示编辑 */
  806. openEdit(type, row = '', powerData) {
  807. if (type != 'add') {
  808. if (!row.checkOutUserName) {
  809. this.$message.warning('请先检出在修改');
  810. return;
  811. }
  812. if (isCheckOut(row)) {
  813. this.$message.warning(
  814. row.name + '已被' + row.checkOutUserName + '检出 无法修改'
  815. );
  816. return;
  817. }
  818. }
  819. if (this.powerFn(powerData, row)) {
  820. return;
  821. }
  822. this.$refs.fileEditRef.open(type, row, this.folderList);
  823. },
  824. /* 显示编辑 */
  825. openEditAll(powerData) {
  826. if (this.powerFn(powerData)) {
  827. return;
  828. }
  829. this.$refs.fileEditAllRef.open(this.folderList);
  830. },
  831. tabClick(data) {
  832. if (this.$refs[data.name] && this.$refs[data.name].init) {
  833. this.$refs[data.name].init();
  834. }
  835. },
  836. parenOpen(type, powerData) {
  837. if (this.powerFn(powerData)) {
  838. return;
  839. }
  840. this.$emit('parenOpen', type);
  841. },
  842. // async success(current) {
  843. // await this.reload();
  844. // this.current = current;
  845. // this.$nextTick(() => {
  846. // this.$refs.PowerRef &&
  847. // this.$refs.PowerRef.setTableList(this.current.userAuthority);
  848. // });
  849. // },
  850. //权限判断
  851. powerFn({ power, dataKey, isArr }, row) {
  852. let arr = isArr ? this.selection : [];
  853. if (!isPower(row || this[dataKey], power, arr)) {
  854. this.$message.warning('抱歉,您没有操作权限!');
  855. return true;
  856. }
  857. },
  858. powerOpen() {
  859. if (!this.selection?.length) {
  860. this.$message.warning('请选择一条数据!');
  861. return;
  862. }
  863. let createUserS = [],
  864. checkOutS = [];
  865. this.selection.forEach((item) => {
  866. if (!isCreateUserId(item)) {
  867. createUserS.push(item.name);
  868. }
  869. if (isCreateUserId(item)) {
  870. checkOutS.push(item.name);
  871. }
  872. });
  873. if (createUserS.toString()) {
  874. this.$message.warning(createUserS + '您不是创建人,无权限修改!');
  875. return;
  876. }
  877. if (!checkOutS.toString()) {
  878. this.$message.warning(checkOutS + '已被检出 无法修改!');
  879. return;
  880. }
  881. this.powerOpenShow = true;
  882. this.$nextTick(() => {
  883. this.$refs.PowerRefAll.setTableList([]);
  884. });
  885. },
  886. //权限保存
  887. powerSave(tableList) {
  888. if (this.powerOpenShow) {
  889. let data = this.selection.map((item) => {
  890. return {
  891. id: item.id,
  892. userAuthority: tableList,
  893. authority: 1
  894. };
  895. });
  896. fileUpdateAllAPI(data).then((msg) => {
  897. this.reload();
  898. });
  899. this.powerOpenShow = false;
  900. } else {
  901. fileUpdateAPI({
  902. id: this.current.id,
  903. userAuthority: tableList,
  904. authority: 1
  905. }).then((msg) => {
  906. this.reload();
  907. });
  908. }
  909. },
  910. //检出
  911. checkOut(powerData) {
  912. if (this.selection.length == 0) {
  913. this.$message.warning('请选择一条数据');
  914. return;
  915. }
  916. if (this.powerFn(powerData)) {
  917. return;
  918. }
  919. checkOut(
  920. this.selection.map((item) => {
  921. return {
  922. id: item.id,
  923. checkOutStatus: 1
  924. };
  925. })
  926. ).then((msg) => {
  927. this.reload();
  928. });
  929. },
  930. //检入
  931. checkEnter(powerData) {
  932. if (this.selection.length == 0) {
  933. this.$message.warning('请选择一条数据');
  934. return;
  935. }
  936. if (this.powerFn(powerData)) {
  937. return;
  938. }
  939. checkEnter(
  940. this.selection.map((item) => {
  941. return {
  942. id: item.id,
  943. checkOutStatus: 0
  944. };
  945. })
  946. ).then((msg) => {
  947. this.reload();
  948. });
  949. },
  950. done() {
  951. this.$refs.table.reRenderTable();
  952. this.selection = [];
  953. },
  954. //下载
  955. getFile(powerData) {
  956. if (this.selection.length == 0) {
  957. this.$message.warning('请选择一条数据');
  958. return;
  959. }
  960. if (this.powerFn(powerData)) {
  961. return;
  962. }
  963. this.selection.forEach((item) => {
  964. getFile(
  965. { objectName: item.stampStoragePath[0].storePath },
  966. item.stampStoragePath[0].name
  967. );
  968. });
  969. },
  970. updateLcyStatus(powerData) {
  971. if (this.selection.length == 0 || this.selection.length.length > 1) {
  972. this.$message.warning('请选择一条数据');
  973. return;
  974. }
  975. if (this.selection[0].checkOutUserName) {
  976. this.$message.warning(
  977. this.selection[0].name +
  978. '已被' +
  979. this.selection[0].checkOutUserName +
  980. '检出 无法归档'
  981. );
  982. return;
  983. }
  984. if (this.powerFn(powerData)) {
  985. return;
  986. }
  987. updateLcyStatus({ id: this.selection[0].id }).then((res) => {
  988. this.reload();
  989. });
  990. },
  991. noUpdateLcyStatus(powerData) {
  992. if (this.selection.length == 0 || this.selection.length > 1) {
  993. this.$message.warning('请选择一条数据');
  994. return;
  995. }
  996. if (this.powerFn(powerData)) {
  997. return;
  998. }
  999. noUpdateLcyStatus({ id: this.selection[0].id }).then((res) => {
  1000. this.reload();
  1001. });
  1002. },
  1003. // selectionChange( selection){
  1004. // console.log( selection,' selection')
  1005. // let data=selection[selection.length-1]
  1006. // this.current=data||this.current
  1007. // this.rowClick(this.current)
  1008. // },
  1009. /* 删除 */
  1010. removeAll(powerData) {
  1011. let fileNames = [];
  1012. let checkOutUserNames = [];
  1013. if (!this.selection.length) {
  1014. this.$message.warning('请至少选择一条数据');
  1015. return;
  1016. }
  1017. if (this.powerFn(powerData)) {
  1018. return;
  1019. }
  1020. this.selection.forEach((item) => {
  1021. if (!item.checkOutUserName) {
  1022. fileNames.push(item.name + '未检出,请先检出在删除');
  1023. }
  1024. if (isCheckOut(item)) {
  1025. checkOutUserNames.push(
  1026. item.name + '已被' + item.checkOutUserName + '检出 无法删除'
  1027. );
  1028. }
  1029. });
  1030. if (fileNames.length) {
  1031. this.$message.warning(fileNames.toString());
  1032. return;
  1033. }
  1034. if (checkOutUserNames.length) {
  1035. this.$message.warning(checkOutUserNames.toString());
  1036. return;
  1037. }
  1038. const loading = this.$loading({ lock: true });
  1039. fileDeleteAPI(this.selection.map((item) => item.id))
  1040. .then((msg) => {
  1041. loading.close();
  1042. this.$message.success('操作成功');
  1043. this.reload();
  1044. })
  1045. .catch((e) => {
  1046. loading.close();
  1047. // this.$message.error(e.message);
  1048. });
  1049. },
  1050. remove(row, powerData) {
  1051. if (this.powerFn(powerData, row)) {
  1052. return;
  1053. }
  1054. if (!row.checkOutUserName) {
  1055. this.$message.warning('请先检出在删除');
  1056. return;
  1057. }
  1058. if (isCheckOut(row)) {
  1059. this.$message.warning(
  1060. row.name + '已被' + row.checkOutUserName + '检出 无法删除'
  1061. );
  1062. return;
  1063. }
  1064. const loading = this.$loading({ lock: true });
  1065. fileDeleteAPI([row.id])
  1066. .then((msg) => {
  1067. loading.close();
  1068. this.$message.success('操作成功');
  1069. this.reload();
  1070. })
  1071. .catch((e) => {
  1072. loading.close();
  1073. // this.$message.error(e.message);
  1074. });
  1075. },
  1076. //发布
  1077. openSendEdit(powerData) {
  1078. if (this.selection.length == 0) {
  1079. this.$message.warning('请选择一条数据');
  1080. return;
  1081. }
  1082. if (this.selection[0].checkOutUserName) {
  1083. this.$message.warning(
  1084. this.selection[0].name +
  1085. '已被' +
  1086. this.selection[0].checkOutUserName +
  1087. '检出 无法发布'
  1088. );
  1089. return;
  1090. }
  1091. if (this.powerFn(powerData)) {
  1092. return;
  1093. }
  1094. this.$refs.sendEditRef.open('add', '', this.selection, this.fileType);
  1095. },
  1096. //移动
  1097. move() {
  1098. if (this.selection.length == 0) {
  1099. this.$message.warning('请选择一条数据');
  1100. return;
  1101. }
  1102. if (this.selection[0].checkOutUserName) {
  1103. this.$message.warning(
  1104. this.selection[0].name +
  1105. '已被' +
  1106. this.selection[0].checkOutUserName +
  1107. '检出 无法移动'
  1108. );
  1109. return;
  1110. }
  1111. this.$refs.moveRef.open(this.selection[0]);
  1112. },
  1113. moveAll(powerData) {
  1114. let fileNames = [];
  1115. let checkOutUserNames = [];
  1116. if (!this.selection.length) {
  1117. this.$message.warning('请至少选择一条数据');
  1118. return;
  1119. }
  1120. if (this.powerFn(powerData)) {
  1121. return;
  1122. }
  1123. this.selection.forEach((item) => {
  1124. if (isCheckOut(item)) {
  1125. checkOutUserNames.push(
  1126. item.name + '已被' + item.checkOutUserName + '检出 无法移动'
  1127. );
  1128. }
  1129. });
  1130. if (fileNames.length) {
  1131. this.$message.warning(fileNames.toString());
  1132. return;
  1133. }
  1134. if (checkOutUserNames.length) {
  1135. this.$message.warning(checkOutUserNames.toString());
  1136. return;
  1137. }
  1138. this.$refs.moveAllRef.open(this.selection.map(item=>item.id).toString())
  1139. },
  1140. getTableList() {
  1141. return JSON.parse(JSON.stringify(this.selection));
  1142. }
  1143. }
  1144. };
  1145. </script>
  1146. <style scoped lang="scss">
  1147. :deep(.el-tabs__content) {
  1148. height: calc(100% - 39px);
  1149. overflow: auto;
  1150. }
  1151. :deep(.ele-table-tool-title-content) {
  1152. display: contents;
  1153. }
  1154. .my-cascader {
  1155. :deep(.el-input__inner) {
  1156. border: none;
  1157. background: none;
  1158. cursor: inherit;
  1159. }
  1160. :deep(.el-input__suffix) {
  1161. display: none;
  1162. }
  1163. }
  1164. </style>