Rap 原分销系统代码Web
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.

136 lines
5.0KB

  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="name">
  7. <el-input v-model="form.name" style="width: 370px;" />
  8. </el-form-item>
  9. <el-form-item label="描述">
  10. <el-input v-model="form.description" style="width: 370px;" />
  11. </el-form-item>
  12. </el-form>
  13. <div slot="footer" class="dialog-footer">
  14. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  15. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
  16. </div>
  17. </el-dialog>
  18. <!-- 字典列表 -->
  19. <el-row :gutter="10">
  20. <el-col :xs="24" :sm="24" :md="10" :lg="11" :xl="11" style="margin-bottom: 10px">
  21. <el-card class="box-card">
  22. <!--工具栏-->
  23. <div class="head-container">
  24. <div v-if="crud.props.searchToggle">
  25. <!-- 搜索 -->
  26. <el-input v-model="query.blurry" clearable size="small" placeholder="输入名称或者描述搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  27. <rrOperation />
  28. </div>
  29. <crudOperation :permission="permission" />
  30. </div>
  31. <!--表格渲染-->
  32. <el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row style="width: 100%;" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
  33. <el-table-column type="selection" width="55" />
  34. <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" />
  35. <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" />
  36. <el-table-column v-if="checkPer(['admin','dict:edit','dict:del'])" label="操作" width="130px" align="center" fixed="right">
  37. <template slot-scope="scope">
  38. <udOperation
  39. :data="scope.row"
  40. :permission="permission"
  41. />
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <!--分页组件-->
  46. <pagination />
  47. </el-card>
  48. </el-col>
  49. <!-- 字典详情列表 -->
  50. <el-col :xs="24" :sm="24" :md="14" :lg="13" :xl="13">
  51. <el-card class="box-card">
  52. <div slot="header" class="clearfix">
  53. <span>字典详情</span>
  54. <el-button
  55. v-if="checkPer(['admin','dict:add']) && this.$refs.dictDetail && this.$refs.dictDetail.query.dictName"
  56. class="filter-item"
  57. size="mini"
  58. style="float: right;padding: 4px 10px"
  59. type="primary"
  60. icon="el-icon-plus"
  61. @click="$refs.dictDetail && $refs.dictDetail.crud.toAdd()"
  62. >新增</el-button>
  63. </div>
  64. <dictDetail ref="dictDetail" :permission="permission" />
  65. </el-card>
  66. </el-col>
  67. </el-row>
  68. </div>
  69. </template>
  70. <script>
  71. import dictDetail from './dictDetail'
  72. import crudDict from '@/api/system/dict'
  73. import CRUD, { presenter, header, form } from '@crud/crud'
  74. import crudOperation from '@crud/CRUD.operation'
  75. import pagination from '@crud/Pagination'
  76. import rrOperation from '@crud/RR.operation'
  77. import udOperation from '@crud/UD.operation'
  78. const defaultForm = { id: null, name: null, description: null, dictDetails: [] }
  79. export default {
  80. name: 'Dict',
  81. components: { crudOperation, pagination, rrOperation, udOperation, dictDetail },
  82. cruds() {
  83. return [
  84. CRUD({ title: '字典', url: 'api/dict', crudMethod: { ...crudDict }})
  85. ]
  86. },
  87. mixins: [presenter(), header(), form(defaultForm)],
  88. data() {
  89. return {
  90. queryTypeOptions: [
  91. { key: 'name', display_name: '字典名称' },
  92. { key: 'description', display_name: '描述' }
  93. ],
  94. rules: {
  95. name: [
  96. { required: true, message: '请输入名称', trigger: 'blur' }
  97. ]
  98. },
  99. permission: {
  100. add: ['admin', 'dict:add'],
  101. edit: ['admin', 'dict:edit'],
  102. del: ['admin', 'dict:del']
  103. }
  104. }
  105. },
  106. methods: {
  107. // 获取数据前设置好接口地址
  108. [CRUD.HOOK.beforeRefresh]() {
  109. if (this.$refs.dictDetail) {
  110. this.$refs.dictDetail.query.dictName = ''
  111. }
  112. return true
  113. },
  114. // 选中字典后,设置字典详情数据
  115. handleCurrentChange(val) {
  116. if (val) {
  117. this.$refs.dictDetail.query.dictName = val.name
  118. this.$refs.dictDetail.dictId = val.id
  119. this.$refs.dictDetail.crud.toQuery()
  120. }
  121. },
  122. // 编辑前将字典明细临时清空,避免日志入库数据过长
  123. [CRUD.HOOK.beforeToEdit](crud, form) {
  124. // 将角色的菜单清空,避免日志入库数据过长
  125. form.dictDetails = null
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped>
  131. </style>