|
@@ -3,10 +3,10 @@
|
|
<el-row>
|
|
<el-row>
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
<el-col :span="24" class="one">
|
|
<el-col :span="24" class="one">
|
|
- <cSearch :is_back="true" @toBack="toBack"></cSearch>
|
|
|
|
|
|
+ <cSearch :is_title="false" :is_back="true" @toBack="toBack"></cSearch>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24" class="two">
|
|
<el-col :span="24" class="two">
|
|
- <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit">
|
|
|
|
|
|
+ <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave">
|
|
<template #pid>
|
|
<template #pid>
|
|
<el-option v-for="(i, index) in pidList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
<el-option v-for="(i, index) in pidList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
</template>
|
|
</template>
|
|
@@ -26,26 +26,30 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import type { FormRules } from 'element-plus';
|
|
|
|
import type { Ref } from 'vue';
|
|
import type { Ref } from 'vue';
|
|
import { ref, reactive, onMounted } from 'vue';
|
|
import { ref, reactive, onMounted } from 'vue';
|
|
-import { ElMessage } from 'element-plus';
|
|
|
|
import { useRoute } from 'vue-router';
|
|
import { useRoute } from 'vue-router';
|
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
|
+import type { FormRules } from 'element-plus';
|
|
|
|
+
|
|
|
|
+// 接口
|
|
import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
|
|
import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
|
|
import { RoleStore } from '@common/src/stores/system/role'; // 角色
|
|
import { RoleStore } from '@common/src/stores/system/role'; // 角色
|
|
-import { AdminStore } from '@common/src/stores/admins/admin'; // 角色
|
|
|
|
|
|
+import { AdminStore } from '@common/src/stores/admins/admin'; //管理员
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
|
+
|
|
const admin = AdminStore();
|
|
const admin = AdminStore();
|
|
const dictData = DictDataStore();
|
|
const dictData = DictDataStore();
|
|
const role = RoleStore();
|
|
const role = RoleStore();
|
|
|
|
+
|
|
|
|
+// 路由
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
|
+
|
|
|
|
+// 加载中
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
-let form: Ref<any> = ref({});
|
|
|
|
-let roleList: Ref<any> = ref([]);
|
|
|
|
-let pidList: Ref<any> = ref([]);
|
|
|
|
-let codeList: Ref<any> = ref([]);
|
|
|
|
|
|
|
|
// 表单
|
|
// 表单
|
|
|
|
+let form: Ref<any> = ref({});
|
|
let formFields: Ref<any[]> = ref([
|
|
let formFields: Ref<any[]> = ref([
|
|
{ label: '所属上级', model: 'pid', type: 'select' },
|
|
{ label: '所属上级', model: 'pid', type: 'select' },
|
|
{ label: '邀请码', model: 'code', type: 'select' },
|
|
{ label: '邀请码', model: 'code', type: 'select' },
|
|
@@ -56,10 +60,13 @@ let formFields: Ref<any[]> = ref([
|
|
{ label: '机构名称', model: 'dept_name' },
|
|
{ label: '机构名称', model: 'dept_name' },
|
|
{ label: '角色', model: 'role', custom: true }
|
|
{ label: '角色', model: 'role', custom: true }
|
|
]);
|
|
]);
|
|
-const rules = reactive<FormRules>({
|
|
|
|
- name: [{ required: true, message: '名称', trigger: 'blur' }],
|
|
|
|
- account: [{ required: true, message: '账号', trigger: 'blur' }]
|
|
|
|
-});
|
|
|
|
|
|
+const rules = reactive<FormRules>({});
|
|
|
|
+
|
|
|
|
+// 字典表
|
|
|
|
+let roleList: Ref<any> = ref([]);
|
|
|
|
+let pidList: Ref<any> = ref([]);
|
|
|
|
+let codeList: Ref<any> = ref([]);
|
|
|
|
+
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
loading.value = true;
|
|
loading.value = true;
|
|
await searchOther();
|
|
await searchOther();
|
|
@@ -67,14 +74,21 @@ onMounted(async () => {
|
|
loading.value = false;
|
|
loading.value = false;
|
|
});
|
|
});
|
|
const search = async () => {
|
|
const search = async () => {
|
|
- if (route.query.id) {
|
|
|
|
|
|
+ let id = route.query.id;
|
|
|
|
+ let res: IQueryResult;
|
|
|
|
+ let info: any = { type: '3' };
|
|
|
|
+ if (id) {
|
|
|
|
+ // 已有数据
|
|
formFields.value = formFields.value.filter((i) => i.model != 'password');
|
|
formFields.value = formFields.value.filter((i) => i.model != 'password');
|
|
- let res: IQueryResult = await admin.fetch(route.query.id);
|
|
|
|
- if (res.errcode == 0) form.value = res.data as {};
|
|
|
|
- } else form.value.type = '3';
|
|
|
|
|
|
+ res = await admin.fetch(route.query.id);
|
|
|
|
+ if (res.errcode == 0) {
|
|
|
|
+ info = res.data;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ form.value = info;
|
|
};
|
|
};
|
|
// 提交
|
|
// 提交
|
|
-const onSubmit = async (data) => {
|
|
|
|
|
|
+const toSave = async (data) => {
|
|
let res: IQueryResult;
|
|
let res: IQueryResult;
|
|
if (data._id) res = await admin.update(data);
|
|
if (data._id) res = await admin.update(data);
|
|
else res = await admin.create(data);
|
|
else res = await admin.create(data);
|