Accept Merge Request #21: (feature/hant -> develop)
Merge Request: 开票 Created By: @todayswind Accepted By: @todayswind URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/21?initial=true
This commit is contained in:
commit
e36704bd28
1
addons/.htaccess
Executable file
1
addons/.htaccess
Executable file
|
|
@ -0,0 +1 @@
|
|||
deny from all
|
||||
|
|
@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|||
|
||||
use app\admin\addresmart\Address;
|
||||
use app\admin\model\AuthGroupAccess;
|
||||
use app\admin\model\order\Invoice;
|
||||
use app\admin\model\OrderDispatch;
|
||||
use app\admin\model\Worker;
|
||||
use app\admin\model\WorkerItem;
|
||||
|
|
@ -11,6 +12,7 @@ use app\common\controller\Backend;
|
|||
use app\common\Logic\OrderLogic;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
use think\exception\DbException;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
use think\Hook;
|
||||
|
|
@ -91,7 +93,6 @@ class Order extends Backend
|
|||
->field(['id', 'nickname'])
|
||||
->select();
|
||||
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("sources", $res);
|
||||
$this->view->assign("coupons", $coupons);
|
||||
$this->view->assign("items", $formattedTree);
|
||||
|
|
@ -572,4 +573,41 @@ class Order extends Backend
|
|||
// 重新索引数组
|
||||
return array_values($filtered_codes);
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param $ids
|
||||
* @return string
|
||||
* @throws DbException
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function invoice($ids = null){
|
||||
if (false === $this->request->isPost()) {
|
||||
$order = model('order')->get($ids);
|
||||
return $this->fetch('order/invoice/add',['row' => $order]);
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
$params['invoice_method'] = 1;
|
||||
$result = (new Invoice())->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
126
application/admin/controller/orders/Invoice.php
Normal file
126
application/admin/controller/orders/Invoice.php
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller\orders;
|
||||
|
||||
use app\admin\controller\order\Exception;
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\exception\DbException;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 发票信息管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Invoice extends Backend
|
||||
{
|
||||
/**
|
||||
* Invoice模型对象
|
||||
* @var \app\admin\model\order\Invoice
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\order\Invoice;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
public function add()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException()->validate($validate);
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param $ids
|
||||
* @return string
|
||||
* @throws DbException
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
if (false === $this->request->isPost()) {
|
||||
$order = model('order')->get($row['order_id']);
|
||||
$this->view->assign('order', $order);
|
||||
$this->view->assign('row', $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException()->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if (false === $result) {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
}
|
||||
22
application/admin/lang/zh-cn/orders/invoice.php
Normal file
22
application/admin/lang/zh-cn/orders/invoice.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'Id' => '发票ID',
|
||||
'Order_id' => '订单ID',
|
||||
'Invoice_type' => '发票类型',
|
||||
'Title' => '发票抬头',
|
||||
'Tax_number' => '纳税人识别号',
|
||||
'Amount' => '发票金额',
|
||||
'Invoice_method' => '发票方式',
|
||||
'Recipient_email' => '接收邮箱(电子)',
|
||||
'Company_address' => '公司注册地址',
|
||||
'Company_phone' => '公司注册电话',
|
||||
'Bank_name' => '开户行名称',
|
||||
'Bank_account' => '银行账号',
|
||||
'Recipient_address' => '收件地址(纸质)',
|
||||
'Recipient_name' => '收件人姓名',
|
||||
'Recipient_phone' => '收件人电话',
|
||||
'Issued_at' => '开票时间',
|
||||
'Status' => '开票状态',
|
||||
'Remark' => '备注'
|
||||
];
|
||||
47
application/admin/model/order/Invoice.php
Normal file
47
application/admin/model/order/Invoice.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\model\order;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'order_invoice';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = false;
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
|
||||
];
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return [
|
||||
'0' => '代处理',
|
||||
'1' => '已开票',
|
||||
'2' => '已完成',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
27
application/admin/validate/order/Invoice.php
Normal file
27
application/admin/validate/order/Invoice.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\validate\order;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Invoice extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@
|
|||
<label class="control-label col-xs-12 col-sm-3">{:__('Coupons')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-coupon" data-live-search="true" title="请选择" data-rule="required" name="row[coupon_id]" class="form-control selectpicker show-tick">
|
||||
<option {if $item['id'] == $row.coupon_id} selected {/if} selected value="0">不使用优惠</option>
|
||||
<option {if $item['id'] == $row.coupon_id} selected {/if} value="0">不使用优惠</option>
|
||||
{foreach $coupons as $item}
|
||||
<option {if $item['id'] == $row.coupon_id} selected {/if} data-subtext="{$item['description']}" value="{$item['id']}">{$item['code']}</option>
|
||||
{/foreach}
|
||||
|
|
|
|||
101
application/admin/view/order/invoice/add.html
Normal file
101
application/admin/view/order/invoice/add.html
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">订单编号:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-order_id" data-rule="required" disabled data-source="order/index" class="form-control" type="text" value="{$row.order_no}">
|
||||
</div>
|
||||
</div>
|
||||
<input class="form-control" style="display: none" name="row[order_id]" type="text" value="{$row.id}">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">发票类型:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[invoice_type]" class="form-control">
|
||||
<option selected value="1">公司发票</option>
|
||||
<option value="2">个人发票</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">抬头/名字:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">纳税人识别号:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-tax_number" class="form-control" name="row[tax_number]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">金额:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-amount" data-rule="required" class="form-control" step="0.01" name="row[amount]" value="{$row.total}" type="number">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">公司地址:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-company_address" class="form-control" name="row[company_address]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">公司电话:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-company_phone" class="form-control" name="row[company_phone]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">开户行:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-bank_name" class="form-control" name="row[bank_name]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">开户账号:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-bank_account" class="form-control" name="row[bank_account]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收邮箱:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_email" class="form-control" name="row[recipient_email]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收地址:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_address" class="form-control" name="row[recipient_address]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收名字:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_name" class="form-control" name="row[recipient_name]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收电话:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_phone" class="form-control" name="row[recipient_phone]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">备注:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-remark" class="form-control " rows="5" name="row[remark]" cols="50"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
101
application/admin/view/orders/invoice/add.html
Normal file
101
application/admin/view/orders/invoice/add.html
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">订单编号:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-order_id" data-rule="required" disabled data-source="order/index" class="form-control" type="text" value="{$row.order_no}">
|
||||
</div>
|
||||
</div>
|
||||
<input class="form-control" style="display: none" name="row[order_id]" type="text" value="{$row.id}">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">发票类型:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[invoice_type]" class="form-control">
|
||||
<option selected value="1">公司发票</option>
|
||||
<option value="2">个人发票</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">抬头/名字:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">纳税人识别号:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-tax_number" class="form-control" name="row[tax_number]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">金额:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-amount" data-rule="required" class="form-control" step="0.01" name="row[amount]" value="{$row.total}" type="number">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">公司地址:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-company_address" class="form-control" name="row[company_address]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">公司电话:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-company_phone" class="form-control" name="row[company_phone]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">开户行:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-bank_name" class="form-control" name="row[bank_name]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">开户账号:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-bank_account" class="form-control" name="row[bank_account]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收邮箱:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_email" class="form-control" name="row[recipient_email]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收地址:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_address" class="form-control" name="row[recipient_address]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收名字:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_name" class="form-control" name="row[recipient_name]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">接收电话:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_phone" class="form-control" name="row[recipient_phone]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">备注:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-remark" class="form-control " rows="5" name="row[remark]" cols="50"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
119
application/admin/view/orders/invoice/edit.html
Normal file
119
application/admin/view/orders/invoice/edit.html
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-order_id" data-rule="required" data-source="order/index" class="form-control" disabled type="text" value="{$order.order_no|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_type')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[invoice_type]" class="form-control">
|
||||
<option {if 1 == $row.invoice_type} selected {/if} value="1">公司发票</option>
|
||||
<option {if 2 == $row.invoice_type} selected {/if} value="2">个人发票</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Tax_number')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-tax_number" class="form-control" name="row[tax_number]" type="text" value="{$row.tax_number|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Amount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-amount" data-rule="required" class="form-control" step="0.01" name="row[amount]" type="number" value="{$row.amount|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_method')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-invoice_method" data-rule="required" class="form-control" name="row[invoice_method]" type="number" value="{$row.invoice_method|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Recipient_email')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_email" class="form-control" name="row[recipient_email]" type="text" value="{$row.recipient_email|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Company_address')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-company_address" class="form-control" name="row[company_address]" type="text" value="{$row.company_address|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Company_phone')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-company_phone" class="form-control" name="row[company_phone]" type="text" value="{$row.company_phone|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Bank_name')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-bank_name" class="form-control" name="row[bank_name]" type="text" value="{$row.bank_name|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Bank_account')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-bank_account" class="form-control" name="row[bank_account]" type="text" value="{$row.bank_account|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Recipient_address')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_address" class="form-control" name="row[recipient_address]" type="text" value="{$row.recipient_address|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Recipient_name')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_name" class="form-control" name="row[recipient_name]" type="text" value="{$row.recipient_name|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Recipient_phone')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-recipient_phone" class="form-control" name="row[recipient_phone]" type="text" value="{$row.recipient_phone|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Issued_at')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-issued_at" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[issued_at]" type="text" value="{$row.issued_at}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-status" data-live-search="true" title="请选择" data-rule="required" name="row[status]" class="form-control">
|
||||
<option {if 0 == $row.status} selected {/if} value="1">待处理</option>
|
||||
<option {if 1 == $row.status} selected {/if} value="2">已开票</option>
|
||||
<option {if 2 == $row.status} selected {/if} value="2">已完成</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-remark" class="form-control " rows="5" name="row[remark]" cols="50">{$row.remark|htmlentities}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
29
application/admin/view/orders/invoice/index.html
Normal file
29
application/admin/view/orders/invoice/index.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('order.invoice/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order.invoice/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order.invoice/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('order.invoice/edit')}"
|
||||
data-operate-del="{:$auth->check('order.invoice/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -21,6 +21,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
Toastr.info('复制成功');
|
||||
}
|
||||
|
||||
|
||||
// 拼装文本
|
||||
function assembleOrderMessage(data) {
|
||||
const message = `
|
||||
|
|
@ -270,6 +271,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
return false;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'invoice',
|
||||
text: '申请开票',
|
||||
title: '申请开票',
|
||||
classname: 'btn btn-xs button-cancel btn-dialog',
|
||||
icon: 'fa fa-send',
|
||||
url: 'order/invoice/',
|
||||
dropdown: "更多",
|
||||
|
||||
visible: function (row) {
|
||||
if (row.status >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
|
|
@ -394,6 +411,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
console.log('delete');
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
invoice: function () {
|
||||
function toggleInvoiceFields() {
|
||||
const type = $('#c-source').val();
|
||||
console.log(type);
|
||||
if (type === '1') {
|
||||
// 公司发票
|
||||
$('#c-tax_number').closest('.form-group').show();
|
||||
$('#c-company_address').closest('.form-group').show();
|
||||
$('#c-company_phone').closest('.form-group').show();
|
||||
$('#c-bank_name').closest('.form-group').show();
|
||||
$('#c-bank_account').closest('.form-group').show();
|
||||
} else {
|
||||
// 个人发票
|
||||
$('#c-tax_number').closest('.form-group').hide();
|
||||
$('#c-company_address').closest('.form-group').hide();
|
||||
$('#c-company_phone').closest('.form-group').hide();
|
||||
$('#c-bank_name').closest('.form-group').hide();
|
||||
$('#c-bank_account').closest('.form-group').hide();
|
||||
}
|
||||
}
|
||||
// 初始化时执行一次
|
||||
toggleInvoiceFields();
|
||||
|
||||
// 监听 select 改变
|
||||
$('#c-source').on('change',function () {
|
||||
toggleInvoiceFields();
|
||||
});
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
|
|
|
|||
104
public/assets/js/backend/orders/invoice.js
Normal file
104
public/assets/js/backend/orders/invoice.js
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'orders.invoice/index' + location.search,
|
||||
add_url: 'orders.invoice/add',
|
||||
edit_url: 'orders.invoice/edit',
|
||||
del_url: 'orders.invoice/del',
|
||||
multi_url: 'orders.invoice/multi',
|
||||
import_url: 'orders.invoice/import',
|
||||
table: 'order_invoice',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'order_id', title: __('Order_id')},
|
||||
{field: 'invoice_type', title: __('Invoice_type'),formatter: function (val) {
|
||||
return val === 1 ? '公司发票': '个人发票';
|
||||
}},
|
||||
{field: 'status', title: __('Status'),formatter:function (val) {
|
||||
let list = [
|
||||
'代处理',
|
||||
'已开票',
|
||||
'已完成',
|
||||
];
|
||||
return list[val] ?? '';
|
||||
}},
|
||||
|
||||
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'tax_number', title: __('Tax_number'), operate: 'LIKE'},
|
||||
{field: 'amount', title: __('Amount'), operate:'BETWEEN'},
|
||||
// {field: 'invoice_method', title: __('Invoice_method')},
|
||||
{field: 'recipient_email', title: __('Recipient_email'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'company_address', title: __('Company_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'company_phone', title: __('Company_phone'), operate: 'LIKE'},
|
||||
{field: 'bank_name', title: __('Bank_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'bank_account', title: __('Bank_account'), operate: 'LIKE'},
|
||||
{field: 'recipient_address', title: __('Recipient_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'recipient_name', title: __('Recipient_name'), operate: 'LIKE'},
|
||||
{field: 'recipient_phone', title: __('Recipient_phone'), operate: 'LIKE'},
|
||||
{field: 'issued_at', title: __('Issued_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
function toggleInvoiceFields() {
|
||||
const type = $('#c-source').val();
|
||||
if (type === '1') {
|
||||
// 公司发票
|
||||
$('#c-tax_number').closest('.form-group').show();
|
||||
$('#c-company_address').closest('.form-group').show();
|
||||
$('#c-company_phone').closest('.form-group').show();
|
||||
$('#c-bank_name').closest('.form-group').show();
|
||||
$('#c-bank_account').closest('.form-group').show();
|
||||
} else {
|
||||
// 个人发票
|
||||
$('#c-tax_number').closest('.form-group').hide();
|
||||
$('#c-company_address').closest('.form-group').hide();
|
||||
$('#c-company_phone').closest('.form-group').hide();
|
||||
$('#c-bank_name').closest('.form-group').hide();
|
||||
$('#c-bank_account').closest('.form-group').hide();
|
||||
}
|
||||
}
|
||||
// 初始化时执行一次
|
||||
toggleInvoiceFields();
|
||||
|
||||
// 监听 select 改变
|
||||
$('#c-source').on('change',function () {
|
||||
toggleInvoiceFields();
|
||||
});
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
BIN
vendor.zip
Normal file
BIN
vendor.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user