dec-role.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <el-table :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange">
  5. <el-table-column prop="SORT" label="序号" width="80">
  6. <template slot-scope="scope">
  7. {{scope.row.SORT}}
  8. </template>
  9. </el-table-column>
  10. <el-table-column prop="ROLE_NAME" label="级别名称">
  11. <template slot-scope="scope">
  12. <el-tag type="warning" size="small" class="no-border">{{scope.row.ROLE_NAME}}</el-tag>
  13. </template>
  14. </el-table-column>
  15. <el-table-column prop="FW_BONUS_PERCENT" label="服务费(%)">
  16. <template slot-scope="scope">
  17. <el-tag type="danger" size="small" class="no-border">{{scope.row.FW_BONUS_PERCENT}}</el-tag>
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="创建时间">
  21. <template slot-scope="scope">
  22. {{tool.formatDate(scope.row.CREATED_AT)}}
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="更新时间">
  26. <template slot-scope="scope">
  27. {{tool.formatDate(scope.row.UPDATED_AT)}}
  28. </template>
  29. </el-table-column>
  30. <el-table-column fixed="right" label="操作" width="150">
  31. <template slot-scope="scope">
  32. <el-button type="primary" plain size="small" @click="editHandle(scope.row)">Edit</el-button>
  33. <el-button type="danger" plain size="small" @click="delHandle(scope)" v-if="false">Delete</el-button>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <div class="white-box-footer">
  38. <el-dropdown size="small" trigger="click" @command="muliDelHandle" v-if="false">
  39. <el-button type="primary" size="small">
  40. Selected data<!--所选数据--><i class="el-icon-arrow-down el-icon--right"></i>
  41. </el-button>
  42. <el-dropdown-menu slot="dropdown">
  43. <el-dropdown-item command="delete">Delete</el-dropdown-item>
  44. </el-dropdown-menu>
  45. </el-dropdown>
  46. <el-button type="primary" size="small" @click="onAdd" v-if="false">添加级别</el-button>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import Vue from 'vue'
  53. import network from './../../utils/network'
  54. import tool from './../../utils/tool'
  55. export default {
  56. name: 'dec-role',
  57. created () {
  58. },
  59. mounted () {
  60. network.getData('config/dec-role').then(response => {
  61. this.tableData = response.list
  62. this.loading = false
  63. })
  64. },
  65. data () {
  66. return {
  67. tableData: null,
  68. loading: true,
  69. tool: tool,
  70. multipleSelection: []
  71. }
  72. },
  73. methods: {
  74. editHandle (row) {
  75. this.$router.push({path: `/config/dec-role-edit/${row.ID}`})
  76. },
  77. onAdd () {
  78. this.$router.push({path: `/config/dec-role-add`})
  79. },
  80. delHandle (scope) {
  81. network.getData(`config/dec-role-delete/${scope.row.ID}`).then(response => {
  82. this.$message({
  83. message: response,
  84. type: 'success'
  85. })
  86. Vue.delete(this.tableData, scope.$index)
  87. })
  88. },
  89. muliDelHandle (command) {
  90. if (command === 'delete') {
  91. let selectedIds = []
  92. for (let val of this.multipleSelection) {
  93. selectedIds.push(val.ID)
  94. }
  95. network.postData(`config/dec-role-delete`, {
  96. selected: selectedIds
  97. }).then(response => {
  98. this.$message({
  99. message: response,
  100. type: 'success'
  101. })
  102. let tempNewTableData = []
  103. for (let i in this.tableData) {
  104. if (!tool.isInArray(selectedIds, this.tableData[i].ID)) {
  105. tempNewTableData.push(this.tableData[i])
  106. }
  107. }
  108. this.tableData = tempNewTableData
  109. })
  110. }
  111. },
  112. handleSelectionChange (val) {
  113. this.multipleSelection = val
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped>
  119. </style>