<?php
namespace app\admin\form;
use app\service\LotteryCategoryService;

/**
 * Lottery动态表格
 */
class Lottery {
    // 基础条件
    public $condition_base = [];

    /**
     * 入口
     * @param   [array]           $params [输入参数]
     */
    public function Run($params = []) {
        $lang = MyLang('lottery.form_table');
        return [
            // 基础配置
            'base' => [
                'key_field'     => 'lottery_id',
                'status_field'  => 'is_finish',
                'is_search'     => 1,
                'is_delete'     => 0,
                'is_middle'     => 0,
            ],
            // 表单配置
            'form' => [
                [
                    'view_type'         => 'checkbox',
                    'is_checked'        => 0,
                    'checked_text'      => MyLang('reverse_select_title'),
                    'not_checked_text'  => MyLang('select_all_title'),
                    'align'             => 'center',
                    'width'             => 80,
                ],
                [
                    'label'         => $lang['lottery_id'],
                    'view_type'     => 'field',
                    'view_key'      => 'lottery_id',
                    'width'         => 110,
                    'is_copy'       => 1,
                    'is_sort'       => 1,
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => '=',
                    ],
                ],
                [
                    'label'         => $lang['lottery_date'],
                    'view_type'     => 'field',
                    'view_key'      => 'lottery_date',
                    'is_sort'       => 1,
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => $lang['lotteryissue'],
                    'view_type'     => 'field',
                    'view_key'      => 'lotteryissue',
                    'width'         => 110,
                    'is_copy'       => 1,
                    'is_sort'       => 1,
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => '=',
                    ],
                ],
                [
                    'label'              => $lang['is_finish'],
                    'view_type'          => 'status',
                    'view_key'           => 'is_finish',
                    'post_url'           => MyUrl('admin/lottery/index'),
                    'is_form_su'         => 1,
                    'align'              => 'center',
                    'is_sort'            => 1,
                    'width'              => 130,
                    'params_where_name'  => 'is_finish',
                    'search_config'      => [
                        'form_type'         => 'select',
                        'where_type'        => 'in',
                        'data'              => MyConst('common_is_text_list'),
                        'data_key'          => 'id',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
                    'label'         => $lang['create_time'],
                    'view_type'     => 'field',
                    'view_key'      => 'create_time',
                    'is_sort'       => 1,
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => MyLang('operate_title'),
                    'view_type'     => 'operate',
                    'view_key'      => 'admin/lottery/index',
                    'align'         => 'center',
                    'fixed'         => 'right',
                ],
            ],
            // 数据配置
            'data'  => [
                'table_name'    => 'aadeitycard',
                'data_handle'   => 'LotteryService::LotteryListHandle',
            ],
        ];
    }

    /**
     * 获取列表
     */
    public function LotteryCategoryList()
    {
        $res = LotteryCategoryService::LotteryCategoryList(['field'=>'id,name']);
        return $res['data'];
    }
}
?>