From 1b977b040a14bedfd13db1177a10af16201f93fd Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 27 Dec 2023 14:30:09 +0800 Subject: [PATCH] * Refactor programplan ajaxCustom page. --- module/programplan/config/form.php | 4 ++-- module/programplan/control.php | 10 ++++------ module/programplan/model.php | 21 +++++++++++++++++++++ module/programplan/tao.php | 1 - module/programplan/zen.php | 25 ------------------------- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/module/programplan/config/form.php b/module/programplan/config/form.php index 4a4af6c668..070e1ed753 100644 --- a/module/programplan/config/form.php +++ b/module/programplan/config/form.php @@ -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); diff --git a/module/programplan/control.php b/module/programplan/control.php index 3561b5308d..3a9399f79c 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -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())); diff --git a/module/programplan/model.php b/module/programplan/model.php index eef34d21f1..ebc21190a7 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -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); + } } diff --git a/module/programplan/tao.php b/module/programplan/tao.php index d20603ee13..1198321033 100644 --- a/module/programplan/tao.php +++ b/module/programplan/tao.php @@ -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) diff --git a/module/programplan/zen.php b/module/programplan/zen.php index 80a96ec183..57b85e8eab 100644 --- a/module/programplan/zen.php +++ b/module/programplan/zen.php @@ -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.