* [task#133857,doing,0.2h] adjust code.

This commit is contained in:
zhouxin
2024-12-09 14:30:01 +08:00
committed by 綦新志
parent ebe4db5881
commit db6ef96e82
2 changed files with 29 additions and 2 deletions
+14 -1
View File
@@ -315,7 +315,7 @@ class doc extends control
*/
public function selectTemplate()
{
$templateList = $this->doc->getTemplatesByType();
$templateList = $this->doc->getTemplatesByType(null, 'normal');
$templatePairs = array();
foreach($templateList as $template) $templatePairs[$template->id] = $template->title;
@@ -324,6 +324,19 @@ class doc extends control
$this->display();
}
/**
* Ajax: get template content.
*
* @param int $id
* @access public
* @return void
*/
public function ajaxGetTemplateContent($id)
{
$template = $this->doc->getTemplateContentByID($id);
return print(json_encode(array('type' => $template->type, 'content' => $template->content)));
}
/**
* 文档模板列表。
* Browse template list.
+15 -1
View File
@@ -3996,15 +3996,28 @@ class docModel extends model
return $moduleID;
}
/**
* Get template content by doc id.
*
* @param int $id
* @access public
* @return int
*/
public function getTemplateContentByID($id)
{
return $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->eq($id)->orderBy('version_desc')->fetch();
}
/**
* 获取某个模板类型下的所有模板。
* Get template list by type.
*
* @param int|null $type
* @param string $status
* @access public
* @return int
*/
public function getTemplatesByType($type = null)
public function getTemplatesByType($type = null, $status = 'all')
{
$types = array();
if(!is_null($type))
@@ -4022,6 +4035,7 @@ class docModel extends model
->where('deleted')->eq('0')
->andWhere('templateType')->ne('')
->beginIF(!is_null($type))->andWhere('module')->in($types)->fi()
->beginIF($status != 'all')->andWhere('status')->eq($status)->fi()
->fetchAll('id');
}
}