permission.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div>
  3. <basic-container>
  4. <h3>表格权限控制</h3>
  5. <avue-crud ref="crud"
  6. :permission="permission"
  7. :option="option"
  8. :data="data">
  9. <template slot="expand"
  10. slot-scope="scope">
  11. {{scope}}
  12. </template>
  13. </avue-crud>
  14. </basic-container>
  15. <basic-container>
  16. 权限开关
  17. <el-switch :active-value="false"
  18. :inactive-value="true"
  19. v-model="text"
  20. active-color="#13ce66"
  21. inactive-color="#ff4949">
  22. </el-switch>
  23. <p> 具体参考<a
  24. href="https://avuex.avue.top/#/doc/crud-permission">https://avuex.avue.top/#/doc/crud-permission</a>
  25. </p>
  26. </basic-container>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. text: false,
  34. permission: {},
  35. option: {
  36. expand: true,
  37. column: [
  38. {
  39. label: "姓名",
  40. prop: "name"
  41. },
  42. {
  43. label: "年龄",
  44. prop: "sex"
  45. }
  46. ]
  47. },
  48. data: [
  49. {
  50. id: 1,
  51. name: "张三",
  52. sex: 12
  53. },
  54. {
  55. id: 2,
  56. name: "李四",
  57. sex: 20
  58. }
  59. ]
  60. };
  61. },
  62. watch: {
  63. text() {
  64. if (this.text === true) {
  65. this.permission = {
  66. delBtn: false,
  67. addBtn: false
  68. };
  69. } else {
  70. this.permission = {
  71. delBtn: true,
  72. addBtn: true
  73. };
  74. }
  75. }
  76. }
  77. };
  78. </script>
  79. <style>
  80. </style>