<?php
$config = array
(
    'list' => array
    (
        'field'      => array
        (
            'ids' => array
            (
                'name' => '编号',
                'show' => '"C" . Dever\Helper\Str::uid("{id}")'
            ),
            'sort' => array
            (
                'type' => 'input',
            ),
            'name' => array
            (
                //'tip' => false,
            ),
            'source' => array
            (
                'show' => 'Dever::call("place/manage.getSource", array({id}, 1, "content"))',
            ),
            'cate' => array
            (
                'show' => 'Dever::call("place/manage.getCateInfo", array("content", "{cate}"))',
            ),
            'status' => array
            (
                'type' => 'switch',
                'show'  => '{status}',
                'active_value' => 1,
                'inactive_value' => 2,
            ),
            'cdate',
        ),
        'button' => array
        (
            '新增' => array('add'),
        ),
        'data_button' => array
        (
            '编辑' => 'edit',
            /*
            '推广素材' => array('route', array
            (
                'path' => 'set_zone_source/source_info_data',
                'param' => array
                (
                    'set' => array('info_id' => 'id', 'menu' => 'set_zone_source/source_info', 'parent' => 'set_zone_source/source_info'),
                ),
            ), 'ChatLineSquare'),
            */
        ),
        'search'    => array
        (
            'cate' => array
            (
                'type' => 'cascader',
                'option'    => 'Dever::call("place/manage.getCateList", array("content"))',
            ),
            'status',
            'name',
        ),
    ),
    'update' => array
    (
        'tab' => array
        (
            '基本信息' => 'name,cate,pic,info,content',
            '附件信息' => 'content/value',
            '价格设置' => 'price,password,content/vip_price,content/agent_price',
        ),
        //'desc' => '原创声明：',
        'field'    => array
        (
            'name' => array
            (
                'rules' => true,
            ),
            'cate' => array
            (
                'rules' => true,
                'type' => 'cascader',
                'option'    => 'Dever::call("place/manage.getCateList", array("content"))',
            ),
            'pic' => array
            (
                'type' => 'upload',
                'upload' => '1',
                'yun' => true,
                'multiple' => false,
                'limit' => 1,
                'style' => 'pic',
            ),
            'info' => array
            (
                'type' => 'textarea',
                //'rows' => 4,
                'autosize' => array('minRows' => 4),
            ),
            'content' => array
            (
                'rules' => true,
                'type' => 'editor',
                'editorMenu' => array
                (
                    'uploadImage' => 1,
                    'uploadVideo' => 3,
                ),
            ),
            'content/value' => array
            (
                'name' => '附件',
                'where'  => array('info_id' => 'id'),
            ),
            'price' => array
            (
                'desc' => '',
            ),
            'password' => array
            (
                'desc' => '输入密码后，可以免费下载附件',
            ),
            'content/vip_price' => array
            (
                'name' => '会员价格',
                'where'  => array('info_id' => 'id'),
                'desc' => '可以按照会员等级设置不同的价格',
            ),
            'content/agent_price' => array
            (
                'name' => '代理价格',
                'where'  => array('info_id' => 'id'),
                'desc' => '可以按照代理等级设置不同的价格',
            ),
            'content/client_price' => array
            (
                'name' => '源主销量折扣',
                'where'  => array('info_id' => 'id'),
            ),
        ),
        'end' => 'place/manage.updateCate',
    ),
);
$extend = Dever::load('common', 'manage')->extend();
$place = Dever::db('info', 'place')->find(array('id' => $extend['data_id']));
if ($place && $place['channel'] == 1) {
    $config['update']['tab']['价格设置'] .= ',content/client_price';
}

$id = Dever::input('id');
if ($id) {
    $info = Dever::db('info', 'content')->find($id);
    if ($info && isset($info['source']) && $info['source'] == 2) {
        $relation = Dever::db('resource_relation', 'place')->find(array('type' => 1, 'type_id' => $id));
        if ($relation && $relation['status'] = 1) {
            unset($config['update']['tab']['附件信息']);
            $place = Dever::db('info', 'place')->find($relation['channel_place_id']);
            $config['update']['tab']['价格设置'] = 'price_show,' . $config['update']['tab']['价格设置'];

            $config['update']['field']['price_show'] = array
            (
                'type' => 'show',
                'name' => '进价参考',
                'default' => $relation['channel_price'],
                'tips' => '这里仅为您进货时记录的价格，如需实时报价请到“'.$place['name'].'”查询',
            );
        }
    }
}

return $config;