123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main">
- <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit"></data-table>
- </el-col>
- </el-row>
- <el-dialog title="菜单信息管理" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
- <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
- <template #custom="{item, form}">
- <el-checkbox-group v-model="form.menus">
- <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i.id">{{ i.title }}</el-checkbox>
- </el-checkbox-group>
- </template>
- </data-form>
- </el-dialog>
- </div>
- </template>
- <script>
- import dataTable from '@common/src/components/frame/filter-page-table.vue';
- import dataForm from '@common/src/components/frame/form.vue';
- import { iconmenu } from '@common/src/util/iconmenu';
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
- const { mapActions: menu } = createNamespacedHelpers('menu');
- export default {
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- name: 'index',
- props: {},
- components: {
- dataTable,
- dataForm,
- },
- data: function() {
- return {
- opera: [
- {
- label: '分配权限',
- method: 'edit',
- },
- ],
- fields: [
- { label: '机构代码或邀请码', prop: 'code' },
- { label: '用户名', prop: 'name' },
- { label: '联系电话', prop: 'phone' },
- { label: '机构名称', prop: 'deptname' },
- ],
- list: [
- {
- name: 'sadas',
- menus: [
- {
- id: '1',
- title: '菜单一',
- },
- {
- id: '2',
- title: '菜单二',
- },
- ],
- },
- ],
- total: 0,
- // 分配权限
- dialog: false,
- formfields: [
- { label: '用户名', model: 'name' },
- { label: '机构名称', model: 'deptname' },
- { label: '权限', model: 'menus', custom: true },
- ],
- form: {
- menus: [],
- },
- rules: {},
- // 菜单列表
- menuList: [
- {
- id: '1',
- title: '菜单一',
- },
- {
- id: '2',
- title: '菜单二',
- },
- {
- id: '3',
- title: '菜单三',
- },
- ],
- };
- },
- async created() {
- await this.searchOther();
- await this.search();
- },
- methods: {
- ...adminLogin(['query']),
- ...menu({ menuQuery: 'query' }),
- // 查询列表
- async search({ skip = 0, limit = 10, ...info } = {}) {
- let res = await this.query({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- // this.$set(this, `list`, res.data);
- // this.$set(this, `total`, res.total);
- }
- },
- // 分配权限
- toEdit({ data }) {
- this.dialog = true;
- this.$set(this, 'form', { ...data, menus: data.menus.map(i => i.id) });
- },
- // 提交分配
- toSave({ data }) {
- console.log(data);
- },
- // 取消添加
- handleClose() {
- this.form = {};
- this.dialog = false;
- this.search();
- },
- // 查询其他信息
- async searchOther() {
- let res = await this.menuQuery();
- if (this.$checkRes(res)) {
- // this.$set(this, `menuList`, res.data);
- }
- },
- },
- computed: {
- ...mapState(['user']),
- },
- watch: {},
- };
- </script>
- <style lang="less" scoped>
- .main {
- .add {
- text-align: right;
- margin: 0 0 10px 0;
- }
- }
- </style>
|