阅行客电子档案
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.

320 lines
14 KiB

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