* Refactor programplan ajaxCustom page.

This commit is contained in:
wangyidong
2023-12-29 10:12:05 +08:00
parent bf6e53ecc7
commit 1b977b040a
5 changed files with 27 additions and 34 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ $config->programplan->form->edit['output'] = array('required' => false, 'type
$config->programplan->form->ajaxCustom = array();
$config->programplan->form->ajaxCustom['zooming'] = array('required' => false, 'type' => 'string');
$config->programplan->form->ajaxCustom['stageCustom'] = array('required' => false, 'type' => 'array');
$config->programplan->form->ajaxCustom['ganttFields'] = array('required' => false, 'type' => 'array');
$config->programplan->form->ajaxCustom['stageCustom'] = array('required' => false, 'type' => 'array', 'filter' => 'join');
$config->programplan->form->ajaxCustom['ganttFields'] = array('required' => false, 'type' => 'array', 'filter' => 'join');
$config->programplan->form->updateDateByGantt['id'] = array('required' => false, 'type' => 'int', 'default' => 0);
$config->programplan->form->updateDateByGantt['startDate'] = array('required' => false, 'type' => 'string', 'default' => null);
+4 -6
View File
@@ -181,10 +181,10 @@ class programplan extends control
if($_POST)
{
$formData = form::data($this->config->product->form->create);
$this->programplanZen->beforeAjaxCustom($formData, $owner, $module);
$settings = form::data($this->config->programplan->form->ajaxCustom)->get();
$this->programplan->saveCustomSetting($settings, $owner, $module);
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'load' => true));
}
/* Set Custom. */
@@ -203,9 +203,7 @@ class programplan extends control
{
if(!$this->post->id || !$this->post->type) return $this->send(array('result' => 'fail', 'message' => ''));
$objectID = $this->post->id;
$objectType = $this->post->type;
$postData = form::data($this->config->programplan->form->updateDateByGantt)->get();
$postData = form::data($this->config->programplan->form->updateDateByGantt)->get();
$this->loadModel('task')->updateEsDateByGantt($postData);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
+21
View File
@@ -936,4 +936,25 @@ class programplanModel extends model
{
return $this->dao->select('attribute')->from(TABLE_EXECUTION)->where('id')->eq($stageID)->fetch('attribute');
}
/**
* 保存自定义配置
* Save custom setting.
*
* @param object $settings
* @param string $owner
* @param string $module
* @access protected
* @return void
*/
protected function saveCustomSetting(object $settings, string $owner, string $module): void
{
$zooming = zget($settings, 'zooming', '');
$stageCustom = zget($settings, 'stageCustom', '');
$ganttFields = zget($settings, 'ganttFields', '');
$this->setting->setItem("$owner.$module.browse.stageCustom", $stageCustom);
$this->setting->setItem("$owner.$module.ganttCustom.ganttFields", $ganttFields);
$this->setting->setItem("$owner.$module.ganttCustom.zooming", $zooming);
}
}
-1
View File
@@ -34,7 +34,6 @@ class programplanTao extends programplanModel
->autoCheck()
->batchCheckIF($requiredFields, $requiredFields, 'notempty')
->checkIF($plan->end != '0000-00-00', 'end', 'ge', $plan->begin)
->checkIF(!empty($plan->percent), 'percent', 'float')
->checkIF(!empty($plan->name) && $getname, 'name', 'unique', "id in ({$relatedExecutionsID}) and type in ('sprint','stage') and `project` = {$oldPlan->project} and `deleted` = '0' and `parent` = {$oldPlan->parent}")
->checkIF(!empty($plan->code) && $setCode, 'code', 'unique', "id != {$plan->id} and type in ('sprint','stage','kanban') and `deleted` = '0'")
->where('id')->eq($plan->id)
-25
View File
@@ -196,31 +196,6 @@ class programplanZen extends programplan
$this->display();
}
/**
* 处理请求数据
* Processing request data.
*
* @param object $formData
* @param string $owner
* @param string $module
* @access protected
* @return object
*/
protected function beforeAjaxCustom(object $formData, string $owner, string $module): object
{
$data = $formData->get();
$zooming = empty($data->zooming) ? '' : $data->zooming;
$stageCustom = empty($data->stageCustom) ? '' : implode(',', $data->stageCustom);
$ganttFields = empty($data->ganttFields) ? '' : implode(',', $data->ganttFields);
$this->setting->setItem("$owner.$module.browse.stageCustom", $stageCustom);
$this->setting->setItem("$owner.$module.ganttCustom.ganttFields", $ganttFields);
$this->setting->setItem("$owner.$module.ganttCustom.zooming", $zooming);
return $data;
}
/**
* 生成自定义设置视图。
* Build custom setting view form data.