|
@@ -1,98 +1,13 @@
|
|
|
<template>
|
|
|
<div id="admin-1">
|
|
|
<el-row>
|
|
|
- <el-col :span="24" class="main">
|
|
|
- <data-form :fields="fields" :form="form" :rules="rules" @save="onSubmit">
|
|
|
- <template #is_super="{ item }">
|
|
|
- <template v-if="item.model === 'is_super'">
|
|
|
- <el-col :span="24" class="one_1">{{ form.is_super == true ? '是' : '否' }}</el-col>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- <template #role="{ item }">
|
|
|
- <template v-if="item.model === 'role'">
|
|
|
- <el-col :span="24" class="one_1" v-if="form.role?.length > 0">{{ getRole(form.role) }}</el-col>
|
|
|
- <el-col :span="24" class="one_1" v-else>暂无角色</el-col>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </data-form>
|
|
|
- </el-col>
|
|
|
+ <el-col :span="24" class="main"> test </el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions } = createNamespacedHelpers('admin');
|
|
|
-const { mapActions: role } = createNamespacedHelpers('role');
|
|
|
-export default {
|
|
|
- name: 'admin-1',
|
|
|
- props: {},
|
|
|
- components: {},
|
|
|
- data: function () {
|
|
|
- return {
|
|
|
- form: {},
|
|
|
- fields: [
|
|
|
- { label: '用户昵称', model: 'name' },
|
|
|
- { label: '用户账号', model: 'account', options: { readonly: true } },
|
|
|
- { label: '角色', model: 'role', custom: true },
|
|
|
- { label: '超级管理员', model: 'is_super', options: { readonly: true }, custom: true },
|
|
|
- ],
|
|
|
- rules: {
|
|
|
- name: [{ required: true, message: '请输入用户昵称', trigger: 'blur' }],
|
|
|
- is_super: [{ required: true, message: '请输入超级管理员', trigger: 'blur' }],
|
|
|
- account: [{ required: true, message: '请输入用户账号', trigger: 'blur' }],
|
|
|
- },
|
|
|
- roleList: [],
|
|
|
- };
|
|
|
- },
|
|
|
- async created() {
|
|
|
- await this.searchOthers();
|
|
|
- await this.search();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- ...role({ roleQuery: 'query' }),
|
|
|
- ...mapActions(['fetch', 'update']),
|
|
|
- //查询
|
|
|
- async search() {
|
|
|
- let res = await this.fetch(this.user._id);
|
|
|
- if (this.$checkRes(res)) this.$set(this, `form`, res.data);
|
|
|
- },
|
|
|
- getRole(i) {
|
|
|
- const arr = [];
|
|
|
- for (const val of i) {
|
|
|
- const r = this.roleList.find((f) => f._id === val);
|
|
|
- if (r) arr.push(r.name);
|
|
|
- }
|
|
|
- return arr.join(';');
|
|
|
- },
|
|
|
- // 提交保存
|
|
|
- async onSubmit({ data }) {
|
|
|
- let object = { _id: data._id, account: data.account, name: data.name };
|
|
|
- let res = await this.update(object);
|
|
|
- if (this.$checkRes(res, '维护信息成功', res.errmsg)) this.search();
|
|
|
- },
|
|
|
- // 查询其他信息
|
|
|
- async searchOthers() {
|
|
|
- let res;
|
|
|
- // 角色
|
|
|
- res = await this.roleQuery();
|
|
|
- if (this.$checkRes(res)) this.$set(this, `roleList`, res.data);
|
|
|
- },
|
|
|
- },
|
|
|
- computed: {
|
|
|
- ...mapState(['user']),
|
|
|
- },
|
|
|
- metaInfo() {
|
|
|
- return { title: this.$route.meta.title };
|
|
|
- },
|
|
|
- watch: {
|
|
|
- test: {
|
|
|
- deep: true,
|
|
|
- immediate: true,
|
|
|
- handler(val) {},
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+<script setup lang="ts">
|
|
|
+import type { Ref } from 'vue';
|
|
|
+import { ref, toRefs } from 'vue';
|
|
|
</script>
|
|
|
-
|
|
|
-<style lang="less" scoped></style>
|
|
|
+<style scoped></style>
|