<?php
$id = Dever::input('id');
if ($id) {
    if (empty($load)) {
        $load = 'content/cate';
    }
    $info = Dever::db($load)->find($id);
    $parent_id = $info['parent_id'];
} else {
    $parent_id = Dever::input('field')['parent_id'] ?? 0;
}

return array
(
    'list' => array
    (
        'field'      => array
        (
            'name',
            'icon_id' => array
            (
                'name' => '图标',
                'show' => 'Dever::call("place/manage.getCateIcon", array("{icon_type}", "{icon_id}", "{icon}"))',
            ),
            'sort' => array
            (
                'type' => 'input',
                'tips' => '双击修改排序',
            ),
            'status' => array
            (
                'type' => 'switch',
                'show'  => '{status}',
                'active_value' => 1,
                'inactive_value' => 2,
            ),
            'cdate',
        ),
        'tree' => array('parent_id', '0', 'id'),
        'button' => array
        (
            '新增主分类' => array('fastadd', array('parent_id' => '0')),
        ),
        'data_button' => array
        (
            '编辑' => array('fastedit', array('field' => 'name,desc,cate_id,icon_type,icon,icon_id,icon_name')),
            '新增子分类' => array('fastadd', array('parent_id' => 'id'), '', 'parent_id=0'),
        ),
        'search'    => array
        (
            'name',
            'key',
            'status',
        ),
    ),
    'update' => array
    (
        'control' => array
        (
            'icon_id' => array
            (
                'icon_type' => 1,
            ),
            'icon' => array
            (
                'icon_type' => 2,
            )
        ),
        'field'    => array
        (
            'name' => array
            (
                'rules' => true,
            ),
            'parent_id',
            //'desc' => 'textarea',
            'cate_id' => array
            (
                'tips' => '平台分类用于同步销售渠道时自动设置第三方网店分类对应关系',
                'rules' => true,
                'type' => 'select',
                'option' => 'Dever::call("place/manage.getPlatformCate", array("{table}", "'.$parent_id.'"))',
                'remote' => 'place/manage.getPlatformIcon?parent_id=' . $parent_id,
                'remote_default' => false,
            ),
            'icon_type' => array
            (
                'type' => 'radio',
                'control' => true,
            ),
            'icon_id' => array
            (
                'type' => 'text',
                'disable' => true,
                'search' => 'icon_name',
                /*
                'type' => 'selector',
                'option'    => 'Dever::url("cate/icon.getList", array("id" => "{icon_id}", "name" => "{name}"))',
                */
            ),
            'icon_name' => 'hidden',
            'icon' => array
            (
                'type' => 'upload',
                'upload' => '1',
                'yun' => true,
                'multiple' => false,
                'limit' => 1,
                'style' => 'pic',
            ),
            /*
            'status' => array
            (
                'type' => 'radio',
            ),
            'sort',
            */
        ),
        #'check' => 'key',
        #'start' => 'manage/common.updateKey',
    ),
);