123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main animate__animated animate__backInRight">
- <el-col :span="24" class="one">
- <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1>
- </el-col>
- <el-col :span="24" class="two">
- <btn-1 table="role" @toAdd="toAdd" :ids="selected" @search="search"></btn-1>
- </el-col>
- <el-col :span="24" class="thr">
- <data-table
- :fields="fields"
- :opera="opera"
- :data="list"
- @query="search"
- :total="total"
- @edit="toEdit"
- @del="toDel"
- :select="true"
- :selected="selected"
- @handleSelect="handleSelect"
- >
- </data-table>
- </el-col>
- </el-col>
- </el-row>
- <e-dialog :dialog="dialog" @toClose="toClose">
- <template v-slot:info>
- <form-1 v-if="dialog.type == '1'" :form="form" @onSubmit="onSubmit" @toReset="toClose" :menuList="menuList" :typeList="typeList"></form-1>
- </template>
- </e-dialog>
- </div>
- </template>
- <script>
- import btn1 from '@/layout/btn-1.vue';
- import search1 from './parts/search-1.vue';
- import form1 from './parts/form-1.vue';
- import { mapState, createNamespacedHelpers } from 'vuex';
- // const { mapActions } = createNamespacedHelpers('role');
- // const { mapActions: menu } = createNamespacedHelpers('menus');
- // const { mapActions: sysdictdata } = createNamespacedHelpers('dictData');
- export default {
- name: 'index',
- props: {},
- components: { search1, form1, btn1 },
- data: function () {
- return {
- // 列表
- opera: [
- { label: '修改', method: 'edit' },
- { label: '删除', method: 'del', confirm: true, type: 'danger' },
- ],
- fields: [
- { label: '角色名称', prop: 'name' },
- { label: '角色代码', prop: 'code' },
- {
- label: '角色状态',
- prop: 'status',
- format: (i) => (i === '0' ? '使用' : '停用'),
- },
- ],
- list: [],
- total: 0,
- // 多选值
- selected: [],
- // 弹框
- dialog: { title: '信息管理', show: false, type: '1' },
- // 增加数据
- form: {},
- // 查詢
- searchForm: {},
- // 菜单
- menuList: [],
- // 角色类型
- typeList: [],
- };
- },
- async created() {
- await this.searchOther();
- await this.search();
- },
- methods: {
- // ...menu({ menuQuery: 'query' }),
- // ...sysdictdata({ sQuery: 'query' }),
- // ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
- // 查询
- async search({ skip = 0, limit = 10, ...info } = {}) {
- const condition = _.cloneDeep(this.searchForm);
- // let res = await this.query({ skip, limit, ...condition, ...info });
- // if (this.$checkRes(res)) {
- // this.$set(this, `list`, res.data);
- // this.$set(this, `total`, res.total);
- // }
- },
- // 新增
- toAdd() {
- this.dialog = { title: '信息管理', show: true, type: '1' };
- },
- // 修改
- async toEdit({ data }) {
- let res = await this.fetch(data._id);
- if (this.$checkRes(res)) {
- this.$set(this, `form`, res.data);
- this.dialog = { title: '信息管理', show: true, type: '1' };
- }
- },
- // 提交
- async onSubmit({ data }) {
- if (data.id) {
- let res = await this.update(data);
- if (this.$checkRes(res)) {
- this.$message({ type: `success`, message: `维护信息成功` });
- this.toClose();
- }
- } else {
- let res = await this.create(data);
- if (this.$checkRes(res)) {
- this.$message({ type: `success`, message: `创建信息成功` });
- this.toClose();
- }
- }
- },
- // 删除
- async toDel({ data }) {
- let res = await this.delete(data._id);
- if (this.$checkRes(res)) {
- this.$message({ type: `success`, message: `刪除信息成功` });
- this.search();
- }
- },
- // 关闭
- toClose() {
- this.form = {};
- this.searchForm = {};
- this.dialog = { title: '信息管理', show: false, type: '1' };
- this.search();
- },
- // 多选
- handleSelect(data) {
- this.$set(this, `selected`, data);
- },
- // 查询其他信息
- async searchOther() {
- // let res = await this.menuQuery({ status: '0' });
- // if (this.$checkRes(res)) {
- // let data = res.data;
- // this.$set(this, `menuList`, res.data);
- // }
- },
- },
- computed: {
- ...mapState(['user']),
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- watch: {
- test: {
- deep: true,
- immediate: true,
- handler(val) {},
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .main {
- .one {
- margin: 0 0 10px 0;
- }
- .two {
- margin: 0 0 10px 0;
- }
- }
- </style>
|