index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="pa-3 white">
  3. <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
  4. <m-table
  5. v-loading="loading"
  6. :items="items"
  7. :headers="headers"
  8. :page-size="pageInfo.size"
  9. :page-current="pageInfo.current"
  10. :total="total"
  11. @page-change="onPageChange"
  12. >
  13. <!-- <template #card-tools>
  14. <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
  15. </template> -->
  16. <template #dictCode="{ row }">
  17. <el-tag>{{ row.dictCode === 'systemCode' ? '系统级' : '用户级'}}</el-tag>
  18. </template>
  19. <template #actions="{ row }">
  20. <!-- <m-button type="primary" text @click="onEdit(row)">编辑</m-button> -->
  21. <m-button type="primary" text @click="onEdit(row)">字典配置</m-button>
  22. <!-- <m-button type="danger" text @click="onDelete(row)">删除</m-button> -->
  23. </template>
  24. </m-table>
  25. <DictionariesEdit ref="dictionariesEditRefs" @success="onInit"></DictionariesEdit>
  26. </div>
  27. </template>
  28. <script>
  29. import {
  30. getDictionariesList,
  31. deleteDictionaries
  32. } from '@/api/system'
  33. import DictionariesEdit from './dictionariesEdit'
  34. export default {
  35. name: 'SystemDictionaries',
  36. components: {
  37. DictionariesEdit
  38. },
  39. data () {
  40. return {
  41. searchValues: {
  42. dictTitle: null,
  43. dictCode: 'systemCode'
  44. },
  45. headers: [
  46. { label: '名称', prop: 'dictTitle' },
  47. { label: '类型', prop: 'dictCode', align: 'center' },
  48. { label: '标识', prop: 'dictValue', align: 'center' },
  49. { label: '创建时间', prop: 'createDate' },
  50. { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
  51. ],
  52. items: [],
  53. total: 0,
  54. pageInfo: {
  55. current: 1,
  56. size: 10
  57. },
  58. orders: [],
  59. loading: false
  60. }
  61. },
  62. computed: {
  63. searchItems () {
  64. return [
  65. {
  66. label: '名称',
  67. prop: 'dictTitle',
  68. type: 'input',
  69. options: {
  70. placeholder: '请输入名称'
  71. }
  72. },
  73. {
  74. label: '类型',
  75. prop: 'dictCode',
  76. type: 'select',
  77. options: {
  78. placeholder: '请输入名称',
  79. clearable: false,
  80. items: [
  81. { label: '系统级', value: 'systemCode' },
  82. { label: '用户级', value: 'userCode' }
  83. ]
  84. }
  85. }
  86. ]
  87. }
  88. },
  89. created () {
  90. this.onInit()
  91. },
  92. methods: {
  93. async onInit () {
  94. this.loading = true
  95. try {
  96. const { data } = await getDictionariesList({
  97. page: {
  98. ...this.pageInfo,
  99. orders: this.orders
  100. },
  101. ...this.searchValues
  102. })
  103. this.items = data.records
  104. this.total = data.total
  105. } catch (error) {
  106. this.$message.error(error)
  107. } finally {
  108. this.loading = false
  109. }
  110. },
  111. onAdd () {
  112. this.$refs.dictionariesEditRefs.open()
  113. },
  114. onEdit (item) {
  115. this.$refs.dictionariesEditRefs.open(item)
  116. },
  117. onDelete (row) {
  118. this.$confirm('确定删除吗?', '提示')
  119. .then(async () => {
  120. try {
  121. await deleteDictionaries({ id: row.id })
  122. this.$message.success('删除成功')
  123. this.onInit()
  124. } catch (error) {
  125. this.$message.error(error)
  126. }
  127. })
  128. .catch(_ => {})
  129. },
  130. onSearch () {
  131. this.pageInfo.current = 1
  132. this.onInit()
  133. },
  134. onPageChange (index) {
  135. this.pageInfo.current = index
  136. this.onInit()
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. </style>