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

305 lines
13 KiB

  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" @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 === 4" @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 === 4" @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' || crud.selections[0].isType === 5" @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 || data.isType === 3 || data.isType===5" class="iconArch">
  39. {{ data.cnName }}
  40. </span>
  41. <span v-if="data.isType===4" 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 === 4" :class="{'active-tab-nav': activeIndex == 1}" @click="changeActiveTab(1)">门类字段管理<i /></li>
  57. <li v-if="selectedCategory.isType && selectedCategory.isType === 4" :class="{'active-tab-nav': activeIndex == 2}" @click="changeActiveTab(2)">著录界面管理<i /></li>
  58. <li v-if="selectedCategory.isType && selectedCategory.isType === 4" :class="{'active-tab-nav': activeIndex == 3}" @click="changeActiveTab(3)">列表界面浏览设置<i /></li>
  59. <li v-if="selectedCategory.isType && selectedCategory.isType === 4" :class="{'active-tab-nav': activeIndex == 4}" @click="changeActiveTab(4)">浏览排序规则设置<i /></li>
  60. <li v-if="selectedCategory.isType && selectedCategory.isType === 4" :class="{'active-tab-nav': activeIndex == 5}" @click="changeActiveTab(5)">档号规则设置<i /></li>
  61. <li v-if="selectedCategory.isType && selectedCategory.isType !== 1 && selectedCategory.isType !== 4" :class="{'active-tab-nav': activeIndex == 6}" @click="changeActiveTab(6)">归档章设置<i /></li>
  62. <li v-if="selectedCategory.isType && selectedCategory.isType !== 1 && selectedCategory.isType !== 4" :class="{'active-tab-nav': activeIndex == 7}" @click="changeActiveTab(7)">公共筛选<i /></li>
  63. <li v-if="selectedCategory.isType && selectedCategory.isType !== 1 && selectedCategory.isType !== 4" :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" :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">
  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/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/archives-type/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. data() {
  137. return {
  138. permission: {
  139. add: ['admin', 'category:add'],
  140. edit: ['admin', 'category:edit'],
  141. del: ['admin', 'category:del'],
  142. sort: ['admin', 'category:sort']
  143. },
  144. defaultProps: {
  145. children: 'children',
  146. label: 'cnName'
  147. },
  148. deleteVisible: false,
  149. reconfirmDeleteVisible: false,
  150. selectedCategory: {},
  151. deleteData: {},
  152. activeIndex: 0,
  153. sortLoading: false,
  154. brotherNodeNum: 0
  155. // sortTableData: []
  156. }
  157. },
  158. computed: {
  159. comName: function() {
  160. if (this.activeIndex === 0) {
  161. return 'baseInfo'
  162. } else if (this.activeIndex === 1) {
  163. return 'fieldManage'
  164. } else if (this.activeIndex === 2) {
  165. return 'descriptionPreview'
  166. } else if (this.activeIndex === 3) {
  167. return 'listBrowsing'
  168. } else if (this.activeIndex === 4) {
  169. return 'orderingRule'
  170. } else if (this.activeIndex === 5) {
  171. return 'fileNoFormat'
  172. } else if (this.activeIndex === 6) {
  173. return 'archiveSealSetting'
  174. } else if (this.activeIndex === 7) {
  175. return 'publicScreening'
  176. } else if (this.activeIndex === 8) {
  177. return 'processManage'
  178. }
  179. return 'baseInfo'
  180. }
  181. },
  182. methods: {
  183. // 逆归实现 获取指定元素
  184. findNode(tree, func) {
  185. for (const node of tree) {
  186. if (func(node)) return node
  187. if (node.children) {
  188. const res = this.findNode(node.children, func)
  189. if (res) return res
  190. }
  191. }
  192. return null
  193. },
  194. // 展开选中的父级
  195. expandParents(node) {
  196. node.expanded = true
  197. if (node.parent) {
  198. this.expandParents(node.parent)
  199. }
  200. },
  201. [CRUD.HOOK.afterRefresh]() {
  202. let currentKey
  203. if (localStorage.getItem('currentCategoryKey')) {
  204. currentKey = JSON.parse(localStorage.getItem('currentCategoryKey'))
  205. } else {
  206. if (this.crud.data[0].isType === 1) {
  207. currentKey = this.findNode(this.crud.data[0].children, (node) => {
  208. return node.isType !== 1
  209. })
  210. } else {
  211. currentKey = this.crud.data[0]
  212. }
  213. }
  214. // 设置某个节点的当前选中状态
  215. this.$refs.tree.setCurrentKey(currentKey.id)
  216. this.$nextTick(() => {
  217. // 设置某个节点的父级展开
  218. const selectedKey = this.$refs.tree.getCurrentNode()
  219. if (this.$refs.tree.getNode(selectedKey) && this.$refs.tree.getNode(selectedKey).parent) {
  220. this.expandParents(this.$refs.tree.getNode(selectedKey).parent)
  221. }
  222. // 选中节点的门类详情
  223. this.handleNodeClick(selectedKey)
  224. })
  225. },
  226. // 选中门类后,设置门类详情数据
  227. handleNodeClick(val) {
  228. if (val) {
  229. this.crud.selectionChangeHandler([val])
  230. this.$refs.eform.pid = val.id
  231. this.selectedCategory = val
  232. if (val.pid !== '0') {
  233. Vue.set(this.selectedCategory, 'parentName', this.$refs.tree.getNode(val.pid).data.cnName)
  234. }
  235. this.changeActiveTab(0)
  236. // 缓存当前的选中的
  237. localStorage.setItem('currentCategoryKey', JSON.stringify(val))
  238. if (this.$refs.tree.getNode(val.pid) && this.$refs.tree.getNode(val.pid).childNodes) {
  239. this.brotherNodeNum = this.$refs.tree.getNode(val.pid).childNodes.length
  240. }
  241. }
  242. },
  243. // 新增 - 判断当前节点类型,卷内/文件不可新建
  244. [CRUD.HOOK.beforeToAdd](crud, form, btn) {
  245. const isCanAddKey = JSON.parse(localStorage.getItem('currentCategoryKey'))
  246. if (isCanAddKey.isType === 4 || isCanAddKey.isType === 5) {
  247. this.$message({
  248. message: '此门类下不可新建门类',
  249. type: 'error',
  250. duration: 2500
  251. })
  252. return false
  253. }
  254. this.$refs.eform.beforeToAdd()
  255. },
  256. // 新增/编辑后 - 新增后默认选中新增的门类
  257. [CRUD.HOOK.afterSubmit](crud, addedCategory) {
  258. if (addedCategory) {
  259. // 缓存当前的选中的
  260. localStorage.setItem('currentCategoryKey', JSON.stringify(addedCategory))
  261. }
  262. },
  263. treeNodeSort(data) {
  264. this.$refs.tree.updateKeyChildren(data[0].pid, JSON.parse(JSON.stringify(data)))
  265. },
  266. toDelete(data) {
  267. this.deleteData = data
  268. this.deleteVisible = true
  269. },
  270. handleConfirm() {
  271. this.deleteVisible = false
  272. setTimeout(() => {
  273. this.reconfirmDeleteVisible = true
  274. }, 300)
  275. },
  276. handleReconfirm() {
  277. this.reconfirmDeleteVisible = false
  278. this.crud.delAllLoading = true
  279. this.crud.doDelete(this.deleteData).then((res) => {
  280. // 清空缓存的门类节点
  281. localStorage.removeItem('currentCategoryKey')
  282. })
  283. },
  284. handleClose(done) {
  285. this.deleteData = {}
  286. done()
  287. },
  288. toSort(data) {
  289. this.$refs.sort.sortTableData = this.$refs.tree.getNode(data[0].pid).data.children
  290. this.$refs.sort.sortVisible = true
  291. },
  292. changeActiveTab(data) {
  293. this.activeIndex = data
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. .tree-scroll{
  300. font-size: 14px;
  301. }
  302. </style>