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

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