2021-11-07 开源测试版 2.4.0
This commit is contained in:
parent
a9e17b5af7
commit
672cc966db
13
Changelog.md
13
Changelog.md
|
@ -42,4 +42,15 @@
|
|||
2021-07-28 开源测试版 2.3.5 更新记录
|
||||
修正
|
||||
1.日历共享事件重复bug
|
||||
SQL更新: 导入database/share-2021-07-28.sql,或者按新的结构修改。
|
||||
SQL更新: 导入database/share-2021-07-28.sql,或者按新的结构修改。
|
||||
|
||||
|
||||
2021-11-07 开源测试版 2.4.0 更新记录
|
||||
新增
|
||||
1.去掉原辅料清单功能,删除product_formula表。
|
||||
2.重新实现物料清单,不在单独建立原辅料表,采用产品关联机制。
|
||||
3.修改生产计划BOM计算逻辑,配合新的物料清单计算原料使用功能。
|
||||
4.首页加入客户统计部件。
|
||||
4.首页加入客户联系人统计部件。
|
||||
4.首页加入销售订单统计部件。
|
||||
SQL更新: 导入database/gdoo-2.4.0.upgrade.sql,或者按新的结构修改。
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
use DB;
|
||||
use Request;
|
||||
use Gdoo\Index\Services\InfoService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class WidgetController extends DefaultController
|
||||
{
|
||||
public $permission = ['birthday'];
|
||||
public $permission = ['birthday', 'customerCount', 'customerContactCount'];
|
||||
|
||||
// 生日提醒
|
||||
public function birthday()
|
||||
|
@ -46,4 +47,71 @@ class WidgetController extends DefaultController
|
|||
}
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户(个)
|
||||
*/
|
||||
public function customerCount()
|
||||
{
|
||||
$config = InfoService::getInfo('customer');
|
||||
|
||||
$model = DB::table('customer')->whereRaw('('.$config['sql'].')');
|
||||
$model2 = DB::table('customer')->whereRaw('('.$config['sql2'].')');
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
$model2->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$count = $model->count();
|
||||
$count2 = $model2->count();
|
||||
|
||||
$rate = 0;
|
||||
if ($count2 > 0) {
|
||||
$rate = ($count - $count2) / $count2 * 100;
|
||||
$rate = number_format($rate, 2);
|
||||
}
|
||||
$res = [
|
||||
'count' => $count,
|
||||
'count2' => $count2,
|
||||
'rate' => $rate,
|
||||
];
|
||||
|
||||
return $this->render([
|
||||
'dates' => $config['dates'],
|
||||
'info' => $config['info'],
|
||||
'res' => $res,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户联系人(个)
|
||||
*/
|
||||
public function customerContactCount()
|
||||
{
|
||||
$config = InfoService::getInfo('customer_contact');
|
||||
$model = DB::table('customer_contact')->whereRaw('('.$config['sql'].')');
|
||||
$model2 = DB::table('customer_contact')->whereRaw('('.$config['sql2'].')');
|
||||
$count = $model->count();
|
||||
$count2 = $model2->count();
|
||||
|
||||
$rate = 0;
|
||||
if ($count2 > 0) {
|
||||
$rate = ($count - $count2) / $count2 * 100;
|
||||
$rate = number_format($rate, 2);
|
||||
}
|
||||
$res = [
|
||||
'count' => $count,
|
||||
'count2' => $count2,
|
||||
'rate' => $rate,
|
||||
];
|
||||
|
||||
return $this->render([
|
||||
'dates' => $config['dates'],
|
||||
'info' => $config['info'],
|
||||
'res' => $res,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,18 @@ return [
|
|||
'url' => 'customer/widget/birthday',
|
||||
'more_url' => 'customer/customer/birthday',
|
||||
],
|
||||
'info_customer_count' => [
|
||||
'name' => '客户',
|
||||
'type' => 2,
|
||||
'url' => 'customer/widget/customerCount',
|
||||
'more_url' => 'customer/customer/index',
|
||||
],
|
||||
'info_customer_contact_count' => [
|
||||
'name' => '客户联系人',
|
||||
'type' => 2,
|
||||
'url' => 'customer/widget/customerContactCount',
|
||||
'more_url' => 'customer/contact/index',
|
||||
],
|
||||
],
|
||||
"listens" => [
|
||||
'customer' => 'Gdoo\Customer\Hooks\CustomerHook',
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div class="panel panel-shadow info-skin1">
|
||||
<div class="info-l hidden-xs" style="background-color:{{$info['color']}}">
|
||||
<i class="fa fa-2x {{$info['icon']}}"></i>
|
||||
</div>
|
||||
<div class="info-c">
|
||||
<div class="info-name">{{$info['name']}}</div>
|
||||
<a href="javascript:;" data-toggle="addtab" data-url="{{$info['more_url']}}" data-id="{{str_replace(['/', '?', '='], ['_', '_', '_'], $info['more_url'])}}" data-name="{{$info['name']}}">
|
||||
<div class="text-info info-item" data-id="{{$info['id']}}" data-more_url="{{$info['more_url']}}">{{$res['count']}}</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="info-r">
|
||||
<div>比{{$dates[$info['params']['date']]}}</div>
|
||||
<div class="rate @if($res['rate'] > 100) red @endif">{{$res['rate']}}%</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
<div class="panel panel-shadow info-skin1">
|
||||
<div class="info-l hidden-xs" style="background-color:{{$info['color']}}">
|
||||
<i class="fa fa-2x {{$info['icon']}}"></i>
|
||||
</div>
|
||||
<div class="info-c">
|
||||
<div class="info-name">{{$info['name']}}</div>
|
||||
<a href="javascript:;" data-toggle="addtab" data-url="{{$info['more_url']}}" data-id="{{str_replace(['/', '?', '='], ['_', '_', '_'], $info['more_url'])}}" data-name="{{$info['name']}}">
|
||||
<div class="text-info info-item" data-id="{{$info['id']}}" data-more_url="{{$info['more_url']}}">{{$res['count']}}</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="info-r">
|
||||
<div>比{{$dates[$info['params']['date']]}}</div>
|
||||
<div class="rate @if($res['rate'] > 100) red @endif">{{$res['rate']}}%</div>
|
||||
</div>
|
||||
</div>
|
|
@ -15,7 +15,7 @@ class Controller extends BaseController
|
|||
/**
|
||||
* @var 程序版本
|
||||
*/
|
||||
public $version = '2.3.5';
|
||||
public $version = '2.4.0';
|
||||
|
||||
/**
|
||||
* @var 配置参数
|
||||
|
|
|
@ -978,7 +978,7 @@ class FieldService
|
|||
$attribute = $field['attribute'];
|
||||
$id = $attribute['id'];
|
||||
$name = $attribute['name'];
|
||||
|
||||
|
||||
$rows = '';
|
||||
if ($value) {
|
||||
if ($field['type']) {
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
use DB;
|
||||
use Request;
|
||||
use Auth;
|
||||
use Gdoo\Index\Services\InfoService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class WidgetController extends DefaultController
|
||||
{
|
||||
public $permission = ['index', 'goods'];
|
||||
public $permission = ['index', 'goods', 'orderCount'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
@ -229,4 +230,48 @@ class WidgetController extends DefaultController
|
|||
}
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单数量
|
||||
*/
|
||||
public function orderCount()
|
||||
{
|
||||
$config = InfoService::getInfo('customer_order');
|
||||
|
||||
$model = DB::table('customer_order')
|
||||
->leftJoin('customer_order_data','customer_order_data.order_id', '=', 'customer_order.id')
|
||||
->whereRaw('('.$config['sql'].')');
|
||||
|
||||
$model2 = DB::table('customer_order')
|
||||
->leftJoin('customer_order_data','customer_order_data.order_id', '=', 'customer_order.id')
|
||||
->whereRaw('('.$config['sql2'].')');
|
||||
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
$model2->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$count = $model->sum('customer_order_data.money');
|
||||
$count2 = $model2->sum('customer_order_data.money');
|
||||
|
||||
$rate = 0;
|
||||
if ($count2 > 0) {
|
||||
$rate = ($count - $count2) / $count2 * 100;
|
||||
$rate = number_format($rate, 2);
|
||||
}
|
||||
$res = [
|
||||
'count' => $count,
|
||||
'count2' => $count2,
|
||||
'rate' => $rate,
|
||||
];
|
||||
|
||||
return $this->render([
|
||||
'dates' => $config['dates'],
|
||||
'info' => $config['info'],
|
||||
'res' => $res,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -40,6 +40,12 @@ return [
|
|||
'url' => 'order/widget/goods',
|
||||
'more_url' => 'order/order/delivery',
|
||||
],
|
||||
'info_order_count' => [
|
||||
'name' => '销售订单(元)',
|
||||
'type' => 2,
|
||||
'url' => 'order/widget/orderCount',
|
||||
'more_url' => 'order/order/index',
|
||||
],
|
||||
],
|
||||
"controllers" => [
|
||||
"order" => [
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div class="panel panel-shadow info-skin1">
|
||||
<div class="info-l hidden-xs" style="background-color:{{$info['color']}}">
|
||||
<i class="fa fa-2x {{$info['icon']}}"></i>
|
||||
</div>
|
||||
<div class="info-c">
|
||||
<div class="info-name">{{$info['name']}}</div>
|
||||
<a href="javascript:;" data-toggle="addtab" data-url="{{$info['more_url']}}" data-id="{{str_replace(['/', '?', '='], ['_', '_', '_'], $info['more_url'])}}" data-name="{{$info['name']}}">
|
||||
<div class="text-info info-item" data-id="{{$info['id']}}" data-more_url="{{$info['more_url']}}">{{$res['count']}}</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="info-r">
|
||||
<div>比{{$dates[$info['params']['date']]}}</div>
|
||||
<div class="rate @if($res['rate'] > 100) red @endif">{{$res['rate']}}%</div>
|
||||
</div>
|
||||
</div>
|
|
@ -9,8 +9,6 @@ use Gdoo\Model\Form;
|
|||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Produce\Models\Material;
|
||||
use Gdoo\Produce\Models\Formula;
|
||||
|
||||
use Gdoo\Produce\Services\ProduceService;
|
||||
|
||||
|
@ -18,94 +16,7 @@ use Gdoo\Index\Controllers\DefaultController;
|
|||
|
||||
class MaterialController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog', 'config', 'configSave', 'planProduct', 'planTotal'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'product_material',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
$header['left_buttons'] = [
|
||||
['name' => '配料', 'color' => 'default', 'icon' => 'fa-file-text-o', 'action' => 'config', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = Material::$tabs;
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
return Grid::dataFilters($rows, $header);
|
||||
}
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function create($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'product_material', 'id' => $id, 'action' => $action]);
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
return $this->create('edit');
|
||||
}
|
||||
|
||||
// 配方
|
||||
public function config()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
if (Request::method() == 'POST') {
|
||||
$rows = DB::table('product_formula')->where('material_id', $id)
|
||||
->leftJoin('product', 'product.id', '=', 'product_formula.product_id')
|
||||
->leftJoin('product_unit', 'product_unit.id', '=', 'product.unit_id')
|
||||
->get([
|
||||
'product.name as product_name',
|
||||
'product.code as product_code',
|
||||
'product.spec as product_spec',
|
||||
'product_unit.name as product_unit',
|
||||
'product_formula.*'
|
||||
]);
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
return $this->display(['id' => $id]);
|
||||
}
|
||||
public $permission = ['planProduct', 'planTotal'];
|
||||
|
||||
// 用料计划
|
||||
public function plan()
|
||||
|
@ -184,7 +95,7 @@ class MaterialController extends DefaultController
|
|||
c.name as product_unit,
|
||||
a.product_num,
|
||||
a.material_id,
|
||||
d.category as category_name,
|
||||
dc.name as category_name,
|
||||
d.name as material_name,
|
||||
a.material_num,
|
||||
a.total_num
|
||||
|
@ -195,8 +106,9 @@ class MaterialController extends DefaultController
|
|||
from material_plan_day a
|
||||
left join product b on a.product_id = b.id
|
||||
left join product_unit AS c ON b.unit_id = c.id
|
||||
left join product_material d on a.Material_Id = d.Id
|
||||
where a.date = '".$date."' and a.Dept_Id = $department_id and a.Product_Id = $product_id";
|
||||
left join product d on a.material_id = d.id
|
||||
left join product_category dc on dc.id = d.category_id
|
||||
where a.date = '".$date."' and a.dept_id = $department_id and a.product_id = $product_id";
|
||||
$rows = DB::select($sql);
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
|
@ -222,16 +134,17 @@ class MaterialController extends DefaultController
|
|||
$sql = "select a.date,
|
||||
a.dept_id,
|
||||
a.material_id,
|
||||
d.category as category_name,
|
||||
dc.name as category_name,
|
||||
d.name as material_name,
|
||||
sum(a.material_num) material_num,
|
||||
sum(a.total_num)total_num
|
||||
sum(a.total_num) total_num
|
||||
from material_plan_day a
|
||||
left join product b on a.product_id = b.id
|
||||
left join product_unit AS c ON b.unit_id = c.id
|
||||
left join product_material d on a.Material_Id = d.Id
|
||||
where a.date = '$date' and a.Dept_Id = ".$department_id."
|
||||
group by a.Date, a.Dept_Id, a.Material_Id, d.category, d.Name";
|
||||
left join product d on a.material_id = d.id
|
||||
left join product_category dc on dc.id = d.category_id
|
||||
where a.date = '$date' and a.dept_id = ".$department_id."
|
||||
group by a.date, a.dept_id, a.material_id, dc.name, d.name";
|
||||
$rows = DB::select($sql);
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
|
@ -241,83 +154,4 @@ class MaterialController extends DefaultController
|
|||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
// 配方保存
|
||||
public function configSave()
|
||||
{
|
||||
$gets = Request::all();
|
||||
$id = $gets['id'];
|
||||
if (empty($id)) {
|
||||
return $this->json('原辅料编号不能为空');
|
||||
}
|
||||
|
||||
$data = $gets['product_formula'];
|
||||
|
||||
// 新增或者修改
|
||||
foreach((array)$data['rows'] as $_row) {
|
||||
$_row['material_id'] = $id;
|
||||
$row = Formula::findOrNew($_row['id']);
|
||||
$row->fill($_row)->save();
|
||||
}
|
||||
|
||||
// 删除记录
|
||||
foreach((array)$data['deleteds'] as $row) {
|
||||
if ($row['id'] > 0) {
|
||||
Formula::where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
return $this->json('配方保存成功。', true);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'product_material', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
|
||||
public function dialog()
|
||||
{
|
||||
$search = search_form([
|
||||
'advanced' => '',
|
||||
'prefix' => '',
|
||||
'offset' => '',
|
||||
'sort' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
], [
|
||||
['text','logistics.name','名称'],
|
||||
]);
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table('logistics');
|
||||
// 排序方式
|
||||
if ($query['sort'] && $query['order']) {
|
||||
$model->orderBy('logistics.'.$query['sort'], $query['order']);
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->selectRaw("logistics.*");
|
||||
|
||||
if ($query['limit']) {
|
||||
$rows = $model->paginate($query['limit']);
|
||||
} else {
|
||||
$rows['total'] = $model->count();
|
||||
$rows['data'] = $model->get();
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ use Gdoo\Model\Grid;
|
|||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Produce\Models\Plan;
|
||||
use Gdoo\Produce\Models\Formula;
|
||||
|
||||
use Gdoo\Produce\Services\ProduceService;
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?php namespace Gdoo\Produce\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Material extends BaseModel
|
||||
{
|
||||
protected $table = 'product_material';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'material.index', 'url' => 'produce/material/index', 'name' => '原辅料档案'],
|
||||
]
|
||||
];
|
||||
}
|
|
@ -25,7 +25,7 @@ class ProduceService
|
|||
if ($date) {
|
||||
if ($isCalAgain) {
|
||||
// 删除先有计划
|
||||
DB::delete("delete FROM material_plan_day where date = '$date' and Dept_Id=$department_id");
|
||||
DB::delete("delete FROM material_plan_day where date = '$date' and dept_id = $department_id");
|
||||
|
||||
// 获取生产计划
|
||||
$items = DB::select("
|
||||
|
@ -35,11 +35,11 @@ class ProduceService
|
|||
c.quantity as material_num,
|
||||
c.material_id,
|
||||
d.department_id,
|
||||
case when ISNULL(c.ratio, 1) = 0 then 0 else ISNULL(d.plan_num, 0) * ISNULL(c.quantity, 0) / ISNULL(c.ratio, 1) end as total_num
|
||||
ISNULL(d.plan_num, 0) * ISNULL(c.quantity, 0) + (ISNULL(c.quantity, 0) * ISNULL(c.loss_rate, 0)) AS total_num
|
||||
FROM produce_plan m, produce_plan_data d
|
||||
left join(
|
||||
select a.product_id, a.material_id, a.quantity, b.ratio
|
||||
from product_formula a left join product_material b on a.material_id = b.id
|
||||
select product_id, material_id, quantity, loss_rate
|
||||
from product_material
|
||||
) c on c.product_id = d.product_id
|
||||
WHERE m.id = d.plan_id
|
||||
AND isnull(department_id, 0) = $department_id
|
||||
|
@ -47,7 +47,7 @@ class ProduceService
|
|||
AND plan_num IS NOT NULL
|
||||
AND m.date = '$date'
|
||||
");
|
||||
|
||||
|
||||
foreach($items as $item) {
|
||||
DB::table("material_plan_day")->insert([
|
||||
'date' => $date,
|
||||
|
@ -76,7 +76,7 @@ class ProduceService
|
|||
c.name as product_unit,
|
||||
a.product_num,
|
||||
a.material_id,
|
||||
d.category as category_name,
|
||||
dc.name as category_name,
|
||||
d.name as material_name,
|
||||
a.material_num,
|
||||
a.total_num,
|
||||
|
@ -87,9 +87,10 @@ class ProduceService
|
|||
from material_plan_day a
|
||||
left join product b on a.product_id = b.id
|
||||
left join product_unit AS c ON b.unit_id = c.id
|
||||
left join product_material d on a.Material_Id = d.id
|
||||
left join department e on a.Dept_Id = e.id
|
||||
where a.date = '$date' and a.Dept_Id = $department_id
|
||||
left join product d on a.material_id = d.id
|
||||
left join product_category dc on dc.id = d.category_id
|
||||
left join department e on a.dept_id = e.id
|
||||
where a.date = '$date' and a.dept_Id = $department_id
|
||||
");
|
||||
}
|
||||
return $rows;
|
||||
|
@ -1021,21 +1022,21 @@ class ProduceService
|
|||
}
|
||||
|
||||
$sql2[] = "select p.id,
|
||||
pc.id as category_id,
|
||||
pc.code as category_code,
|
||||
pc.name as category_name,
|
||||
pc.id as category_id,
|
||||
pc.code as category_code,
|
||||
pc.name as category_name,
|
||||
p.id as product_id,
|
||||
p.code as product_code,
|
||||
p.name as product_name,
|
||||
p.spec as product_spec,
|
||||
Concat(p.name,' ', isnull(p.spec,'')) as product_name_spec,
|
||||
p.code as product_code,
|
||||
p.name as product_name,
|
||||
p.spec as product_spec,
|
||||
Concat(p.name,' ', isnull(p.spec,'')) as product_name_spec,
|
||||
isnull(batch_sn,'') as batch_sn,
|
||||
pu.name as product_unit,
|
||||
sum(wf_num) dphz_num,
|
||||
sum(wf_num_ydk) ydk_num,
|
||||
sum(wf_num_wdk) wdk_num,
|
||||
sum(kc_num) kc_num,
|
||||
ISNULL(sum(wf_num), 0) - ISNULL(sum(kc_num), 0) as xqzc_num,
|
||||
ISNULL(sum(wf_num), 0) - ISNULL(sum(kc_num), 0) as xqzc_num,
|
||||
ISNULL(sum(wf_num_ydk) ,0) as yhk_num,
|
||||
ISNULL(sum(wf_num_ydk), 0) - ISNULL(sum(kc_num), 0) as kfzc_num,
|
||||
ISNULL(sum(wfhjh_num), 0) - ISNULL(sum(kc_num), 0) as kfjh_num,
|
||||
|
@ -1057,8 +1058,7 @@ class ProduceService
|
|||
$sql2[] = "and p.is_export = 1";
|
||||
}
|
||||
|
||||
$sql2[] = "group by pc.id,pc.name,pc.code,p.id,p.code,p.name,isnull(batch_sn,''),p.spec,pu.name
|
||||
order by p.code";
|
||||
$sql2[] = "group by pc.id,pc.name,pc.code,p.id,p.code,p.name,isnull(batch_sn,''),p.spec,pu.name order by p.code";
|
||||
$rows = DB::select(join(' ', $sql2));
|
||||
return $rows;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
<?php namespace Gdoo\Product\Controllers;
|
||||
|
||||
use DB;
|
||||
use Input;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Product\Models\ProductMaterial;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class MaterialController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog', 'list', 'getMaterials'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'product_material',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['right_buttons'] = [
|
||||
['name' => '导入', 'icon' => 'fa-mail-reply', 'color' => 'default', 'action' => 'import', 'display' => $this->access['import']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = ProductMaterial::$tabs;
|
||||
$header['bys'] = ProductMaterial::$bys;
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
$model->where('product_id_product.id', '>', 0);
|
||||
$model->where('product_id_product.status', 1);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
return Grid::dataFilters($rows, $header);
|
||||
}
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function create($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'product_material', 'id' => $id, 'action' => $action]);
|
||||
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
return $this->create();
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
return $this->create('edit');
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if ($gets['product_id']) {
|
||||
$header = Grid::header([
|
||||
'code' => 'product_material',
|
||||
]);
|
||||
$model = ProductMaterial::where('product_id', $gets['product_id']);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
|
||||
$model->leftJoin('product_unit as material_unit', 'material_unit.id', '=', 'material_id_product.unit_id');
|
||||
|
||||
$model->where('product_id_product.status', 1);
|
||||
$model->orderBy('product_material.id', 'asc');
|
||||
|
||||
$header['select'][] = 'material_id_product.code as material_code';
|
||||
$header['select'][] = 'material_id_product.spec as material_spec';
|
||||
$header['select'][] = 'material_id_product.barcode as material_barcode';
|
||||
$header['select'][] = 'material_unit.name as material_unit';
|
||||
|
||||
$rows = $model->get($header['select']);
|
||||
$rows = Grid::dataFilters($rows, $header, function($row) {
|
||||
$row['material_name'] = $row['material_id_name'];
|
||||
$row['warehouse_name'] = $row['warehouse_id_name'];
|
||||
return $row;
|
||||
});
|
||||
} else {
|
||||
$rows = ['data' =>[], 'header' => []];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getMaterials()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if ($gets['product_id']) {
|
||||
$rows = ProductMaterial::leftJoin('product', 'product.id', '=', 'product_material.material_id')
|
||||
->leftJoin('product_unit', 'product_unit.id', '=', 'product.unit_id')
|
||||
->leftJoin('warehouse', 'warehouse.id', '=', 'product.warehouse_id')
|
||||
->where('product_material.product_id', $gets['product_id'])
|
||||
->selectRaw('
|
||||
product_material.quantity,
|
||||
product_material.quantity base_quantity,
|
||||
product_material.loss_rate,
|
||||
product.warehouse_id,
|
||||
warehouse.name warehouse_id_name,
|
||||
product_material.material_id product_id,
|
||||
product.spec product_code,
|
||||
product.name product_name,
|
||||
product.spec product_spec,
|
||||
product.barcode product_barcode,
|
||||
product.purchase_price price,
|
||||
product_unit.name product_unit
|
||||
')
|
||||
->get();
|
||||
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
return Form::import(['table' => 'product_material', 'keys' => ['product_id', 'material_id']]);
|
||||
}
|
||||
$tips = '注意:表格里必须包含[存货编码,物料编码]列。';
|
||||
return $this->render(['tips' => $tips], 'layouts.import');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'product_material', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?php namespace Gdoo\Product\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Product\Models\ProductMaterial;
|
||||
|
||||
class MaterialHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
$gets = $params['gets'];
|
||||
$material = $gets['product_material'];
|
||||
$material_data = $gets['product_material_data'];
|
||||
|
||||
$id = 0;
|
||||
|
||||
// 新增或者修改
|
||||
foreach((array)$material_data['rows'] as $row) {
|
||||
$row['product_id'] = $material['product_id'];
|
||||
$_bom = ProductMaterial::findOrNew($row['id']);
|
||||
$_bom->fill($row)->save();
|
||||
$id = $_bom->id;
|
||||
}
|
||||
|
||||
// 删除记录
|
||||
foreach((array)$material_data['deleteds'] as $row) {
|
||||
if ($row['id'] > 0) {
|
||||
ProductMaterial::where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$master['id'] = $id;
|
||||
$params['master'] = $master;
|
||||
|
||||
// 终止执行的进程后
|
||||
$params['terminate'] = false;
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
}
|
|
@ -39,4 +39,9 @@ class Product extends BaseModel
|
|||
{
|
||||
return $this->belongsTo('Gdoo\Product\Models\Warehouse');
|
||||
}
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
<?php namespace Gdoo\Produce\Models;
|
||||
<?php namespace Gdoo\Product\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Formula extends BaseModel
|
||||
class ProductMaterial extends BaseModel
|
||||
{
|
||||
protected $table = 'product_formula';
|
||||
protected $table = 'product_material';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'material.index', 'url' => 'produce/material/index', 'name' => '原辅料档案'],
|
||||
['value' => 'material.index', 'url' => 'product/material/index', 'name' => '物料清单'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
|
@ -5,6 +5,7 @@ return [
|
|||
"description" => "产品列表,产品类别,库存类型,仓库类别,库存管理,仓库列表。",
|
||||
"listens" => [
|
||||
'product_category' => 'Gdoo\Product\Hooks\CategoryHook',
|
||||
'product_material' => 'Gdoo\Product\Hooks\MaterialHook',
|
||||
],
|
||||
'dialogs' => [
|
||||
'product' => [
|
||||
|
@ -62,7 +63,7 @@ return [
|
|||
]
|
||||
],
|
||||
"material" => [
|
||||
"name" => "原材料清单",
|
||||
"name" => "物料清单",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
|
@ -73,9 +74,15 @@ return [
|
|||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"import" => [
|
||||
"name" => "导入"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
"category" => [
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
<div class="panel">
|
||||
{{$form['tpl']}}
|
||||
</div>
|
||||
<div id="tab-content-product_material">
|
||||
<div id="grid_product_material_data" class="ag-theme-balham ag-bordered" style="width:100%;"></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var $table = null;
|
||||
var product_id = $('#product_material_product_id').val();
|
||||
var params = {product_id: product_id};
|
||||
|
||||
(function($) {
|
||||
var options = {};
|
||||
options.columns = [
|
||||
{field:'id', hide: true},
|
||||
{field:'material_id', hide: true},
|
||||
{field:'warehouse_id', hide: true},
|
||||
{suppressSizeToFit: true, headerName:'', cellRenderer:'optionCellRenderer', width: 60, sortable: false, cellClass: 'text-center', suppressNavigable: true},
|
||||
{headerName: '仓库',editable: true, cellClass:'text-center', suppressNavigable: false, width: 100,
|
||||
cellEditorParams: {
|
||||
form_type: 'dialog',
|
||||
title: '仓库',
|
||||
type: 'warehouse',
|
||||
field: 'warehouse_name',
|
||||
url: 'stock/warehouse/dialog',
|
||||
query: {
|
||||
form_id: "product_material_data",
|
||||
id: "warehouse_id",
|
||||
name: "warehouse_name"
|
||||
}
|
||||
},
|
||||
cellEditor: 'dialogCellEditor',
|
||||
field: 'warehouse_name'
|
||||
},
|
||||
{headerName: '物料编码', field:'material_code', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName: '物料名称',editable: true,suppressNavigable: false, width: 220,
|
||||
cellEditorParams: {
|
||||
form_type: 'dialog',
|
||||
title: '物料',
|
||||
type: 'product',
|
||||
field: 'material_name',
|
||||
url: 'product/product/dialog',
|
||||
query: {
|
||||
form_id: "product_material_data",
|
||||
id: "material_id",
|
||||
name: "material_name"
|
||||
}
|
||||
},
|
||||
cellEditor: 'dialogCellEditor',
|
||||
field: 'material_name'
|
||||
},
|
||||
{headerName: '规格型号', field:'material_spec', cellClass:'text-center', suppressNavigable: false, width: 160},
|
||||
{headerName: '物料条码', field:'material_barcode', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName: '计量单位', field:'material_unit', cellClass:'text-center', suppressNavigable: false, width: 100},
|
||||
{headerName: '用量', field:'quantity', editable: true, cellClass:'text-right', width: 100},
|
||||
{headerName: '损耗率(%)', field:'loss_rate', type:'number', editable: true, cellClass:'text-center', width: 100},
|
||||
{headerName: '备注', field:'remark', editable: true, width: 200},
|
||||
];
|
||||
|
||||
options.table = "product_material_data";
|
||||
options.title = "物料列表";
|
||||
options.heightTop = 12;
|
||||
|
||||
options.links = {
|
||||
warehouse_id: {
|
||||
warehouse_id: "id",
|
||||
warehouse_name: "name",
|
||||
},
|
||||
material_id: {
|
||||
material_id: "id",
|
||||
material_name: "name",
|
||||
material_code: "code",
|
||||
material_spec: "spec",
|
||||
material_barcode: "barcode",
|
||||
material_unit: "unit_id_name"
|
||||
}
|
||||
};
|
||||
|
||||
var grid = gridForms("product_material", "product_material_data", options);
|
||||
grid.dataKey = 'material_id';
|
||||
|
||||
$.post(app.url('product/material/list'), params, function(res) {
|
||||
if (res.data.length > 0) {
|
||||
grid.api.setRowData(res.data);
|
||||
}
|
||||
});
|
||||
|
||||
// 选择产品事件
|
||||
gdoo.event.set('product_material.product_id', {
|
||||
onSelect(row) {
|
||||
if (row.id) {
|
||||
params['product_id'] = row.id;
|
||||
$.post(app.url('product/material/list'), params, function(res) {
|
||||
if (res.data.length > 0) {
|
||||
grid.api.setRowData(res.data);
|
||||
} else {
|
||||
grid.api.setRowData([]);
|
||||
grid.api.memoryStore.create({});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
|
@ -0,0 +1,46 @@
|
|||
<div class="gdoo-list-page" id="{{$header['master_table']}}-page">
|
||||
<div class="gdoo-list panel">
|
||||
<div class="gdoo-list-header">
|
||||
<gdoo-grid-header :header="header" :grid="grid" :action="action" />
|
||||
</div>
|
||||
<div class='gdoo-list-grid'>
|
||||
<div id="{{$header['master_table']}}-grid" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
Vue.createApp({
|
||||
components: {
|
||||
gdooGridHeader,
|
||||
},
|
||||
setup(props, ctx) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
|
||||
var config = new gdoo.grid(table);
|
||||
|
||||
var grid = config.grid;
|
||||
grid.autoColumnsToFit = true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
|
||||
var action = config.action;
|
||||
|
||||
// 详情页打开方式
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 双击行执行的方法
|
||||
action.rowDoubleClick = action.edit;
|
||||
|
||||
var setup = config.setup;
|
||||
|
||||
Vue.onMounted(function() {
|
||||
var gridDiv = config.div(136);
|
||||
// 初始化数据
|
||||
grid.remoteData({page: 1}, function(res) {
|
||||
config.init(res);
|
||||
});
|
||||
});
|
||||
return setup;
|
||||
}
|
||||
}).mount("#{{$header['master_table']}}-page");
|
||||
</script>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,32 @@
|
|||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
DROP TABLE IF EXISTS `product_formula`;
|
||||
|
||||
DROP TABLE IF EXISTS `product_material`;
|
||||
CREATE TABLE `product_material` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`warehouse_id` int(11) NULL DEFAULT NULL COMMENT '仓库',
|
||||
`product_id` int(11) NULL DEFAULT NULL COMMENT '产品名称',
|
||||
`material_id` int(11) NULL DEFAULT NULL COMMENT '物料名称',
|
||||
`quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '用量',
|
||||
`loss_rate` decimal(18, 2) NULL DEFAULT NULL COMMENT '损耗率(%)',
|
||||
`created_id` int(11) NULL DEFAULT NULL,
|
||||
`created_by` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
|
||||
`created_at` int(11) NULL DEFAULT NULL,
|
||||
`updated_at` int(11) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`updated_by` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '更新人',
|
||||
`updated_id` int(11) NULL DEFAULT NULL COMMENT '编辑人ID',
|
||||
`status` tinyint(3) NOT NULL DEFAULT 1,
|
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_product_id`(`product_id`) USING BTREE,
|
||||
INDEX `idx_material_id`(`material_id`) USING BTREE,
|
||||
INDEX `idx_warehouse_id`(`warehouse_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
INSERT INTO `widget`(`name`, `color`, `type`, `sort`, `url`, `more_url`, `receive_id`, `receive_name`, `status`, `default`, `icon`, `updated_by`, `updated_at`, `created_at`, `created_by`, `updated_id`, `created_id`, `code`, `grid`) VALUES ('销售订单(元)', '#FF6600', 2, 0, 'order/widget/orderCount', 'order/order/index', 'all', '全体人员', 1, 0, 'fa-file-text-o', '系统管理员', 1636268193, 1636267940, '系统管理员', 1, 1, 'info_order_count', 8);
|
||||
INSERT INTO `widget`(`name`, `color`, `type`, `sort`, `url`, `more_url`, `receive_id`, `receive_name`, `status`, `default`, `icon`, `updated_by`, `updated_at`, `created_at`, `created_by`, `updated_id`, `created_id`, `code`, `grid`) VALUES ('客户', '#66CC00', 2, 0, 'customer/widget/customerCount', 'customer/customer/index', 'all', '全体人员', 1, 0, 'fa-users', '系统管理员', 1636269063, 1636268914, '系统管理员', 1, 1, 'info_customer_count', 8);
|
||||
INSERT INTO `widget`(`name`, `color`, `type`, `sort`, `url`, `more_url`, `receive_id`, `receive_name`, `status`, `default`, `icon`, `updated_by`, `updated_at`, `created_at`, `created_by`, `updated_id`, `created_id`, `code`, `grid`) VALUES ('客户联系人', '#3399FF', 2, 0, 'customer/widget/customerContactCount', 'customer/contact/index', 'all', '全体人员', 1, 0, 'fa-address-book-o', '系统管理员', 1636269516, 1636268914, '系统管理员', 1, 1, 'info_customer_contact_count', 8);
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : localhost_3308
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 100508
|
||||
Source Host : localhost:3308
|
||||
Source Schema : gdoo_demo
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 100508
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/07/2021 04:51:07
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for share
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `share`;
|
||||
CREATE TABLE `share` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`source_id` int(11) NOT NULL,
|
||||
`source_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`is_repeat` tinyint(3) NOT NULL DEFAULT 0 COMMENT '重复标记',
|
||||
`receive_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '共享编号',
|
||||
`receive_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '共享名称',
|
||||
`permissions` smallint(6) NULL DEFAULT NULL,
|
||||
`start_at` int(11) NULL DEFAULT NULL COMMENT '开始时间',
|
||||
`end_at` int(11) NULL DEFAULT NULL COMMENT '结束时间',
|
||||
`created_by` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
|
||||
`created_id` int(11) NULL DEFAULT NULL,
|
||||
`created_at` int(10) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_source_id`(`source_id`) USING BTREE,
|
||||
INDEX `idx_source_type`(`source_type`) USING BTREE,
|
||||
INDEX `idx_is_repeat`(`is_repeat`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of share
|
||||
-- ----------------------------
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
Loading…
Reference in New Issue