数据模型

企业信息模型

字段 类型 说明
id int 主键
cid varchar 企业ID
name varchar 企业名称
short_name varchar 企业简称
type varchar 企业类型
owner varchar 法定代表人
address varchar 注册地址
date date 注册日期
reg_capital decimal 注册资本
reg_capital_currency varchar 注册资本货币
actual_capital decimal 实缴金额
actual_capital_currency varchar 实缴货币
reg_status varchar 登记状态:存续

项目信息模型

字段 类型 说明
id int 主键
company_id int 关联企业id
name varchar 项目名称
intro text 项目介绍
status varchar 运营状态

企业信息页面模板

项目信息翻页直接使用AJAX请求接口,输出项目列表信息

<?php
$this->title = '企业详情';

$js = <<< JS
$(document).ready(function (){
   // 项目
    $(function () {
        $('#project-list-wrapper').on('click', '.project-pager a', function (e) {
            e.preventDefault();
            $('#project-list-wrapper').load($(e.target).attr('href'));

            return false;
        });
    });
});
JS;
$this->registerJs($js);
?>
<section class="content-header">
    
        产业监测
    
    <ol class="breadcrumb">
        <li><a rel="nofollow" href="#"><i class="fa fa-dashboard"></i> 产业监测</a></li>
        <li><a rel="nofollow" href="javascript:history.go(-1)">企业列表</a></li>
        <li class="active">企业详情</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <div class="box">
        <div class="box-body">
            <div class="row">
                <div class="col-md-9">
                    <div class="media-left">
                        <img class="media-object" src="holder.js/96x96">
                    </div>
                    <div class="media-body" style="line-height: 2em;">
                        <h4 class="media-body">
                            <?= $company->name; ?>
                            <span style="color: #5cb85c;"><?= $company->reg_status; ?></span>
                        </h4>
                        <p>
                            <span class="label label-info"><?= $company->type; ?></span>
                            <span class="label label-info"><?= $company->industry; ?></span>
                        </p>
                        <div class="row">
                            <div class="col-md-4">法定代表人:<?= $company->owner; ?></div>
                            <div class="col-md-4">注册资本:<?= $company->reg_capital . $company->reg_capital_currency; ?></div>
                            <div class="col-md-4">成立日期:<?= $company->date; ?></div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">联系电话:<?= $company->phone_number; ?></div>
                            <div class="col-md-4">官网:<?= $company->website; ?></div>
                            <div class="col-md-4">邮箱:<?= $company->email; ?></div>
                        </div>
                        <div>注册地址:<?= $company->address; ?></div>
                        <div>经营范围:<?= $company->scope; ?></div>
                    </div>
                </div>
                <div class="col-md-3">
                    <div id="chart-growth" style="height: 350px;">

                    </div>

                    <div id="chart-risk">

                    </div>
                </div>
            </div>
        </div>
</div>

        <h3>项目信息 <?= count($company->projects); ?></h3>
        <input id="project" hidden value="0">
        <div id="project-list-wrapper" style="background-color: #fff; padding: 10px;">
            <?= \Yii::$app->runAction('/industry/projects',['id' => $company->id]); ?>
        </div>
</section>

项目控制器

public function actionProjects($id, $page = 1, $limit = 5)
    {
        $params = [
            'company_id' => $id,
            'page' => $page,
            'limit' => $limit,
        ];
        if ($this->region) {
            $params['region'] = $this->region;
        }
        $dataProvider = ProjectSearch::search($params);

        return $this->renderFile('@backend/views/industry/project.php', ['dataProvider' => $dataProvider]);
    }

项目搜索模型

<?php
namespace backend\models;

use common\models\Project;
use yii\data\ActiveDataProvider;

class ProjectSearch extends Project
{
    public static function search($params)
    {
        $query = Project::find();
        $query = self::query($query, $params);

        return new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'defaultPageSize' => $params['limit'],
                'pageSizeParam' => 'limit',
                'validatePage' => false,
            ],
        ]);

    }

    public static function query($query, $params)
    {
        // 企业id
        if (!empty($params['company_id'])) {
            $query->andWhere(['company_id' => $params['company_id']]);
        }
        return $query;
    }
}

项目模板

<?php
?>
<table class="table table-striped">
    <thead>
        <tr>
            <th style="width: 5em;">序号</th>
            <th>项目名称</th>
            <th>上线时间</th>
            <th>状态</th>
            <th>地区</th>
            <th>备案号</th>
        </tr>
    </thead>

    <tbody>

<?php foreach ($dataProvider->getModels() as $id => $model) : ?>
    <tr>
    <td><?= ($id + 1 + ($page * $limit - $limit)) ?></td>
    <td><?= $model->name; ?></td>
    <td><?= $model->date ; ?></td>
    <td><?= $model->status; ?> </td>
    <td><?= $model->provinceRegion->name . $model->cityRegion->name; ?> </td>
    <td><?= $model->reg_number ; ?></td>
    </tr>
<?php endforeach; ?>
</tbody></table>
<nav class="text-center project-pager">
    <ul class="pagination">
       <?=\yii\widgets\LinkPager::widget(['pagination' => $dataProvider->getPagination()]); ?>
    </ul>
</nav>