Ver Fonte

管理员个人中心

YY há 2 anos atrás
pai
commit
1a193a50e1
1 ficheiros alterados com 73 adições e 3 exclusões
  1. 73 3
      src/components/account/admin-1.vue

+ 73 - 3
src/components/account/admin-1.vue

@@ -1,13 +1,83 @@
 <template>
-  <div id="admin-1">
+  <div id="updatepwd-1">
     <el-row>
-      <el-col :span="24" class="main"> test </el-col>
+      <el-col :span="24" class="main">
+        <component :is="CForm" :span="12" :fields="fields" :form="form" :rules="rules" @save="toSave">
+          <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>
+        </component>
+      </el-col>
     </el-row>
   </div>
 </template>
 
 <script setup lang="ts">
+import store from '@/stores/counter';
+import CForm from '@common/src/components/frame/c-form.vue';
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { ref, toRefs } from 'vue';
+import { ref, reactive, onMounted } from 'vue';
+import { ElMessage } from 'element-plus';
+import { RoleStore } from '@common/src/stores/admin/role';
+import { AdminStore } from '@common/src/stores/users/admin';
+import type { IQueryResult } from '@/util/types.util';
+const role = RoleStore();
+const admin = AdminStore();
+let fields: Ref<any[]> = ref([
+  { label: '用户昵称', model: 'name' },
+  { label: '用户账号', model: 'account', options: { readonly: true } },
+  { label: '角色', model: 'role', custom: true },
+  { label: '超级管理员', model: 'is_super', options: { readonly: true }, custom: true },
+]);
+const rules = reactive<FormRules>({
+  name: [{ required: true, message: '请输入用户昵称', trigger: 'blur' }],
+  is_super: [{ required: true, message: '请输入超级管理员', trigger: 'blur' }],
+  account: [{ required: true, message: '请输入用户账号', trigger: 'blur' }],
+});
+const form: Ref<{ is_super: boolean; role: any }> = ref({ is_super: false, role: [] });
+let roleList: Ref<any> = ref([]);
+let user = store.state.user as { _id: string; role_type: string };
+onMounted(async () => {
+  await searchOther();
+  await search();
+});
+// 查询
+const search = async () => {
+  const res: IQueryResult = await admin.fetch(user._id);
+  if (res.errcode == 0) {
+    form.value = res.data as { is_super: boolean; role: any };
+  }
+};
+// 审核保存
+const toSave = async (data: { _id: string; account: string; name: string }) => {
+  let res: IQueryResult;
+  let object = { _id: data._id, account: data.account, name: data.name };
+  res = await admin.update(object);
+  if (res.errcode == 0) {
+    ElMessage({ type: 'success', message: '维护信息成功' });
+    search();
+  }
+};
+const getRole = (i: any[]) => {
+  const arr = [];
+  for (const val of i) {
+    const r = roleList.value.find((f: any) => f._id === val);
+    if (r) arr.push(r.name);
+  }
+  return arr.join(';');
+};
+const searchOther = async () => {
+  const p1: IQueryResult = await role.query({ dict_type: 'studio_status' });
+  roleList.value = p1.data as [];
+};
 </script>
 <style scoped></style>