diff --git a/application/admin/form/Goods.php b/application/admin/form/Goods.php index aa8e6a521f68d57f055752861e4e9773e25f620e..1b478856b42636cb33cd69d2f8466c2b50a69440 100644 --- a/application/admin/form/Goods.php +++ b/application/admin/form/Goods.php @@ -66,7 +66,7 @@ class Goods 'label' => '商品ID', 'view_type' => 'field', 'view_key' => 'id', - 'width' => 120, + 'width' => 105, 'search_config' => [ 'form_type' => 'input', 'form_name' => 'id', diff --git a/application/admin/form/Order.php b/application/admin/form/Order.php new file mode 100644 index 0000000000000000000000000000000000000000..af3561a719deed3ec52c2d647b279941a8648964 --- /dev/null +++ b/application/admin/form/Order.php @@ -0,0 +1,334 @@ + [ + 'key_field' => 'id', + 'status_field' => 'is_shelves', + 'is_search' => 1, + 'search_url' => MyUrl('admin/order/index'), + ], + // 表单配置 + 'form' => [ + [ + 'label' => '订单ID', + 'view_type' => 'field', + 'view_key' => 'id', + 'width' => 105, + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => '=', + ], + ], + [ + 'label' => '订单号', + 'view_type' => 'field', + 'view_key' => 'order_no', + 'width' => 170, + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => '=', + ], + ], + [ + 'label' => '基础信息', + 'view_type' => 'module', + 'view_key' => 'order/module/info', + 'grid_size' => 'lg', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'id', + 'where_type' => 'in', + 'placeholder' => '请输入商品名称/型号', + 'where_custom' => 'WhereValueBaseInfo', + ], + ], + [ + 'label' => '用户信息', + 'view_type' => 'module', + 'view_key' => 'order/module/user', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'user_id', + 'where_type' => 'in', + 'placeholder' => '请输入用户名/昵称/手机/邮箱', + 'where_custom' => 'WhereValueUserInfo', + ], + ], + [ + 'label' => '地址信息', + 'view_type' => 'module', + 'view_key' => 'order/module/address', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'user_id', + 'where_type' => 'in', + 'placeholder' => '请输入收件姓名/电话/地址', + 'where_custom' => 'WhereValueAddressInfo', + ], + ], + [ + 'label' => '取货信息', + 'view_type' => 'module', + 'view_key' => 'order/module/take', + 'width' => 120, + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'id', + 'where_type' => '=', + 'placeholder' => '请输入取货码', + 'where_custom' => 'WhereValueAddressInfo', + ], + ], + [ + 'label' => '订单状态', + 'view_type' => 'module', + 'view_key' => 'order/module/status', + 'width' => 120, + 'search_config' => [ + 'form_type' => 'select', + 'form_name' => 'status', + 'where_type' => 'in', + 'data' => lang('common_order_admin_status'), + 'data_key' => 'id', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '支付状态', + 'view_type' => 'module', + 'view_key' => 'order/module/pay_status', + 'width' => 120, + 'search_config' => [ + 'form_type' => 'select', + 'form_name' => 'pay_status', + 'where_type' => 'in', + 'data' => lang('common_order_pay_status'), + 'data_key' => 'id', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '订单模式', + 'view_type' => 'field', + 'view_key' => 'order_model_name', + 'width' => 120, + 'search_config' => [ + 'form_type' => 'select', + 'form_name' => 'order_model', + 'where_type' => 'in', + 'data' => lang('common_site_type_list'), + 'data_key' => 'id', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '来源', + 'view_type' => 'field', + 'view_key' => 'client_type_name', + 'width' => 120, + 'search_config' => [ + 'form_type' => 'select', + 'form_name' => 'client_type', + 'where_type' => 'in', + 'data' => lang('common_platform_type'), + 'data_key' => 'id', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '单价(元)', + 'view_type' => 'field', + 'view_key' => 'price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '总价(元)', + 'view_type' => 'field', + 'view_key' => 'total_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '支付金额(元)', + 'view_type' => 'field', + 'view_key' => 'pay_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '退款金额(元)', + 'view_type' => 'field', + 'view_key' => 'refund_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '退货数量', + 'view_type' => 'field', + 'view_key' => 'returned_quantity', + 'search_config' => [ + 'form_type' => 'section', + ], + ], + [ + 'label' => '增加金额(元)', + 'view_type' => 'field', + 'view_key' => 'increase_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '优惠金额(元)', + 'view_type' => 'field', + 'view_key' => 'preferential_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '支付方式', + 'view_type' => 'field', + 'view_key' => 'payment_name', + 'search_config' => [ + 'form_type' => 'select', + 'form_name' => 'payment_id', + 'where_type' => 'in', + 'data' => PaymentService::PaymentList(), + 'data_key' => 'id', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '扩展信息', + 'view_type' => 'module', + 'view_key' => 'order/module/extension', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'extension_data', + 'where_type' => 'like', + ], + ], + [ + 'label' => '快递信息', + 'view_type' => 'module', + 'view_key' => 'order/module/express', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'express_number', + 'where_type' => 'like', + 'placeholder' => '请输入快递单号', + ], + ], + [ + 'label' => '最新售后', + 'view_type' => 'module', + 'view_key' => 'order/module/aftersale', + 'grid_size' => 'sm', + ], + [ + 'label' => '操作', + 'view_type' => 'operate', + 'view_key' => 'order/module/operate', + 'align' => 'center', + 'fixed' => 'right', + ], + ], + ]; + } + + /** + * 商品分类条件处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-06-03 + * @desc description + * @param [string] $name [字段名称] + * @param [array] $params [输入参数] + */ + public function WhereValueGoodsCategory($value, $params = []) + { + if(!empty($value)) + { + // 是否为数组 + if(!is_array($value)) + { + $value = [$value]; + } + + // 获取分类下的所有分类 id + $category_ids = GoodsService::GoodsCategoryItemsIds($value, 1); + + // 获取商品 id + $goods_ids = Db::name('GoodsCategoryJoin')->where(['category_id'=>$category_ids])->column('goods_id'); + + // 避免空条件造成无效的错觉 + return empty($goods_ids) ? [0] : $goods_ids; + } + return $value; + } +} \ No newline at end of file diff --git a/application/admin/view/default/order/index.html b/application/admin/view/default/order/index.html index 4d22aeb6d4724502ab11e168a5fa0e844e4b48b2..907d6eab95e767c1fc9a3b87019485f42b200cbc 100755 --- a/application/admin/view/default/order/index.html +++ b/application/admin/view/default/order/index.html @@ -1,483 +1,2 @@ -{{include file="public/header" /}} - - -
-
- - - - - -
- - {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} -
- plugins_view_admin_order_top_operate -
- {{/if}} - {{php}} - $hook_name = 'plugins_view_admin_order_top_operate'; - $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>true]); - if(!empty($hook_data) && is_array($hook_data)) - { - foreach($hook_data as $hook) - { - if(is_string($hook) || is_int($hook)) - { - echo htmlspecialchars_decode($hook); - } - } - } - {{/php}} -
- - - -
- - - - - - - - - - - - - - - - {{if !empty($data_list)}} - {{foreach $data_list as $v}} - - - - - - - - - - - - {{/foreach}} - {{/if}} - -
基础信息用户信息地址信息订单状态订单金额(元)最新售后快递信息扩展数据操作
-
- {{$v.order_no}} - {{$v.order_model_name}} - {{$v.client_type_name}} -
-
- {{foreach $v.items as $vs}} -
- -
- - {{if !empty($vs.spec_text)}} - {{$vs.spec_text}} - {{/if}} - - {{if $vs['returned_quantity'] gt 0 or $vs['refund_price'] gt 0}} - 已退 {{$vs.returned_quantity}} / {{$vs.refund_price}} - {{/if}} - {{$vs.price}}x{{$vs.buy_number}} -
-
-
- {{/foreach}} -
{{$v.describe}}
-
- {{if in_array($v['order_model'], [0,2])}} - {{$v.address_data.name}}
- {{$v.address_data.tel}}
- {{$v.address_data.province_name}}
- {{$v.address_data.city_name}}
- {{$v.address_data.county_name}}
- {{$v.address_data.address}} - {{else /}} - 无信息 - {{/if}} -
- {{$v.status_name}} - - {{if $v['pay_status'] eq 1}} - {{$v.pay_status_name}} - {{elseif $v['pay_status'] gt 1 /}} - {{$v.pay_status_name}} - {{else /}} - {{$v.pay_status_name}} - {{/if}} - {{if !empty($v['is_under_line_text'])}} - {{$v.is_under_line_text}}

- {{/if}} - {{if $v['user_is_delete_time'] neq 0}} - 用户已删除 - {{/if}} -
- 金额:{{$v.price}}
- 增加:{{$v.increase_price}}
- 优惠:{{$v.preferential_price}}
- 总价:{{$v.total_price}}
- 支付:{{$v.pay_price}}
- 退款:{{if $v['refund_price'] gt 0}}{{$v.refund_price}}{{else /}}{{$v.refund_price}}{{/if}} -
- {{if !empty($v['aftersale_first'])}} - 状态:{{$v.aftersale_first.status_text}}
- 类型:{{$v.aftersale_first.type_text}}
- 金额:{{$v.aftersale_first.price}}
- 数量:{{$v.aftersale_first.number}}
- 原因:{{$v.aftersale_first.reason}} - {{/if}} -
- {{if !empty($v['express_name'])}} - {{$v.express_name}}
{{$v.express_number}} - {{/if}} -
- {{if !empty($v['extension_data'])}} - {{foreach $v.extension_data as $extk=>$ext}} - {{if $extk gt 0}}
{{/if}} - {{$ext.name}} [{{$ext.tips}}] - {{/foreach}} - {{/if}} -
-
- - {{if in_array($v['status'], [0])}} - - {{/if}} - {{if in_array($v['status'], [0,1])}} - - {{if in_array($v['status'], [1])}} - - {{/if}} - {{/if}} - {{if $v['status'] eq 2}} - {{if $v['order_model'] eq 2}} - - {{else /}} - - {{/if}} - {{/if}} - {{if $v['status'] eq 3}} - - {{/if}} - {{if in_array($v['status'], [5,6])}} - - {{/if}} - - - {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} -
- plugins_view_admin_order_list_operate -
- {{/if}} - {{php}} - $hook_name = 'plugins_view_admin_order_list_operate'; - $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>true, 'id'=>$v['id'], 'data'=>$v]); - if(!empty($hook_data) && is_array($hook_data)) - { - foreach($hook_data as $hook) - { - if(is_string($hook) || is_int($hook)) - { - echo htmlspecialchars_decode($hook); - } - } - } - {{/php}} -
-
- {{if empty($data_list)}} -
没有相关数据
- {{/if}} -
- - - -
- - {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} -
- plugins_view_admin_order_bottom_operate -
- {{/if}} - {{php}} - $hook_name = 'plugins_view_admin_order_bottom_operate'; - $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>true]); - if(!empty($hook_data) && is_array($hook_data)) - { - foreach($hook_data as $hook) - { - if(is_string($hook) || is_int($hook)) - { - echo htmlspecialchars_decode($hook); - } - } - } - {{/php}} -
- - - -
-
-
- × -
-
-
-
- - -
-
- - - -
-
-
-
-
- - -
-
-
-

发货操作

- × -
-
-
-
- {{if !empty($express_list)}} -
    - {{foreach $express_list as $express}} - {{if $express.is_enable eq 1}} -
  • - {{if !empty($express.icon)}} - - {{/if}} - {{$express.name}} - -
  • - {{/if}} - {{/foreach}} -
- {{/if}} - {{if empty($express_list)}} -
没有快递方式
- {{/if}} -
- -
- - -
- -
- - - - -
-
-
-
-
- - -
-
-
-

支付操作

- × -
-
-
-
- {{if !empty($buy_payment_list)}} -
    - {{foreach $buy_payment_list as $payment}} -
  • - {{if !empty($payment.logo)}} - - {{/if}} - {{$payment.name}} - -
  • - {{/foreach}} -
- {{/if}} - {{if empty($buy_payment_list)}} -
没有支付方式
- {{/if}} -
-
- - - -
-
-
-
-
- - - {{if !empty($data_list)}} - {{$page_html|raw}} - {{/if}} - -
-
- - - -{{include file="public/footer" /}} - \ No newline at end of file + +{{extend name="public/module/form" /}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/address.html b/application/admin/view/default/order/module/address.html new file mode 100644 index 0000000000000000000000000000000000000000..700378820db06a8a3773f03917d368e558e3a22b --- /dev/null +++ b/application/admin/view/default/order/module/address.html @@ -0,0 +1,13 @@ + +{{if !empty($module_data)}} + {{if in_array($module_data['order_model'], [0,2]) and !empty($module_data['address_data'])}} + {{$module_data.address_data.name}}
+ {{$module_data.address_data.tel}}
+ {{$module_data.address_data.province_name}}
+ {{$module_data.address_data.city_name}}
+ {{$module_data.address_data.county_name}}
+ {{$module_data.address_data.address}} + {{else /}} + 无信息 + {{/if}} +{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/aftersale.html b/application/admin/view/default/order/module/aftersale.html new file mode 100644 index 0000000000000000000000000000000000000000..445efe744fd4c8ea0d8d172292b868e17f0c8ded --- /dev/null +++ b/application/admin/view/default/order/module/aftersale.html @@ -0,0 +1,8 @@ + +{{if !empty($module_data) and !empty($module_data['aftersale_first'])}} +

状态:{{$module_data.aftersale_first.status_text}}

+

类型:{{$module_data.aftersale_first.type_text}}

+

金额:{{$module_data.aftersale_first.price}}

+

数量:{{$module_data.aftersale_first.number}}

+

原因:{{$module_data.aftersale_first.reason}}

+{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/express.html b/application/admin/view/default/order/module/express.html new file mode 100644 index 0000000000000000000000000000000000000000..946f316d9536f7cca500b5c1aeac8c46ff481318 --- /dev/null +++ b/application/admin/view/default/order/module/express.html @@ -0,0 +1,5 @@ + +{{if !empty($module_data) and !empty($module_data['express_name'])}} +

快递:{{$module_data.express_name}}

+

单号:{{$module_data.express_number}}

+{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/extension.html b/application/admin/view/default/order/module/extension.html new file mode 100644 index 0000000000000000000000000000000000000000..3f2c76756d00b6081eb3a46360fa2f5d7cdc64a2 --- /dev/null +++ b/application/admin/view/default/order/module/extension.html @@ -0,0 +1,6 @@ + +{{if !empty($module_data) and !empty($module_data['extension_data'])}} + {{foreach $v.extension_data as $extk=>$ext}} +

{{$ext.name}} [{{$ext.tips}}]

+ {{/foreach}} +{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/info.html b/application/admin/view/default/order/module/info.html new file mode 100644 index 0000000000000000000000000000000000000000..98487a86af085eae40c47da072bb5063bc6639c4 --- /dev/null +++ b/application/admin/view/default/order/module/info.html @@ -0,0 +1,26 @@ + +{{if !empty($module_data) and !empty($module_data['items'])}} + {{foreach $module_data.items as $item}} +
+
+ + + + {{$item.title}} +
+
+ + {{if !empty($item.spec_text)}} + {{$item.spec_text}} + {{/if}} + + {{$item.price}}x{{$item.buy_number}} + {{if $item['returned_quantity'] gt 0 or $item['refund_price'] gt 0}} + 已退 {{$item.returned_quantity}} / {{$item.refund_price}} + {{/if}} +
+
+
+ {{/foreach}} +
{{$module_data.describe}}
+{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/operate.html b/application/admin/view/default/order/module/operate.html new file mode 100644 index 0000000000000000000000000000000000000000..85f7f05b9b51fde4a310776dc08ef48403011096 --- /dev/null +++ b/application/admin/view/default/order/module/operate.html @@ -0,0 +1,48 @@ + + +{{if in_array($module_data['status'], [0])}} + +{{/if}} +{{if in_array($module_data['status'], [0,1])}} + + {{if in_array($module_data['status'], [1])}} + + {{/if}} +{{/if}} +{{if $module_data['status'] eq 2}} + {{if $module_data['order_model'] eq 2}} + + {{else /}} + + {{/if}} +{{/if}} +{{if $module_data['status'] eq 3}} + +{{/if}} +{{if in_array($module_data['status'], [5,6])}} + +{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/pay_status.html b/application/admin/view/default/order/module/pay_status.html new file mode 100644 index 0000000000000000000000000000000000000000..2d2481c2b0c831d503f3b22bf4fcce61fc963e81 --- /dev/null +++ b/application/admin/view/default/order/module/pay_status.html @@ -0,0 +1,13 @@ + +{{if !empty($module_data)}} + {{if $module_data['pay_status'] eq 1}} +

{{$module_data.pay_status_name}}

+ {{elseif $module_data['pay_status'] gt 1 /}} +

{{$module_data.pay_status_name}}

+ {{else /}} +

{{$module_data.pay_status_name}}

+ {{/if}} + {{if !empty($module_data['is_under_line_text'])}} +

{{$module_data.is_under_line_text}}

+ {{/if}} +{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/status.html b/application/admin/view/default/order/module/status.html new file mode 100644 index 0000000000000000000000000000000000000000..3f7b07dced487c99d828db79f66aa7b7837ee2f3 --- /dev/null +++ b/application/admin/view/default/order/module/status.html @@ -0,0 +1,7 @@ + +{{if !empty($module_data)}} +

{{$module_data.status_name}}

+ {{if $module_data['user_is_delete_time'] neq 0}} +

用户已删除

+ {{/if}} +{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/take.html b/application/admin/view/default/order/module/take.html new file mode 100644 index 0000000000000000000000000000000000000000..d6856e9091e365f62ea26c4a547d9b7a44958830 --- /dev/null +++ b/application/admin/view/default/order/module/take.html @@ -0,0 +1,16 @@ + +{{if !empty($module_data) and !empty($module_data['extraction_data'])}} +

+ 取货码: + {{if empty($module_data['extraction_data']['code'])}} + 取货码不存在、请联系管理员 + {{else /}} + {{$module_data.extraction_data.code}} + {{/if}} +

+ {{if !empty($module_data['extraction_data']['images'])}} +

+ 取货码 +

+ {{/if}} +{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/user.html b/application/admin/view/default/order/module/user.html new file mode 100644 index 0000000000000000000000000000000000000000..b6784522a083cff9dc781444a50b67e46b8d9f81 --- /dev/null +++ b/application/admin/view/default/order/module/user.html @@ -0,0 +1,14 @@ + +{{if !empty($module_data)}} + {{if !empty($module_data['user'])}} + {{$module_data.user.user_name_view}} + + {{else /}} + 用户信息异常 + {{/if}} +{{/if}} \ No newline at end of file diff --git a/application/module/FormHandleModule.php b/application/module/FormHandleModule.php index 5886174cc44740abad51b8925175568c1c739b4e..14984980d10990dde748d5d2fc1167c363fdf550 100644 --- a/application/module/FormHandleModule.php +++ b/application/module/FormHandleModule.php @@ -164,181 +164,189 @@ class FormHandleModule break; } } - // 条件处理 - if(!empty($v['search_config']) && !empty($v['search_config']['form_type']) && !empty($v['search_config']['form_name'])) + if(!empty($v['search_config']) && !empty($v['search_config']['form_type'])) { - // 基础数据处理 - // 显示名称 - $label = empty($v['label']) ? '' : $v['label']; - - // 唯一 formkey - $form_key = 'fp'.$k; - $v['form_key'] = $form_key; - - // 根据组件类型处理 - switch($v['search_config']['form_type']) + // 搜索 key 未指定则使用显示数据的字段名称 + if(empty($v['search_config']['form_name'])) { - // 单个输入 - case 'input' : - // 提示信息处理 - if(empty($v['search_config']['placeholder'])) - { - $v['search_config']['placeholder'] = '请输入'.$label; - } - break; - - // 选择 - case 'select' : - // 提示信息处理 - if(empty($v['search_config']['placeholder'])) - { - $v['search_config']['placeholder'] = '请选择'.$label; - } - - // 选择数据 key=>name - if(empty($v['search_config']['data_key'])) - { - $v['search_config']['data_key'] = 'id'; - } - if(empty($v['search_config']['data_name'])) - { - $v['search_config']['data_key'] = 'name'; - } - break; - - // 区间 - case 'section' : - // 提示信息处理 - if(empty($v['search_config']['placeholder_min'])) - { - $v['search_config']['placeholder_min'] = '最小值'; - } - if(empty($v['search_config']['placeholder_max'])) - { - $v['search_config']['placeholder_max'] = '最大值'; - } - break; - - // 时间 - case 'datetime' : - case 'date' : - // 提示信息处理 - if(empty($v['search_config']['placeholder_start'])) - { - $v['search_config']['placeholder_start'] = '开始'; - } - if(empty($v['search_config']['placeholder_end'])) - { - $v['search_config']['placeholder_end'] = '结束'; - } - break; + $v['search_config']['form_name'] = isset($v['view_key']) ? $v['view_key'] : ''; } - // 搜索条件数据处理 - // 表单字段名称 - $name = $v['search_config']['form_name']; - // 条件类型 - $type = isset($v['search_config']['where_type']) ? $v['search_config']['where_type'] : $v['search_config']['form_type']; - // 是否自定义条件处理方法 - $custom = isset($v['search_config']['where_custom']) ? $v['search_config']['where_custom'] : ''; - // 根据条件类型处理 - switch($type) + // 基础数据处理 + if(!empty($v['search_config']['form_name'])) { - // 单个值 - case '=' : - case '<' : - case '>' : - case '<=' : - case '>=' : - case 'like' : - if(array_key_exists($form_key, $this->out_params) && $this->out_params[$form_key] !== null && $this->out_params[$form_key] !== '') - { - // 参数值 - $value = urldecode($this->out_params[$form_key]); - $this->where_params[$form_key] = $value; + // 显示名称 + $label = empty($v['label']) ? '' : $v['label']; - // 条件值处理 - $value = $this->WhereValueHandle($value, $custom); + // 唯一 formkey + $form_key = 'fp'.$k; + $v['form_key'] = $form_key; - // 是否 like 条件 - if($type == 'like') + // 根据组件类型处理 + switch($v['search_config']['form_type']) + { + // 单个输入 + case 'input' : + // 提示信息处理 + if(empty($v['search_config']['placeholder'])) { - $value = '%'.$value.'%'; + $v['search_config']['placeholder'] = '请输入'.$label; } + break; - // 条件 - $this->where[] = [$name, $type, $value]; - } - break; + // 选择 + case 'select' : + // 提示信息处理 + if(empty($v['search_config']['placeholder'])) + { + $v['search_config']['placeholder'] = '请选择'.$label; + } - // in - case 'in' : - if(array_key_exists($form_key, $this->out_params) && $this->out_params[$form_key] !== null && $this->out_params[$form_key] !== '') - { - // 参数值 - $value = urldecode($this->out_params[$form_key]); - if(!is_array($value)) + // 选择数据 key=>name + if(empty($v['search_config']['data_key'])) { - $value = explode(',', $value); + $v['search_config']['data_key'] = 'id'; } - $this->where_params[$form_key] = $value; + if(empty($v['search_config']['data_name'])) + { + $v['search_config']['data_key'] = 'name'; + } + break; - // 条件 - $this->where[] = [$name, $type, $this->WhereValueHandle($value, $custom)]; - } - break; + // 区间 + case 'section' : + // 提示信息处理 + if(empty($v['search_config']['placeholder_min'])) + { + $v['search_config']['placeholder_min'] = '最小值'; + } + if(empty($v['search_config']['placeholder_max'])) + { + $v['search_config']['placeholder_max'] = '最大值'; + } + break; - // 区间值 - case 'section' : - $key_min = $form_key.'_min'; - $key_max = $form_key.'_max'; - if(array_key_exists($key_min, $this->out_params) && $this->out_params[$key_min] !== null && $this->out_params[$key_min] !== '') - { - // 参数值 - $value = urldecode($this->out_params[$key_min]); - $this->where_params[$key_min] = $value; + // 时间 + case 'datetime' : + case 'date' : + // 提示信息处理 + if(empty($v['search_config']['placeholder_start'])) + { + $v['search_config']['placeholder_start'] = '开始'; + } + if(empty($v['search_config']['placeholder_end'])) + { + $v['search_config']['placeholder_end'] = '结束'; + } + break; + } - // 条件 - $this->where[] = [$name, '>=', $this->WhereValueHandle($value, $custom, ['is_min'=>1])]; - } - if(array_key_exists($key_max, $this->out_params) && $this->out_params[$key_max] !== null && $this->out_params[$key_max] !== '') - { - // 参数值 - $value = urldecode($this->out_params[$key_max]); - $this->where_params[$key_max] = $value; + // 搜索条件数据处理 + // 表单字段名称 + $name = $v['search_config']['form_name']; + // 条件类型 + $type = isset($v['search_config']['where_type']) ? $v['search_config']['where_type'] : $v['search_config']['form_type']; + // 是否自定义条件处理方法 + $custom = isset($v['search_config']['where_custom']) ? $v['search_config']['where_custom'] : ''; + // 根据条件类型处理 + switch($type) + { + // 单个值 + case '=' : + case '<' : + case '>' : + case '<=' : + case '>=' : + case 'like' : + if(array_key_exists($form_key, $this->out_params) && $this->out_params[$form_key] !== null && $this->out_params[$form_key] !== '') + { + // 参数值 + $value = urldecode($this->out_params[$form_key]); + $this->where_params[$form_key] = $value; - // 条件 - $this->where[] = [$name, '<=', $this->WhereValueHandle($value, $custom, ['is_end'=>1])]; - } - break; + // 条件值处理 + $value = $this->WhereValueHandle($value, $custom); - // 时间 - case 'datetime' : - case 'date' : - $key_start = $form_key.'_start'; - $key_end = $form_key.'_end'; - if(array_key_exists($key_start, $this->out_params) && $this->out_params[$key_start] !== null && $this->out_params[$key_start] !== '') - { - // 参数值 - $value = urldecode($this->out_params[$key_start]); - $this->where_params[$key_start] = $value; + // 是否 like 条件 + if($type == 'like') + { + $value = '%'.$value.'%'; + } - // 条件 - $this->where[] = [$name, '>=', $this->WhereValueHandle(strtotime($value), $custom, ['is_start'=>1])]; - } - if(array_key_exists($key_end, $this->out_params) && $this->out_params[$key_end] !== null && $this->out_params[$key_end] !== '') - { - // 参数值 - $value = urldecode($this->out_params[$key_end]); - $this->where_params[$key_end] = $value; + // 条件 + $this->where[] = [$name, $type, $value]; + } + break; - // 条件 - $this->where[] = [$name, '<=', $this->WhereValueHandle(strtotime($value), $custom, ['is_end'=>1])]; + // in + case 'in' : + if(array_key_exists($form_key, $this->out_params) && $this->out_params[$form_key] !== null && $this->out_params[$form_key] !== '') + { + // 参数值 + $value = urldecode($this->out_params[$form_key]); + if(!is_array($value)) + { + $value = explode(',', $value); + } + $this->where_params[$form_key] = $value; + + // 条件 + $this->where[] = [$name, $type, $this->WhereValueHandle($value, $custom)]; + } + break; - } - break; + // 区间值 + case 'section' : + $key_min = $form_key.'_min'; + $key_max = $form_key.'_max'; + if(array_key_exists($key_min, $this->out_params) && $this->out_params[$key_min] !== null && $this->out_params[$key_min] !== '') + { + // 参数值 + $value = urldecode($this->out_params[$key_min]); + $this->where_params[$key_min] = $value; + + // 条件 + $this->where[] = [$name, '>=', $this->WhereValueHandle($value, $custom, ['is_min'=>1])]; + } + if(array_key_exists($key_max, $this->out_params) && $this->out_params[$key_max] !== null && $this->out_params[$key_max] !== '') + { + // 参数值 + $value = urldecode($this->out_params[$key_max]); + $this->where_params[$key_max] = $value; + + // 条件 + $this->where[] = [$name, '<=', $this->WhereValueHandle($value, $custom, ['is_end'=>1])]; + } + break; + + // 时间 + case 'datetime' : + case 'date' : + $key_start = $form_key.'_start'; + $key_end = $form_key.'_end'; + if(array_key_exists($key_start, $this->out_params) && $this->out_params[$key_start] !== null && $this->out_params[$key_start] !== '') + { + // 参数值 + $value = urldecode($this->out_params[$key_start]); + $this->where_params[$key_start] = $value; + + // 条件 + $this->where[] = [$name, '>=', $this->WhereValueHandle(strtotime($value), $custom, ['is_start'=>1])]; + } + if(array_key_exists($key_end, $this->out_params) && $this->out_params[$key_end] !== null && $this->out_params[$key_end] !== '') + { + // 参数值 + $value = urldecode($this->out_params[$key_end]); + $this->where_params[$key_end] = $value; + + // 条件 + $this->where[] = [$name, '<=', $this->WhereValueHandle(strtotime($value), $custom, ['is_end'=>1])]; + + } + break; + } } } }