整理对话框相关逻辑,封装部分js方法

This commit is contained in:
2021-03-18 06:39:17 +08:00
parent bc79583fe7
commit 7223845862
96 changed files with 317 additions and 1887 deletions
+4 -42
View File
@@ -10,7 +10,7 @@ class OrderHook
$permission = $params['permission'];
$data = $permission['customer_order_data'];
// 是客户不能编辑产品类型
// 以下角色类型无法修改子表字段
$role_ids = [2, 83, 84, 85];
if (in_array(auth()->user()->role_id, $role_ids)) {
// 不能编辑类型
@@ -44,33 +44,15 @@ class OrderHook
// 只限制内销和直营
if (in_array($master['type_id'], [1, 3])) {
// 客户和区域经理和业务员限制下单数和倍数
$role_ids = [2, 83, 84];
// 成品数量
$product_quantity = $product_money = 0;
$role_ids = [2, 83, 84, 85];
if (in_array(auth()->user()->role_id, $role_ids)) {
$_product_ids = DB::table('product')
->whereRaw('product_type = 1')
->pluck('id', 'id')->toArray();
$quantitys = [];
$product_ids = [];
foreach($params['datas'] as $i => $datas) {
if ($datas['table'] == 'customer_order_data') {
foreach($datas['data'] as $j => $row) {
$quantitys[$row['product_id']][] = $row['quantity'];
$product_ids[] = $row['product_id'];
// 获取产成品数量
if (isset($_product_ids[$row['product_id']])) {
if ($row['type_id'] == 1) {
$product_quantity += $row['quantity'];
$product_money += $row['money'];
}
}
}
}
}
@@ -101,11 +83,6 @@ class OrderHook
}
}
$params['master'] = $master;
$fee = 0;
$amount = 0;
foreach($params['datas'] as $i => $datas) {
if ($datas['table'] == 'customer_order_data') {
@@ -116,9 +93,10 @@ class OrderHook
if (empty($row['promotion_sn'])) {
abort_error('赠品必须有编号。');
}
// 赠品修改客户促销开票单位
if ($row['fee_src_id'] > 0) {
// 检查赠品是否在其他订单里已经使用过了
// 促销费用首次使用回写开票单位到促销申请
$count = DB::table('customer_order_data')
->where('order_id', '<>', $row['order_id'])
->where('fee_src_id', $row['fee_src_id'])
@@ -139,27 +117,11 @@ class OrderHook
}
}
// 判断费用比例
$money = floatval($row['money']);
if ($row['product_code'] == '99001') {
$fee += $money;
} else {
$amount += $money;
}
$datas['data'][$j] = $row;
}
$params['datas'][$i] = $datas;
}
}
// 费用不能大于20%
/*
$feeAmount = $amount * 0.2;
if (abs($fee) > $feeAmount) {
abort_error('费用金额不能大于'.$feeAmount);
}
*/
return $params;
}
@@ -50,7 +50,6 @@
var gridDiv = document.querySelector("#dialog-delivery_plan");
new agGrid.Grid(gridDiv, grid);
// 读取数据
grid.remoteData();
$('#plan_delivery_submit').on('click', function() {
+3 -56
View File
@@ -15,7 +15,6 @@
var event = gdoo.event.get(option.key);
event.trigger('query', params);
var sid = params.prefix == 1 ? 'sid' : 'id';
var multiple = params.multi == 0 ? false : true;
var grid = new agGridOptions();
@@ -41,71 +40,19 @@
};
grid.onRowDoubleClicked = function (row) {
var ret = writeSelected();
var ret = gdoo.writeSelected(event, params, option, grid);
if (ret == true) {
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
}
};
/**
* 初始化选择
*/
function initSelected() {
if (params.is_grid) {
} else {
var rows = {};
var id = $('#'+option.id).val();
if (id) {
var ids = id.split(',');
for (var i = 0; i < ids.length; i++) {
rows[ids[i]] = ids[i];
}
}
grid.api.forEachNode(function(node) {
var key = node.data[sid];
if (rows[key] != undefined) {
node.setSelected(true);
}
});
}
}
/**
* 写入选中
*/
function writeSelected() {
var rows = grid.api.getSelectedRows();
if (params.is_grid) {
var list = gdoo.forms[params.form_id];
list.api.dialogSelected(params);
} else {
var id = [];
var text = [];
$.each(rows, function(k, row) {
id.push(row[sid]);
text.push(row.name);
});
$('#'+option.id).val(id.join(','));
$('#'+option.id+'_text').val(text.join(','));
if (event.exist('onSelect')) {
return event.trigger('onSelect', multiple ? rows : rows[0]);
}
}
return true;
}
grid.writeSelected = writeSelected;
gdoo.dialogs[option.id] = grid;
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
new agGrid.Grid(gridDiv, grid);
// 读取数据
grid.remoteData({page: 1});
// 数据载入成功
grid.remoteSuccessed = function() {
initSelected();
grid.remoteAfterSuccess = function() {
gdoo.initSelected(params, option, grid);
}
var data = search.forms;
@@ -53,9 +53,10 @@ var params = JSON.parse('{{json_encode($query)}}');
sGrid.remoteData(params);
};
new agGrid.Grid(mGridDiv, mGrid);
// 读取数据
mGrid.remoteData();
$ref_customer_order = mGrid;
params['master'] = 0;
var sGridDiv = document.querySelector("#ref_customer_order_data");
var sGrid = new agGridOptions();
@@ -95,7 +96,6 @@ var params = JSON.parse('{{json_encode($query)}}');
};
new agGrid.Grid(sGridDiv, sGrid);
// 读取数据
sGrid.remoteData();
$ref_customer_order_data = sGrid;
@@ -53,9 +53,9 @@ var params = JSON.parse('{{json_encode($query)}}');
sGrid.remoteData(params);
};
new agGrid.Grid(mGridDiv, mGrid);
// 读取数据
mGrid.remoteData();
$ref_customer_order = mGrid;
params['master'] = 0;
var sGridDiv = document.querySelector("#ref_cancel_order_data");
var sGrid = new agGridOptions();
@@ -92,7 +92,6 @@ var params = JSON.parse('{{json_encode($query)}}');
};
new agGrid.Grid(sGridDiv, sGrid);
// 读取数据
sGrid.remoteData();
$ref_customer_order_data = sGrid;
@@ -55,9 +55,9 @@ var params = JSON.parse('{{json_encode($query)}}');
sGrid.remoteData(params);
};
new agGrid.Grid(mGridDiv, mGrid);
// 读取数据
mGrid.remoteData();
$ref_customer_order = mGrid;
params['master'] = 0;
var sGridDiv = document.querySelector("#ref_customer_order_data");
var sGrid = new agGridOptions();
@@ -101,7 +101,6 @@ var params = JSON.parse('{{json_encode($query)}}');
};
new agGrid.Grid(sGridDiv, sGrid);
// 读取数据
sGrid.remoteData();
$ref_customer_order_data = sGrid;
@@ -53,9 +53,9 @@
sGrid.remoteData(params);
};
new agGrid.Grid(mGridDiv, mGrid);
// 读取数据
mGrid.remoteData();
$ref_customer_order = mGrid;
params['master'] = 0;
var sGridDiv = document.querySelector("#ref_customer_order_data");
var sGrid = new agGridOptions();
@@ -90,7 +90,6 @@
};
new agGrid.Grid(sGridDiv, sGrid);
// 读取数据
sGrid.remoteData();
$ref_customer_order_data = sGrid;
@@ -22,7 +22,6 @@ var $promotion_customer_order_data = null;
var event = gdoo.event.get(option.key);
event.trigger('query', params);
var sid = params.prefix == 1 ? 'sid' : 'id';
var multiple = params.multi == 0 ? false : true;
var mGrid = new agGridOptions();
@@ -56,69 +55,19 @@ var $promotion_customer_order_data = null;
};
mGrid.onRowDoubleClicked = function (row) {
var ret = writeSelected();
var ret = gdoo.writeSelected(event, params, option, mGrid);
if (ret == true) {
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
}
};
/**
* 初始化选择
*/
function initSelected() {
if (params.is_grid) {
} else {
var rows = {};
var id = $('#'+option.id).val();
if (id) {
var ids = id.split(',');
for (var i = 0; i < ids.length; i++) {
rows[ids[i]] = ids[i];
}
}
mGrid.api.forEachNode(function(node) {
var key = node.data[sid];
if (rows[key] != undefined) {
node.setSelected(true);
}
});
}
}
/**
* 写入选中
*/
function writeSelected() {
var rows = mGrid.api.getSelectedRows();
if (params.is_grid) {
var list = gdoo.forms[params.form_id];
list.api.dialogSelected(params);
} else {
var id = [];
var text = [];
$.each(rows, function(k, row) {
id.push(row[sid]);
text.push(row.name);
});
$('#'+option.id).val(id.join(','));
$('#'+option.id+'_text').val(text.join(','));
if (event.exist('onSelect')) {
return event.trigger('onSelect', multiple ? rows : rows[0]);
}
}
return true;
}
mGrid.writeSelected = writeSelected;
gdoo.dialogs[option.id] = mGrid;
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
new agGrid.Grid(gridDiv, mGrid);
// 读取数据
mGrid.remoteData();
// 数据载入成功
mGrid.remoteSuccessed = function() {
initSelected();
mGrid.remoteAfterSuccess = function() {
gdoo.initSelected(params, option, mGrid);
}
params['master'] = 0;
@@ -148,7 +97,6 @@ var $promotion_customer_order_data = null;
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
];
new agGrid.Grid(sGridDiv, sGrid);
// 读取数据
sGrid.remoteData();
$promotion_customer_order_data = sGrid;
@@ -47,7 +47,6 @@
new agGrid.Grid(gridDiv, grid);
gridDiv.style.height = getPanelHeight(12);
// 读取数据
grid.remoteData();
var search = $('#' + table + '-search-form-advanced').searchForm({
@@ -54,7 +54,6 @@
new agGrid.Grid(gridDiv, grid);
gridDiv.style.height = getPanelHeight(12);
// 读取数据
grid.remoteData();
var search_advanced = $('#' + table + '-search-form-advanced').searchForm({
@@ -74,7 +74,6 @@
grid.api.setColumnDefs(columnDefs);
}
// 读取数据
grid.remoteData(null, function(res) {
setColumns(res);
});
@@ -37,7 +37,6 @@
var gridDiv = document.querySelector("#dialog-delivery_plan");
new agGrid.Grid(gridDiv, grid);
// 读取数据
grid.remoteData();
})(jQuery);
@@ -55,7 +55,6 @@ var params = JSON.parse('{{json_encode($query)}}');
sGrid.remoteData(params);
};
new agGrid.Grid(mGridDiv, mGrid);
// 读取数据
mGrid.remoteData();
$ref_sample_apply = mGrid;
@@ -89,7 +88,7 @@ var params = JSON.parse('{{json_encode($query)}}');
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
];
new agGrid.Grid(sGridDiv, sGrid);
// 读取数据
sGrid.remoteData();
$ref_sample_apply_data = sGrid;
@@ -31,7 +31,6 @@
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.remoteData({page: 1});
gdoo.widgets['order_widget_goods'] = options;
})(jQuery);
+1 -1
View File
@@ -24,7 +24,7 @@
}];
options.columnDefs = columnDefs;
new agGrid.Grid(gridDiv, options);
// 读取数据
options.remoteData({page: 1});
gdoo.widgets['order_widget_index'] = options;
})(jQuery);