533 lines
24 KiB
Plaintext
533 lines
24 KiB
Plaintext
@{
|
||
ViewBag.Title = "发票";
|
||
Layout = "~/Views/Shared/_content.cshtml";
|
||
|
||
}
|
||
<script src="/Scripts/jquery.easyui.min.js" type="text/javascript"></script>
|
||
<link href="/Content/themes/blue/easyui.css" rel="stylesheet" />
|
||
<link href="/Content/Site.css" rel="stylesheet" />
|
||
<script src="/Scripts/common.js"></script>
|
||
<link href="/Content/data_grid_list.css" rel="stylesheet" />
|
||
<script src="/Scripts/op/jquery.rewrite.js"></script>
|
||
|
||
<style type="text/css">
|
||
.layui-table-cell {
|
||
display: table-cell;
|
||
vertical-align: middle;
|
||
}
|
||
.layui-form-label {
|
||
width:110px;
|
||
}
|
||
.layui-input-block {
|
||
margin-left:150px;
|
||
}
|
||
</style>
|
||
|
||
<div class="layui-form" style="padding:10px;" id="content">
|
||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
|
||
<legend>客户信息</legend>
|
||
<span style="padding:30px; color:red">注:收集完务必核实一遍,个人原因提供错开票信息或者登记错的不接受重开</span>
|
||
</fieldset>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label"><span style="color:red">*</span>事业部:</label>
|
||
<div class="layui-input-inline">
|
||
@if (ViewBag.DeptList != null)
|
||
{
|
||
<select name="Channel" id="Channel" lay-filter="ChannelChange">
|
||
@*@{ var allchannel = string.Empty; var ch = string.Empty; }
|
||
@foreach (var item in ViewBag.DeptList as List<SelectListItem>)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(item.Value))
|
||
{
|
||
allchannel += item.Value + "|";
|
||
}
|
||
}
|
||
@{ if (!string.IsNullOrEmpty(allchannel)) { ch = allchannel.Remove(allchannel.LastIndexOf("|"), 1); } }*@
|
||
@*<option value="@ch">请选择</option>*@
|
||
<option value="">请选择</option>
|
||
@foreach (var item in ViewBag.DeptList as List<SelectListItem>)
|
||
{
|
||
<option value="@item.Value" selected="@item.Selected">@item.Text</option>
|
||
}
|
||
</select>
|
||
}
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label"><span style="color:red">*</span>客户id:</label>
|
||
<div class="layui-input-inline">
|
||
<input name="ResId" id="ResId" lay-verify="required" autocomplete="off" class="layui-input">
|
||
</div>
|
||
<div class="layui-form-mid" style="padding: 0!important;">
|
||
<button type="button" class="layui-btn layui-btn-primary" data-method="search">查询</button>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">客户姓名:</label>
|
||
<div class="layui-input-block">
|
||
<span id="CNameTxt" class="layui-form-mid"></span>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">订单列表:</label>
|
||
<div class="layui-input-block">
|
||
<input name="Orders" id="Orders" lay-verify="required" lay-reqText="订单不能为空,请确认!" autocomplete="off" class="layui-hide" type="hidden">
|
||
<table class="layui-hide" id="tabl1" lay-filter="tabl1"></table>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">订单金额:</label>
|
||
<div class="layui-input-block">
|
||
<span id="OrderPriceTxt" class="layui-form-mid"></span>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">退款金额:</label>
|
||
<div class="layui-input-block">
|
||
<span id="RefundPriceTxt" class="layui-form-mid"></span>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">开票金额:</label>
|
||
<div class="layui-input-block">
|
||
<span id="InvoicePriceTxt" class="layui-form-mid"></span>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label"><span style="color:red">*</span>发票类型:</label>
|
||
<div class="layui-input-block">
|
||
<select name="InvoiceType" id="InvoiceType" lay-filter="InvoiceTypeChange">
|
||
<option value="1">个人电子普票</option>
|
||
<option value="2">企业电子普票</option>
|
||
<option value="3">增值税专用发票</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label"><span style="color:red">*</span>抬头名称:</label>
|
||
<div class="layui-input-block">
|
||
<input name="InvoiceTitle" lay-verify="required" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice2 invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>税号:</label>
|
||
<div class="layui-input-block">
|
||
<input name="TaxCode" id="TaxCode" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>开户银行:</label>
|
||
<div class="layui-input-block">
|
||
<input name="Bank" id="Bank" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>开户账号:</label>
|
||
<div class="layui-input-block">
|
||
<input name="Account" id="Account" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>企业地址:</label>
|
||
<div class="layui-input-block">
|
||
<input name="CompanyAddress" id="CompanyAddress" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>企业电话:</label>
|
||
<div class="layui-input-block">
|
||
<input name="CompanyTel" id="CompanyTel" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">电子邮箱:</label>
|
||
<div class="layui-input-block">
|
||
<input name="Email" id="Email" lay-verify="email" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label">寄送地址:</label>
|
||
<div class="layui-input-block">
|
||
<input name="SendAddress" id="SendAddress" autocomplete="off" class="layui-input">
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice2 invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>授权委托书:</label>
|
||
<div class="layui-input-block">
|
||
<input name="PowerOfAttorney" id="PowerOfAttorney" autocomplete="off" class="layui-hide" type="hidden">
|
||
<button type="button" class="layui-btn" id="PowerOfAttorneyUpload">上传</button>
|
||
<div class="layui-upload-list">
|
||
<a href="" target="_blank"><img class="layui-upload-img" id="PowerOfAttorneyImg" width="100"></a>
|
||
<a href="" target="_blank" id="PowerOfAttorneyFile"></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice2 invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>营业执照:</label>
|
||
<div class="layui-input-block">
|
||
<input name="BusinessLicense" id="BusinessLicense" autocomplete="off" class="layui-hide" type="hidden">
|
||
<button type="button" class="layui-btn" id="BusinessLicenseUpload">上传</button>
|
||
<div class="layui-upload-list">
|
||
<a href="" target="_blank"><img class="layui-upload-img" id="BusinessLicenseImg" width="100"></a>
|
||
<a href="" target="_blank" id="BusinessLicenseFile"></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>一般纳税人证明:</label>
|
||
<div class="layui-input-block">
|
||
<input name="GeneralTaxPayer" id="GeneralTaxPayer" autocomplete="off" class="layui-hide" type="hidden">
|
||
<button type="button" class="layui-btn" id="GeneralTaxPayerUpload">上传</button>
|
||
<div class="layui-upload-list">
|
||
<a href="" target="_blank"><img class="layui-upload-img" id="GeneralTaxPayerImg" width="100"></a>
|
||
<a href="" target="_blank" id="GeneralTaxPayerFile"></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item invoice invoice3">
|
||
<label class="layui-form-label"><span style="color:red">*</span>转帐流水证明:</label>
|
||
<div class="layui-input-block">
|
||
<input name="ProofOfFlow" id="ProofOfFlow" autocomplete="off" class="layui-hide" type="hidden">
|
||
<button type="button" class="layui-btn" id="ProofOfFlowUpload">上传</button>
|
||
<div class="layui-upload-list">
|
||
<a href="" target="_blank"><img class="layui-upload-img" id="ProofOfFlowImg" width="100"></a>
|
||
<a href="" target="_blank" id="ProofOfFlowFile"></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<div class="layui-input-block">
|
||
<input type="hidden" name="Creator" autocomplete="off" class="layui-hide" value="@ViewBag.Eid">
|
||
<input type="hidden" name="CreatorName" autocomplete="off" class="layui-hide" value="@ViewBag.UserName">
|
||
<button type="submit" class="layui-btn" lay-submit="" lay-filter="save">提交</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
layui.use(['layer', 'form', 'upload', 'element', 'table'], function () {
|
||
var form = layui.form,
|
||
layer = layui.layer,
|
||
upload = layui.upload,
|
||
table = layui.table,
|
||
element = layui.element;
|
||
|
||
var token = $.cookie("AuthToken");
|
||
|
||
//监听提交
|
||
form.on('submit(save)', function (data) {
|
||
var url = "@ViewBag.ApiUrl/InvoiceHandler.ashx?action=add";
|
||
var para = data.field;
|
||
console.log(para);
|
||
$.ajax({
|
||
type: 'post',
|
||
url: url,
|
||
data: JSON.stringify(para),
|
||
headers: { auth: token },
|
||
cache: false,
|
||
dataType: 'json',
|
||
contentType: "application/json",
|
||
success: function (rep) {
|
||
console.log(rep);
|
||
if (rep.result) {
|
||
layer.msg('提交成功!', { icon: 1 }, function () { parent.window.location.reload(); });
|
||
}
|
||
else {
|
||
layer.msg('操作失败了,请联系管理员!', { icon: 2 });
|
||
}
|
||
},
|
||
error: function () { }
|
||
});
|
||
return false;
|
||
});
|
||
|
||
form.on('select(ChannelChange)', function (data) {
|
||
loadOrder(null);
|
||
});
|
||
|
||
form.on('select(InvoiceTypeChange)', function (data) {
|
||
//console.log(data);
|
||
$('.invoice').each(function () { $(this).hide(); });
|
||
|
||
$('#TaxCode').removeAttr('lay-verify');
|
||
$('#Bank').removeAttr('lay-verify');
|
||
$('#Account').removeAttr('lay-verify');
|
||
$('#CompanyAddress').removeAttr('lay-verify');
|
||
$('#CompanyTel').removeAttr('lay-verify');
|
||
$('#SendAddress').removeAttr('lay-verify');
|
||
$('#PowerOfAttorney').removeAttr('lay-verify');
|
||
$('#BusinessLicense').removeAttr('lay-verify');
|
||
$('#GeneralTaxPayer').removeAttr('lay-verify');
|
||
$('#ProofOfFlow').removeAttr('lay-verify');
|
||
|
||
if (data.value === "2") {
|
||
$('.invoice2').each(function () { $(this).show(); });
|
||
$('#TaxCode').attr('lay-verify', 'taxcode');
|
||
$('#PowerOfAttorney').attr('lay-verify', 'powerofattorney');
|
||
$('#BusinessLicense').attr('lay-verify', 'businesslicense');
|
||
}
|
||
if (data.value === "3") {
|
||
$('.invoice3').each(function () { $(this).show(); });
|
||
$('#TaxCode').attr('lay-verify', 'taxcode');
|
||
$('#PowerOfAttorney').attr('lay-verify', 'powerofattorney');
|
||
$('#BusinessLicense').attr('lay-verify', 'businesslicense');
|
||
$('#Bank').attr('lay-verify', 'bank');
|
||
$('#Account').attr('lay-verify', 'account');
|
||
$('#CompanyAddress').attr('lay-verify', 'companyaddress');
|
||
$('#CompanyTel').attr('lay-verify', 'companytel');
|
||
$('#GeneralTaxPayer').attr('lay-verify', 'generaltaxpayer');
|
||
$('#ProofOfFlow').attr('lay-verify', 'proofofflow');
|
||
$('#SendAddress').attr('lay-verify', 'sendaddress');
|
||
}
|
||
});
|
||
|
||
form.verify({
|
||
taxcode: function (value) {
|
||
if (value == "") { return "税号不能为空!"; }
|
||
if (value.length > 30) { return "字数太多了!"; }
|
||
},
|
||
powerofattorney: function (value) {
|
||
if (value == "") { return "请上传授权委托书!"; }
|
||
},
|
||
businesslicense: function (value) {
|
||
if (value == "") { return "请上传营业执照!"; }
|
||
},
|
||
bank: function (value) {
|
||
if (value == "") { return "开户银行不能为空!"; }
|
||
if (value.length > 50) { return "字数太多了!"; }
|
||
},
|
||
account: function (value) {
|
||
if (value == "") { return "开户账号不能为空!"; }
|
||
if (value.length > 30) { return "字数太多了!"; }
|
||
},
|
||
companyaddress: function (value) {
|
||
if (value == "") { return "企业地址不能为空!"; }
|
||
if (value.length > 50) { return "字数太多了!"; }
|
||
},
|
||
companytel: function (value) {
|
||
if (value == "") { return "企业电话不能为空!"; }
|
||
if (value.length > 20) { return "字数太多了!"; }
|
||
},
|
||
generaltaxpayer: function (value) {
|
||
if (value == "") { return "请上传一般纳税人证明!"; }
|
||
},
|
||
proofofflow: function (value) {
|
||
if (value == "") { return "请上传转帐流水证明!"; }
|
||
},
|
||
email: function (value) {
|
||
if (value != '') {
|
||
var re = /^([a-zA-Z0-9_-])+@@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
|
||
if (!re.test(value)) {
|
||
return "邮箱格式不正确!"
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
var uploadList = [
|
||
{ id: '#PowerOfAttorney', uploadbutton: '#PowerOfAttorneyUpload', uploadimg: '#PowerOfAttorneyImg', uploadfile: '#PowerOfAttorneyFile', filename: '授权委托书' },
|
||
{ id: '#BusinessLicense', uploadbutton: '#BusinessLicenseUpload', uploadimg: '#BusinessLicenseImg', uploadfile: '#BusinessLicenseFile', filename: '营业执照' },
|
||
{ id: '#GeneralTaxPayer', uploadbutton: '#GeneralTaxPayerUpload', uploadimg: '#GeneralTaxPayerImg', uploadfile: '#GeneralTaxPayerFile', filename: '一般纳税人证明' },
|
||
{ id: '#ProofOfFlow', uploadbutton: '#ProofOfFlowUpload', uploadimg: '#ProofOfFlowImg', uploadfile: '#ProofOfFlowFile', filename: '转帐流水证明' }
|
||
];
|
||
|
||
function uploadfile() {
|
||
//let url = 'http://localhost:55047/InvoiceService.svc/Upload';//要提交数据的路由
|
||
//var url = '/WeiXin/Invoice/Upload';
|
||
//var url = 'http://localhost:55047/InvoiceHandler.ashx';
|
||
|
||
//let formData = new FormData();
|
||
|
||
//formData.append('action', 'upload');
|
||
//formData.append('FileName', 'aaa.jpg');
|
||
//formData.append('SavePath', '111');
|
||
|
||
//for (let i in files) { //这个files就是全局变量
|
||
// formData.append('file', files[i]);
|
||
//}
|
||
|
||
////formData.append('content', '我是文本内容');
|
||
|
||
//$.ajax({
|
||
// url: url,
|
||
// type: 'post',
|
||
// data: formData,
|
||
// cache: false,
|
||
// contentType: false, //需要设置为false,不然后台拿不到数据
|
||
// processData: false, //传送DOM信息,所以设为false
|
||
// success: function (msg) {
|
||
// files = '';//初始化全局变量
|
||
|
||
// }
|
||
//})
|
||
var imageFile = 'jpg|png|gif|bmp|jpeg';
|
||
|
||
$.each(uploadList, function (x, y) {
|
||
var resid = $("#ResId").val();
|
||
if (resid == "") {
|
||
layer.msg('请先填写资源ID');
|
||
return;
|
||
}
|
||
upload.render({
|
||
elem: y.uploadbutton
|
||
, url: '@ViewBag.ApiUrl/InvoiceHandler.ashx'
|
||
, data: { action: 'upload', FileName: y.filename, SavePath: resid }
|
||
, headers: { auth: token }
|
||
, auto: true
|
||
, size: 2048
|
||
, accept: 'file'
|
||
, exts: 'doc|docx|xls|xlsx|pdf|zip|jpg|png|gif|bmp|jpeg|'
|
||
, before: function (obj) {
|
||
//console.log(obj);
|
||
obj.preview(function (index, file, result) {
|
||
//console.log(result);
|
||
console.log(file);
|
||
var type = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length);
|
||
//console.log(type);
|
||
if (imageFile.indexOf(type) != -1) {
|
||
$(y.uploadimg).attr('src', result); //图片链接(base64)
|
||
}
|
||
});
|
||
}
|
||
, done: function (res) {
|
||
$(y.id).val('');
|
||
$(y.uploadimg).hide();
|
||
$(y.uploadfile).hide();
|
||
//如果上传失败
|
||
if (!res.result) {
|
||
return layer.msg('上传失败');
|
||
}
|
||
//上传成功的一些操作
|
||
console.log(res);
|
||
$(y.id).val(res.retmsg);
|
||
var type = res.retmsg.substring(res.retmsg.lastIndexOf(".") + 1, res.retmsg.length);
|
||
//console.log(type);
|
||
if (imageFile.indexOf(type) != -1) {
|
||
$(y.uploadimg).show();
|
||
$(y.uploadimg).parent().attr('href', '@ViewBag.WebUrl' + res.retmsg);
|
||
}
|
||
else {
|
||
$(y.uploadfile).attr('href', '@ViewBag.WebUrl' + res.retmsg).text(y.filename).show();
|
||
}
|
||
}
|
||
, error: function () {
|
||
$(y.id).val('');
|
||
$(y.uploadimg).removeAttr('src');
|
||
layer.msg('上传失败,请重试!');
|
||
}
|
||
});
|
||
});
|
||
|
||
}
|
||
|
||
function loadOrder(data) {
|
||
if (data == null) {
|
||
data = [];
|
||
$("#OrderPriceTxt").html(0);
|
||
$("#RefundPriceTxt").html(0);
|
||
$("#InvoicePriceTxt").html(0).attr('style', 'color:red');
|
||
}
|
||
var len = data.length;
|
||
var opt = {
|
||
id: 'tabl1'
|
||
, elem: '#tabl1'
|
||
, limit: 500
|
||
, cols: [[
|
||
{ type: 'checkbox' }
|
||
, { field: 'OrderId', title: '订单号' }
|
||
, { field: 'InvoicePrice', title: '可开票金额', templet: function (res) { return '<div style="color:red">' + res.InvoicePrice + '</div>'; } }
|
||
, { field: 'Price', title: '付款金额' }
|
||
, { field: 'RefundPrice', title: '退款金额' }
|
||
, { field: 'OrderStatusName', title: '订单状态' }
|
||
, { field: 'ChannelName', title: '事业部' }
|
||
]]
|
||
, data: data
|
||
};
|
||
if (len > 6) {
|
||
opt.height = 280;
|
||
}
|
||
table.render(opt);
|
||
|
||
table.on('checkbox(tabl1)', function (obj) {
|
||
var checkStatus = table.checkStatus('tabl1');
|
||
var data = checkStatus.data;
|
||
console.log(data);
|
||
var orders = [];
|
||
var orderPrice = 0;
|
||
var refundPrice = 0;
|
||
var invoicePrice = 0;
|
||
if (data.length > 0) {
|
||
$.each(data, function (i, j) {
|
||
orderPrice += j.Price;
|
||
refundPrice += j.RefundPrice;
|
||
invoicePrice += j.InvoicePrice;
|
||
orders.push(j.OrderId);
|
||
});
|
||
$("#Orders").val(orders.join(','));
|
||
}
|
||
else {
|
||
$("#Orders").val('');
|
||
}
|
||
if (orderPrice > 0) {
|
||
orderPrice = orderPrice.toFixed(2);
|
||
}
|
||
if (refundPrice > 0) {
|
||
refundPrice = refundPrice.toFixed(2);
|
||
}
|
||
if (invoicePrice > 0) {
|
||
invoicePrice = invoicePrice.toFixed(2);
|
||
}
|
||
$("#OrderPriceTxt").html(orderPrice);
|
||
$("#RefundPriceTxt").html(refundPrice);
|
||
$("#InvoicePriceTxt").html(invoicePrice).attr('style','color:red');
|
||
});
|
||
}
|
||
|
||
var active = {
|
||
search: function () {
|
||
var resid = $("#ResId").val();
|
||
if (resid == "") {
|
||
layer.msg('请先填写资源ID');
|
||
return;
|
||
}
|
||
var channel = $('#Channel').val();
|
||
if (channel == "") {
|
||
layer.msg('请选择事业部!');
|
||
return;
|
||
}
|
||
var url = "@ViewBag.ApiUrl/InvoiceHandler.ashx";
|
||
var data = { action: "load", resid: resid, channel: channel };
|
||
$.ajax({
|
||
type: 'get',
|
||
url: url,
|
||
headers: { auth: token },
|
||
data: data,
|
||
dataType: 'json',
|
||
success: function (rep) {
|
||
console.log(rep);
|
||
if (rep.retmsg == null) {
|
||
loadOrder(null);
|
||
layer.msg('找不到可申请发票的订单,请确认');
|
||
return;
|
||
}
|
||
else {
|
||
$("#CNameTxt").html(rep.retmsg.CName);
|
||
|
||
loadOrder(JSON.parse(rep.retmsg.Orders));
|
||
|
||
uploadfile();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
};
|
||
$('.layui-btn').on('click', function () {
|
||
var othis = $(this), method = othis.data('method');
|
||
active[method] ? active[method].call(this, othis) : '';
|
||
});
|
||
|
||
$('#InvoiceType').siblings("div.layui-form-select").find('dl dd.layui-this').click();
|
||
|
||
});
|
||
</script>
|