file-table-list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <div>
  3. <file-search ref="file-search" @search="reload"></file-search>
  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. @selection-change="selectionClick"
  17. @done="done"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <el-dropdown trigger="click">
  22. <el-button type="primary">
  23. 新建<i class="el-icon-arrow-down el-icon--right"></i>
  24. </el-button>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item
  27. @click.native="
  28. parenOpen('add', {
  29. power: 'add',
  30. dataKey: 'parentData',
  31. isArr: false
  32. })
  33. "
  34. >新建文件夹</el-dropdown-item
  35. >
  36. <el-dropdown-item
  37. @click.native="
  38. openEdit('add', '', {
  39. power: 'add',
  40. dataKey: 'parentData',
  41. isArr: false
  42. })
  43. "
  44. >新建文档</el-dropdown-item
  45. >
  46. </el-dropdown-menu>
  47. </el-dropdown>
  48. <el-dropdown trigger="click">
  49. <el-button type="primary">
  50. 编辑<i class="el-icon-arrow-down el-icon--right"></i>
  51. </el-button>
  52. <el-dropdown-menu slot="dropdown">
  53. <el-dropdown-item
  54. @click.native="
  55. parenOpen('edit', {
  56. power: 'revise',
  57. dataKey: 'parentData',
  58. isArr: false
  59. })
  60. "
  61. >修改</el-dropdown-item
  62. >
  63. <el-dropdown-item
  64. @click.native="
  65. parenOpen('del', {
  66. power: 'del',
  67. dataKey: 'parentData',
  68. isArr: false
  69. })
  70. "
  71. >删除</el-dropdown-item
  72. >
  73. </el-dropdown-menu>
  74. </el-dropdown>
  75. <el-button
  76. :disabled="selection.length == 0"
  77. type="danger"
  78. @click.native="batchRemove"
  79. >
  80. 批量删除
  81. </el-button>
  82. </template>
  83. <template v-slot:code="{ row }">
  84. <el-link type="primary" :underline="false" @click="openEdit('detail', row, {
  85. power: 'detail',
  86. dataKey: 'current',
  87. isArr: false
  88. })">{{ row.code }}</el-link>
  89. </template>
  90. <!-- 操作列 -->
  91. <template v-slot:action="{ row }">
  92. <el-link type="primary" :underline="false" @click="copy(row)">
  93. 复制
  94. </el-link>
  95. <el-link type="primary" :underline="false" @click="openEdit('edit', row, {
  96. power: 'revise',
  97. dataKey: 'current',
  98. isArr: false
  99. })">
  100. 编辑
  101. </el-link>
  102. <el-link v-if="row.status == 0" type="primary" :underline="false" @click="changeStatus(row.id, 1)">
  103. 启用
  104. </el-link>
  105. <el-link v-if="row.status == 1" type="primary" :underline="false" @click="changeStatus(row.id, 0)">
  106. 停用
  107. </el-link>
  108. <el-popconfirm
  109. class="ele-action"
  110. title="确定要删除吗?"
  111. @confirm="
  112. remove(row, {
  113. power: 'del',
  114. dataKey: 'current',
  115. isArr: false
  116. })
  117. "
  118. >
  119. <template v-slot:reference>
  120. <el-link type="danger" :underline="false"> 删除 </el-link>
  121. </template>
  122. </el-popconfirm>
  123. </template>
  124. </ele-pro-table>
  125. <copy-dialog ref="copyDialogRef" @done="reload"></copy-dialog>
  126. <pop-modal
  127. :visible.sync="delVisible"
  128. content="是否确定删除?"
  129. @done="commitBtn"
  130. />
  131. </div>
  132. </template>
  133. <script>
  134. import fileSearch from './file-search.vue';
  135. import popModal from '@/components/pop-modal';
  136. import { fileStatus } from '../util.js';
  137. import copyDialog from './copy-dialog.vue';
  138. import {
  139. filePageV1API,
  140. statusChange,
  141. deleteDoc,
  142. batchDeleteDoc
  143. } from '@/api/documents/doc-manage';
  144. export default {
  145. components: {
  146. fileSearch,
  147. copyDialog,
  148. popModal,
  149. },
  150. props: {
  151. // 上级
  152. parentData: {
  153. type: Object,
  154. default: () => {}
  155. },
  156. // 文件夹数据
  157. folderList: {
  158. type: Array,
  159. default: () => []
  160. },
  161. disabledTableList: {
  162. //已选择列表
  163. default: () => []
  164. }
  165. },
  166. data() {
  167. return {
  168. delVisible: false,
  169. selection: [],
  170. processSubmitDialogFlag: false,
  171. current: {},
  172. // 表格列配置
  173. columns: [
  174. {
  175. width: 45,
  176. type: 'selection',
  177. columnKey: 'selection',
  178. align: 'center',
  179. // selectable: (row, index) => {
  180. // return (
  181. // !this.disabledTableList
  182. // .map((item) => item.id)
  183. // .includes(row.id) &&
  184. // row.reviewStatus != 1 &&
  185. // row.status != 1
  186. // );
  187. // }
  188. },
  189. {
  190. label: '文档位置',
  191. prop: 'directoryPath',
  192. width: 180,
  193. align: 'center',
  194. fixed: 'left',
  195. showOverflowTooltip: true,
  196. // formatter: () => {
  197. // // 优先使用fullPath,如果没有则回退到name
  198. // return this.parentData?.fullPath || this.parentData?.name || '';
  199. // }
  200. },
  201. {
  202. label: '编码',
  203. prop: 'code',
  204. slot: 'code',
  205. width: 180,
  206. align: 'center',
  207. fixed: 'left',
  208. showOverflowTooltip: true
  209. },
  210. {
  211. prop: 'name',
  212. label: '范文名称',
  213. align: 'center',
  214. slot: 'name',
  215. showOverflowTooltip: true,
  216. minWidth: 200
  217. },
  218. {
  219. prop: 'createUserName',
  220. label: '创建人',
  221. align: 'center',
  222. showOverflowTooltip: true,
  223. minWidth: 100
  224. },
  225. {
  226. prop: 'createTime',
  227. label: '创建时间',
  228. align: 'center',
  229. showOverflowTooltip: true,
  230. minWidth: 160
  231. },
  232. {
  233. prop: 'status',
  234. label: '状态',
  235. align: 'center',
  236. showOverflowTooltip: true,
  237. minWidth: 100,
  238. formatter: (_row, _column, cellValue) => {
  239. return fileStatus(cellValue);
  240. }
  241. },
  242. {
  243. columnKey: 'action',
  244. label: '操作',
  245. width: 200,
  246. align: 'center',
  247. resizable: false,
  248. slot: 'action',
  249. showOverflowTooltip: true,
  250. fixed: 'right'
  251. }
  252. ],
  253. // 是否显示编辑弹窗
  254. showEditFlag: false
  255. };
  256. },
  257. computed: {
  258. seekList() {
  259. return [
  260. {
  261. prop: 'code:',
  262. label: '范文名称',
  263. type: 'input'
  264. },
  265. {
  266. prop: 'name',
  267. label: '创建人:',
  268. type: 'input'
  269. }
  270. ];
  271. }
  272. },
  273. created() {},
  274. methods: {
  275. commitBtn() {
  276. const dataId = this.selection.map((v) => v.id);
  277. batchDeleteDoc(dataId).then((res) => {
  278. this.$message.success('删除成功!');
  279. this.reload();
  280. });
  281. },
  282. // 复制
  283. copy(row) {
  284. this.$refs.copyDialogRef.open('copy', row, this.folderList);
  285. },
  286. // 状态变更
  287. async changeStatus(id, status) {
  288. await statusChange({
  289. id: id,
  290. status: status
  291. });
  292. this.$message.success('操作成功');
  293. this.reload();
  294. },
  295. /* 表格数据源 */
  296. datasource({ page, limit, where, order }) {
  297. this.current = {};
  298. return filePageV1API({
  299. ...where,
  300. ...order,
  301. pageNum: page,
  302. size: limit,
  303. directoryId: this.parentData?.id,
  304. });
  305. },
  306. /* 刷新表格 */
  307. reload(where) {
  308. this.$refs.table &&
  309. this.$refs.table.reload({ pageNum: 1, where: where });
  310. },
  311. selectionClick(data) {
  312. this.current = data.reverse()[0] || {};
  313. this.$refs.table.setCurrentRow(this.current);
  314. },
  315. /* 显示编辑 */
  316. openEdit(type, row = '', powerData) {
  317. const query = {};
  318. // if (row?.id) {
  319. query.id = row?.id;
  320. query.type = type;
  321. query.treeId = this.parentData?.id;
  322. // }
  323. this.$router.push({
  324. path: '/documents/documentTemplate/file-add',
  325. query
  326. });
  327. },
  328. parenOpen(type, powerData) {
  329. this.$emit('parenOpen', type);
  330. },
  331. done() {
  332. this.$refs.table.reRenderTable();
  333. this.selection = [];
  334. },
  335. /* 删除 */
  336. remove(row, powerData) {
  337. const loading = this.$loading({ lock: true });
  338. deleteDoc([row.id])
  339. .then((msg) => {
  340. loading.close();
  341. this.$message.success('操作成功');
  342. this.reload();
  343. })
  344. .catch((e) => {
  345. loading.close();
  346. // this.$message.error(e.message);
  347. });
  348. },
  349. //移动
  350. batchRemove() {
  351. if (this.selection.length == 0) {
  352. this.$message.warning('请选择一条数据');
  353. return;
  354. }
  355. this.delVisible = true;
  356. },
  357. getTableList() {
  358. return JSON.parse(JSON.stringify(this.selection));
  359. }
  360. }
  361. };
  362. </script>
  363. <style scoped lang="scss">
  364. :deep(.el-tabs__content) {
  365. height: calc(100% - 39px);
  366. overflow: auto;
  367. }
  368. :deep(.ele-table-tool-title-content) {
  369. display: contents;
  370. }
  371. </style>