【前端】智能库房综合管理系统前端项目
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.

285 lines
10 KiB

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