From 98af69e9e46bc47676b7afd8ed328eb084ec489a Mon Sep 17 00:00:00 2001 From: hawind Date: Thu, 25 Feb 2021 02:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=A1=A8=E5=8D=95=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E5=85=B3=E8=81=94=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20=E4=BF=AE=E6=AD=A3=E5=8F=91=E8=B4=A7=E5=8D=95=E7=89=A9?= =?UTF-8?q?=E6=B5=81=E4=BF=A1=E6=81=AF=E6=97=A0=E6=B3=95=E5=A1=AB=E5=86=99?= =?UTF-8?q?=20=E4=BF=AE=E6=AD=A3=E5=8F=91=E8=B4=A7=E5=8D=95=E7=9B=B4?= =?UTF-8?q?=E8=90=A5=E7=89=A9=E6=B5=81=E4=BF=A1=E6=81=AF=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=A1=AB=E5=86=99=20=E5=8E=BB=E6=8E=89=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CustomerController.php | 8 +- .../Controllers/DeliveryAddressController.php | 9 +- app/Gdoo/Index/Controllers/Controller.php | 4 +- app/Gdoo/Model/Form.php | 2101 ++++++++--------- app/Gdoo/Model/Grid.php | 9 +- app/Gdoo/Model/Services/FieldService.php | 297 +-- app/Gdoo/Order/views/order/create.blade.php | 1 - .../Product/Controllers/ProductController.php | 18 +- .../Controllers/AllocationController.php | 4 +- .../Stock/Controllers/DeliveryController.php | 4 +- .../Stock/views/allocation/logistics.html | 208 +- database/gdoo-2.2.sql | 292 +-- public/assets/css/gdoo.css | 2 +- public/assets/dist/app.min.css | 2 +- public/assets/dist/app.min.js | 2 +- public/assets/dist/index.min.css | 2 +- public/assets/js/select2.js | 6 +- public/mix-manifest.json | 6 +- 18 files changed, 1419 insertions(+), 1556 deletions(-) diff --git a/app/Gdoo/Customer/Controllers/CustomerController.php b/app/Gdoo/Customer/Controllers/CustomerController.php index e3f1947f..4f1dfbdf 100644 --- a/app/Gdoo/Customer/Controllers/CustomerController.php +++ b/app/Gdoo/Customer/Controllers/CustomerController.php @@ -283,11 +283,11 @@ class CustomerController extends DefaultController $model->addSelect(DB::raw('cda.*')); + if ($query['q']) { + $model->whereRaw("(customer.code like '%{$query['q']}%' or customer.name like '%{$query['q']}%')"); + } + if ($query['suggest']) { - if ($query['q']) { - $q = $query['q']; - $model->whereRaw("(customer.code like '%$q%' or customer.name like '%$q%')"); - } $rows = $model->limit(15)->get(); $data = Grid::dataFilters($rows, $header, function($item) { return $item; diff --git a/app/Gdoo/Customer/Controllers/DeliveryAddressController.php b/app/Gdoo/Customer/Controllers/DeliveryAddressController.php index 8612634a..bef730cf 100644 --- a/app/Gdoo/Customer/Controllers/DeliveryAddressController.php +++ b/app/Gdoo/Customer/Controllers/DeliveryAddressController.php @@ -131,17 +131,10 @@ class DeliveryAddressController extends DefaultController } } - if (isset($query['select2']) && $query['q']) { + if ($query['q']) { $model->where('customer_delivery_address.address', 'like', '%'. $query['q'] .'%'); } - // 搜索条件 - foreach ($search['where'] as $where) { - if ($where['active']) { - $model->search($where); - } - } - $model->whereRaw('customer_delivery_address.customer_id > 0 and customer_delivery_address.customer_id = ?', [$query['customer_id']]); $header['select'][] = 'customer_delivery_address.id'; diff --git a/app/Gdoo/Index/Controllers/Controller.php b/app/Gdoo/Index/Controllers/Controller.php index a3f8100b..2ff5b924 100644 --- a/app/Gdoo/Index/Controllers/Controller.php +++ b/app/Gdoo/Index/Controllers/Controller.php @@ -15,12 +15,12 @@ class Controller extends BaseController /** * @var 程序版本 */ - public $version = 'Gdoo 2.2.1'; + public $version = 'Gdoo 2.2.2'; /** * @var 资源版本 */ - public $resVersion = '20210221'; + public $resVersion = '20210225'; /** * @var 开发商名称 diff --git a/app/Gdoo/Model/Form.php b/app/Gdoo/Model/Form.php index 618d6863..fafc7a52 100644 --- a/app/Gdoo/Model/Form.php +++ b/app/Gdoo/Model/Form.php @@ -41,85 +41,10 @@ use Illuminate\Support\Arr; class Form { - public static function dataFilter($options) - { - $table = $options['table']; - $gets = $options['gets']; - $master = $gets['master']; - $tables = is_string($table) ? [$table] : $table; - - $permission = DB::table('model_permission') - ->where('id', $master['permission_id']) - ->first(); - - $permissions = json_decode($permission['data'], true); - $dataFiles = []; - foreach ($tables as $table) { - - $flow = DB::table('model') - ->where('table', $table) - ->first(); - - $fields = DB::table('model_field') - ->where('model_id', $flow['id']) - ->orderBy('sort', 'asc') - ->get()->keyBy('field'); - - $rows = $permissions[$table]; - - foreach ($rows as $field => $permission) { - $value = $gets[$table][$field]; - $column = $fields[$field]; - $setting = json_decode($column['setting'], true); - - if ($permission['w'] == 1) { - switch ($column['form_type']) { - case 'address': - $value = join("\n", (array)$value); - break; - case 'files': - $value = (array)$value; - $dataFiles = array_merge($dataFiles, $value); - $value = join("\n", $value); - break; - case 'images': - $value = join("\n", (array)$value); - break; - case 'date': - if ($setting['save'] == 'u') { - $value = empty($value) ? '' : strtotime($value); - } - break; - case 'checkbox': - $value = intval($value); - break; - } - } - $gets[$table][$field] = $value; - } - } - $gets['dataFiles'] = $dataFiles; - return $gets; - } - - public static function getSelect($setting) { - $_select = explode("\n", $setting['content']); - $values = []; - $a1 = false; - foreach ($_select as $t) { - $n = $v = ''; - list($n, $v) = explode('|', $t); - if (is_null($v)) { - - } else { - $a1 = true; - } - $v = is_null($v) ? trim($n) : trim($v); - $values[] = ['id' => $v, 'name' => $n]; - } - } - - public static function columnFormat($table, &$field, &$join, &$select, &$links) + /** + * 关联字段处理 + */ + public static function fieldRelated($table, &$field, &$join, &$select, &$links) { if ($field['data_type']) { $data_type = $field['data_type']; @@ -136,31 +61,62 @@ class Form $column = $field['field']; } - if (strpos($data_field, ':')) { - list($var1, $var2) = explode(':', $data_field); - list($_v1, $_v2) = explode('.', $var1); - list($_t1, $_t2) = explode('.', $var2); - $_table = $data_link.'_'.$_t1; - $join[$_table] = [$_t1.' as '.$_table, $_table.'.id', '=', $data_link.'_'.$data_type.'.'.$_v2]; - $index = $_table.'.'.$_t2; - if ($field['field'] == $data_link) { - $column = $field['field'].'_'.$_v1; - // 这里本地字段和右表字段一样时,直接取右表名称 - $links[$data_link][$column] = $_v1; - } else { - // $_v2 右表关联字段,$_t2 右表映射字段 - if ($field['type']) { - $links[$data_link][$column] = $_v2; - // 右表 id_name - $links[$data_link][$column.'_'.$_t2] = $_v2.'_'.$_t2; + $field_count = mb_substr_count($data_field, ':'); + if ($field_count > 0) { + $var1 = explode(':', $data_field); + list($_v1, $_v2) = explode('.', $var1[0]); + if ($field_count == 2) { + // 分割对应的多表联合查询 + list($_t1, $_t2, $_t3) = explode('.', $var1[1]); + list($_c1, $_c2) = explode('.', $var1[2]); - $field['dest_column'] = $column.'_'.$_t2; - $column = $column.'_'.$_t2; + // 获取左表名 + $_left_table = $data_link.'_'.$_v2.'_'.$_t1; + + $join[$_left_table] = [$_t1.' as '.$_left_table, $_left_table.'.id', '=', $_table.'.'.$_v2]; + + $_table = $data_link.'_'.$_v2.'_'.$_t1.'_'.$_t3; + $join[$_table] = [$_c1.' as '.$_table, $_table.'.id', '=', $_left_table.'.'.$_t3]; + + $index = $_table.'.'.$_c2; + + // 远程字段和本地字段名称一样重命名 + if ($data_link == $field['field']) { + $column = $column.'_'.$_v1; + $links[$data_link][$column] = $_v1; } else { - $links[$data_link][$column] = $_v2.'_'.$_t2; + if ($field['type']) { + // 右表 id_name + // 二层关联后无法获取远程字段是否有本地字段(这里暂时没有想到好的解决办法) + // $links[$data_link][$column.'_'.$_t2] = $_v2.'_'.$_t2; + $column = $column.'_'.$_c2; + } + $links[$data_link][$column] = $_v1; + } + + } else { + list($_t1, $_t2) = explode('.', $var1[1]); + $_table = $data_link.'_'.$_t1; + $join[$_table] = [$_t1.' as '.$_table, $_table.'.id', '=', $data_link.'_'.$data_type.'.'.$_v2]; + $index = $_table.'.'.$_t2; + if ($field['field'] == $data_link) { + $column = $field['field'].'_'.$_v1; + // 这里本地字段和右表字段一样时,直接取右表名称 + $links[$data_link][$column] = $_v1; + } else { + // $_v2 右表关联字段,$_t2 右表映射字段 + if ($field['type']) { + $links[$data_link][$column] = $_v2; + // 右表 id_name + $links[$data_link][$column.'_'.$_t2] = $_v2.'_'.$_t2; + + $field['dest_column'] = $column.'_'.$_t2; + $column = $column.'_'.$_t2; + } else { + $links[$data_link][$column] = $_v2.'_'.$_t2; + } } } - } else { if ($field['type']) { if ($field['field'] == $data_link) { @@ -179,6 +135,856 @@ class Form } } + public static function make($options) + { + $assets = UserAssetService::getNowRoleAssets(); + + // 权限查询类型 + $code = $options['code']; + $bill = Bill::where('code', $code)->first(); + + // 表数据 + $flow = DB::table('model') + ->where('id', $bill['model_id']) + ->first(); + + // 主表字段 + $fields = DB::table('model_field') + ->where('model_id', $bill['model_id']) + ->orderBy('sort', 'asc') + ->get()->keyBy('field'); + + $table = $flow['table']; + + // 查询主表数据 + $join = $select = $links = []; + $select[] = $table.'.*'; + foreach($fields as $field) { + static::fieldRelated($table, $field, $join, $select, $links); + } + + $q = DB::table($table) + ->where($table.'.id', (int)$options['id']); + foreach($join as $j) { + $q->leftJoin($j[0], $j[1], $j[2], $j[3]); + } + $row = $q->select($select)->first(); + + $auth = auth()->user(); + + $action = $options['action']; + if ($action == 'show') { + $tpl = 'show'; + $type_sql = '(' . join(' or ', [db_instr('type', $tpl)]) . ')'; + } else { + $tpl = $row['id'] > 0 ? 'edit' : 'create'; + $type_sql = '(' . join(' or ', [db_instr('type', $tpl)]) . ')'; + } + + if ($action == 'print') { + $type_sql = '(' . join(' or ', [db_instr('type', 'print')]) . ')'; + } + + $key = AES::encrypt($bill['id'].'.'.(int)$row['id'], config('app.key')); + + $run_id = 0; + $step_id = 0; + $run_log_id = 0; + $run_step_id = 0; + $recall_log_id = 0; + $recall_btn = $audit_btn = $abort_btn = $read_btn = false; + + if ($bill['audit_type'] == 1) { + + $run = DB::table('model_run') + ->where('bill_id', $bill['id']) + ->where('data_id', $row['id']) + ->first(); + + // 流程是新建的 + if (empty($run)) { + $step = DB::table('model_step') + ->where('bill_id', $bill['id']) + ->where('type', 'start') + ->first(); + $step_id = $step['id']; + } else { + $step = DB::table('model_run_log') + ->leftJoin('model_run_step', 'model_run_step.id', '=', 'model_run_log.run_step_id') + ->where('model_run_log.run_id', $run['id']) + ->where('model_run_log.user_id', $auth['id']) + ->where('model_run_log.status', 0) + ->orderBy('model_run_log.id', 'asc') + ->first([ + 'model_run_log.*', + 'model_run_step.type as step_type', + 'model_run_step.step_id', + 'model_run_step.permission_id' + ]); + + $run_id = $run['id']; + $step_id = $step['step_id']; + $run_step_id = $step['run_step_id']; + $run_log_id = $step['id']; + $option = $step['option']; + + // 判断是有审核权限 + $audit_status = $step['user_id'] == auth()->id(); + if ($option == 1) { + $audit_btn = $audit_status; + } else { + $read_btn = $audit_status; + } + } + + if ($row['status'] == '0') { + $audit_btn = 1; + } + + if ($row['status'] == '1') { + $abort_btn = 1; + } + + // 获取表单操作权限 + $_permission = DB::table('model_permission') + ->permission('receive_id') + ->where('id', $step['permission_id']) + ->first(); + + // 获取最后已转交节点 + $passed = DB::table('model_run_log') + ->where('run_id', $run['id']) + ->where('user_id', $auth['id']) + ->where('status', '>', 0) + ->orderBy('id', 'desc') + ->first(); + + if ($passed) { + $recall_log_id = $passed['id']; + $nodes = DB::table('model_run_log') + ->where('parent_id', $passed['id']) + ->get(); + + $node_count = $nodes->count(); + $todo_count = $nodes->where('status', 0)->count(); + // 全部未办理才能撤回 + if ($node_count > 0) { + if ($node_count == $todo_count) { + $recall_btn = true; + } + } + } + + /* + if ($audit_btn == true && $run_id > 0) { + // 更新待办接收时间 + if ($step['received_id'] == 0) { + DB::table('model_run_log')->where('id', $step['id'])->update([ + 'updated_id' => 0, + 'updated_by' => '', + 'updated_at' => 0, + 'received_id' => $auth['id'], + 'received_by' => $auth['name'], + 'received_at' => time(), + ]); + } + } + */ + + } else { + $_permission = DB::table('model_permission') + ->permission('receive_id') + ->whereRaw($type_sql) + ->where('bill_id', $bill['id']) + ->first(); + } + + $permission = json_decode($_permission['data'], true); + + $model = DB::table('model_template') + ->permission('receive_id', null, false, false) + ->whereRaw($type_sql) + ->where('bill_id', $bill['id']); + if ($options['template_id'] > 0) { + $model->where('id', $options['template_id']); + } + $template = $model->first(); + + if (empty($template)) { + $model = DB::table('model_template') + ->where('receive_id', 'all') + ->whereRaw($type_sql) + ->where('bill_id', $bill['id']); + if ($options['template_id'] > 0) { + $model->where('id', $options['template_id']); + } + $template = $model->first(); + } + + $prints_btn = ''; + if (isset($assets['print']) && $row['id'] > 0) { + // 获取打印模板 + $prints = DB::table('model_template') + ->permission('receive_id') + ->where('type', 'print') + ->where('bill_id', $bill['id']) + ->orderBy('sort', 'asc') + ->get(); + + if ($prints) { + $prints_btn .= '
+ +
'; + } + } + + $views = json_decode($template['tpl'], true); + + $js = ''; + $html .= $js; + + } + + View::share([ + 'model_view' => 1, + ]); + + return [ + 'table' => $table, + 'model_id' => $flow['id'], + 'run_id' => $run_id, + 'row' => $row, + 'action' => $action, + 'actions' => $permission['actions'], + 'permission' => $permission, + 'btn' => $btn, + 'key' => $key, + 'tpl' => $html, + 'tabs' => $tabs, + 'access' => $assets, + 'template' => $template, + 'prints' => $prints, + 'print_data' => $_prints, + 'print_type' => $template['print_type'], + 'width' => $template['width'], + 'bill_code' => $options['code'], + ]; + } + + /** + * 多行子表构建 + */ public static function sublist($options) { $sublist = $options['sublist']; @@ -291,7 +1097,7 @@ class Form $select[] = $model['table'].'.'.$field['field']; } - static::columnFormat($model['table'], $field, $join, $select, $links); + static::fieldRelated($model['table'], $field, $join, $select, $links); $column = []; @@ -689,977 +1495,9 @@ class Form return $tabs; } - public static function make($options) - { - $assets = UserAssetService::getNowRoleAssets(); - - // 权限查询类型 - $code = $options['code']; - $bill = Bill::where('code', $code)->first(); - - // 表数据 - $flow = DB::table('model') - ->where('id', $bill['model_id']) - ->first(); - - $table = $flow['table']; - - $row = DB::table($table) - ->where('id', (int)$options['id']) - ->first(); - - $auth = auth()->user(); - - $action = $options['action']; - if ($action == 'show') { - $tpl = 'show'; - $type_sql = '(' . join(' or ', [db_instr('type', $tpl)]) . ')'; - } else { - $tpl = $row['id'] > 0 ? 'edit' : 'create'; - $type_sql = '(' . join(' or ', [db_instr('type', $tpl)]) . ')'; - } - - if ($action == 'print') { - $type_sql = '(' . join(' or ', [db_instr('type', 'print')]) . ')'; - } - - $key = AES::encrypt($bill['id'].'.'.(int)$row['id'], config('app.key')); - - $run_id = 0; - $step_id = 0; - $run_log_id = 0; - $run_step_id = 0; - $recall_log_id = 0; - $recall_btn = $audit_btn = $abort_btn = $read_btn = false; - - if ($bill['audit_type'] == 1) { - - $run = DB::table('model_run') - ->where('bill_id', $bill['id']) - ->where('data_id', $row['id']) - ->first(); - - // 流程是新建的 - if (empty($run)) { - $step = DB::table('model_step') - ->where('bill_id', $bill['id']) - ->where('type', 'start') - ->first(); - $step_id = $step['id']; - } else { - $step = DB::table('model_run_log') - ->leftJoin('model_run_step', 'model_run_step.id', '=', 'model_run_log.run_step_id') - ->where('model_run_log.run_id', $run['id']) - ->where('model_run_log.user_id', $auth['id']) - ->where('model_run_log.status', 0) - ->orderBy('model_run_log.id', 'asc') - ->first([ - 'model_run_log.*', - 'model_run_step.type as step_type', - 'model_run_step.step_id', - 'model_run_step.permission_id' - ]); - - $run_id = $run['id']; - $step_id = $step['step_id']; - $run_step_id = $step['run_step_id']; - $run_log_id = $step['id']; - $option = $step['option']; - - // 判断是有审核权限 - $audit_status = $step['user_id'] == auth()->id(); - if ($option == 1) { - $audit_btn = $audit_status; - } else { - $read_btn = $audit_status; - } - } - - if ($row['status'] == '0') { - $audit_btn = 1; - } - - if ($row['status'] == '1') { - $abort_btn = 1; - } - - // 获取表单操作权限 - $_permission = DB::table('model_permission') - ->permission('receive_id') - ->where('id', $step['permission_id']) - ->first(); - - // 获取最后已转交节点 - $passed = DB::table('model_run_log') - ->where('run_id', $run['id']) - ->where('user_id', $auth['id']) - ->where('status', '>', 0) - ->orderBy('id', 'desc') - ->first(); - - if ($passed) { - $recall_log_id = $passed['id']; - $nodes = DB::table('model_run_log') - ->where('parent_id', $passed['id']) - ->get(); - - $node_count = $nodes->count(); - $todo_count = $nodes->where('status', 0)->count(); - // 全部未办理才能撤回 - if ($node_count > 0) { - if ($node_count == $todo_count) { - $recall_btn = true; - } - } - } - - /* - if ($audit_btn == true && $run_id > 0) { - // 更新待办接收时间 - if ($step['received_id'] == 0) { - DB::table('model_run_log')->where('id', $step['id'])->update([ - 'updated_id' => 0, - 'updated_by' => '', - 'updated_at' => 0, - 'received_id' => $auth['id'], - 'received_by' => $auth['name'], - 'received_at' => time(), - ]); - } - } - */ - - } else { - $_permission = DB::table('model_permission') - ->permission('receive_id') - ->whereRaw($type_sql) - ->where('bill_id', $bill['id']) - ->first(); - } - - $permission = json_decode($_permission['data'], true); - - $fields = DB::table('model_field') - ->where('model_id', $bill['model_id']) - ->orderBy('sort', 'asc') - ->get()->keyBy('field'); - - $model = DB::table('model_template') - ->permission('receive_id', null, false, false) - ->whereRaw($type_sql) - ->where('bill_id', $bill['id']); - if ($options['template_id'] > 0) { - $model->where('id', $options['template_id']); - } - $template = $model->first(); - - if (empty($template)) { - $model = DB::table('model_template') - ->where('receive_id', 'all') - ->whereRaw($type_sql) - ->where('bill_id', $bill['id']); - if ($options['template_id'] > 0) { - $model->where('id', $options['template_id']); - } - $template = $model->first(); - } - - $prints_btn = ''; - if (isset($assets['print']) && $row['id'] > 0) { - // 获取打印模板 - $prints = DB::table('model_template') - ->permission('receive_id') - ->where('type', 'print') - ->where('bill_id', $bill['id']) - ->orderBy('sort', 'asc') - ->get(); - - if ($prints) { - $prints_btn .= '
- -
'; - } - } - - $views = json_decode($template['tpl'], true); - - $js = ''; - $html .= $js; - - } - - View::share([ - 'model_view' => 1, - ]); - - return [ - 'table' => $table, - 'model_id' => $flow['id'], - 'run_id' => $run_id, - 'row' => $row, - 'action' => $action, - 'actions' => $permission['actions'], - 'permission' => $permission, - 'btn' => $btn, - 'key' => $key, - 'tpl' => $html, - 'tabs' => $tabs, - 'access' => $assets, - 'template' => $template, - 'prints' => $prints, - 'print_data' => $_prints, - 'print_type' => $template['print_type'], - 'width' => $template['width'], - 'bill_code' => $options['code'], - ]; - } - - public static function getField($flow, $table, $action, $row, $attr, $field) { - $field['model'] = $flow; - $attribute = []; - if ($action == 'show') { - $field['is_show'] = true; - } - - $p = []; - - $p['w'] = $attr['read'] == 1 ? 0 : 1; - - $p['s'] = $attr['hidden'] == 1 ? 1 : 0; - - $field['is_print'] = $action == 'print'; - $field['is_write'] = $p['w'] == 1 ? 1 : 0; - $field['is_read'] = $p['w'] == 1 ? 0 : 1; - $field['is_auto'] = $p['m'] == 1 ? 1 : 0; - $field['is_hide'] = $p['s'] == 1 ? 1 : $field['is_hide']; - - // 单据编码规则 - $field['data_sn'] = $flow['data_sn']; - - $validate = (array) $p['v']; - - if ($action == 'print') { - $field['is_show'] = true; - } - - if ($action == 'print') { - } else { - $required = ''; - if (in_array('required', $validate)) { - $required = '* '; - if ($field['is_write']) { - $attribute['required'] = 'required'; - if ($field['is_auto'] == 0) { - $attribute['class'][] = 'input-required'; - } else { - $attribute['class'][] = 'input-auto'; - } - } - } - } - - $field['verify'] = $validate; - $field['attribute'] = $attribute; - $field['table'] = $table; - - $tooltip = $field['tips'] ? ' ' : ''; - - if ($action == 'show' || $action == 'print') { - $tooltip = ''; - $required = ''; - } - - $_replace['{' . $field['name'] . '}'] = $required . $field['name'] . $tooltip; - - $data_type = $field['data_type']; - $data_field = $field['data_field']; - $data_link = $field['data_link']; - if ($data_type) { - $related = []; - if (strpos($data_field, ':')) { - list($var1, $var2) = explode(':', $data_field); - list($_v1, $_v2) = explode('.', $var1); - list($_t1, $_t2) = explode('.', $var2); - if ($field['type']) { - $related['table'] = $table; - $related['field'] = $field['field']; - $value = $row[$field['field']]; - } else { - $related['table'] = $_t1; - $related['field'] = $_v2; - $value = $row[$data_type][$_v2]; - } - } else { - if ($field['type']) { - $related['table'] = $table; - $related['field'] = $field['field']; - $value = $row[$field['field']]; - } else { - $related['table'] = $data_type; - $related['field'] = $data_field; - $value = $row[$data_type][$data_field]; - } - } - $field['related'] = $related; - } else { - $value = $row[$field['field']]; - } - - $field['view'] = $attr; - if ($field['form_type']) { - return FieldService::{'content_' . $field['form_type']}($field, $value, $row, $permission = []); - } else { - return FieldService::{'content_text'}($field, $value, $row, $permission = []); - } - } - public static function make2($options) { - $assets = UserAsset::getNowRoleAssets(); + $assets = UserAssetService::getNowRoleAssets(); // 权限查询类型 $table = $options['table']; @@ -1668,11 +1506,11 @@ class Form $auth = auth()->user(); // 表数据 - $flow = DB::table('flow') + $flow = DB::table('model') ->where('table', $table) ->first(); - $fields = DB::table('flow_field') + $fields = DB::table('model_field') ->where('model_id', $flow['id']) ->orderBy('sort', 'asc') ->get()->keyBy('field'); @@ -1684,7 +1522,6 @@ class Form $js .= '$(function() {'; $html = ''; - $data_links = []; $col = 0; $sublist_status = false; $tabs = []; @@ -1693,27 +1530,6 @@ class Form $_master_data = Hook::fire($table . '.onBeforeForm', ['options' => $options, 'permission' => $permission, 'model' => $flow, 'fields' => $fields, 'views' => $views, 'row' => $row]); extract($_master_data); - // 处理关系查询 - $relateds = []; - foreach ($fields as $field) { - $data_type = $field['data_type']; - $data_link = $field['data_link']; - if ($data_type) { - $relateds[$data_link.'.'.$data_type]['id'] = $row[$data_link]; - $relateds[$data_link.'.'.$data_type]['table'] = $data_type; - if (empty($field['type'])) { - $data_links[$data_type] = [ - 'field' => $data_link, - 'data' => $row[$data_link], - ]; - } - } - } - // 查询本表和其他表的关联表数据 - foreach($relateds as $related) { - $row[$related['table']] = DB::table($related['table'])->where('id', $related['id'])->first(); - } - $tpls = []; $sublist = []; @@ -1800,6 +1616,97 @@ class Form return $tpl; } + public static function getField($flow, $table, $action, $row, $attr, $field) { + $field['model'] = $flow; + $attribute = []; + if ($action == 'show') { + $field['is_show'] = true; + } + + $p = []; + + $p['w'] = $attr['read'] == 1 ? 0 : 1; + + $p['s'] = $attr['hidden'] == 1 ? 1 : 0; + + $field['is_print'] = $action == 'print'; + $field['is_write'] = $p['w'] == 1 ? 1 : 0; + $field['is_read'] = $p['w'] == 1 ? 0 : 1; + $field['is_auto'] = $p['m'] == 1 ? 1 : 0; + $field['is_hide'] = $p['s'] == 1 ? 1 : $field['is_hide']; + + $validate = (array) $p['v']; + + if ($action == 'print') { + $field['is_show'] = true; + } + + if ($action == 'print') { + } else { + $required = ''; + if (in_array('required', $validate)) { + $required = '* '; + if ($field['is_write']) { + $attribute['required'] = 'required'; + if ($field['is_auto'] == 0) { + $attribute['class'][] = 'input-required'; + } else { + $attribute['class'][] = 'input-auto'; + } + } + } + } + + $field['verify'] = $validate; + $field['attribute'] = $attribute; + $field['table'] = $table; + + $tooltip = $field['tips'] ? ' ' : ''; + + if ($action == 'show' || $action == 'print') { + $tooltip = ''; + $required = ''; + } + + $_replace['{' . $field['name'] . '}'] = $required . $field['name'] . $tooltip; + + $data_type = $field['data_type']; + $data_field = $field['data_field']; + $data_link = $field['data_link']; + if ($data_type) { + $related = []; + if (strpos($data_field, ':')) { + list($var1, $var2) = explode(':', $data_field); + list($_v1, $_v2) = explode('.', $var1); + list($_t1, $_t2) = explode('.', $var2); + if ($field['type']) { + $related['table'] = $table; + $related['field'] = $field['field']; + } else { + $related['table'] = $_t1; + $related['field'] = $_v2; + } + } else { + if ($field['type']) { + $related['table'] = $table; + $related['field'] = $field['field']; + } else { + $related['table'] = $data_type; + $related['field'] = $data_field; + } + } + $field['related'] = $related; + } + $value = $row[$field['field']]; + + $field['view'] = $attr; + if ($field['form_type']) { + return FieldService::{'content_' . $field['form_type']}($field, $value, $row, $permission = []); + } else { + return FieldService::{'content_text'}($field, $value, $row, $permission = []); + } + } + public static function flowRules($models, $gets) { $master = $gets['master']; @@ -2085,7 +1992,7 @@ class Form return hash_equals($sessionToken, $token); } - public static function dataFilter2($table, $fields, $permissions, $master, $values) + public static function dataFilter($table, $fields, $permissions, $master, $values) { $permission = $permissions[$table]; @@ -2202,7 +2109,7 @@ class Form // 格式化子表数据格式 foreach ($rows as $i => $row) { - $rows[$i] = static::dataFilter2($table, $fields, $permissions, $master, $row); + $rows[$i] = static::dataFilter($table, $fields, $permissions, $master, $row); } $datas[] = [ @@ -2214,7 +2121,7 @@ class Form ]; } else { // 处理主表的字段格式 - $gets[$t] = static::dataFilter2($table, $fields, $permissions, $master, $gets[$t]); + $gets[$t] = static::dataFilter($table, $fields, $permissions, $master, $gets[$t]); } } diff --git a/app/Gdoo/Model/Grid.php b/app/Gdoo/Model/Grid.php index 1c8e034c..4b910750 100644 --- a/app/Gdoo/Model/Grid.php +++ b/app/Gdoo/Model/Grid.php @@ -289,7 +289,7 @@ class Grid return $rows; } - public static function columnFormat($table, $row, &$join, &$select, &$index, &$column, &$search, $setting) + public static function fieldRelated($table, $row, &$join, &$select, &$index, &$column, &$search, $setting) { if ($row['data_type']) { $data_type = $row['data_type']; @@ -325,8 +325,9 @@ class Grid } else { if ($row['type']) { $column = $column.'_'.$_c2; + } else { + $column = $column; } - $column = $column; } } else { @@ -532,7 +533,7 @@ class Grid } } - static::columnFormat($_table, $row, $join, $select, $index, $column, $_search, $setting); + static::fieldRelated($_table, $row, $join, $select, $index, $column, $_search, $setting); $_search['field2'] = $index; if ($row['form_type'] == 'urd') { @@ -872,7 +873,7 @@ class Grid $index = $field; $_search = ['field' => $index]; - static::columnFormat($_table, $row, $join, $select, $index, $column, $_search, $setting); + static::fieldRelated($_table, $row, $join, $select, $index, $column, $_search, $setting); if ($row['form_type'] == 'urd') { $field = str_replace('_id', '_text', $field); diff --git a/app/Gdoo/Model/Services/FieldService.php b/app/Gdoo/Model/Services/FieldService.php index 88c8f4d2..89284ba6 100644 --- a/app/Gdoo/Model/Services/FieldService.php +++ b/app/Gdoo/Model/Services/FieldService.php @@ -19,11 +19,10 @@ class FieldService 'text' => 'text(单行文本)', 'textarea' => 'textarea(多行文本)', 'password' => 'password(密码文本)', - 'option' => 'option(选项菜单)', + 'option' => 'enum(枚举)', 'radio' => 'radio(单选按钮)', 'select' => 'select(下拉菜单)', 'select2' => 'select2(下拉菜单)', - 'autocomplete' => 'autocomplete(自动完成)', 'checkbox' => 'checkbox(复选框)', 'dialog' => 'dialog(对话框)', 'urd' => 'urd(权限对话框)', @@ -41,8 +40,6 @@ class FieldService 'notification' => 'notification(通知)', 'sn' => 'sn(单据编号)', 'audit' => 'audit(审核状态)', - 'auditsign' => '审批(单人)', - 'auditsign2' => '审批(多人)', 'custom' => 'custom(自定义)', ]; } @@ -431,25 +428,26 @@ class FieldService } else { $setting = $field['setting']; } - + + $attribute = $field['attribute']; + if ($field['data_type']) { if ($field['type']) { - $field['data'] = $field['table'].'['.$field['field'].']'; - $field['key'] = $field['table'].'_'.$field['field']; + $name = $field['table'].'['.$field['field'].']'; + $id = $field['table'].'_'.$field['field']; } else { - $field['data'] = $field['data_type'].'['.$field['data_field'].']'; - $field['key'] = $field['data_type'].'_'.$field['data_field']; + $id = $field['table'].'_'.$field['field']; } } else { if ($field['type']) { - $field['data'] = $field['table'].'['.$field['field'].']'; - $field['key'] = $field['table'].'_'.$field['field']; + $name = $field['table'].'['.$field['field'].']'; + $id = $field['table'].'_'.$field['field']; } else { - $field['key'] = $field['table'].'_'.$field['field']; + $id = $field['table'].'_'.$field['field']; } } - $attribute = $field['attribute']; + $attribute['key'] = $field['table'].'.'.$field['field']; $attribute['class'][] = 'form-control'; $attribute['class'][] = 'input-sm'; @@ -474,11 +472,12 @@ class FieldService $attribute['autocomplete'] = 'off'; - $attribute['id'] = $field['key']; - $attribute['name'] = $field['data']; + $attribute['id'] = $id; + $attribute['name'] = $name; $field['attribute'] = $attribute; $field['setting'] = $setting; + $field['auth_id'] = auth()->id(); return $field; } @@ -649,27 +648,26 @@ class FieldService $_content = explode("\n", $content); + $attribute = $field['attribute']; + $id = $attribute['id']; + $name = $attribute['name']; + $class = ['form-control','input-sm']; - - $attribute[] = 'class="'. join(' ', $class).'"'; - - $attr = join(' ', $attribute); - - $field['attribute']['placeholder'] = '街道'; + $attr = 'class="'. join(' ', $class).'"'; $readonly = ''; if ($field['is_read']) { $readonly = 'readonly="readonly"'; } - $str = '
'; - $str .= ' '; - $str .= ' '; - $str .= ' '; + $str = '
'; + $str .= ' '; + $str .= ' '; + $str .= ' '; $str .= '
'; if ($readonly == '') { - $pcas = 'new pcas("'.$field['key'].'_0", "'.$field['key'].'_1", "'.$field['key'].'_2", "'.$_content[0].'", "'.$_content[1].'", "'.$_content[2].'");'; + $pcas = 'new pcas("'.$id.'_0", "'.$id.'_1", "'.$id.'_2", "'.$_content[0].'", "'.$_content[1].'", "'.$_content[2].'");'; $str .= ''; } return $str; @@ -678,6 +676,8 @@ class FieldService public static function content_region($field, $content = '', $row) { $field = static::content_field($field); + $attribute = $field['attribute']; + $id = $attribute['id']; if ($field['is_show']) { $ids = [$row['province_id'], $row['city_id'], $row['county_id']]; @@ -685,19 +685,19 @@ class FieldService return join(' ', $content); } - $attr = 'class="'. join(' ', $field['attribute']['class']).'"'; + $attr = 'class="'. join(' ', $attribute['class']).'"'; $readonly = ''; if ($field['is_read']) { $readonly = 'readonly="readonly"'; } - $str = '
'; - $str .= ' '; - $str .= ' '; + $str = '
'; + $str .= ' '; + $str .= ' '; $str .= '
'; if ($readonly == '') { - $pcas = 'new regionSelect("'.$field['key'].'_0", "'.$field['key'].'_1", "'.$field['key'].'_2", "'.$row['province_id'].'", "'.$row['city_id'].'", "'.$row['county_id'].'");'; + $pcas = 'new regionSelect("'.$id.'_0", "'.$id.'_1", "'.$id.'_2", "'.$row['province_id'].'", "'.$row['city_id'].'", "'.$row['county_id'].'");'; $str .= ''; } return $str; @@ -731,12 +731,13 @@ class FieldService public static function content_editor($field, $content = '') { $field = static::content_field($field); - + $attribute = $field['attribute']; + if ($field['is_show']) { return $content; } - return ueditor($field['data'], $content); + return ueditor($attribute['name'], $content); } public static function content_notification($field, $content = '') @@ -769,7 +770,11 @@ class FieldService list($k, $v) = explode('=', $setting['query']); if (strpos($v, '$') === 0) { $v = substr($v, 1); - $query[$k] = $row[$v]; + if ($v == 'auth_id') { + $query[$k] = $row[$v]; + } else { + $query[$k] = $row[$v]; + } } else { $query[$k] = explode(',', $v); } @@ -865,7 +870,7 @@ class FieldService return $str . ''; } - public static function content_autocomplete($field, $content = '', $row = []) + public static function content_select2($field, $content = '', $row = []) { $field = static::content_field($field); $setting = $field['setting']; @@ -920,22 +925,11 @@ class FieldService $multi = (int)!$setting['single']; - if ($related) { - $id = $related['table'].'_'.$related['field']; - $key = $related['table'].'.'.$related['field']; - $id_name = $related['table'].'['.$related['field'].']'; - } else { - $id = $field['table'].'_'.$field['field']; - $key = $field['table'].'.'.$field['field']; - $id_name = $field['table'].'['.$field['field'].']'; - } - - $attribute['id'] = $id; - $attribute['key'] = $key; - $attribute['name'] = $id_name; + $id = $attribute['id']; + $name = $attribute['name']; if ($field['is_read']) { - $html[] = ''; + $html[] = ''; return join("\n", $html); } else { $html[] = ''; @@ -957,82 +951,6 @@ class FieldService } } - public static function content_select2($field, $content = '', $row = []) - { - $field = static::content_field($field); - $setting = $field['setting']; - $related = $field['related']; - - $value = $content == 0 ? '' : $content; - - $dialog = ModuleService::dialogs($field['data_type']); - - $rows = []; - $ids = explode(',', $value); - if ($value) { - $rows = $dialog['model']($ids)->pluck('name', 'id')->toArray(); - } - - if ($field['is_show']) { - return join(',', $rows); - } - - $options = []; - foreach ($rows as $k => $v) { - $options[] = ''; - } - - $relations = explode(',', $setting['query']); - $query = ['select2' => 'true']; - if ($relations) { - foreach ($relations as $relation) { - if ($relation) { - list($k, $v) = explode('=', $relation); - $query[$v] = $row[$k]; - } - } - } - - $attribute = $field['attribute']; - - $css = ''; - if($attribute['required']) { - $css = 'input-select2-required'; - } - - $attribute['class'][] = 'input-select2-custom'; - - $multi = (int)!$setting['single']; - $id = $related['table'].'_'.$related['field']; - $id_key = $related['table'].'.'.$related['field']; - $id_name = $related['table'].'['.$related['field'].']'; - - $attribute['id'] = $id; - $attribute['name'] = $id_name; - $attribute['key'] = $id_key; - - if ($field['is_read']) { - $html[] = ''; - return join("\n", $html); - } else { - $html[] = ''; - $select2_options = [ - 'placeholder' => '请选择'.$field['name'], - 'width' => '100%', - 'allowClear' => true, - 'search_key' => $field['data_type'], - 'containerCssClass' => $css, - 'multiple' => $multi, - 'ajaxParams' => $query, - 'ajax' => [ - 'url' => url($dialog['url']), - ], - ]; - $html[] = ''; - return join("\n", $html); - } - } - public static function content_dialog($field, $content = '', $row = []) { $field = static::content_field($field); @@ -1050,22 +968,25 @@ class FieldService } $dialog = ModuleService::dialogs($setting['type']); - $multi = (int)!$setting['single']; if ($related) { - $id_key = $related['table'].'_'.$related['field']; - $id_name = $related['table'].'['.$related['field'].']'; } else { - $id_key = $field['table'].'_'.$field['field']; - $id_name = $field['table'].'['.$field['field'].']'; $related['field'] = $field['field']; $related['table'] = $field['table']; } + $attribute = $field['attribute']; + $id = $attribute['id']; + $name = $attribute['name']; + $rows = ''; if ($value) { - $ids = explode(',', $value); - $rows = $dialog['model']($ids)->implode(','); + if ($field['type']) { + $ids = explode(',', $value); + $rows = $dialog['model']($ids)->implode(','); + } else { + $rows = $value; + } } if ($field['is_print']) { @@ -1073,7 +994,7 @@ class FieldService } if ($field['is_show']) { - return ''.$rows; + return ''.$rows; } if ($field['is_hide'] == 1) { @@ -1086,15 +1007,15 @@ class FieldService $width = '153px'; } if ($setting['width']) { - //$width = $setting['width'].'px'; + // $width = $setting['width'].'px'; } - $html[] = '
'; + $html[] = '
'; } else { if ($setting['css'] == 'input-inline') { $width = '225px'; } if ($setting['width']) { - //$width = $setting['width'].'px'; + // $width = $setting['width'].'px'; } $attribute = $field['attribute']; @@ -1124,10 +1045,10 @@ class FieldService foreach ($query as $k => $v) { $jq .= ' data-'.$k.'="'. $v.'"'; } - $html[] = '
'; - $html[] = ''; + $html[] = '
'; + $html[] = ''; $html[] = ''; } $html[] = '
'; @@ -1139,11 +1060,12 @@ class FieldService { $field = static::content_field($field); $setting = $field['setting']; + $attribute = $field['attribute']; - $id = $field['data']; - $name = str_replace('_id', '_name', $id); - $key_id = $field['key']; - $key_name = str_replace('_id', '_name', $key_id); + $attr_id = $attribute['id']; + $attr_name = $attribute['name']; + $name = str_replace('_id', '_name', $attr_name); + $key_name = str_replace('_id', '_name', $attr_id); $v_id = $field['field']; $v_name = str_replace('_id', '_name', $v_id); @@ -1154,7 +1076,7 @@ class FieldService 'name' => $key_name, 'title' => '', 'url' => 'index/api/dialog', - 'id' => $key_id, + 'id' => $attr_id, 'toggle' => 'dialog-view' ]; @@ -1177,7 +1099,7 @@ class FieldService if ($setting['width']) { $width = $setting['width'].'px'; } - $html[] = '
'; + $html[] = '
'; } else { if ($setting['css'] == 'input-inline') { $width = '225px'; @@ -1185,12 +1107,12 @@ class FieldService if ($setting['width']) { $width = $setting['width'].'px'; } - $html[] = '
'; + $html[] = '
'; $html[] = '
'; - $html[] = ''; + $html[] = ''; $html[] = '
'; } - $html[] = ''; + $html[] = ''; $html[] = '
'; return join("\n", $html); @@ -1223,8 +1145,6 @@ class FieldService $field['attribute']['onchange'] = 'this.selectedIndex=this.defaultIndex;'; } - $id = $field['attribute']['id']; - $width = '100%'; if ($setting['css'] == 'input-inline') { $width = '153px'; @@ -1315,6 +1235,7 @@ class FieldService { $field = static::content_field($field); $setting = $field['setting']; + $select = explode("\n", $setting['content']); $str = []; $w = $permission[$field['field']]['w'] == 1 ? '' : 'disabled="disabled"'; @@ -1336,6 +1257,7 @@ class FieldService $attribute = $field['attribute']; unset($attribute['class']); $id = $attribute['id']; + $name = $attribute['name']; foreach ($select as $i => $t) { @@ -1345,9 +1267,9 @@ class FieldService $checked = $content == $v ? 'checked="checked"' : ''; $attribute['id'] = $id.'_'.$i; if ($field['is_show']) { - $str[] = '
'; + $str[] = '
'; } else { - $str[] = '
'; + $str[] = '
'; } } return join('', $str); @@ -1356,12 +1278,15 @@ class FieldService public static function content_checkbox($field, $content = '', $row = [], $permission = []) { $field = static::content_field($field); - // 配置 $setting = $field['setting']; $default = $setting['default']; $content = is_null($content) ? $default : $content; $str = []; + $attribute = $field['attribute']; + $id = $attribute['id']; + $name = $attribute['name']; + $_select = explode("\n", $setting['content']); if ($field['is_print']) { foreach ($_select as $t) { @@ -1383,7 +1308,7 @@ class FieldService if ($field['is_show']) { $str[] = ''; } else { - $str[] = ''; + $str[] = ''; } } else { foreach ($_select as $t) { @@ -1407,11 +1332,14 @@ class FieldService public static function content_image($field, $content = '') { $field = static::content_field($field); - $attribute = $field['attribute']; $setting = $field['setting']; + $attribute = $field['attribute']; $attribute['readonly'] = 'readonly'; + $id = $attribute['id']; + $name = $attribute['name']; + if ($field['is_show']) { if (empty($content)) { $src = 'assets/images/nopic.jpg'; @@ -1419,7 +1347,7 @@ class FieldService $src = 'uploads/'.$content; } return ' -
+
@@ -1432,16 +1360,16 @@ class FieldService $src = 'uploads/'.$content; $close = '×'; } - $dialog = "mediaDialog('system/media/dialog', '".$field['data']."', '".$field['key']."', 0)"; + $dialog = "mediaDialog('system/media/dialog', '".$name."', '".$id."', 0)"; $str = '
-
+
- + '.$close.'
@@ -1453,13 +1381,16 @@ class FieldService public static function content_images($field, $content = '') { $field = static::content_field($field); - $attribute = $field['attribute']; $setting = $field['setting']; + $attribute = $field['attribute']; + $id = $attribute['id']; + $name = $attribute['name']; + $attribute['readonly'] = 'readonly'; if ($field['is_show']) { - $html = '
'; + $html = '
'; if (empty($content)) { $src = 'assets/images/nopic.jpg'; $html .= '
@@ -1481,19 +1412,19 @@ class FieldService $src = 'assets/images/nopic.jpg'; $items .= '
- +
'; } else { $srcs = explode("\n", $content); foreach($srcs as $src) { $items .= '
- + ×
'; } } - $dialog = "mediaDialog('system/media/dialog', '".$field['data']."', '".$field['key']."', 1)"; + $dialog = "mediaDialog('system/media/dialog', '".$name."', '".$id."', 1)"; $html = '
@@ -1501,7 +1432,7 @@ class FieldService
'; - $html .= '
'; + $html .= '
'; $html .= $items; $html .= '
'; } @@ -1511,27 +1442,30 @@ class FieldService public static function content_location($field, $content = '', $row) { $field = static::content_field($field); - $attribute = $field['attribute']; $setting = $field['setting']; + + $attribute = $field['attribute']; + $id = $attribute['id']; + $name = $attribute['name']; + $attribute['readonly'] = 'readonly'; if ($field['is_show']) { return ' -
+ '; } else { - $dialog = "locationDialog('system/map/dialog', '".$field['data']."', '".$field['key']."', 0)"; $str = ' -
- - - +
+ + +
'; } return $str; @@ -1555,10 +1489,13 @@ class FieldService $field = static::content_field($field); $setting = $field['setting']; - $_setting = Setting::where('type', 'system')->pluck('value', 'key'); + $attribute = $field['attribute']; + $name = $attribute['name']; + $key = $attribute['key']; - $key = str_replace(['[',']'], ['.',''], $field['data']); - $input_id = str_replace('.', '_', $key); + $config = Setting::where('type', 'system')->pluck('value', 'key'); + + $input_id = $attribute['id']; $attachment = AttachmentService::edit($content, $key); @@ -1605,7 +1542,7 @@ class FieldService ! <%=name%> (<%=size%>) - +
@@ -1622,7 +1559,7 @@ class FieldService } */ - $str .= ' 文件上传'; + $str .= ' 文件上传'; /* 扫码上传 @@ -1636,7 +1573,7 @@ class FieldService '.$file['name'].' ('.human_filesize($file['size']).') - +
'; } @@ -1650,7 +1587,7 @@ class FieldService ! '.$file['name'].' ('.human_filesize($file['size']).') - +
'; } diff --git a/app/Gdoo/Order/views/order/create.blade.php b/app/Gdoo/Order/views/order/create.blade.php index 7eb9f421..5106e197 100644 --- a/app/Gdoo/Order/views/order/create.blade.php +++ b/app/Gdoo/Order/views/order/create.blade.php @@ -145,7 +145,6 @@ var form_action = '{{$action}}'; params.resultCache = false; }, query(query) { - query.field_0 = 'customer_delivery_address.address'; query.customer_id = get_customer_id(); }, onSelect(row) { diff --git a/app/Gdoo/Product/Controllers/ProductController.php b/app/Gdoo/Product/Controllers/ProductController.php index 4513124b..26379bed 100644 --- a/app/Gdoo/Product/Controllers/ProductController.php +++ b/app/Gdoo/Product/Controllers/ProductController.php @@ -163,11 +163,12 @@ class ProductController extends DefaultController $header['select'][] = 'product.weight'; $model->select($header['select']); + $q = $query['q']; + if ($q) { + $model->whereRaw("(product.code like '%$q%' or product.name like '%$q%' or product.spec like '%$q%' or product.barcode like '%$q%')"); + } + if ($query['suggest']) { - if ($query['q']) { - $q = $query['q']; - $model->whereRaw("(product.code like '%$q%' or product.name like '%$q%' or product.spec like '%$q%' or product.barcode like '%$q%')"); - } $rows = $model->limit(15)->get(); $data = Grid::dataFilters($rows, $header, function($item) { return $item; @@ -245,11 +246,12 @@ class ProductController extends DefaultController $model->select($header['select']); + $q = $query['q']; + if ($q) { + $model->whereRaw("(product.code like '%$q%' or product.name like '%$q%' or product.spec like '%$q%' or product.barcode like '%$q%')"); + } + if ($query['suggest']) { - if ($query['q']) { - $q = $query['q']; - $model->whereRaw("(product.code like '%$q%' or product.name like '%$q%' or product.spec like '%$q%' or product.barcode like '%$q%')"); - } $rows = $model->limit(15)->get(); $data = Grid::dataFilters($rows, $header, function($item) { return $item; diff --git a/app/Gdoo/Stock/Controllers/AllocationController.php b/app/Gdoo/Stock/Controllers/AllocationController.php index 632d926d..05c786e7 100644 --- a/app/Gdoo/Stock/Controllers/AllocationController.php +++ b/app/Gdoo/Stock/Controllers/AllocationController.php @@ -192,7 +192,7 @@ class AllocationController extends WorkflowController DB::table('stock_allocation')->where('id', $id)->update($gets); return $this->json('物流信息提交成功。', true); } - $file = base_path().'/addons/'.ucfirst(Request::module()).'/views/'.Request::controller().'/'.Request::action().'.html'; + $file = base_path().'/app/Gdoo/'.ucfirst(Request::module()).'/views/'.Request::controller().'/'.Request::action().'.html'; $id = Request::get('id'); $row = Allocation::find($id); $freight_quantity = floatval($row['freight_quantity']); @@ -205,7 +205,7 @@ class AllocationController extends WorkflowController $row['freight_quantity'] = $quantity; $row['freight_weight'] = $weight; } - $form = Form::make1(['table' => 'stock_allocation', 'file' => $file, 'row' => $row]); + $form = Form::make2(['table' => 'stock_allocation', 'file' => $file, 'row' => $row]); return $form; } diff --git a/app/Gdoo/Stock/Controllers/DeliveryController.php b/app/Gdoo/Stock/Controllers/DeliveryController.php index e193d788..7b3bc6d1 100644 --- a/app/Gdoo/Stock/Controllers/DeliveryController.php +++ b/app/Gdoo/Stock/Controllers/DeliveryController.php @@ -390,7 +390,7 @@ class DeliveryController extends WorkflowController DB::table('stock_delivery')->where('id', $id)->update($gets); return $this->json('物流信息提交成功。', true); } - $file = base_path().'/addons/'.ucfirst(Request::module()).'/views/'.Request::controller().'/'.Request::action().'.xml'; + $file = base_path().'/app/Gdoo/'.ucfirst(Request::module()).'/views/'.Request::controller().'/'.Request::action().'.xml'; $id = Request::get('id'); $row = Delivery::find($id); $freight_quantity = floatval($row['freight_quantity']); @@ -404,7 +404,7 @@ class DeliveryController extends WorkflowController $row['freight_quantity'] = $quantity; $row['freight_weight'] = $weight; } - $form = Form::make1(['table' => 'stock_delivery', 'file' => $file, 'row' => $row]); + $form = Form::make2(['table' => 'stock_delivery', 'file' => $file, 'row' => $row]); return $form; } diff --git a/app/Gdoo/Stock/views/allocation/logistics.html b/app/Gdoo/Stock/views/allocation/logistics.html index afb3935c..b35c3bd7 100644 --- a/app/Gdoo/Stock/views/allocation/logistics.html +++ b/app/Gdoo/Stock/views/allocation/logistics.html @@ -1,105 +1,109 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -