Files
peko-admin-web/src/views/anchor/AnchorBillUploadView.vue

268 lines
12 KiB
Vue
Raw Normal View History

2023-09-19 10:55:46 +08:00
<template>
<section class="content">
<div class="box box-primary">
<div class="box-body">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1 id="itemTitle"></h1>
</section>
<!-- .content -->
<div class="col-sm-12">
<button id="btnImport" class="btn btn-default">
<i class="glyphicon glyphicon-import"></i>上传流水附件
</button>
</div>
</div>
</div>
<div id="table"></div>
</section>
<div class=" modal fade" id="fileUpload" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="modalLabel1">上传文件</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" id="uploadForm">
<div class="form-group">
<label for="uploadFile" class="col-sm-3 control-label">上传文件:</label>
<div class="col-sm-9">
<input type="file" class="form-control validate[required]" name="uploadFile"
id="uploadFile" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">注意:</label>
<div class="col-sm-9">
<span>
<font color="#dd4b39">1.上传文件仅支持.xlsx格式的文件<br>
2.文件内容第一行为标题(:平台号,金币,钻石)<br>
3.第一列为用户平台号,第二列为用户要添加的金币数量,第三列为用户要添加的钻石数量
</font>
</span>
</div>
</div>
</form>
</div>
<div class="modal-footer" style="height: 20%">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="upload">确定</button>
</div>
</div>
</div>
</div>
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
import { showLoading, hideLoading } from '@/utils/maintainer';
export default {
name: "AnchorBillUploadView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
//获取模板列表
//初始化表格
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
columns: [
// {field: 'temp', title: 'id', align: 'center', checkbox: true, width: '5%'},
{ field: 'id', title: 'ID', align: 'center', width: '5%' },
{ field: 'adminName', title: '上传者', align: 'center', width: '5%' },
{
field: 'uploadTime',
title: '上传时间',
align: 'center',
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:00");
} else {
return '-';
}
}
},
{ field: 'realName', title: '文件名', align: 'center', width: '5%' },
{
field: 'fileName', title: '下载', align: 'center', width: '5%',
formatter: function (val, row, index) {
var downloadLink = '/admin/anchor/downloadExcel?id=' + row.id;
var alink = '<a href="' + downloadLink + '">' + row.realName + ' </a> ';
// window.location.href=
return alink;
}
},
{
field: 'status', title: '状态', align: 'center', width: '5%',
formatter: function (val, row, index) {
if (val == 1) {
return "审核中";
} if (val == 2) {
return "审核通过";
} if (val == 3) {
return "驳回";
} if (val == 4) {
return "已导入";
} else {
return '-';
}
}
},
{ field: 'checkAdminName', title: '审核人', align: 'center', width: '5%' },
{
field: 'checkTime',
title: '审核时间',
align: 'center',
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:00");
} else {
return '-';
}
}
},
{
field: 'id',
title: '操作',
align: 'center',
width: '15%',
formatter: function (val, row, index) {
var result = '';
console.log(row.status)
if (row.status == 2) {
result += '<button id="import" name="import" class="btn btn-sm btn-success opt-import" data-id=' + val + '>' +
'<i class="glyphicon glyphicon-import"></i> 导入</button>&nbsp;&nbsp;';
}
return result;
}
}
],
cache: false,
striped: true,
showRefresh: false,
pageSize: 20,
pagination: true,
pageList: [20, 50, 100, 200, 300, 500],
search: false,
sidePagination: "server", //表示服务端请求
//设置为undefined可以获取pageNumberpageSizesearchTextsortNamesortOrder
//设置为limit可以获取limit, offset, search, sort, order
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
page: params.pageNumber,
pageSize: params.pageSize,
erbanNo: $('#erbanNo').val(),
templateId: $('#templateId').val(),
sendStatus: $('#sendStatus').val(),
createTime: $('#createTime').val(),
sendTime: $('#sendTime').val()
};
return param;
},
toolbar: '#toolbar',
url: '/admin/anchor/uploadList',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
$("#btnSearch").click(function () {
TableHelper.doRefresh('#table');
})
$("#btnImport").click(function () {
$("#uploadFile").val("");
$("#fileUpload").modal('show');
});
$("#upload").click(function () {
var file = $("#uploadFile").val();
if (file == null || file == undefined || file == '') {
$("#tipMsg").text("上传文件不能为空.");
$("#tipModal").modal('show');
}
debugger;
$("#fileUpload").modal('hide');
showLoading();
var option = ({
type: "POST",
url: "/admin/anchor/uploadExcel",
cache: false,
contentType: false, //不可缺
processData: false, //不可缺
dataType: "json",
success: function (json) {
hideLoading();
console.log(json)
if (json.code == 200) {
$("#tipMsg").text("上传成功");
$("#tipModal").modal('show');
TableHelper.doRefresh('#table');
} else {
$("#tipMsg").text("上传失败.");
$("#tipModal").modal('show');
}
},
error: function () {
hideLoading();
$("#tipMsg").text("上传失败.");
$("#tipModal").modal('show');
}
});
$("#uploadForm").ajaxSubmit(option);
});
//更改
$('#table').on('click', '.opt-import', function () {
var key = parseInt($(this).data('id'));
console.log(key, typeof key);
if (confirm("确定要导入该流水账单吗?")) {
$.ajax({
type: 'post',
url: '/admin/anchor/check/import',
data: { 'id': key },
dataType: 'json',
success: function (data) {
if (data.code == 200) {
$("#tipMsg").text("操作成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("操作失败,错误信息:" + data.message);
$("#tipModal").modal('show');
}
}
});
}
})
});
}
},
2023-11-14 17:59:51 +08:00
2023-09-19 10:55:46 +08:00
};
</script>
<style scoped></style>