|
|
|
@ -1,57 +1,61 @@ |
|
|
|
<!-- UserStatisticsSearch.vue --> |
|
|
|
<template> |
|
|
|
<div class="search-area"> |
|
|
|
<!-- 题目类型 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>题目类型</label> |
|
|
|
<select v-model="filters.type"> |
|
|
|
<option value="">全部</option> |
|
|
|
<option value="股票知识">股票知识</option> |
|
|
|
<option value="企业文化">企业文化</option> |
|
|
|
</select> |
|
|
|
<div> |
|
|
|
<div class="top"> |
|
|
|
<h2>用户数据</h2> |
|
|
|
</div> |
|
|
|
<div class="search-area"> |
|
|
|
<!-- 题目类型 --> |
|
|
|
<div class="search-item"> |
|
|
|
<h3>题目类型</h3> |
|
|
|
<select v-model="filters.type"> |
|
|
|
<option value="">全部</option> |
|
|
|
<option value="股票知识">股票知识</option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 时间选择 --> |
|
|
|
<div class="search-item date-range"> |
|
|
|
<label>时间选择</label> |
|
|
|
<div class="date-input-wrapper"> |
|
|
|
<div class="date-box"> |
|
|
|
<input type="date" v-model="filters.startDate" /> |
|
|
|
</div> |
|
|
|
<span class="separator">至</span> |
|
|
|
<div class="date-box"> |
|
|
|
<input type="date" v-model="filters.endDate" /> |
|
|
|
<!-- 时间选择 --> |
|
|
|
<div class="search-item date-range"> |
|
|
|
<h3>时间选择</h3> |
|
|
|
<div class="date-input-wrapper"> |
|
|
|
<div class="date-box"> |
|
|
|
<input type="datetime-local" v-model="filters.startDate" step="1" /> |
|
|
|
</div> |
|
|
|
<span class="separator">至</span> |
|
|
|
<div class="date-box"> |
|
|
|
<input type="datetime-local" v-model="filters.endDate" step="1" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 用户名称 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>用户名称</label> |
|
|
|
<input type="text" v-model="filters.userName" placeholder="请输入用户名称" /> |
|
|
|
</div> |
|
|
|
<!-- 用户名称 --> |
|
|
|
<div class="search-item"> |
|
|
|
<h3>用户名称</h3> |
|
|
|
<input type="text" v-model="filters.userName" placeholder="请输入用户名称" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 精网号 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>精网号</label> |
|
|
|
<input type="text" v-model="filters.jingwangId" placeholder="请输入精网号" /> |
|
|
|
</div> |
|
|
|
<!-- 精网号 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>精网号</label> |
|
|
|
<input type="text" v-model="filters.jingwangId" placeholder="请输入精网号" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 身份 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>身份</label> |
|
|
|
<select v-model="filters.user_identity"> |
|
|
|
<option value="">全部</option> |
|
|
|
<option value="非网">非网</option> |
|
|
|
<option value="半年">半年</option> |
|
|
|
<option value="终身">终身</option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
<!-- 身份 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>身份</label> |
|
|
|
<select v-model="filters.user_identity"> |
|
|
|
<option value="">全部</option> |
|
|
|
<option value="非网">非网</option> |
|
|
|
<option value="半年">半年</option> |
|
|
|
<option value="终身">终身</option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 操作按钮 --> |
|
|
|
<div class="btn-group"> |
|
|
|
<button class="btn-red" @click="searchUserStatistics">查找</button> |
|
|
|
<button class="btn-red" @click="exportToExcel">Excel导出</button> |
|
|
|
<!-- 操作按钮 --> |
|
|
|
<div class="btn-group"> |
|
|
|
<button class="btn-red" @click="searchUserStatistics">查找</button> |
|
|
|
<button class="btn-red" @click="exportToExcel">Excel导出</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
@ -79,7 +83,45 @@ export default { |
|
|
|
}, |
|
|
|
async exportToExcel() { |
|
|
|
try{ |
|
|
|
const response = await axios.post('http://192.168.40.41:8000/admin/user/export',{},{responseType: 'blob'}); |
|
|
|
const params = new URLSearchParams(); |
|
|
|
const questionTypeIdMap = { |
|
|
|
'股票知识':1, |
|
|
|
'企业文化':2 |
|
|
|
}; |
|
|
|
// 处理题目类型 |
|
|
|
if (this.filters.type) { |
|
|
|
params.append('question_type_id', questionTypeIdMap[this.filters.type]); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理时间范围 |
|
|
|
if (this.filters.startDate) { |
|
|
|
params.append('start_time', this.filters.startDate); |
|
|
|
} |
|
|
|
if (this.filters.endDate) { |
|
|
|
params.append('end_time', this.filters.endDate); |
|
|
|
} |
|
|
|
if(this.filters.startDate>this.filters.endDate){ |
|
|
|
alert('开始时间不能晚于结束时间'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 处理用户名称 |
|
|
|
if (this.filters.userName) { |
|
|
|
params.append('user_name', this.filters.userName); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理精网号 |
|
|
|
if (this.filters.jingwangId) { |
|
|
|
params.append('jingwang_id', this.filters.jingwangId); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理身份 |
|
|
|
if (this.filters.user_identity) { |
|
|
|
params.append('user_identity', this.filters.user_identity); |
|
|
|
} |
|
|
|
console.log(params); |
|
|
|
const response = await axios.post('http://192.168.40.41:8000/admin/user/export',params,{responseType: 'blob'}); |
|
|
|
console.log(response); |
|
|
|
const url = window.URL.createObjectURL(new Blob([response.data])); |
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = url; |
|
|
|
@ -103,7 +145,6 @@ export default { |
|
|
|
display: flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
gap: 20px; |
|
|
|
padding: 20px; |
|
|
|
background-color: white; |
|
|
|
border-radius: 4px; |
|
|
|
} |
|
|
|
@ -111,7 +152,7 @@ export default { |
|
|
|
.search-item { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
min-width: 200px; |
|
|
|
min-width: 100px; |
|
|
|
} |
|
|
|
|
|
|
|
.search-item label { |
|
|
|
|