刘翔宇-旅管家 2 years ago
parent 7387348f2e
commit ded40d28b2

@ -200,7 +200,8 @@ export default {
list,
rowKey,
deleteClick,
editorClick
editorClick,
selectionChange
} = this
return (
<div class="table-tree" style={{'position': 'relative'}}>

@ -0,0 +1,92 @@
import axios from 'axios'
import { getToken } from '@/utils/auth'
import { Loading, Message } from 'element-ui'
/*
* @params {string} url 请求拼接地址
* @params {object} info 请求参数params或data
*/
let loading;
export async function download(url,method='get',info,filename){
loading = Loading.service({
lock:true,
background:"rgba(0,0,0,0.4)",
text:"文件正在生成中..."
})
let options = {
baseURL:process.env.VUE_APP_BASE_API,
url,
method,
responseType: 'blob',
timeout:10000,
headers: {
Accept: 'application/json','Content-Type':'application/json; charset=utf-8',
withCredentials: true,
Authorization:"Bearer " + getToken()
},
}
if(method === 'get'){
Object.defineProperty(options,'params',{
value:info,
enumerable:true,
writable:false
})
}
if(method === 'post'){
Object.defineProperty(options,'data',{
value:info,
enumerable:true,
writable:false
})
}
try {
const response = await axios.request(options)
loading.close()
// 提取文件名
if(!filename){
filename = response.headers['content-disposition']?.match(
/filename=(.*)/
)[1] || ''
}
// 将二进制流转为blob
const blob = new Blob([response.data], { type: 'application/octet-stream' })
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// 兼容IEwindow.navigator.msSaveBlob以本地方式保存文件
window.navigator.msSaveBlob(blob, decodeURI(filename))
} else {
// 创建新的URL并指向File对象或者Blob对象的地址
const blobURL = window.URL.createObjectURL(blob)
// 创建a标签用于跳转至下载链接
const tempLink = document.createElement('a')
tempLink.style.display = 'none'
tempLink.href = blobURL
tempLink.setAttribute('download', decodeURI(filename))
// 兼容某些浏览器不支持HTML5的download属性
if (typeof tempLink.download === 'undefined') {
tempLink.setAttribute('target', '_blank')
}
// 挂载a标签
document.body.appendChild(tempLink)
tempLink.click()
document.body.removeChild(tempLink)
// 释放blob URL地址
window.URL.revokeObjectURL(blobURL)
}
}catch (err){
console.error(err)
loading.close()
Message({
type:'error',
message:err
})
}
}

@ -35,6 +35,28 @@
</div>
</div>
</template> <template v-slot:sort>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>排序
</div>
<div class="xy-table-item-content">
<el-input clearable placeholder="请填写排序" v-model="detail.sort" style="width: 100px;" />
</div>
</div>
</template>
<template v-slot:money>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>金额
</div>
<div class="xy-table-item-content">
<el-input clearable placeholder="请填写金额" v-model="detail.money" style="width: 100px;" />
</div>
</div>
</template>
<template v-slot:has_total>
@ -126,7 +148,9 @@
image_id: "",
total: 0,
has_total: 0,
image_id_url: ""
image_id_url: "",
sort:1,
money: 0,
},
action: process.env.VUE_APP_UPLOAD_API,
rules: {
@ -150,7 +174,11 @@
}
} else {
this.id = ''
this.type = ''
this.type = '';
this.detail.image_id='';
this.detail.image_id_url='';
this.$refs['addActivity'].reset()
}
}
@ -182,7 +210,8 @@
})
Object.assign(this.detail, res);
this.detail.activity_list_id = parseInt(res.activity_list_id)
this.detail.image_id = res.id
this.detail.image_id = res.image_id;
this.detail.image_id_url = res.image_file.url;
},
editor() {
save(this.detail).then(res => {

@ -90,6 +90,14 @@
prop: 'has_total',
label: '剩余数量',
align: 'right'
}, {
prop: 'sort',
label: '排序',
align: 'right'
}, {
prop: 'money',
label: '金额',
align: 'right'
},
{
prop: 'created_at',

@ -23,13 +23,17 @@
<Button style="margin-left: 10px" type="primary" @click="select={page:1,keyword:''}">
</Button>
<Button style="margin-left: 10px" type="primary" @click="doSearch"></Button>
<Button style="margin-left: 10px" type="error" @click="doExcel"></Button>
<Button style="margin-left: 10px" type="primary" @click="doGet"></Button>
<Button style="margin-left: 10px" type="warning" @click="doNoGet"></Button>
</div>
</slot>
</lx-header>
<xy-table :list="list" :table-item="table" @pageSizeChange="pageSizeChange" @pageIndexChange="pageChange" :total="total" @delete="deleteitem">
<template v-slot:btns v-if="type==0">
<xy-table :list="list" :table-item="table" @pageSizeChange="pageSizeChange" @pageIndexChange="pageChange"
:total="total" @delete="deleteitem" @selectAllClick="handleSelectionChange">>
<template v-slot:btns>
</template>
</xy-table>
@ -44,7 +48,9 @@
import {
index as activityIndex
} from "@/api/activity/index";
import {
download
} from '@/utils/downloadRequest'
export default {
data() {
return {
@ -52,28 +58,53 @@
page: 1,
page_size: 20,
keyword: '',
activity_list_id: ""
activity_list_id: "",
ids: []
},
listActivity: [],
total: 0,
list: [],
table: [{
width: 36,
sortable: false,
type: 'selection',
fixed: "left"
},
{
prop: 'activity_list.name',
label: '项目名称',
fixed: 'left',
align: 'left'
}, {
},
{
prop: 'mobile',
label: '手机号',
align: 'center',
width: "120px"
},
{
prop: 'user.name',
label: '用户名称',
align: 'left',
align: 'center',
width: "120px"
}, {
prop: 'user.username',
label: '登录名',
align: 'center'
align: 'center',
width: "120px"
}, {
prop: 'draw_prize.name',
label: '中奖信息',
align: 'center'
align: 'center',
width: "200px"
}, {
prop: 'is_send',
label: '是否领奖',
align: 'center',
width: "120px",
formatter: (v1, v2, value) => {
return value == 1 ? "已领取" : "未领取";
}
},
{
@ -88,7 +119,29 @@
}
},
methods: {
doGet() {
},
doNoGet() {
},
//
handleSelectionChange(val) {
this.select.ids = val
},
doExcel() {
download(
'/api/admin/draw-prize/draw-log',
'get', {
is_export: 1,
...this.select
},
'中奖列表.xlsx')
},
async loadActivity() {
const res = await activityIndex({
page: 1,
@ -146,4 +199,4 @@
margin-bottom: 6px;
}
}
</style>
</style>

Loading…
Cancel
Save