添加用户统计信息,修复管理功能空输入搜索
This commit is contained in:
parent
6aa8d9c8cf
commit
fb7e6d8fe8
|
|
@ -135,6 +135,18 @@ export const SearchUserService = (Data) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const GetUserStatisticService = (Data) => {
|
||||
const params = new URLSearchParams();
|
||||
for (let key in Data) {
|
||||
params.append(key, Data[key])
|
||||
}
|
||||
return request.post('/user/statistic', params,{
|
||||
headers: {
|
||||
'token': Data.token,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export const getQRService = (qrData) => {
|
||||
const params = new URLSearchParams();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import { ElMessage } from 'element-plus';
|
|||
const handle = (rawFile: any) => {
|
||||
console.log(rawFile);
|
||||
};
|
||||
const allowedTypes = ['doc', 'docx', 'pdf', 'txt', 'png', 'jpg', 'jpeg'];
|
||||
const allowedTypes = ['doc', 'docx', 'pdf', 'txt', 'png', 'jpg', 'jpeg','md'];
|
||||
|
||||
interface UploadData {
|
||||
upload_type: string;
|
||||
|
|
@ -65,7 +65,7 @@ const headers = {
|
|||
const fileExtension = file.name.split('.').pop().toLowerCase();
|
||||
const isAllowedType = allowedTypes.includes(fileExtension);
|
||||
if (!isAllowedType) {
|
||||
ElMessage.error('不允许的文件类型,仅支持 doc, docx, pdf, txt, png, jpg, jpeg 格式');
|
||||
ElMessage.error('不允许的文件类型,仅支持 doc, docx, pdf, txt, png, jpg, jpeg, md 格式');
|
||||
return false;
|
||||
}
|
||||
// 可以在这里进行文件验证等操作
|
||||
|
|
|
|||
|
|
@ -11,13 +11,16 @@
|
|||
</div>
|
||||
<div class="user-footer">
|
||||
<div class="user-footer-item">
|
||||
<el-statistic title="提问数" :value="1800" />
|
||||
<el-statistic title="提问数" :value="userStatistic.question" />
|
||||
</div>
|
||||
<div class="user-footer-item">
|
||||
<el-statistic title="会话数" :value="666" />
|
||||
<el-statistic title="会话数" :value="userStatistic.session" />
|
||||
</div>
|
||||
<div class="user-footer-item">
|
||||
<el-statistic title="总计" :value="888" />
|
||||
<el-statistic title="文件数" :value="userStatistic.file_count" />
|
||||
</div>
|
||||
<div class="user-footer-item">
|
||||
<el-statistic title="总计" :value="userStatistic.total" />
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
|
@ -81,6 +84,7 @@ import 'vue-cropper/dist/index.css';
|
|||
import avatar from '@/assets/img/img.jpg';
|
||||
import TabsComp from '../element/tabs.vue';
|
||||
import {GetUserInfoService} from "@/api/user";
|
||||
import { GetUserStatisticService } from "@/api/user";
|
||||
import { UploadFileService } from "@/api/tool";
|
||||
import { UserInfo } from '@/types/user';
|
||||
import { FormOption, FormOptionList } from '@/types/form-option';
|
||||
|
|
@ -96,6 +100,12 @@ const form = reactive({
|
|||
new: '',
|
||||
old: '',
|
||||
});
|
||||
const userStatistic = reactive({
|
||||
question: 0,
|
||||
session: 0,
|
||||
total: 0,
|
||||
file_count: 0,
|
||||
});
|
||||
const userInfo = ref<UserInfo>();
|
||||
const isUserInfoLoaded = ref(false);
|
||||
const globalData = inject("globalData");
|
||||
|
|
@ -242,6 +252,27 @@ const dataURLtoFile = (dataurl, filename) => {
|
|||
return new File([u8arr], filename, { type: mime });
|
||||
};
|
||||
|
||||
const getUserStatistics = async () => {
|
||||
let req = {
|
||||
token: localStorage.getItem('token'),
|
||||
id: localStorage.getItem('userId')
|
||||
};
|
||||
try{
|
||||
let result = await GetUserStatisticService(req);
|
||||
if (result["code"] == 0) {
|
||||
userStatistic.question = result.data.message_count;
|
||||
userStatistic.session = result.data.session_count;
|
||||
userStatistic.file_count = result.data.file_count;
|
||||
userStatistic.total = userStatistic.question + userStatistic.session + userStatistic.file_count;
|
||||
}else{
|
||||
ElMessage.error(result["msg"]);
|
||||
}
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
getUserStatistics();
|
||||
|
||||
|
||||
const saveAvatar =async () => {
|
||||
let token = localStorage.getItem('token');
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import TableCustom from '@/components/table-custom.vue';
|
|||
import TableDetail from '@/components/table-detail.vue';
|
||||
import TableSearch from '@/components/table-search.vue';
|
||||
import { FormOption, FormOptionList } from '@/types/form-option';
|
||||
import { number } from 'echarts';
|
||||
|
||||
const userRole = localStorage.getItem('role') == 'admin';
|
||||
|
||||
|
|
@ -55,6 +56,10 @@ const handleSearch = async () => {
|
|||
ElMessage.error('请输入数字');
|
||||
return;
|
||||
}
|
||||
if (query.name === '') {
|
||||
ElMessage.error('请输入模型ID');
|
||||
return;
|
||||
}
|
||||
let req={
|
||||
token: localStorage.getItem('token'),
|
||||
type: "ID",
|
||||
|
|
|
|||
|
|
@ -61,11 +61,22 @@ const handleSearch = async () => {
|
|||
// ElMessage.error("请输入正确的会话ID");
|
||||
// return;
|
||||
// }
|
||||
let req={
|
||||
let req={}
|
||||
try{
|
||||
req={
|
||||
token: localStorage.getItem('token'),
|
||||
type: "ID",
|
||||
id: parseInt(query.name)
|
||||
}
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
ElMessage.error("请输入正确的会话ID");
|
||||
}
|
||||
if (query.name == ""){
|
||||
ElMessage.error("请输入会话ID");
|
||||
return;
|
||||
}
|
||||
|
||||
let result = await FindSessionService(req);
|
||||
tableData.value = result.data;
|
||||
page.total = result.data.length;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ const searchOpt = ref<FormOptionList[]>([
|
|||
const handleSearch = async () => {
|
||||
let search_id= -1;
|
||||
let keyword_ = "";
|
||||
if (query.name === ''){
|
||||
ElMessage.error('请输入用户名或ID');
|
||||
return;
|
||||
}
|
||||
try{
|
||||
search_id = parseInt(query.name);
|
||||
}catch(e){
|
||||
|
|
|
|||
Loading…
Reference in New Issue