init Area full CRUD

This commit is contained in:
dongpd 2020-10-09 14:19:15 +07:00
parent 5538d74b1b
commit 70db83d3ab
15 changed files with 318 additions and 144 deletions

View File

@ -8,6 +8,9 @@ use app\models\AreaSearch;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\Url;
use yii\helpers\Html;
use app\models\common;
/** /**
* AreaController implements the CRUD actions for Area model. * AreaController implements the CRUD actions for Area model.
@ -42,43 +45,75 @@ class AreaController extends Controller {
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
]); "areaArray" => Area::areaArray()
}
public function actionView($id) {
return $this->render('view', [
'model' => $this->findModel($id),
]); ]);
} }
public function actionCreate() { public function actionCreate() {
$model = new Area(); $model = new Area();
Yii::$app->response->format = "json";
if (Yii::$app->request->post()) {
$data = Yii::$app->request->post();
$check = Area::findOne(['code' => $data['Code']]);
if ($check)
return ["status" => false, "type" => "code"];
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->create($data)) {
return $this->redirect(['view', 'id' => $model->id]); common::insertSystemLogs(["action" => "insert", "description" => "Thêm mới khu vực: " . $data["Name"], "type" => Yii::$app->controller->id]);
return ["status" => true];
} else
return ["status" => false, "type" => "error"];
} else {
return [
"title" => Html::tag("i", "", ["class" => "fa fa-plus-square"]) . " Thêm",
"form" => $this->renderPartial("form", [
"model" => $model,
"url" => Url::to(["create"]),
"areaArray" => Area::areaArray()
])
];
} }
return $this->render('create', [
'model' => $model,
]);
} }
public function actionUpdate($id) { public function actionUpdate($id) {
$model = $this->findModel($id); $model = $this->findModel($id);
Yii::$app->response->format = "json";
if ($model->load(Yii::$app->request->post()) && $model->save()) { if (Yii::$app->request->post()) {
return $this->redirect(['view', 'id' => $model->id]); $data = Yii::$app->request->post();
$check = Area::findOne(['code' => $data['Code']]);
if ($check && $check->id != $id)
return ["status" => false, "type" => "code"];
$oldCode = $model->code;
$model->name = $data["Name"];
$model->code = $data["Code"];
$model->pid = $data["Pid"];
$model->description = $data["Description"];
$model->modified_at = time();
if ($model->save()) {
Area::updateAll(["pid" => $data["Code"]], ["pid" => $oldCode]);
common::insertSystemLogs(["action" => "update", "description" => "Chỉnh sửa khu vực: " . $data["Name"], "type" => Yii::$app->controller->id]);
return ["status" => true];
} else
return ["status" => false, "type" => "error"];
} else {
return [
"title" => Html::tag("i", "", ["class" => "fa fa-edit"]) . " Tùy chỉnh",
"form" => $this->renderPartial("form", [
"model" => $model,
"url" => Url::to(["update", "id" => $id]),
"areaArray" => Area::areaArrayWithOut($id)
])
];
} }
return $this->render('update', [
'model' => $model,
]);
} }
public function actionDelete($id) { public function actionDelete() {
$this->findModel($id)->delete(); if (Yii::$app->request->post()) {
$lists = Yii::$app->request->post("lists");
return $this->redirect(['index']); foreach ($lists as $key => $value) {
Area::deleteArea($value);
}
}
} }
protected function findModel($id) { protected function findModel($id) {
@ -89,4 +124,87 @@ class AreaController extends Controller {
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
public function actionExport() {
$objPHPExcel = new \PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$toExcelFile[] = ["Mã khu vực", "Tên khu vực", "khu vực cha", "Chú thích"];
$areas = Area::find()->all();
$areaArray = Area::areaArray();
foreach ($areas as $k => $v) {
$ExportData[] = $v->code;
$ExportData[] = $v->name;
$ExportData[] = isset($areaArray[$v->pid]) ? $areaArray[$v->pid] : "";
$ExportData[] = $v->description;
$toExcelFile[] = $ExportData;
unset($ExportData);
}
$totals = count($areas) + 1;
$activeSheet = $objPHPExcel->getActiveSheet();
$activeSheet->getColumnDimension('A')->setWidth(15);
$activeSheet->getColumnDimension('B')->setWidth(50);
$activeSheet->getColumnDimension('C')->setWidth(50);
$activeSheet->getColumnDimension('D')->setWidth(50);
$activeSheet->getStyle("A1:D" . $totals)->getFont()->setName('Time New Roman')->setSize(10);
$activeSheet->getStyle("A1:D1")->applyFromArray([
'fill' => array(
'type' => \PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => '7ac3ec')
)
]);
$rowCount = 1;
for ($i = 0; $i < count($toExcelFile); $i++) {
$column = 'A';
$row = $toExcelFile[$i];
for ($j = 0; $j < count($row); $j++) {
if (!isset($row[$j]))
$value = NULL;
elseif ($row[$j] != "")
$value = strip_tags($row[$j]);
else
$value = "";
$activeSheet->setCellValue($column . $rowCount, $value);
$column = chr(ord($column) + 1);
}
$rowCount++;
}
$activeSheet->getStyle("A1:D" . $totals)->applyFromArray([
'alignment' => [
'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
],
'borders' => [
'allborders' => [
'style' => \PHPExcel_Style_Border::BORDER_THIN
]
]
]);
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="area_' . date("YmdHis") . '.xlsx"');
header('Cache-Control: max-age=0');
common::SaveViaTempFile($objWriter);
exit();
}
public function actionLogs() {
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = "json";
return [
"title" => Html::tag("i", "", ["class" => "fa fa-file"]) . " Ghi nhận hệ thống",
"form" => \app\widgets\SystemLogsView::widget(['type' => Yii::$app->controller->id])
];
}
}
public function actionTree() {
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = "json";
return [
"title" => Html::tag("i", "", ["class" => "fa fa-sitemap"]) . " Cây thư mục",
"form" => \app\widgets\Tree::widget(["model" => new Area()])
];
}
}
} }

View File

@ -5,7 +5,6 @@ namespace app\controllers;
use Yii; use Yii;
use app\models\Department; use app\models\Department;
use app\models\DepartmentSearch; use app\models\DepartmentSearch;
use app\models\SystemLogs;
use app\models\common; use app\models\common;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
@ -225,10 +224,7 @@ class DepartmentController extends Controller {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
return [ return [
"title" => Html::tag("i", "", ["class" => "fa fa-file"]) . " Ghi nhận hệ thống", "title" => Html::tag("i", "", ["class" => "fa fa-file"]) . " Ghi nhận hệ thống",
"form" => $this->renderPartial("logs", [ "form" => \app\widgets\SystemLogsView::widget(['type' => Yii::$app->controller->id])
"logs" => SystemLogs::find()->andWhere(["type" => Yii::$app->controller->id])->orderBy(['time' => SORT_DESC])->limit(30)->all(),
"userArray" => \app\models\User::userArray()
])
]; ];
} }
} }
@ -238,9 +234,7 @@ class DepartmentController extends Controller {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
return [ return [
"title" => Html::tag("i", "", ["class" => "fa fa-sitemap"]) . " Cây thư mục", "title" => Html::tag("i", "", ["class" => "fa fa-sitemap"]) . " Cây thư mục",
"form" => $this->renderPartial("tree", [ "form" => \app\widgets\Tree::widget(["model" => new Department()])
"root" => Department::findOne(1)
])
]; ];
} }
} }

View File

@ -73,7 +73,7 @@ class CommonGrid {
public static function rows($type) { public static function rows($type) {
return function($model, $index, $widget, $grid) use ($type) { return function($model, $index, $widget, $grid) use ($type) {
return [ return [
"onclick" => "common.form(this, '{$type}');", "ondblclick" => "common.form(this, '{$type}');",
"style" => "cursor: pointer;", "style" => "cursor: pointer;",
"data" => [ "data" => [
"href" => Url::to(["update", "id" => $model->id]) "href" => Url::to(["update", "id" => $model->id])
@ -82,4 +82,10 @@ class CommonGrid {
}; };
} }
public static function pid($array) {
return function($model) use ($array) {
return isset($array[$model->pid]) ? $array[$model->pid] : "";
};
}
} }

View File

@ -51,4 +51,55 @@ class Area extends \yii\db\ActiveRecord {
]; ];
} }
public static function areaArray() {
$lists = self::find()->all();
$results = [];
foreach ($lists as $key => $value) {
$results[$value->code] = $value->name;
}
return $results;
}
public static function areaArrayWithOut($id) {
$lists = self::find()->andWhere(["<>", "id", $id])->all();
$results = [];
foreach ($lists as $key => $value) {
$results[$value->code] = $value->name;
}
return $results;
}
public function create($data) {
$r = $this->load([
"code" => $data["Code"],
"pid" => $data["Pid"],
"name" => $data["Name"],
"description" => $data["Description"],
"created_at" => time(),
"modified_at" => time()
], '');
if ($r) {
try {
$this->save();
return $this->id;
} catch (\Exception $ex) {
return false;
}
}
}
public static function deleteArea($id) {
if ($id == 1)
return;
$model = self::findOne($id);
if ($model) {
$childs = self::find()->andWhere(["pid" => $model->code])->all();
foreach ($childs as $key => $value) {
self::deleteArea($value->id);
}
$model->delete();
common::insertSystemLogs(["action" => "delete", "description" => "Xóa khu vực: " . $model->name, "type" => "area"]);
}
}
} }

View File

@ -10,24 +10,22 @@ use app\models\Area;
/** /**
* AreaSearch represents the model behind the search form of `app\models\Area`. * AreaSearch represents the model behind the search form of `app\models\Area`.
*/ */
class AreaSearch extends Area class AreaSearch extends Area {
{
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function rules() public function rules() {
{
return [ return [
[['id', 'code', 'pid', 'created_at', 'modified_at'], 'integer'], [['id', 'code', 'pid'], 'integer'],
[['name', 'description'], 'safe'], [['name', 'description'], 'safe'],
]; ];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function scenarios() public function scenarios() {
{
// bypass scenarios() implementation in the parent class // bypass scenarios() implementation in the parent class
return Model::scenarios(); return Model::scenarios();
} }
@ -39,8 +37,7 @@ class AreaSearch extends Area
* *
* @return ActiveDataProvider * @return ActiveDataProvider
*/ */
public function search($params) public function search($params) {
{
$query = Area::find(); $query = Area::find();
// add conditions that should always apply here // add conditions that should always apply here
@ -67,8 +64,9 @@ class AreaSearch extends Area
]); ]);
$query->andFilterWhere(['like', 'name', $this->name]) $query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'description', $this->description]); ->andFilterWhere(['like', 'description', $this->description]);
return $dataProvider; return $dataProvider;
} }
} }

View File

@ -12,26 +12,32 @@
</style> </style>
<div class="form-group" id="name"> <div class="form-group" id="name">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon">Tên phòng ban <i class="text-red">*</i></div> <div class="input-group-addon">Tên khu vực <i class="text-red">*</i></div>
<input type="text" class="form-control" value="{$model->name|default:""}" name="Name"> <input type="text" class="form-control" value="{$model->name|default:""}" name="Name">
</div> </div>
<span class="help-block hidden"></span> <span class="help-block hidden"></span>
</div> </div>
<div class="form-group" id="code"> <div class="form-group" id="code">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon">Mã phòng ban <i class="text-red">*</i></div> <div class="input-group-addon">Mã khu vực <i class="text-red">*</i></div>
<input type="number" class="form-control" value="{$model->code|default:""}" name="Code" {if $model->code==1}disabled=""{/if}> <input type="number" class="form-control" value="{$model->code|default:""}" name="Code" {if $model->code==1}disabled=""{/if}>
</div> </div>
<span class="help-block hidden"></span> <span class="help-block hidden"></span>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon">Trực thuộc <i class="text-red">*</i></div> <div class="input-group-addon">Khu vực cha <i class="text-red">*</i></div>
<select class="form-control" name="Pid" id="Pid" {if $model->code==1}disabled=""{/if}> <select class="form-control" name="Pid" id="Pid" {if $model->code==1}disabled=""{/if}>
{html_options options=$departmentArray selected=$model->pid|default:1} {html_options options=$areaArray selected=$model->pid|default:1}
</select> </select>
</div> </div>
</div> </div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">Chú thích</div>
<textarea class="form-control" name="Description">{$model->description}</textarea>
</div>
</div>
<div class="text-right"> <div class="text-right">
<button class="btn btn-primary" onclick="save(this);" data-href="{$url}"> <button class="btn btn-primary" onclick="save(this);" data-href="{$url}">
<i class="fa fa-floppy-o"></i> Lưu <i class="fa fa-floppy-o"></i> Lưu

View File

@ -10,7 +10,7 @@
<label class="action-button" onclick="common.form(this, '');" data-href="{Url::to(['tree'])}"> <label class="action-button" onclick="common.form(this, '');" data-href="{Url::to(['tree'])}">
<i class="fa fa-sitemap fa-1-5x"></i> Cây thư mục <i class="fa fa-sitemap fa-1-5x"></i> Cây thư mục
</label> </label>
<label class="action-button" onclick="common.form(this, 'department');" data-href="{Url::to(['create'])}"> <label class="action-button" onclick="common.form(this, 'area');" data-href="{Url::to(['create'])}">
<i class="fa fa-plus-square fa-1-5x"></i> Thêm <i class="fa fa-plus-square fa-1-5x"></i> Thêm
</label> </label>
<label class="action-button" onclick="_form(this);" data-href="{Url::to(['update'])}"> <label class="action-button" onclick="_form(this);" data-href="{Url::to(['update'])}">
@ -30,12 +30,12 @@
{GridView::widget([ {GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'filterModel' => $searchModel, 'filterModel' => $searchModel,
'layout'=> \app\helpers\AreaGrid::getLayout(), 'layout'=> \app\helpers\CommonGrid::getLayout(),
'tableOptions' => [ 'tableOptions' => [
'class' => 'table table-striped table-bordered table-hover', 'class' => 'table table-striped table-bordered table-hover',
'style' => 'background:#fff;min-width:700px;' 'style' => 'background:#fff;min-width:700px;'
], ],
'rowOptions' => \app\helpers\AreaGrid::rows("area"), 'rowOptions' => \app\helpers\CommonGrid::rows("area"),
'columns' => [ 'columns' => [
[ [
'class' => 'yii\grid\SerialColumn', 'class' => 'yii\grid\SerialColumn',
@ -47,19 +47,23 @@
'format' => 'raw', 'format' => 'raw',
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'], 'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
'value' => \app\helpers\AreaGrid::checkbox("area") 'value' => \app\helpers\CommonGrid::checkbox("area")
], ],
'code', 'code',
'pid', [
'attribute' => 'pid',
'filter' => $areaArray,
'value' => \app\helpers\CommonGrid::pid($areaArray)
],
'name', 'name',
'description:ntext', 'description:ntext',
[ [
'attribute' => 'created_at', 'attribute' => 'created_at',
'value' => \app\helpers\AreaGrid::createdAt() 'value' => \app\helpers\CommonGrid::createdAt()
], ],
[ [
'attribute' => 'modified_at', 'attribute' => 'modified_at',
'value' => \app\helpers\AreaGrid::modifiedAt() 'value' => \app\helpers\CommonGrid::modifiedAt()
] ]
] ]
])} ])}

View File

@ -6,7 +6,7 @@ function validate() {
var error = 0; var error = 0;
var Name = $("input[name='Name']").val(); var Name = $("input[name='Name']").val();
if (Name === "") { if (Name === "") {
common.error("name", "Tên phòng ban không được để trống"); common.error("name", "Tên khu vực không được để trống");
error++; error++;
} else { } else {
common.success("name"); common.success("name");
@ -14,7 +14,7 @@ function validate() {
var Code = $("input[name='Code']").val(); var Code = $("input[name='Code']").val();
if (Code === "") { if (Code === "") {
common.error("code", "Mã phòng ban không được để trống"); common.error("code", "Mã khu vực không được để trống");
error++; error++;
} else { } else {
common.success("code"); common.success("code");
@ -31,20 +31,21 @@ function save(e) {
data: { data: {
Name: $("input[name='Name']").val(), Name: $("input[name='Name']").val(),
Code: $("input[name='Code']").val(), Code: $("input[name='Code']").val(),
Pid: $("select[name='Pid']").val() Pid: $("select[name='Pid']").val(),
Description: $("textarea[name='Description']").val()
}, },
success: function (data) { success: function (data) {
common.modalBlock(false); common.modalBlock(false);
if (data.status) { if (data.status) {
notification.success("Đã lưu thông tin", 1000); notification.success("Đã lưu thông tin", 1000);
$.pjax.reload({container: '#department-list'}); $.pjax.reload({container: '#area-list'});
$("#department-list").on('pjax:success', function () { $("#area-list").on('pjax:success', function () {
common.checkboxInit("department"); common.checkboxInit("area");
}); });
$("#myModal").modal("hide"); $("#myModal").modal("hide");
} else { } else {
if (data.type === "code") { if (data.type === "code") {
common.error("code", "Mã phòng ban đã tồn tại"); common.error("code", "Mã khu vực đã tồn tại");
} else { } else {
notification.danger("Có lỗi xảy ra, không lưu được dữ liệu!", 1000); notification.danger("Có lỗi xảy ra, không lưu được dữ liệu!", 1000);
} }
@ -60,7 +61,7 @@ function save(e) {
function _form(e) { function _form(e) {
var lists = []; var lists = [];
$.each($("input[name='checkbox-department']:checked"), function () { $.each($("input[name='checkbox-area']:checked"), function () {
lists.push($(this).val()); lists.push($(this).val());
}); });
if (lists.length == 0) { if (lists.length == 0) {
@ -89,7 +90,7 @@ function _form(e) {
function _delete(e) { function _delete(e) {
var lists = []; var lists = [];
$.each($("input[name='checkbox-department']:checked"), function () { $.each($("input[name='checkbox-area']:checked"), function () {
lists.push($(this).val()); lists.push($(this).val());
}); });
if (lists.length == 0) { if (lists.length == 0) {
@ -111,9 +112,9 @@ function _delete(e) {
success: function (data) { success: function (data) {
common.modalBlock(false); common.modalBlock(false);
notification.danger("Đã xóa dữ liệu", 1000); notification.danger("Đã xóa dữ liệu", 1000);
$.pjax.reload({container: '#department-list'}); $.pjax.reload({container: '#area-list'});
$("#department-list").on('pjax:success', function () { $("#area-list").on('pjax:success', function () {
common.checkboxInit("department"); common.checkboxInit("area");
}); });
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
@ -128,60 +129,6 @@ function _export(e) {
window.location = $(e).attr("data-href"); window.location = $(e).attr("data-href");
} }
function btnUpload(mUrl, className, extension, fileSize) {
var fData = {
UploadFile: true,
Name: className
};
fData[common.csrfParam] = common.csrf;
new afuButton({
uploadURI: mUrl,
formData: fData,
wrap: {
tagName: 'div',
classes: ''
},
fileExtension: extension,
fileSizeLimit: fileSize,
classes: 'btn btn-default file-paperclip-' + className,
fakeInputContent: '<span class=\'fa fa-upload\'></span> Nhập dữ liệu',
onUploaded: function (data) {
data = JSON.parse(data);
common.modalOpen(data.form, true, data.title);
common.uploadBlock(false);
common.checkboxInit("department-import");
}
}).addInstance('file' + className);
$(".file-paperclip-" + className).closest("div").attr("style", "display:inline-block;");
}
function _import(e) {
var lists = [];
$.each($("input[name='checkbox-department-import']:checked"), function () {
lists.push($(this).val());
});
if (lists.length == 0) {
alert("Vui lòng lựa chọn đối tượng để nhập!");
return;
}
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
data: {
lists: lists
},
success: function (data) {
common.modalBlock(false);
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function _logs(e) { function _logs(e) {
common.modalBlock(true); common.modalBlock(true);
$.ajax({ $.ajax({

View File

@ -1,22 +0,0 @@
<?php
namespace app\widgets;
use yii\base\Widget;
class Department extends Widget {
public $pid;
public function init() {
parent::init();
}
public function run() {
return $this->render("department", [
"lists" => \app\models\Department::find()->andWhere(['pid' => $this->pid])->all()
]);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace app\widgets;
use yii\base\Widget;
use app\models\SystemLogs;
use app\models\User;
class SystemLogsView extends Widget {
public $type;
public function init() {
parent::init();
}
public function run() {
return $this->render("system-logs-view", [
"logs" => SystemLogs::find()->andWhere(["type" => $this->type])->orderBy(['time' => SORT_DESC])->limit(30)->all(),
"userArray" => User::userArray()
]);
}
}

23
widgets/Tree.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace app\widgets;
use yii\base\Widget;
class Tree extends Widget {
public $model;
public function init() {
parent::init();
}
public function run() {
return $this->render("tree", [
"root" => $this->model->findOne(1),
"model" => $this->model
]);
}
}

24
widgets/TreeSub.php Normal file
View File

@ -0,0 +1,24 @@
<?php
namespace app\widgets;
use yii\base\Widget;
class TreeSub extends Widget {
public $pid;
public $model;
public function init() {
parent::init();
}
public function run() {
return $this->render("tree-sub", [
"lists" => $this->model->find()->andWhere(['pid' => $this->pid])->all(),
"model" => $this->model
]);
}
}

View File

@ -3,7 +3,7 @@
<i class="fa fa-minus-square-o" onclick="common.tree(this);" data="{$l->code}" data-stt="true"></i> <i class="fa fa-minus-square-o" onclick="common.tree(this);" data="{$l->code}" data-stt="true"></i>
<span class="tree-drop">{$l->code}-{$l->name}</span> <span class="tree-drop">{$l->code}-{$l->name}</span>
<div id="sub-tree-{$l->code}" style="padding-left: 20px;"> <div id="sub-tree-{$l->code}" style="padding-left: 20px;">
{\app\widgets\Department::widget(["pid"=>$l->code])} {\app\widgets\TreeSub::widget(["pid"=>$l->code,"model"=>$model])}
</div> </div>
</div> </div>
{/foreach} {/foreach}

View File

@ -2,6 +2,6 @@
<i class="fa fa-minus-square-o" onclick="common.tree(this);" data="1" data-stt="true"></i> <i class="fa fa-minus-square-o" onclick="common.tree(this);" data="1" data-stt="true"></i>
<b class="tree tree-drop" data="0">{$root->code}-{$root->name}</b> <b class="tree tree-drop" data="0">{$root->code}-{$root->name}</b>
<div id="sub-tree-1" style="padding-left: 20px;"> <div id="sub-tree-1" style="padding-left: 20px;">
{\app\widgets\Department::widget(["pid"=>1])} {\app\widgets\TreeSub::widget(["pid"=>1,"model"=>$model])}
</div> </div>
</div> </div>