<?php
/**
 * +----------------------------------------------------------------------
 * 用例-UI-列表
 * +----------------------------------------------------------------------
 * 官网：https://www.sw-x.cn
 * +----------------------------------------------------------------------
 * 作者：小黄牛 <1731223728@qq.com>
 * +----------------------------------------------------------------------
 * 开源协议：http://www.apache.org/licenses/LICENSE-2.0
 * +----------------------------------------------------------------------
*/

namespace app\controller\admin\test;
use app\controller\SuperClass\Admin;

class Scene_index extends Admin
{

    /**
     * @AopBefore(class="app\aop\AdminLogin", function="before")
     * @RequestMapping(route="/admin/test/scene_index", method="GET|POST", title="用例-UI-列表")
     * @Param(name="page", value="1")
     * @Param(name="limit", value="10")
     * @Param(name="item_id", value="0")
     * @Param(name="edition_id", value="0")
     * @Param(name="ui_id", value="0")
    */
    public function run() {
        $param = \x\Request::get();
        $Db = new \x\Db();
        // 项目
        $item_list = $Db->name('item')->order('id ASC')->select();
        $this->assign('item_list', $item_list);
        // 版本
        $edition_list = [];
        if ($item_list) {
            $id = $item_list[0]['id'];
            if ($param['item_id']) $id =$param['item_id'];
            $edition_list = $Db->name('edition')->where('item_id='.$id)->order('id DESC')->select();
        }
        // 功能
        $ui_list = [];
        if ($edition_list) {
            $id = $edition_list[0]['id'];
            if ($param['edition_id']) $id =$param['edition_id'];
            $ui_list = $Db->name('test_scene')->where('edition_id='.$id)->order('id DESC')->select();
        }
        
        $this->assign('edition_list', $edition_list);
        $this->assign('ui_list', $ui_list);
        $this->assign('param', $param);

        $this->assign('test_level', test_level());
        $this->assign('test_status', test_status());


        $list = [];
        if ($ui_list) {
            $pid = $ui_list[0]['id'];
            if ($param['ui_id']) $pid =$param['ui_id'];
            $list = $Db->name('test_scene_data')->where('pid', $pid)->order('id ASC')->select();
        }
        $this->assign('list', $list);

        $Db->return();
        return $this->display();
    }

}