index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit"></data-table>
  6. </el-col>
  7. </el-row>
  8. <el-dialog title="菜单信息管理" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
  9. <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
  10. <template #custom="{item, form}">
  11. <el-checkbox-group v-model="form.menus">
  12. <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i.id">{{ i.title }}</el-checkbox>
  13. </el-checkbox-group>
  14. </template>
  15. </data-form>
  16. </el-dialog>
  17. </div>
  18. </template>
  19. <script>
  20. import dataTable from '@common/src/components/frame/filter-page-table.vue';
  21. import dataForm from '@common/src/components/frame/form.vue';
  22. import { iconmenu } from '@common/src/util/iconmenu';
  23. import { mapState, createNamespacedHelpers } from 'vuex';
  24. const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
  25. const { mapActions: menu } = createNamespacedHelpers('menu');
  26. export default {
  27. metaInfo() {
  28. return { title: this.$route.meta.title };
  29. },
  30. name: 'index',
  31. props: {},
  32. components: {
  33. dataTable,
  34. dataForm,
  35. },
  36. data: function() {
  37. return {
  38. opera: [
  39. {
  40. label: '分配权限',
  41. method: 'edit',
  42. },
  43. ],
  44. fields: [
  45. { label: '机构代码或邀请码', prop: 'code' },
  46. { label: '用户名', prop: 'name' },
  47. { label: '联系电话', prop: 'phone' },
  48. { label: '机构名称', prop: 'deptname' },
  49. ],
  50. list: [
  51. {
  52. name: 'sadas',
  53. menus: [
  54. {
  55. id: '1',
  56. title: '菜单一',
  57. },
  58. {
  59. id: '2',
  60. title: '菜单二',
  61. },
  62. ],
  63. },
  64. ],
  65. total: 0,
  66. // 分配权限
  67. dialog: false,
  68. formfields: [
  69. { label: '用户名', model: 'name' },
  70. { label: '机构名称', model: 'deptname' },
  71. { label: '权限', model: 'menus', custom: true },
  72. ],
  73. form: {
  74. menus: [],
  75. },
  76. rules: {},
  77. // 菜单列表
  78. menuList: [
  79. {
  80. id: '1',
  81. title: '菜单一',
  82. },
  83. {
  84. id: '2',
  85. title: '菜单二',
  86. },
  87. {
  88. id: '3',
  89. title: '菜单三',
  90. },
  91. ],
  92. };
  93. },
  94. async created() {
  95. await this.searchOther();
  96. await this.search();
  97. },
  98. methods: {
  99. ...adminLogin(['query']),
  100. ...menu({ menuQuery: 'query' }),
  101. // 查询列表
  102. async search({ skip = 0, limit = 10, ...info } = {}) {
  103. let res = await this.query({ skip, limit, ...info });
  104. if (this.$checkRes(res)) {
  105. // this.$set(this, `list`, res.data);
  106. // this.$set(this, `total`, res.total);
  107. }
  108. },
  109. // 分配权限
  110. toEdit({ data }) {
  111. this.dialog = true;
  112. this.$set(this, 'form', { ...data, menus: data.menus.map(i => i.id) });
  113. },
  114. // 提交分配
  115. toSave({ data }) {
  116. console.log(data);
  117. },
  118. // 取消添加
  119. handleClose() {
  120. this.form = {};
  121. this.dialog = false;
  122. this.search();
  123. },
  124. // 查询其他信息
  125. async searchOther() {
  126. let res = await this.menuQuery();
  127. if (this.$checkRes(res)) {
  128. // this.$set(this, `menuList`, res.data);
  129. }
  130. },
  131. },
  132. computed: {
  133. ...mapState(['user']),
  134. },
  135. watch: {},
  136. };
  137. </script>
  138. <style lang="less" scoped>
  139. .main {
  140. .add {
  141. text-align: right;
  142. margin: 0 0 10px 0;
  143. }
  144. }
  145. </style>