|
@@ -0,0 +1,187 @@
|
|
|
+<template>
|
|
|
+ <div id="index">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
|
|
|
+ <template #type>
|
|
|
+ <el-option v-for="i in typeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </cSearch>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @chat="toChat" @edit="toEdit" @del="toDel">
|
|
|
+ <template #is_read="{ item, row }">
|
|
|
+ <template v-if="item.model === 'is_read'">
|
|
|
+ <span :class="[row.is_read == '未读' ? 'text' : '']">{{ row.is_read }}</span>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </cTable>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <cDialog :dialog="dialog" @toClose="toClose">
|
|
|
+ <template v-slot:info>
|
|
|
+ <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
|
|
|
+ <cForm :span="24" :fields="formFields" :form="form" :rules="{}" @save="toSave" label-width="auto">
|
|
|
+ <template #gender>
|
|
|
+ <el-option v-for="i in genderList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #type>
|
|
|
+ <el-option v-for="i in typeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #status>
|
|
|
+ <el-option v-for="i in statusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </cForm>
|
|
|
+ </el-col>
|
|
|
+ </template>
|
|
|
+ </cDialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+// 基础
|
|
|
+import type { Ref } from 'vue';
|
|
|
+import { onMounted, ref, getCurrentInstance } from 'vue';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
+// 接口
|
|
|
+import { UserStore } from '@/stores/users/user';
|
|
|
+import { DictDataStore } from '@/stores/basic/dictData'; // 字典表
|
|
|
+import type { IQueryResult } from '@/util/types.util';
|
|
|
+const userAxios = UserStore();
|
|
|
+const dictAxios = DictDataStore();
|
|
|
+const { proxy } = getCurrentInstance() as any;
|
|
|
+// 路由
|
|
|
+const router = useRouter();
|
|
|
+// 加载中
|
|
|
+const loading: Ref<any> = ref(false);
|
|
|
+let list: Ref<any> = ref([]);
|
|
|
+let total: Ref<number> = ref(0);
|
|
|
+let skip = 0;
|
|
|
+let limit: number = proxy.$limit;
|
|
|
+let fields: Ref<any[]> = ref([
|
|
|
+ { label: '微信用户标识', model: 'openid' },
|
|
|
+ { label: '真实姓名', model: 'name', isSearch: true },
|
|
|
+ { label: '昵称', model: 'nick_name', isSearch: true },
|
|
|
+ { label: '性别', model: 'gender', format: (i: any) => getDict(i, genderList.value) },
|
|
|
+ { label: '手机号', model: 'phone', isSearch: true },
|
|
|
+ { label: '生日', model: 'birthday' },
|
|
|
+ { label: '类型', model: 'type', format: (i: any) => getDict(i, typeList.value), isSearch: true },
|
|
|
+ { label: '所在城市', model: 'city', isSearch: true },
|
|
|
+ { label: '是否已读', model: 'is_read', custom: true }
|
|
|
+]);
|
|
|
+// 操作
|
|
|
+let opera: Ref<any[]> = ref([
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' },
|
|
|
+ { label: '聊天记录', method: 'chat' }
|
|
|
+]);
|
|
|
+// 查询数据
|
|
|
+let searchForm: Ref<any> = ref({});
|
|
|
+// 字典表
|
|
|
+const genderList: Ref<any> = ref([]);
|
|
|
+const statusList: Ref<any> = ref([]);
|
|
|
+const typeList: Ref<any> = ref([]);
|
|
|
+// 弹框
|
|
|
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
|
|
|
+const form: Ref<any> = ref({ file: [] });
|
|
|
+const formFields: Ref<any> = ref([
|
|
|
+ { label: '微信用户标识', model: 'openid', options: { disabled: true } },
|
|
|
+ { label: '真实姓名', model: 'name' },
|
|
|
+ { label: '昵称', model: 'nick_name' },
|
|
|
+ { label: '性别', model: 'gender', type: 'select' },
|
|
|
+ { label: '手机号', model: 'phone' },
|
|
|
+ { label: '生日', model: 'birthday', type: 'date' },
|
|
|
+ { label: '类型', model: 'type', type: 'select' },
|
|
|
+ { label: '所在城市', model: 'city' },
|
|
|
+ { label: '状态', model: 'status', type: 'select' }
|
|
|
+]);
|
|
|
+// 请求
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true;
|
|
|
+ await searchOther();
|
|
|
+ await search({ skip, limit });
|
|
|
+ loading.value = false;
|
|
|
+});
|
|
|
+const search = async (e: { skip: number; limit: number }) => {
|
|
|
+ const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
|
|
|
+ const res: IQueryResult = await userAxios.user(info);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ list.value = res.data;
|
|
|
+ total.value = res.total;
|
|
|
+ }
|
|
|
+};
|
|
|
+const toSearch = (query: any) => {
|
|
|
+ searchForm.value = query;
|
|
|
+ search({ skip, limit });
|
|
|
+};
|
|
|
+const getDict = (e: any, model: any) => {
|
|
|
+ let data: any = model.find((i: any) => i.value == e);
|
|
|
+ if (data) return data.label;
|
|
|
+ else return '暂无';
|
|
|
+};
|
|
|
+// 提交保存
|
|
|
+const toSave = async (data: any) => {
|
|
|
+ delete data.is_read;
|
|
|
+ let res: IQueryResult = await userAxios.update(data);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ ElMessage({ message: '信息审核成功', type: 'success' });
|
|
|
+ toClose();
|
|
|
+ } else {
|
|
|
+ ElMessage({ message: `${res.errmsg}`, type: 'error' });
|
|
|
+ }
|
|
|
+};
|
|
|
+// 修改
|
|
|
+const toEdit = async (data: any) => {
|
|
|
+ let res: IQueryResult = await userAxios.fetch(data._id);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ form.value = res.data;
|
|
|
+ dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
|
+ }
|
|
|
+};
|
|
|
+// 聊天记录
|
|
|
+const toChat = async (data: any) => {
|
|
|
+ router.push({ path: '/user/chat', query: { id: data._id } });
|
|
|
+};
|
|
|
+// 删除
|
|
|
+const toDel = async (data: any) => {
|
|
|
+ let res: IQueryResult = await userAxios.del(data._id);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ ElMessage({ type: `success`, message: `刪除信息成功` });
|
|
|
+ search({ skip, limit });
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 关闭弹框
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {};
|
|
|
+ dialog.value = { show: false };
|
|
|
+ search({ skip, limit });
|
|
|
+};
|
|
|
+
|
|
|
+// 查询其他信息
|
|
|
+const searchOther = async () => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ // 性别
|
|
|
+ res = await dictAxios.query({ type: 'gender', is_use: '0' });
|
|
|
+ if (res.errcode == '0') genderList.value = res.data;
|
|
|
+ // 类型
|
|
|
+ res = await dictAxios.query({ type: 'user_type', is_use: '0' });
|
|
|
+ if (res.errcode == '0') typeList.value = res.data;
|
|
|
+ // 状态
|
|
|
+ res = await dictAxios.query({ type: 'exam_status', is_use: '0' });
|
|
|
+ if (res.errcode == '0') statusList.value = res.data;
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.main {
|
|
|
+ .two {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ .text {
|
|
|
+ color: #f10000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|