diff --git a/module/metric/control.php b/module/metric/control.php index fbfaf3c375..419e0e27e7 100755 --- a/module/metric/control.php +++ b/module/metric/control.php @@ -87,4 +87,21 @@ class metric extends control $this->metric->insertMetricLib($records); } + + /** + * 查询度量项详情页。 + * View a metric. + * + * @param int $metricID + * @access public + * @return void + */ + public function view(int $metricID) + { + $this->view->metric = $this->metric->getByID($metricID); + $this->view->legendBasic = $this->metricZen->getBasicInfo($this->view); + $this->view->createEditInfo = $this->metricZen->getCreateEditInfo($this->view); + + $this->display(); + } } diff --git a/module/metric/lang/zh-cn.php b/module/metric/lang/zh-cn.php index 697af7be7a..3155c3c383 100755 --- a/module/metric/lang/zh-cn.php +++ b/module/metric/lang/zh-cn.php @@ -1,20 +1,20 @@ metric->common = "度量项"; -$lang->metric->name = "度量项名称"; -$lang->metric->stage = "阶段"; -$lang->metric->scope = "范围"; -$lang->metric->object = "对象"; -$lang->metric->purpose = "目的"; -$lang->metric->unit = "单位"; -$lang->metric->code = "代号"; -$lang->metric->desc = "描述"; -$lang->metric->definition = "定义"; -$lang->metric->formula = "计算方式"; -$lang->metric->when = "收集方式"; -$lang->metric->createdBy = "创建者"; -$lang->metric->implementBy = "由谁实现"; -$lang->metric->removeBy = "由谁下架"; -$lang->metric->lastEdited = "最后修改"; +$lang->metric->common = "度量项"; +$lang->metric->name = "度量项名称"; +$lang->metric->stage = "阶段"; +$lang->metric->scope = "范围"; +$lang->metric->object = "对象"; +$lang->metric->purpose = "目的"; +$lang->metric->unit = "单位"; +$lang->metric->code = "代号"; +$lang->metric->desc = "描述"; +$lang->metric->definition = "定义"; +$lang->metric->formula = "计算方式"; +$lang->metric->when = "收集方式"; +$lang->metric->createdBy = "创建者"; +$lang->metric->implementedBy = "由谁实现"; +$lang->metric->removedBy = "由谁下架"; +$lang->metric->lastEdited = "最后修改"; $lang->metric->legendBasicInfo = '基本信息'; $lang->metric->legendCreateInfo = '创建编辑信息'; diff --git a/module/metric/model.php b/module/metric/model.php index 07726046e5..5ba909a10e 100755 --- a/module/metric/model.php +++ b/module/metric/model.php @@ -57,12 +57,27 @@ class metricModel extends model * @access public * @return object|false */ - public function getByCode($code, $fieldList = '*') + public function getByCode(string $code, string|array $fieldList = '*') { if(is_array($fieldList)) $fieldList = implode(',', $fieldList); return $this->dao->select($fieldList)->from(TABLE_METRIC)->where('code')->eq($code)->fetch(); } + /** + * 根据ID获取度量项信息。 + * Get metric info by id. + * + * @param int $metricID + * @param string|array $fieldList + * @access public + * @return object|false + */ + public function getByID(int $metricID, string|array $fieldList = '*') + { + if(is_array($fieldList)) $fieldList = implode(',', $fieldList); + return $this->dao->select($fieldList)->from(TABLE_METRIC)->where('id')->eq($metricID)->fetch(); + } + /** * 获取度量项数据源句柄。 * Get data source statement of calculator. diff --git a/module/metric/ui/view.html.php b/module/metric/ui/view.html.php new file mode 100644 index 0000000000..3f08ac1443 --- /dev/null +++ b/module/metric/ui/view.html.php @@ -0,0 +1,110 @@ + + * @package metric + * @link http://www.zentao.net + */ +namespace zin; + +/** + * Build content of table data. + * + * @param array $items + * @access public + * @return array + */ +$buildItems = function($items): array +{ + $itemList = array(); + foreach($items as $item) + { + $itemList[] = item + ( + set::name($item['name']), + !empty($item['href']) ? a + ( + set::href($item['href']), + !empty($item['attr']) && is_array($item['attr']) ? set($item['attr']) : null, + $item['text'] + ) : $item['text'], + set::collapse(!empty($item['text'])), + ); + } + + return $itemList; +}; + +detailHeader +( + to::title + ( + entityLabel + ( + set::entityID($metric->id), + set::level(), + set::text($metric->name) + ) + ), + to::prefix + ( + backBtn + ( + set::icon('back'), + set::class('ghost text-white'), + $lang->goback + ) + ) +); + +detailBody +( + sectionList + ( + section + ( + set::title($lang->metric->desc), + set::content($metric->desc), + set::useHtml(true) + ), + section + ( + set::title($lang->metric->formula), + set::content($metric->definition), + set::useHtml(true) + ) + ), + history(), + detailSide + ( + tabs + ( + set::collapse(true), + tabPane + ( + set::key('legendBasicInfo'), + set::title($lang->metric->legendBasicInfo), + set::active(true), + tableData + ( + $buildItems($legendBasic) + ) + ), + tabPane + ( + set::key('legendCreateInfo'), + set::title($lang->metric->legendCreateInfo), + tableData + ( + $buildItems($createEditInfo) + ) + ) + ), + ) +); + +render(); diff --git a/module/metric/zen.php b/module/metric/zen.php index 0403ee8988..917803d852 100644 --- a/module/metric/zen.php +++ b/module/metric/zen.php @@ -91,4 +91,48 @@ class metricZen extends metric } } } + + /** + * 获取度量项的基本信息。 + * Get the basic information of the metric. + * + * @param object $view + * @access protected + * @return array + */ + protected function getBasicInfo(object $view) + { + extract((array)$view); + + $legendBasic = array(); + $legendBasic['scope'] = array('name' => $this->lang->metric->scope, 'text' => zget($this->lang->metric->scopeList, $metric->scope)); + $legendBasic['object'] = array('name' => $this->lang->metric->object, 'text' => zget($this->lang->metric->objectList, $metric->object)); + $legendBasic['purpose'] = array('name' => $this->lang->metric->purpose, 'text' => zget($this->lang->metric->purposeList, $metric->purpose)); + $legendBasic['code'] = array('name' => $this->lang->metric->code, 'text' => $metric->code); + $legendBasic['unit'] = array('name' => $this->lang->metric->unit, 'text' => $metric->unit); + $legendBasic['stage'] = array('name' => $this->lang->metric->stage, 'text' => zget($this->lang->metric->stageList, $metric->stage)); + + return $legendBasic; + } + + /** + * 获取度量项的创建和编辑信息。 + * Get the create and edit information of the metric. + * + * @param object $view + * @access protected + * @return array + */ + protected function getCreateEditInfo(object $view) + { + extract((array)$view); + + $createEditInfo = array(); + $createEditInfo['createdBy'] = array('name' => $this->lang->metric->createdBy, 'text' => zget($users, $metric->createdBy) . ($metric->createdBy ? $this->lang->at . $metric->createdBy : '')); + $createEditInfo['implementedBy'] = array('name' => $this->lang->metric->implementedBy, 'text' => zget($users, $metric->implementedBy) . ($metric->implementedBy ? $this->lang->at . $metric->implementedBy : '')); + $createEditInfo['removedBy'] = array('name' => $this->lang->metric->removedBy, 'text' => zget($users, $metric->removedBy) . ($metric->removedBy ? $this->lang->at . $metric->removedBy : '')); + + return $createEditInfo; + + } }