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

142 lines
4.6 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
  1. <template>
  2. <div class="app-container">
  3. <!--表单组件-->
  4. <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="500px">
  5. <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
  6. <el-form-item label="字典名称" prop="dic_name">
  7. <el-input v-model="form.dic_name" style="width: 370px;" />
  8. </el-form-item>
  9. <el-form-item label="字典代码" prop="dic_code">
  10. <el-input v-model="form.dic_code" style="width: 370px;" />
  11. </el-form-item>
  12. <el-form-item label="内容说明">
  13. <el-input v-model="form.dic_explain" style="width: 370px;" type="textarea" :rows="2" />
  14. </el-form-item>
  15. </el-form>
  16. <div slot="footer" class="dialog-footer">
  17. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  18. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
  19. </div>
  20. </el-dialog>
  21. <!-- 字典列表 -->
  22. <el-row class="container-main" :gutter="10">
  23. <el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="5">
  24. <el-card class="box-card">
  25. <span class="right-top-line" />
  26. <span class="left-bottom-line" />
  27. <crudOperation :permission="permission" />
  28. <!--字典树状结构-->
  29. <el-tree ref="tree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :default-expand-all="true" highlight-current @node-click="handleNodeClick" />
  30. </el-card>
  31. </el-col>
  32. <!-- 字典详情列表 -->
  33. <el-col :xs="24" :sm="24" :md="18" :lg="18" :xl="19">
  34. <el-card class="box-card">
  35. <span class="right-top-line" />
  36. <span class="left-bottom-line" />
  37. <dictDetail ref="dictDetail" :permission="permission" :active-add-btn="activeAddBtn" @treeRefresh="treeRefresh" />
  38. </el-card>
  39. </el-col>
  40. </el-row>
  41. </div>
  42. </template>
  43. <script>
  44. import dictDetail from './dictDetail'
  45. import crudDict from '@/api/archivesConfig/dict'
  46. import CRUD, { presenter, header, form } from '@crud/crud'
  47. import crudOperation from '@crud/CRUD.operation'
  48. const defaultForm = { id: null, dic_name: null, dic_code: null, dic_explain: null, dic_type: true }
  49. export default {
  50. name: 'Dict',
  51. components: { crudOperation, dictDetail },
  52. cruds() {
  53. return [
  54. CRUD({
  55. title: '字典', url: 'api/dictrionary/menu',
  56. crudMethod: { ...crudDict },
  57. optShow: {
  58. add: true,
  59. edit: true,
  60. del: true,
  61. download: false,
  62. group: false
  63. }
  64. })
  65. ]
  66. },
  67. mixins: [presenter(), header(), form(defaultForm)],
  68. data() {
  69. return {
  70. queryTypeOptions: [
  71. { key: 'name', display_name: '字典名称' },
  72. { key: 'description', display_name: '描述' }
  73. ],
  74. rules: {
  75. dic_name: [
  76. { required: true, message: '请输入字典名称', trigger: 'blur' }
  77. ],
  78. dic_code: [
  79. { required: true, message: '请输入字典代码', trigger: 'blur' }
  80. ]
  81. },
  82. permission: {
  83. add: ['admin', 'dict:add'],
  84. edit: ['admin', 'dict:edit'],
  85. del: ['admin', 'dict:del']
  86. },
  87. defaultProps: {
  88. children: 'child_menus',
  89. label: 'dic_name'
  90. },
  91. activeAddBtn: false
  92. }
  93. },
  94. methods: {
  95. // 获取数据前设置好接口地址
  96. [CRUD.HOOK.beforeRefresh]() {
  97. if (this.$refs.dictDetail) {
  98. this.$refs.dictDetail.query.id = ''
  99. }
  100. return true
  101. },
  102. // 选中字典后,设置字典详情数据
  103. handleNodeClick(val) {
  104. if (val) {
  105. if (val.dic_type === 'true') {
  106. this.crud.selectionChangeHandler([val])
  107. } else {
  108. this.crud.selectionChangeHandler([])
  109. }
  110. this.$refs.dictDetail.query.id = val.id
  111. this.$refs.dictDetail.dicPid = val.id
  112. this.$refs.dictDetail.crud.toQuery()
  113. this.activeAddBtn = true
  114. }
  115. },
  116. // 编辑前将字典明细临时清空,避免日志入库数据过长
  117. [CRUD.HOOK.beforeToEdit](crud, form) {
  118. // 将角色的菜单清空,避免日志入库数据过长
  119. form.dictDetails = null
  120. },
  121. treeRefresh() {
  122. this.crud.refresh()
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .el-card{
  129. min-height: calc(100vh - 210px);
  130. }
  131. .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  132. /* background-color: rgb(158, 213, 250) !important; */
  133. }
  134. .el-card__body .crud-opts {
  135. justify-content: space-around;
  136. }
  137. </style>