阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

295 lines
12 KiB

1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
  1. <template>
  2. <div class="app-container category-container" style="height: calc(100vh - 140px);">
  3. <!-- 门类列表 -->
  4. <div class="container-main">
  5. <div class="elect-cont-left">
  6. <div class="head-container">
  7. <crudOperation :permission="permission">
  8. <template v-slot:left>
  9. <el-button size="mini" :disabled="crud.selections.length === 0 || crud.selections[0].isType !== 1 || crud.selections[0].isType === 3" @click="crud.toAdd">
  10. <i class="iconfont icon-xinzeng" />
  11. 新增
  12. </el-button>
  13. <el-button size="mini" :disabled="crud.selections.length !== 1 || crud.selections[0].pid === '0' || crud.selections[0].isType === 3" @click="crud.toEdit(crud.selections[0])">
  14. <i class="iconfont icon-bianji" />
  15. 编辑
  16. </el-button>
  17. </template>
  18. <template v-slot:right>
  19. <el-button size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0 || (crud.selections.length === 1 && crud.selections[0].pid === '0' ) || crud.selections[0].isType === 3" @click="toDelete(crud.selections)">
  20. <i class="iconfont icon-shanchu" />
  21. 删除
  22. </el-button>
  23. <el-button icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="brotherNodeNum <= 1 || crud.selections[0].pid === '0' || crud.selections[0].isType === 3 " @click="toSort(crud.selections)">排序</el-button>
  24. </template>
  25. </crudOperation>
  26. </div>
  27. <div class="container-left">
  28. <span class="right-top-line" />
  29. <span class="left-bottom-line" />
  30. <!--门类树状结构-->
  31. <div class="tree-scroll">
  32. <el-scrollbar style="height: calc(100vh - 230px);">
  33. <el-tree ref="tree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleNodeClick">
  34. <span slot-scope="{ node, data }" class="custom-tree-node">
  35. <span v-if="data.isType === 1 " class="iconFolder">
  36. {{ data.cnName }}
  37. </span>
  38. <span v-if="data.isType === 2" class="iconArch">
  39. {{ data.cnName }}
  40. </span>
  41. <span v-if="data.isType === 3" class="iconFile">
  42. {{ data.cnName }}
  43. </span>
  44. </span>
  45. </el-tree>
  46. </el-scrollbar>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- 门类管理tab -->
  51. <div class="elect-cont-right">
  52. <div class="container-right tab-content">
  53. <span class="right-top-line" />
  54. <span class="left-bottom-line" />
  55. <ul class="tab-nav">
  56. <li :class="{'active-tab-nav': activeIndex == 0}" @click="changeActiveTab(0)">基本信息<i /></li>
  57. <li v-if="selectedCategory.isType && selectedCategory.isType === 3 && selectedCategory.cnName !== '电子原文表'" :class="{'active-tab-nav': activeIndex == 1}" @click="changeActiveTab(1)">字段管理<i /></li>
  58. <li v-if="selectedCategory.isType && selectedCategory.isType === 3 && selectedCategory.cnName !== '电子原文表'" :class="{'active-tab-nav': activeIndex == 2}" @click="changeActiveTab(2)">著录界面设置<i /></li>
  59. <li v-if="selectedCategory.isType && selectedCategory.isType === 3 && selectedCategory.cnName !== '电子原文表'" :class="{'active-tab-nav': activeIndex == 3}" @click="changeActiveTab(3)">列表界面设置<i /></li>
  60. <li v-if="selectedCategory.isType && selectedCategory.isType === 3 && selectedCategory.cnName !== '电子原文表'" :class="{'active-tab-nav': activeIndex == 4}" @click="changeActiveTab(4)">排序规则设置<i /></li>
  61. <!-- 最右侧装饰img -->
  62. <span class="tab-right-img" />
  63. </ul>
  64. <component :is="comName" :selected-category="selectedCategory" />
  65. </div>
  66. </div>
  67. <!--修改新增表单组件-->
  68. <eForm ref="eform" :selected-category="selectedCategory" />
  69. <el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="deleteVisible" :before-close="handleClose">
  70. <div class="setting-dialog">
  71. <div class="tip-content">
  72. <p class="tipMsg">此操作将删除当前所选分类项及其子集</p>
  73. <span>你是否还要继续?</span>
  74. </div>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button type="text" @click="deleteVisible = false">取消</el-button>
  77. <el-button type="primary" @click.native="handleConfirm">确定</el-button>
  78. </div>
  79. </div>
  80. </el-dialog>
  81. <el-dialog class="tip-dialog" title="确认删除" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="reconfirmDeleteVisible" :before-close="handleClose">
  82. <div class="setting-dialog">
  83. <div class="tip-content">
  84. <p class="tipMsg">删除后会永久清除此门类的相关设置及报表请谨慎操作</p>
  85. <span>提示为确保档案安全必须先手工删除此门类的所有档案数据</span>
  86. </div>
  87. <div slot="footer" class="dialog-footer">
  88. <el-button type="text" @click="reconfirmDeleteVisible = false">取消</el-button>
  89. <el-button type="primary" @click.native="handleReconfirm">确定</el-button>
  90. </div>
  91. </div>
  92. </el-dialog>
  93. <!--排序对话框组件-->
  94. <sortDialog ref="sort" @treeNodeSort="treeNodeSort" />
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import crudDocument from '@/api/system/fileLibrary/fileLibrary'
  100. import CRUD, { presenter, header } from '@crud/crud'
  101. import eForm from './form'
  102. import sortDialog from './sortDialog'
  103. import baseInfo from './baseInfo/index'
  104. import fieldManage from './fieldManage/index'
  105. import descriptionPreview from './descriptionPreview/index'
  106. import listBrowsing from './listBrowsing/index'
  107. import orderingRule from './orderingRule/index'
  108. import crudOperation from '@crud/CRUD.operation'
  109. import Vue from 'vue'
  110. export default {
  111. name: 'FileLibraryManage',
  112. components: { crudOperation, eForm, sortDialog, baseInfo, fieldManage, descriptionPreview, listBrowsing, orderingRule },
  113. cruds() {
  114. return [
  115. CRUD({
  116. title: '分类', url: 'api/document/menu',
  117. crudMethod: { ...crudDocument },
  118. optShow: {
  119. add: false,
  120. edit: false,
  121. del: false,
  122. download: false,
  123. group: false
  124. }
  125. })
  126. ]
  127. },
  128. mixins: [presenter(), header()],
  129. provide() {
  130. return {
  131. parentsData: this
  132. }
  133. },
  134. data() {
  135. return {
  136. permission: {
  137. add: ['admin', 'category:add'],
  138. edit: ['admin', 'category:edit'],
  139. del: ['admin', 'category:del'],
  140. sort: ['admin', 'category:sort']
  141. },
  142. defaultProps: {
  143. children: 'children',
  144. label: 'cnName'
  145. },
  146. deleteVisible: false,
  147. reconfirmDeleteVisible: false,
  148. selectedCategory: {},
  149. deleteData: {},
  150. activeIndex: 0,
  151. sortLoading: false,
  152. brotherNodeNum: 0
  153. // sortTableData: []
  154. }
  155. },
  156. computed: {
  157. comName: function() {
  158. if (this.activeIndex === 0) {
  159. return 'baseInfo'
  160. } else if (this.activeIndex === 1) {
  161. return 'fieldManage'
  162. } else if (this.activeIndex === 2) {
  163. return 'descriptionPreview'
  164. } else if (this.activeIndex === 3) {
  165. return 'listBrowsing'
  166. } else if (this.activeIndex === 4) {
  167. return 'orderingRule'
  168. }
  169. return 'baseInfo'
  170. }
  171. },
  172. methods: {
  173. // 逆归实现 获取指定元素
  174. findNode(tree, func) {
  175. for (const node of tree) {
  176. if (func(node)) return node
  177. if (node.children) {
  178. const res = this.findNode(node.children, func)
  179. if (res) return res
  180. }
  181. }
  182. return null
  183. },
  184. // 展开选中的父级
  185. expandParents(node) {
  186. node.expanded = true
  187. if (node.parent) {
  188. this.expandParents(node.parent)
  189. }
  190. },
  191. [CRUD.HOOK.afterRefresh]() {
  192. let currentKey
  193. if (localStorage.getItem('documentCategoryKey')) {
  194. currentKey = JSON.parse(localStorage.getItem('documentCategoryKey'))
  195. } else {
  196. if (this.crud.data[0].isType === 1) {
  197. currentKey = this.findNode(this.crud.data[0].children, (node) => {
  198. return node.isType !== 1
  199. })
  200. } else {
  201. currentKey = this.crud.data[0]
  202. }
  203. }
  204. // 设置某个节点的当前选中状态
  205. this.$refs.tree.setCurrentKey(currentKey.id)
  206. this.$nextTick(() => {
  207. // 设置某个节点的父级展开
  208. const selectedKey = this.$refs.tree.getCurrentNode()
  209. if (this.$refs.tree.getNode(selectedKey) && this.$refs.tree.getNode(selectedKey).parent) {
  210. this.expandParents(this.$refs.tree.getNode(selectedKey).parent)
  211. }
  212. // 选中节点的门类详情
  213. this.handleNodeClick(selectedKey)
  214. })
  215. },
  216. // 选中门类后,设置门类详情数据
  217. handleNodeClick(val) {
  218. if (val) {
  219. this.crud.selectionChangeHandler([val])
  220. this.$refs.eform.pid = val.id
  221. this.selectedCategory = val
  222. if (val.pid !== '0') {
  223. Vue.set(this.selectedCategory, 'parentName', this.$refs.tree.getNode(val.pid).data.cnName)
  224. }
  225. this.changeActiveTab(0)
  226. // 缓存当前的选中的
  227. localStorage.setItem('documentCategoryKey', JSON.stringify(val))
  228. if (this.$refs.tree.getNode(val.pid) && this.$refs.tree.getNode(val.pid).childNodes) {
  229. this.brotherNodeNum = this.$refs.tree.getNode(val.pid).childNodes.length
  230. }
  231. }
  232. },
  233. // 新增 - 判断当前节点类型,卷内/文件不可新建
  234. [CRUD.HOOK.beforeToAdd](crud, form) {
  235. if (this.selectedCategory.pid === '0') {
  236. this.$refs.eform.parentName = '文件库'
  237. } else if (this.selectedCategory.isType === 1) {
  238. this.$refs.eform.parentName = this.selectedCategory.cnName
  239. }
  240. this.$refs.eform.beforeToAdd()
  241. },
  242. // 初始化编辑
  243. [CRUD.HOOK.beforeToEdit](crud, form) {
  244. this.$refs.eform.parentName = this.selectedCategory.parentName
  245. },
  246. // 新增/编辑后 - 新增后默认选中新增的门类
  247. [CRUD.HOOK.afterSubmit](crud, addedCategory) {
  248. if (addedCategory) {
  249. // 缓存当前的选中的
  250. localStorage.setItem('documentCategoryKey', JSON.stringify(addedCategory))
  251. }
  252. },
  253. treeNodeSort(data) {
  254. this.$refs.tree.updateKeyChildren(data[0].pid, JSON.parse(JSON.stringify(data)))
  255. },
  256. toDelete(data) {
  257. this.deleteData = data
  258. this.deleteVisible = true
  259. },
  260. handleConfirm() {
  261. this.deleteVisible = false
  262. setTimeout(() => {
  263. this.reconfirmDeleteVisible = true
  264. }, 300)
  265. },
  266. handleReconfirm() {
  267. this.reconfirmDeleteVisible = false
  268. this.crud.delAllLoading = true
  269. this.crud.doDelete(this.deleteData).then((res) => {
  270. // 清空缓存的门类节点
  271. localStorage.removeItem('documentCategoryKey')
  272. })
  273. },
  274. handleClose(done) {
  275. this.deleteData = {}
  276. done()
  277. },
  278. toSort(data) {
  279. this.$refs.sort.sortTableData = this.$refs.tree.getNode(data[0].pid).data.children
  280. this.$refs.sort.sortVisible = true
  281. },
  282. changeActiveTab(data) {
  283. this.activeIndex = data
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. .tree-scroll{
  290. font-size: 14px;
  291. }
  292. </style>