添加发票
This commit is contained in:
236
application/admin/controller/Invoice.php
Normal file
236
application/admin/controller/Invoice.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\Invoice as InvoiceModel;
|
||||
use app\admin\model\InvoiceLog;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class Invoice extends AdminBase
|
||||
{
|
||||
/**
|
||||
* 发票列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
|
||||
// 构建查询条件
|
||||
$where = [];
|
||||
if (!empty($get['keyword'])) {
|
||||
$where[] = ['i.oid|i.invoice_id', 'like', '%' . $get['keyword'] . '%'];
|
||||
}
|
||||
if (isset($get['state']) && $get['state'] !== '') {
|
||||
$where[] = ['i.state', '=', intval($get['state'])];
|
||||
}
|
||||
|
||||
// 查询数据(关联订单表获取订单编号)
|
||||
$list = Db::name('invoice_log')
|
||||
->where($where)
|
||||
->order('state asc')
|
||||
->select();
|
||||
|
||||
// 格式化数据
|
||||
$currentDomain = $_SERVER['HTTP_HOST'];
|
||||
$result = [];
|
||||
foreach ($list as $item) {
|
||||
$result[] = [
|
||||
'id' => $item['id'] ?? 0,
|
||||
'invoice_id' => $item['invoice_id'] ?? 0,
|
||||
'oid' => $item['oid'] ?? 0,
|
||||
'state' => $item['state'] ?? 1,
|
||||
'document' => "http://".$currentDomain."/public/".$item['document'] ?? '',
|
||||
'create_time' => $item['create_time'] ?? '',
|
||||
'update_time' => $item['update_time'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'count' => count($result),
|
||||
'lists' => $result
|
||||
];
|
||||
|
||||
$this->_success('', $data);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$id = $this->request->param('id', 0);
|
||||
if (empty($id)) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
|
||||
$invoice = InvoiceLog::with([
|
||||
"order" => function ($query) {
|
||||
$query->field('id, order_sn');
|
||||
},
|
||||
"invoice" => function ($query) {
|
||||
$query->with('user');
|
||||
},
|
||||
])
|
||||
->where('id', $id)
|
||||
->find();
|
||||
if (empty($invoice)) {
|
||||
$this->_error('数据不存在');
|
||||
}
|
||||
|
||||
// 处理文件路径(转换为完整URL)
|
||||
$currentDomain = $_SERVER['HTTP_HOST'];
|
||||
if (!empty($invoice['document'])) {
|
||||
$invoice['document_url'] = "http://".$currentDomain."/public/".$invoice['document'];
|
||||
}
|
||||
|
||||
$this->assign([
|
||||
'invoice' => $invoice,
|
||||
]);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->param('id', 0);
|
||||
if (empty($id)) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
|
||||
if ($this->request->isAjax() && $this->request->isPost()) {
|
||||
$post = $this->request->post();
|
||||
|
||||
// 表单验证
|
||||
if (empty($post['invoice_id'])) {
|
||||
$this->_error('请输入发票信息ID');
|
||||
}
|
||||
if (empty($post['document'])){
|
||||
$this->_error('请上传发票文件');
|
||||
}
|
||||
$data = [
|
||||
'state' => $post['state'],
|
||||
'document' => $post['document'],
|
||||
'update_time' => date('Y-m-d H:i:s', time()),
|
||||
];
|
||||
|
||||
// 更新数据
|
||||
$result = Db::name('invoice_log')->where('id', $id)->update($data);
|
||||
|
||||
if ($result) {
|
||||
$this->_success('上传成功');
|
||||
} else {
|
||||
$this->_error('上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 处理文件路径(转换为完整URL用于显示)
|
||||
if (!empty($invoice['document'])) {
|
||||
$invoice['document'] = UrlServer::getFileUrl($invoice['document']);
|
||||
}
|
||||
|
||||
// 查询订单列表
|
||||
$orders = Db::name('order')
|
||||
->where('order_status', '>', 0)
|
||||
->field('id, order_sn')
|
||||
->order('id desc')
|
||||
->limit(100)
|
||||
->select();
|
||||
|
||||
$this->assign([
|
||||
'invoice' => $invoice,
|
||||
'orders' => $orders,
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if ($this->request->isAjax() && $this->request->isPost()) {
|
||||
$id = $this->request->post('id', 0);
|
||||
if (empty($id)) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
|
||||
// 检查数据是否存在
|
||||
$invoice = Db::name('invoice_log')->where('id', $id)->find();
|
||||
if (empty($invoice)) {
|
||||
$this->_error('数据不存在');
|
||||
}
|
||||
|
||||
// 删除数据
|
||||
$result = Db::name('invoice_log')->where('id', $id)->delete();
|
||||
|
||||
if ($result) {
|
||||
$this->_success('删除成功');
|
||||
} else {
|
||||
$this->_error('删除失败');
|
||||
}
|
||||
} else {
|
||||
$this->_error('请求方式错误');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传发票文件
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$file = $this->request->file('file');
|
||||
if (empty($file)) {
|
||||
$this->_error('请选择文件');
|
||||
}
|
||||
|
||||
// 获取文件信息
|
||||
$fileInfo = $file->getInfo();
|
||||
$fileName = $fileInfo['name'] ?? '';
|
||||
|
||||
// 验证文件类型(PDF)- 从文件名获取扩展名(最可靠的方法)
|
||||
$ext = '';
|
||||
if (!empty($fileName)) {
|
||||
// 使用pathinfo获取扩展名,支持中文文件名
|
||||
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
}
|
||||
|
||||
// 如果从文件名获取失败,尝试从MIME类型判断
|
||||
if (empty($ext) && isset($fileInfo['type'])) {
|
||||
$mimeType = strtolower($fileInfo['type']);
|
||||
if (strpos($mimeType, 'pdf') !== false || $mimeType === 'application/pdf') {
|
||||
$ext = 'pdf';
|
||||
}
|
||||
}
|
||||
|
||||
// 验证扩展名
|
||||
if (empty($ext) || $ext !== 'pdf') {
|
||||
$this->_error('只支持PDF格式文件,当前文件:' . $fileName . ',扩展名:' . ($ext ?: '未知'));
|
||||
}
|
||||
|
||||
// 设置验证规则
|
||||
$file->validate(['ext' => 'pdf']);
|
||||
|
||||
// 上传文件
|
||||
$uploadPath = rtrim(ROOT_PATH, '/\\') . '/public/uploads/invoice';
|
||||
$info = $file->move($uploadPath);
|
||||
if ($info) {
|
||||
// 返回文件路径(相对路径)
|
||||
$filePath = 'uploads/invoice/' . $info->getSaveName();
|
||||
$this->_success('上传成功', ['path' => $filePath]);
|
||||
} else {
|
||||
$errorMsg = $file->getError();
|
||||
$this->_error('上传失败:' . ($errorMsg ?: '未知错误'));
|
||||
}
|
||||
} else {
|
||||
$this->_error('请求方式错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,14 +57,11 @@ class ControlLogic{
|
||||
$item['add']=$order_info['add'];
|
||||
|
||||
$order=Db::name('order')->where('order_sn',$order_info['order_sn'])->find();
|
||||
$item['adderss']=$order['address'];
|
||||
|
||||
$goods=Db::name('goods')->where('id',$order['goods_id'])->find();
|
||||
|
||||
$item['goods_name']=$goods['name'];
|
||||
|
||||
|
||||
|
||||
if ($order != null){
|
||||
$item['adderss']=$order['address'] ?? "";
|
||||
$goods=Db::name('goods')->where('id',$order['goods_id'])->find();
|
||||
$item['goods_name']=$goods['name'] ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
16
application/admin/model/Invoice.php
Normal file
16
application/admin/model/Invoice.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
protected $name = 'invoice';
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uid', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
20
application/admin/model/InvoiceLog.php
Normal file
20
application/admin/model/InvoiceLog.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class InvoiceLog extends Model
|
||||
{
|
||||
protected $name = 'invoice_log';
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class, 'invoice_id', 'id');
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'oid', 'id');
|
||||
}
|
||||
}
|
||||
0
application/admin/view/invoice/details.html
Normal file
0
application/admin/view/invoice/details.html
Normal file
111
application/admin/view/invoice/edit.html
Normal file
111
application/admin/view/invoice/edit.html
Normal file
@@ -0,0 +1,111 @@
|
||||
{layout name="layout2" /}
|
||||
<div class="">
|
||||
<div class="layui-tab-content layui-form">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-card-body" pad15>
|
||||
<div lay-filter="">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="form-label-asterisk">*</span>发票信息ID:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="invoice_id" lay-verify="required" lay-verType="tips"
|
||||
autocomplete="off"
|
||||
switch-tab="0" verify-msg="请输入发票信息ID" placeholder="请输入发票信息ID"
|
||||
value="{$invoice.invoice_id}"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="state" value="1" title="开票中" {if $invoice.state == 1}checked{/if}>
|
||||
<input type="radio" name="state" value="2" title="驳回" {if $invoice.state == 2}checked{/if}>
|
||||
<input type="radio" name="state" value="3" title="完成" {if $invoice.state == 3}checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">发票文件:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-upload">
|
||||
<button type="button" class="layui-btn" id="upload-btn">上传PDF文件</button>
|
||||
<div class="layui-upload-list" style="margin-top: 10px;">
|
||||
<input type="hidden" name="document" id="document" value="{$invoice.document|default=''}">
|
||||
<div id="file-list">
|
||||
{if $invoice.document}
|
||||
<div style="padding: 10px; background: #f5f5f5; border-radius: 4px; margin-bottom: 10px;">
|
||||
<a href="{$invoice.document_url}" target="_blank">{$invoice.document}</a>
|
||||
<span style="color: #5FB878;">已上传</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="invoice-submit" id="invoice-submit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
layui.config({
|
||||
version:"{$front_version}",
|
||||
base: '/static/plug/layui-admin/dist/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'form', 'upload', 'jquery'], function () {
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var upload = layui.upload;
|
||||
|
||||
// 文件上传
|
||||
upload.render({
|
||||
elem: '#upload-btn',
|
||||
url: '{:url("invoice/upload")}',
|
||||
accept: 'file',
|
||||
exts: 'pdf',
|
||||
done: function(res){
|
||||
if(res.code == 1){
|
||||
$('#document').val(res.data.path);
|
||||
$('#file-list').html('<div style="padding: 10px; background: #f5f5f5; border-radius: 4px;"><a href="' + res.data.path + '" target="_blank">' + res.data.path + '</a> <span style="color: #5FB878;">上传成功</span></div>');
|
||||
layer.msg('上传成功', {icon: 1});
|
||||
} else {
|
||||
layer.msg(res.msg || '上传失败', {icon: 2});
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
layer.msg('上传失败', {icon: 2});
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(invoice-submit)', function(data){
|
||||
var field = data.field;
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
|
||||
$.ajax({
|
||||
url: '{:url("invoice/edit")}?id={$invoice.id}',
|
||||
type: 'post',
|
||||
data: field,
|
||||
success: function(res){
|
||||
if(res.code == 1){
|
||||
parent.layer.msg(res.msg, {icon: 1, time: 1000}, function(){
|
||||
parent.layer.close(index);
|
||||
parent.layui.table.reload('user-lists');
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
layer.msg('请求失败', {icon: 2});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
194
application/admin/view/invoice/info.html
Normal file
194
application/admin/view/invoice/info.html
Normal file
@@ -0,0 +1,194 @@
|
||||
{layout name="layout2" /}
|
||||
<style>
|
||||
.invoice-info-card {
|
||||
margin-bottom: 15px;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
||||
}
|
||||
.invoice-info-card .layui-card-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
border-radius: 4px 4px 0 0;
|
||||
}
|
||||
.invoice-info-card .layui-card-header:first-child {
|
||||
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
||||
}
|
||||
.info-row {
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
.info-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.info-label {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
min-width: 180px;
|
||||
display: inline-block;
|
||||
}
|
||||
.info-value {
|
||||
color: #666;
|
||||
word-break: break-all;
|
||||
}
|
||||
.info-badge {
|
||||
font-size: 13px;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
.file-preview {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
.section-divider {
|
||||
height: 1px;
|
||||
background: linear-gradient(to right, transparent, #e0e0e0, transparent);
|
||||
margin: 20px 0;
|
||||
}
|
||||
</style>
|
||||
<div class="">
|
||||
<div class="layui-card-body" pad15>
|
||||
<!-- 基本信息 -->
|
||||
<div class="layui-card invoice-info-card">
|
||||
<div class="layui-card-header">
|
||||
<i class="layui-icon layui-icon-file"></i> 基本信息
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="info-row">
|
||||
<span class="info-label">记录ID:</span>
|
||||
<span class="info-value">{$invoice.id}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">发票信息ID:</span>
|
||||
<span class="info-value">{$invoice.invoice_id}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">状态:</span>
|
||||
<span class="info-value">
|
||||
{if $invoice.state == 1}
|
||||
<span class="layui-badge layui-bg-blue info-badge">待开票</span>
|
||||
{elseif $invoice.state == 2}
|
||||
<span class="layui-badge layui-bg-red info-badge">驳回</span>
|
||||
{elseif $invoice.state == 3}
|
||||
<span class="layui-badge layui-bg-green info-badge">完成</span>
|
||||
{else}
|
||||
<span class="layui-badge layui-bg-gray info-badge">未知</span>
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">发票文件:</span>
|
||||
<span class="info-value">
|
||||
{if $invoice.document}
|
||||
<div class="file-preview">
|
||||
<a href="{$invoice.document_url}" target="_blank" class="layui-btn layui-btn-primary layui-btn-xs">
|
||||
<i class="layui-icon layui-icon-download-circle"></i> 查看文件
|
||||
</a>
|
||||
<span style="color: #999; font-size: 12px;">{$invoice.document_url}</span>
|
||||
</div>
|
||||
{else}
|
||||
<span style="color: #999;">无文件</span>
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">创建时间:</span>
|
||||
<span class="info-value">{$invoice.create_time|default='--'}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">更新时间:</span>
|
||||
<span class="info-value">{$invoice.update_time|default='--'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<div class="layui-card invoice-info-card">
|
||||
<div class="layui-card-header">
|
||||
<i class="layui-icon layui-icon-cart"></i> 订单信息
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="info-row">
|
||||
<span class="info-label">订单编号:</span>
|
||||
<span class="info-value">{$invoice.order.order_sn ?? "--"}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">订单金额:</span>
|
||||
<span class="info-value" style="color: #f56c6c; font-weight: bold; font-size: 16px;">
|
||||
¥{$invoice.order.settle_amount ?? "0.00"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户信息 -->
|
||||
<div class="layui-card invoice-info-card">
|
||||
<div class="layui-card-header">
|
||||
<i class="layui-icon layui-icon-user"></i> 用户信息
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="info-row">
|
||||
<span class="info-label">系统用户名:</span>
|
||||
<span class="info-value">{$invoice.invoice.user.nickname ?? "--"}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 发票抬头信息 -->
|
||||
<div class="layui-card invoice-info-card">
|
||||
<div class="layui-card-header">
|
||||
<i class="layui-icon layui-icon-form"></i> 发票抬头信息
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="info-row">
|
||||
<span class="info-label">类型:</span>
|
||||
<span class="info-value">
|
||||
{if $invoice.invoice.type == 1}
|
||||
<span class="layui-badge layui-bg-blue info-badge">个人</span>
|
||||
{elseif $invoice.invoice.type == 2}
|
||||
<span class="layui-badge layui-bg-orange info-badge">企业</span>
|
||||
{else}
|
||||
<span class="layui-badge layui-bg-gray info-badge">未知</span>
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">发票类型:</span>
|
||||
<span class="info-value">{$invoice.invoice.invoice_type ?? "--"}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">发票抬头/企业名称:</span>
|
||||
<span class="info-value" style="font-weight: 500;">{$invoice.invoice.invoice_title ?? "--"}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">纳税人识别号/统一社会信用代码:</span>
|
||||
<span class="info-value" style="font-family: 'Courier New', monospace; letter-spacing: 1px;">
|
||||
{$invoice.invoice.identification ?? "--"}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">注册地址:</span>
|
||||
<span class="info-value">{$invoice.invoice.address ?? "--"}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">注册电话:</span>
|
||||
<span class="info-value">{$invoice.invoice.phone ?? "--"}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">开户行:</span>
|
||||
<span class="info-value">{$invoice.invoice.bank ?? "--"}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">开户账号:</span>
|
||||
<span class="info-value" style="font-family: 'Courier New', monospace;">
|
||||
{$invoice.invoice.account ?? "--"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
189
application/admin/view/invoice/lists.html
Normal file
189
application/admin/view/invoice/lists.html
Normal file
@@ -0,0 +1,189 @@
|
||||
{layout name="layout1" /}
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
|
||||
<div class="layui-colla-content layui-show">
|
||||
<p>*发票管理列表,对发票进行编辑、查看和删除等操作。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 200px;">
|
||||
<input type="text" id="keyword" name="keyword" placeholder="请输入订单号或发票ID" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width: 150px;">
|
||||
<select name="state" id="state">
|
||||
<option value="">全部状态</option>
|
||||
<option value="1">待开票</option>
|
||||
<option value="2">驳回</option>
|
||||
<option value="3">完成</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-sm layuiadmin-btn-user {$view_theme_color}" lay-submit lay-filter="user-search">查询</button>
|
||||
<button class="layui-btn layui-btn-sm layuiadmin-btn-user layui-btn-primary " lay-submit lay-filter="user-clear-search">清空查询</button>
|
||||
<!-- <button class="layui-btn layui-btn-sm layuiadmin-btn-user {$view_theme_color}" data-type="add">添加</button>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
<table id="user-lists" lay-filter="user-lists"></table>
|
||||
<script type="text/html" id="user-operation">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-sm" lay-event="info">资料</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
|
||||
</script>
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.state == 1){ }}
|
||||
<span class="layui-badge layui-bg-blue">待开票</span>
|
||||
{{# } else if(d.state == 2){ }}
|
||||
<span class="layui-badge layui-bg-red">驳回</span>
|
||||
{{# } else if(d.state == 3){ }}
|
||||
<span class="layui-badge layui-bg-green">完成</span>
|
||||
{{# } else { }}
|
||||
<span class="layui-badge layui-bg-gray">未知</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
<script type="text/html" id="document-templet">
|
||||
{{# if(d.document){ }}
|
||||
<a href="{{ d.document }}" target="_blank" class="layui-btn layui-btn-xs layui-btn-primary">查看文件</a>
|
||||
{{# } else { }}
|
||||
<span>无文件</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
layui.config({
|
||||
version:"{$front_version}",
|
||||
base: '/static/plug/layui-admin/dist/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index','table','like'], function(){
|
||||
var $ = layui.$
|
||||
,form = layui.form
|
||||
,table = layui.table
|
||||
,like = layui.like;
|
||||
|
||||
//监听搜索
|
||||
form.on('submit(user-search)', function(data){
|
||||
var field = data.field;
|
||||
table.reload('user-lists', {
|
||||
where: field,
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//清空查询
|
||||
form.on('submit(user-clear-search)', function(data){
|
||||
$('#keyword').val('');
|
||||
$('#state').val('');
|
||||
form.render('select');
|
||||
table.reload('user-lists', {
|
||||
where: {},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//监听工具条
|
||||
table.on('tool(user-lists)', function(obj){
|
||||
var data = obj.data;
|
||||
if(obj.event === 'info'){
|
||||
layer.open({
|
||||
type: 2
|
||||
,title: '发票详情'
|
||||
,content: '{:url("invoice/info")}?id=' + data.id
|
||||
,area: ['800px', '600px']
|
||||
,btn: ['关闭']
|
||||
,yes: function(index){
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else if(obj.event === 'edit'){
|
||||
layer.open({
|
||||
type: 2
|
||||
,title: '编辑发票'
|
||||
,content: '{:url("invoice/edit")}?id=' + data.id
|
||||
,area: ['800px', '600px']
|
||||
,btn: ['确定', '取消']
|
||||
,yes: function(index, layero){
|
||||
var iframeWindow = window['layui-layer-iframe'+ index]
|
||||
,submit = layero.find('iframe').contents().find("#invoice-submit");
|
||||
submit.trigger('click');
|
||||
}
|
||||
});
|
||||
} else if(obj.event === 'del'){
|
||||
layer.confirm('确定删除吗?', function(index){
|
||||
$.ajax({
|
||||
url: '{:url("invoice/del")}',
|
||||
type: 'post',
|
||||
data: {id: data.id},
|
||||
success: function(res){
|
||||
if(res.code == 1){
|
||||
layer.msg(res.msg, {icon: 1, time: 1000}, function(){
|
||||
layer.close(index);
|
||||
table.reload('user-lists');
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('.layui-btn.layuiadmin-btn-user').on('click', function(){
|
||||
var type = $(this).data('type');
|
||||
active[type] ? active[type].call(this) : '';
|
||||
});
|
||||
|
||||
//管理员管理
|
||||
table.render({
|
||||
id:'user-lists'
|
||||
,elem: '#user-lists'
|
||||
,url: '{:url("invoice/lists")}'
|
||||
,cols: [[
|
||||
{type: 'checkbox'}
|
||||
,{field: 'id', title: 'ID', width: 80}
|
||||
,{field: 'invoice_id', title: '发票信息ID'}
|
||||
,{field: 'state', title: '状态', align: 'center', templet: '#status'}
|
||||
,{field: 'document', title: '发票文件', align: 'center', templet: '#document-templet'}
|
||||
,{field: 'create_time', title: '创建时间'}
|
||||
,{field: 'update_time', title: '更新时间'}
|
||||
,{fixed: 'right', title: '操作', width: 280, align: 'center', toolbar: '#user-operation'}
|
||||
]]
|
||||
,page: true
|
||||
,text: {none: '暂无数据!'}
|
||||
,parseData: function(res){
|
||||
return {
|
||||
"code": res.code,
|
||||
"msg": res.msg,
|
||||
"count": res.data.count,
|
||||
"data": res.data.lists,
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
0
application/admin/view/invoice/upload.html
Normal file
0
application/admin/view/invoice/upload.html
Normal file
Reference in New Issue
Block a user