fileIE.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <div class="main-container">
  3. <!-- 外部 -->
  4. <div slot="west">
  5. <div class="box">
  6. <!-- 选择内外部文件的侧边栏 -->
  7. <ibps-type-tree
  8. :width="width"
  9. :height="height"
  10. :category-key="categoryKey"
  11. :has-permission="true"
  12. @node-click="handleNodeClick"
  13. @expand-collapse="handleExpandCollapse"
  14. />
  15. </div>
  16. <ibps-container :margin-left="width + 'px'" class="page">
  17. <el-alert
  18. v-if="!show"
  19. :closable="false"
  20. title="请选择点击记录分类菜单进行操作!"
  21. type="warning"
  22. show-icon
  23. style="height: 50px"
  24. />
  25. <!-- 选择文件,展示在右边 -->
  26. <template v-else>
  27. <ibps-crud
  28. key="istree"
  29. ref="crud"
  30. :data="listData"
  31. :toolbars="listConfig.toolbars"
  32. :search-form="listConfig.searchForm"
  33. :pk-key="pkKey"
  34. :columns="listConfig.columns"
  35. :loading="loading"
  36. :pagination="pagination"
  37. :display-field="tableTitle"
  38. :index-row="false"
  39. @sort-change="handleSortChange"
  40. @action-event="handleAction"
  41. @pagination-change="handlePaginationChange"
  42. >
  43. <template slot="position">
  44. <ibps-user-selector
  45. v-model="pos"
  46. type="position"
  47. readonly-text="text"
  48. :multiple="true"
  49. />
  50. </template>
  51. <template
  52. v-if="scope.row.fu_jian_"
  53. slot="file"
  54. slot-scope="scope"
  55. >
  56. <ibps-attachment
  57. v-model="scope.row.fu_jian_"
  58. allow-download
  59. download
  60. multiple
  61. accept="*"
  62. store="id"
  63. readonly
  64. />
  65. </template>
  66. <template
  67. v-if="scope.row.file_info_"
  68. slot="wenjinachayue"
  69. slot-scope="scope"
  70. >
  71. <div>
  72. <!-- <img
  73. :src="wordPng"
  74. style="vertical-align: middle; height: 20px;"
  75. > -->
  76. <i class="el-icon-document" />
  77. <el-tag
  78. type="info"
  79. style="cursor: pointer"
  80. @click="handleClickTag(scope.row)"
  81. >{{ scope.row.file_info_ }}</el-tag>
  82. </div>
  83. </template>
  84. </ibps-crud>
  85. </template>
  86. </ibps-container>
  87. <!-- 查看修订历史 -->
  88. <file-lookup
  89. v-if="dialogVisible"
  90. :visible="dialogVisible"
  91. :file-infos="fileArray"
  92. @colseVisible="colseVisible"
  93. />
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import ActionUtils from '@/utils/action'
  99. import IbpsAttachment from '@/business/platform/file/attachment/selector'
  100. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  101. import FixHeight from '@/mixins/height'
  102. import IbpsTypeTree from '@/business/platform/cat/type/tree'
  103. import BpmnFormrender from '@/business/platform/bpmn/form/dialog'
  104. import closeFilePng from '@/assets/images/icons/closeFile.png'
  105. import openFilePng from '@/assets/images/icons/openFile.png'
  106. import wordPng from '@/assets/images/icons/word.png'
  107. import fileTraining from '@/views/component/fileTraining'
  108. import UpdateFile from './updateFile'
  109. import DataTemplateFormrenderDialog from '@/business/platform/data/templaterender/form/dialog.vue'
  110. import ibpsUserSelector from '@/business/platform/org/selector'
  111. export default {
  112. components: {
  113. IbpsTypeTree,
  114. BpmnFormrender,
  115. UpdateFile,
  116. 'ibps-attachment': IbpsAttachment,
  117. 'file-lookup': fileTraining,
  118. DataTemplateFormrenderDialog,
  119. ibpsUserSelector
  120. },
  121. mixins: [FixHeight],
  122. data () {
  123. return {
  124. dialogFormVisibles: false,
  125. fileLookShow: false,
  126. sonData: '',
  127. showCaoZuoColumn: false,
  128. // treeData: [],
  129. show: '',
  130. // rightsArr: ['join', 'delete'],
  131. // rowHandle: true,
  132. width: 210,
  133. oldorgId: null,
  134. height: document.clientHeight,
  135. loading: false,
  136. filterText: '',
  137. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  138. formKey: 'ywyxjl', // 编辑dialog需要使用
  139. pkValue: '',
  140. templateKey: 'ywyxjlsc',
  141. visible: false,
  142. categoryKey: 'FILE_TYPE',
  143. tableTitle: '',
  144. listData: [],
  145. selectListData: [],
  146. bianlistData: {
  147. dataResult: [],
  148. pageResult: {
  149. limit: 0,
  150. page: 0,
  151. totalCount: 0,
  152. totalPages: 0
  153. }
  154. },
  155. // listTreeData: [],
  156. listConfig: {
  157. // 工具栏
  158. toolbars: [{ key: 'search' }],
  159. // 查询条件
  160. searchForm: {
  161. forms: []
  162. },
  163. // 表格字段配置
  164. columns: []
  165. },
  166. pagination: {
  167. limit: 20,
  168. page: 1
  169. },
  170. sorts: {},
  171. sqlWhere: {},
  172. searchWhere: {},
  173. pageKey: '',
  174. dialogFormVisible: false,
  175. defId: '',
  176. addDataCont: {},
  177. srcUrl: '', // 报表字段
  178. fileTypesDatas: {
  179. comAuthority: [],
  180. buMenAuthority: [],
  181. authority: []
  182. }, // 存放所点击列表的分类信息
  183. closeFilePng,
  184. openFilePng,
  185. wordPng,
  186. dialogVisible: false,
  187. fileInfos: {},
  188. // 本人修改
  189. fileArray: [],
  190. editDialogVisible: false,
  191. editPkValue: '',
  192. editToolbars: [{
  193. button_type: 'close',
  194. label: '关闭',
  195. key: 'close'
  196. },
  197. {
  198. button_type: 'save',
  199. label: '保存',
  200. key: 'save'
  201. }],
  202. pos: ''
  203. }
  204. },
  205. watch: {
  206. filterText (val) {
  207. this.$refs.tree.filter(val)
  208. },
  209. showCaoZuoColumn (val) {
  210. this.showCaoZuoColumn = val
  211. }
  212. },
  213. created () {
  214. this.listConfig.searchForm.forms = [
  215. { prop: 'wen_jian_bian_hao', label: '文件编号' },
  216. { prop: 'wen_jian_ming_che', label: '文件名称' }
  217. ]
  218. this.listConfig.columns = [
  219. { prop: 'wen_jian_bian_hao', label: '文件编号', sortable: 'custom', width: 150 },
  220. { prop: 'wen_jian_ming_che', label: '文件名称', minWidth: 150 },
  221. { prop: 'ban_ben_hao_', label: '版本', width: 65 },
  222. { prop: 'file_info_', label: '查阅', slotName: 'wenjinachayue', minWidth: 150 },
  223. { prop: 'fa_bu_xiu_ding_zu', label: '发布日期', sortable: 'custom', width: 150 }
  224. ]
  225. },
  226. methods: {
  227. colseVisible (val) {
  228. this.dialogVisible = val
  229. },
  230. getcolse () {
  231. this.dialogFormVisibles = false
  232. },
  233. // 外部文件更新
  234. updateDate (data) {
  235. this.sonData = data
  236. this.dialogFormVisibles = true
  237. },
  238. handleClose (done) {
  239. this.$confirm('确认关闭?')
  240. .then((_) => {
  241. done()
  242. })
  243. .catch((_) => {})
  244. },
  245. handleExpandCollapse (isExpand, readonly = false) {
  246. this.width = isExpand ? 200 : 50
  247. },
  248. loadNode () {
  249. this.loading = true
  250. },
  251. getDatas () {
  252. const { fileType, sorts } = this.sqlWhere
  253. const sql = `select wj.id_, wj.wen_jian_ming_che, wj.wen_jian_bian_hao, wj.ban_ben_hao_, wj.fa_bu_xiu_ding_zu, wj.xin_wen_jian_fu_j, wj.wen_jian_lei_xing, wj.wen_jian_zhu_jian, wj.wen_jian_fen_lei_ , concat(file.file_name_,'.',file.ext_,'(大小:', CASE WHEN file.total_bytes_ >= 1024 * 1024 THEN CONCAT(ROUND(file.total_bytes_ / (1024.0 * 1024), 2), ' M') WHEN file.total_bytes_ >= 1024 THEN CONCAT(ROUND(file.total_bytes_ / 1024.0, 2), ' K') ELSE CONCAT(file.total_bytes_, 'B') END ,')') as file_info_ from t_wjylb wj left join ibps_file_attachment file on file.id_ = wj.xin_wen_jian_fu_j where wj.shi_fou_guo_shen_ ='有效' and wj.fa_fang_ri_qi_ is not null and wj.fa_fang_ri_qi_ <> '' and ( wj.wen_jian_wai_jian = '0' or wj.wen_jian_wai_jian = '2') and FIND_IN_SET (wj.fen_lei_id_,'${fileType}') `
  254. curdPost('sql', sql)
  255. .then((res) => {
  256. const tableDatas = res.variables.data
  257. this.selectListData = JSON.parse(JSON.stringify(tableDatas))
  258. let filterDatas = []
  259. this.bianlistData.pageResult.totalCount = tableDatas.length
  260. this.bianlistData.pageResult.totalPages = Math.ceil(
  261. tableDatas.length / this.pagination.limit
  262. )
  263. this.bianlistData.pageResult.limit = this.pagination.limit
  264. this.bianlistData.pageResult.page = this.pagination.page
  265. if (this.pagination.limit > tableDatas.length) {
  266. filterDatas = JSON.parse(JSON.stringify(tableDatas))
  267. } else {
  268. for (let index = 0; index < 20; index++) {
  269. filterDatas.push(tableDatas[index])
  270. }
  271. }
  272. this.bianlistData.dataResult = filterDatas
  273. ActionUtils.handleListData(this, this.bianlistData)
  274. })
  275. .catch((res) => {
  276. this.loading = false
  277. this.listData = []
  278. })
  279. },
  280. refreshData () {
  281. this.listData = []
  282. this.getSearcFormData()
  283. this.getDatas()
  284. },
  285. hasColumnByProp (columns, prop) {
  286. return columns.some((column) => column.prop === prop)
  287. },
  288. removeColumnByProp (columns, prop) {
  289. return columns.filter((column) => column.prop !== prop)
  290. },
  291. handleNodeClick (nodeId, nodeData, treeDatas) {
  292. // 判断是否显示外部文件更新按钮
  293. if (nodeData.depth !== 0) {
  294. const pathId = nodeData.path ? nodeData.path.split('.') : []
  295. const pathNameList = pathId.map((id) => {
  296. const node = treeDatas.find((item) => item.id === id)
  297. return node ? node.name : ''
  298. })
  299. if (pathNameList.includes('外部文件') && this.isSuper) {
  300. this.showCaoZuoColumn = true
  301. if (
  302. !this.hasColumnByProp(
  303. this.listConfig.columns,
  304. 'cao_zuo'
  305. )
  306. ) {
  307. this.listConfig.columns.push({
  308. prop: 'cao_zuo',
  309. label: '操作',
  310. slotName: 'caozuo',
  311. width: 100
  312. })
  313. }
  314. } else {
  315. this.showCaoZuoColumn = false
  316. this.listConfig.columns = this.removeColumnByProp(
  317. this.listConfig.columns,
  318. 'cao_zuo'
  319. )
  320. }
  321. }
  322. this.show = 'detail'
  323. this.addDataCont = { fenLei: nodeData.name, fenLeiId: nodeId }
  324. const fileTypes = []
  325. // 避免重复请求
  326. if (this.oldorgId === nodeId) {
  327. return
  328. }
  329. // 判断是否存在下级菜单
  330. const noHadNext = !nodeData.children || !nodeData.children.length
  331. if (noHadNext && this.pageKey === 'wjkzgl-ywyxjlsc') {
  332. const chongfu = this.listConfig.toolbars.filter((el) => {
  333. return el.key === 'add'
  334. })
  335. if (chongfu.length === 0 && this.depth !== 0) {
  336. this.listConfig.toolbars.splice(1, 0, { key: 'add' })
  337. }
  338. } else {
  339. this.listConfig.toolbars = this.listConfig.toolbars.filter(
  340. (el) => {
  341. return el.key !== 'add'
  342. }
  343. )
  344. }
  345. this.fileTypesDatas = {
  346. comAuthority: [],
  347. buMenAuthority: [],
  348. authority: [],
  349. shiJiSql: [],
  350. sheBeiSql: []
  351. }
  352. const processAuthority = (nodeId, authorityName) => {
  353. fileTypes.push(nodeId)
  354. if (!authorityName || !authorityName.chaYue) {
  355. return
  356. }
  357. switch (authorityName.chaYue) {
  358. case '公用查阅':
  359. this.fileTypesDatas.comAuthority.push(nodeId)
  360. break
  361. case '部门查阅':
  362. this.fileTypesDatas.buMenAuthority.push(nodeId)
  363. break
  364. case '受限查阅':
  365. this.fileTypesDatas.authority.push(nodeId)
  366. break
  367. }
  368. }
  369. // 递归获取所有子节点
  370. // 存在子节点时,需获取当前节点及所有子节点信息 - task3329
  371. const getTail = (item) => {
  372. const result = [item] // 将自身信息添加到结果中
  373. if (item.children && item.children.length > 0) {
  374. // 如果有子节点,则递归获取子节点的信息
  375. item.children.forEach((child) => {
  376. result.push(...getTail(child)) // 将子节点信息添加到结果中
  377. })
  378. }
  379. return result
  380. }
  381. const result = getTail(nodeData)
  382. result.forEach(({ id, authorityName }) => {
  383. const parsedAuthority = JSON.parse(authorityName)
  384. processAuthority(id, parsedAuthority)
  385. })
  386. this.oldorgId = nodeId
  387. this.sqlWhere = {
  388. fileType: fileTypes.join(',')
  389. }
  390. this.getDatas()
  391. },
  392. // 开启表单页面
  393. openTask (id) {
  394. this.dialogFormVisible = true
  395. this.defId = id
  396. },
  397. // 关闭编辑表单
  398. closeHandle (v) {
  399. this.dialogFormVisible = v
  400. this.refreshData()
  401. },
  402. /**
  403. * 获取格式化参数
  404. */
  405. getSearcFormData () {
  406. this.searchWhere = this.$refs['crud']
  407. ? this.$refs['crud'].getSearcFormData()
  408. : {}
  409. // this.getDatas()
  410. },
  411. /**
  412. * 处理按钮事件
  413. */
  414. handleAction (command, position, selection, data, index, button) {
  415. switch (command) {
  416. case 'search': // 查询
  417. this.refreshData()
  418. break
  419. case 'remove':
  420. if (!data || !data.length) {
  421. this.$message({
  422. message: '请选择数据再进行删除',
  423. type: 'error'
  424. })
  425. }
  426. // eslint-disable-next-line no-case-declarations
  427. const ids = []
  428. for (var i of data) {
  429. ids.push(i.id_)
  430. }
  431. // eslint-disable-next-line no-case-declarations
  432. const deleteParams = {
  433. tableName: 't_ywyxjlb',
  434. paramWhere: { id_: ids.join(',') }
  435. }
  436. curdPost('delete', deleteParams).then(() => {
  437. this.$message({
  438. message: '删除成功!',
  439. type: 'warning'
  440. })
  441. this.refreshData()
  442. })
  443. break
  444. case 'add': // 添加
  445. this.openTask('1072813170935988224')
  446. break
  447. case 'colect': // 收藏或取消收藏
  448. if (!data || !data.length) {
  449. return this.$message({
  450. message: '请先选择数据再进行操作~',
  451. type: 'warning'
  452. })
  453. }
  454. this.handleColect(data)
  455. break
  456. default:
  457. break
  458. }
  459. },
  460. /**
  461. * 处理排序
  462. */
  463. handleSortChange (sort) {
  464. this.sqlWhere.sorts = sort
  465. this.getDatas()
  466. },
  467. // 处理分页事件
  468. handlePaginationChange (page) {
  469. ActionUtils.setPagination(this.pagination, page)
  470. this.bianlistData.pageResult.limit = page.limit
  471. this.bianlistData.pageResult.page = page.page
  472. const filterDatas = []
  473. if (this.selectListData.length >= page.limit * page.page) {
  474. for (
  475. let index = page.limit * page.page - page.limit;
  476. index < page.limit * page.page;
  477. index++
  478. ) {
  479. filterDatas.push(this.selectListData[index])
  480. }
  481. this.bianlistData.dataResult = JSON.parse(
  482. JSON.stringify(filterDatas)
  483. )
  484. } else {
  485. for (
  486. let index = page.limit * page.page - page.limit;
  487. index < this.selectListData.length;
  488. index++
  489. ) {
  490. filterDatas.push(this.selectListData[index])
  491. }
  492. this.bianlistData.dataResult = JSON.parse(
  493. JSON.stringify(filterDatas)
  494. )
  495. }
  496. ActionUtils.handleListData(this, this.bianlistData)
  497. },
  498. async handleColect (data) {
  499. const addScDatas = []
  500. const delIds = []
  501. const scTableName = 't_wjscjl'
  502. for (const i of data) {
  503. // 如果是有sc_id_说明是已经收藏过的,再次点击按钮的时候就取消收藏
  504. if (i.sc_id_) {
  505. delIds.push(i.sc_id_)
  506. } else {
  507. addScDatas.push({
  508. bian_zhi_ren_: this.userId,
  509. bian_zhi_shi_jian: this.$common.getDateNow(19),
  510. parent_id_: i.id
  511. })
  512. }
  513. }
  514. if (addScDatas.length) {
  515. const addParams = {
  516. tableName: scTableName,
  517. paramWhere: addScDatas
  518. }
  519. await curdPost('add', addParams).then((res) => {})
  520. }
  521. if (delIds.length) {
  522. const deleteParams = {
  523. tableName: scTableName,
  524. paramWhere: { id_: delIds.join(',') }
  525. }
  526. await curdPost('delete', deleteParams).then(() => {})
  527. }
  528. this.refreshData()
  529. },
  530. handleClickTag (val) {
  531. this.fileArray = []
  532. // 查看文件修订历史记录
  533. const sql = `select * FROM t_wjylb where wen_jian_zhu_jian = '${val.wen_jian_zhu_jian}' or yuan_shi_id_ = '${val.wen_jian_zhu_jian}' and shi_fou_guo_shen_ = '有效' and wen_jian_wai_jian <> '1'`
  534. this.$common.request('sql', sql).then(async (res) => {
  535. const list = res.variables.data
  536. for (let i = 0; i < list.length; i++) {
  537. const el = list[i]
  538. const obj = {
  539. id: el.wen_jian_zhu_jian,
  540. wen_jian_ming_che: el.wen_jian_ming_che,
  541. ban_ben_: el.ban_ben_,
  542. xin_wen_jian_fu_j: el.xin_wen_jian_fu_j,
  543. xiu_ding_nei_rong: el.xiu_ding_nei_rong,
  544. yuan_yin_: el.xiu_ding_zuo_fei_,
  545. fa_fang_ri_qi_: el.fa_fang_ri_qi_,
  546. wen_jian_bian_hao: el.wen_jian_bian_hao,
  547. bian_zhi_ren_: el.bian_zhi_ren_
  548. }
  549. await this.handleFileInfo(obj)
  550. }
  551. this.dialogVisible = true
  552. })
  553. },
  554. async handleFileInfo (val) {
  555. // 修订附件作废附件不再使用,修订在文件附件上操作
  556. const sql = `select * from ibps_file_attachment where id_= '${val.xin_wen_jian_fu_j}'`
  557. const res = await this.$common.request('sql', sql)
  558. this.fileInfos = {}
  559. const { data = [] } = res.variables || {}
  560. if (!data.length) {
  561. this.$message.warning('没有可查阅的文件,请查明原因!')
  562. return
  563. }
  564. this.fileInfos = {
  565. id: val.id,
  566. FILE_NAME_: val.wen_jian_ming_che,
  567. fileInfos: data[0],
  568. ban_ben_: val.ban_ben_,
  569. xiu_ding_nei_rong: val.xiu_ding_nei_rong ? val.xiu_ding_nei_rong : '',
  570. yuan_yin_: val.yuan_yin_ ? val.yuan_yin_ : '',
  571. wen_jian_bian_hao: val.wen_jian_bian_hao,
  572. fa_fang_ri_qi_: val.fa_fang_ri_qi_,
  573. bian_zhi_ren_: val.bian_zhi_ren_
  574. }
  575. this.fileArray.push(this.fileInfos)
  576. },
  577. handleUpdate (fileId, time) {
  578. const addParams = {
  579. tableName: 't_wjcyjl',
  580. paramWhere: [
  581. {
  582. bian_zhi_ren_: this.userId,
  583. bian_zhi_shi_jian: this.$common.getDateNow(19),
  584. parent_id_: fileId,
  585. shi_chang_: time
  586. }
  587. ]
  588. }
  589. curdPost('add', addParams).then((res) => {
  590. this.refreshData()
  591. })
  592. }
  593. }
  594. }
  595. </script>
  596. <style lang="less" scoped>
  597. .box {
  598. width: 230px;
  599. }
  600. .title {
  601. font-size: 14px;
  602. margin: 21px 5px 5px;
  603. padding: 0;
  604. }
  605. /deep/ .el-tree-node__content {
  606. display: block;
  607. }
  608. /deep/ .el-form-item__label {
  609. text-align: left;
  610. }
  611. /deep/ .el-dialog__footer {
  612. display: flex;
  613. justify-content: center;
  614. }
  615. </style>