diff --git a/framework/control.class.php b/framework/control.class.php index 99df999935..1f73b8e7c7 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -627,53 +627,6 @@ class control extends baseControl return array(); } - /** - * 追加工作流新增的字段到表单提交配置。 - * append workflow form config. - * - * @param array $config - * @param string $moduleName - * @param string $methodName - * @access public - * @return array - */ - public function appendExtendFormConfig(array $config, string $moduleName = '', string $methodName = ''): array - { - if($this->config->edition == 'open') return $config; - - $moduleName = $moduleName ? $moduleName : $this->app->getModuleName(); - $methodName = $methodName ? $moduleName : $this->app->getMethodName(); - - $flow = $this->loadModel('workflow')->getByModule($moduleName); - if(!$flow) return $config; - - $action = $this->loadModel('workflowaction')->getByModuleAndAction($flow->module, $methodName); - if(!$action) return $config; - - $fieldList = $this->workflowaction->getFields($flow->module, $action->action); - $layouts = $this->loadModel('workflowlayout')->getFields($moduleName, $methodName); - $notEmptyRule = $this->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty'); - if($layouts) - { - foreach($fieldList as $key => $field) - { - if($field->buildin || !$field->show || !isset($layouts[$field->field])) continue; - - $required = $field->readonly || ($notEmptyRule && strpos(",$field->rules,", ",{$notEmptyRule->id},") !== false); - if($field->control == 'multi-select' || $field->control == 'checkbox') - { - $config[$field->field] = array('required' => $required, 'type' => 'array', 'default' => array(''), 'filter' => 'join'); - } - else - { - $config[$field->field] = array('required' => $required, 'type' => 'string'); - if($field->control == 'richtext') $config[$field->field]['control'] = 'editor'; - } - } - } - return $config; - } - /** * Process status of an object according to its subStatus. * diff --git a/lib/form/form.class.php b/lib/form/form.class.php index 78977d7923..cb1e793e37 100644 --- a/lib/form/form.class.php +++ b/lib/form/form.class.php @@ -71,9 +71,10 @@ class form extends fixer { global $app, $config; + $form = new form; if($configObject === null) $configObject = $config->{$app->moduleName}->form->{$app->methodName}; - $configObject = $app->control->appendExtendFormConfig($configObject); - return (new form)->config($configObject); + $configObject = $form->appendExtendFormConfig($configObject); + return $form->config($configObject); } /** @@ -87,9 +88,59 @@ class form extends fixer { global $app, $config; + $form = new form; if($configObject === null) $configObject = $config->{$app->moduleName}->form->{$app->methodName}; - $configObject = $app->control->appendExtendFormConfig($configObject); - return (new form)->config($configObject, 'batch'); + $configObject = $form->appendExtendFormConfig($configObject); + return $form->config($configObject, 'batch'); + } + + + /** + * 追加工作流新增的字段到表单提交配置。 + * append workflow form config. + * + * @param array $config + * @param string $moduleName + * @param string $methodName + * @access public + * @return array + */ + public function appendExtendFormConfig(array $configObject, string $moduleName = '', string $methodName = ''): array + { + global $app, $config; + if($config->edition == 'open') return $configObject; + + $moduleName = $moduleName ? $moduleName : $app->getModuleName(); + $methodName = $methodName ? $moduleName : $app->getMethodName(); + + $flow = $app->control->loadModel('workflow')->getByModule($moduleName); + if(!$flow) return $configObject; + + $action = $app->control->loadModel('workflowaction')->getByModuleAndAction($flow->module, $methodName); + if(!$action) return $configObject; + + $fieldList = $app->control->workflowaction->getFields($flow->module, $action->action); + $layouts = $app->control->loadModel('workflowlayout')->getFields($moduleName, $methodName); + $notEmptyRule = $app->control->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty'); + if($layouts) + { + foreach($fieldList as $key => $field) + { + if($field->buildin || !$field->show || !isset($layouts[$field->field])) continue; + + $required = $field->readonly || ($notEmptyRule && strpos(",$field->rules,", ",{$notEmptyRule->id},") !== false); + if($field->control == 'multi-select' || $field->control == 'checkbox') + { + $configObject[$field->field] = array('required' => $required, 'type' => 'array', 'default' => array(''), 'filter' => 'join'); + } + else + { + $configObject[$field->field] = array('required' => $required, 'type' => 'string'); + if($field->control == 'richtext') $configObject[$field->field]['control'] = 'editor'; + } + } + } + return $configObject; } /** diff --git a/module/my/test/model/getactions.php b/module/my/test/model/getactions.php index 2291809653..10329693f8 100755 --- a/module/my/test/model/getactions.php +++ b/module/my/test/model/getactions.php @@ -17,6 +17,11 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/my.class.php'; zdtable('action')->gen('100'); +zdtable('doc')->gen('0'); +zdtable('api')->gen('0'); +zdtable('doclib')->gen('0'); +zdtable('project')->gen('0'); +zdtable('product')->gen('0'); zdTable('user')->gen('1'); su('admin'); diff --git a/module/pivot/test/model/processdatevar.php b/module/pivot/test/model/processdatevar.php index b0eea3ca57..bdb712d2ac 100644 --- a/module/pivot/test/model/processdatevar.php +++ b/module/pivot/test/model/processdatevar.php @@ -21,13 +21,14 @@ $pivot = new pivotTest(); $varList = array('', '123123123', '$MONDAY', '$SUNDAY', '$MONTHBEGIN', '$MONTHEND'); -$monday = date('Y-m-d', strtotime('this monday')); -$sunday = date('Y-m-d', strtotime('this sunday')); + +$monday = date('Y-m-d', strtotime('monday this week')); +$sunday = date('Y-m-d', strtotime('sunday this week')); $monthbegin = date('Y-m-01'); $monthend = date('Y-m-t'); -r($pivot->processDateVar($varList[0])) && p('') && e('0'); //测试空值 -r($pivot->processDateVar($varList[1])) && p('') && e('123123123'); //测试非法值生成是正确 +r($pivot->processDateVar($varList[0])) && p('') && e('0'); //测试空值 +r($pivot->processDateVar($varList[1])) && p('') && e('123123123'); //测试非法值生成是正确 r($pivot->processDateVar($varList[2]) === $monday) && p('') && e('1'); //测试$MONDAY生成是否正确 r($pivot->processDateVar($varList[3]) === $sunday) && p('') && e('1'); //测试$SUNDAY生成是否正确 r($pivot->processDateVar($varList[4]) === $monthbegin) && p('') && e('1'); //测试$MONTHBEGIN生成是否正确 diff --git a/module/repo/test/model/saveaction2pms.php b/module/repo/test/model/saveaction2pms.php index e82f41fde3..bddd176bcd 100755 --- a/module/repo/test/model/saveaction2pms.php +++ b/module/repo/test/model/saveaction2pms.php @@ -52,6 +52,8 @@ $bug = zdTable('bug'); $bug->execution->range('0'); $bug->gen(10); +zdTable('product')->gen(20); +zdTable('user')->gen(20); zdTable('repo')->config('repo')->gen(4); global $app; @@ -87,4 +89,4 @@ $log->msg = $log->comment = 'Fix bug#1,2'; $repo->saveAction2PMSTest($log, $repoID); $result = $tester->loadModel('bug')->getByIdList(array(1,2)); r($result) && p('1:status,resolution') && e('resolved,fixed'); //修复bug1 -r($result) && p('2:status,resolution') && e('resolved,fixed'); //修复bug2 \ No newline at end of file +r($result) && p('2:status,resolution') && e('resolved,fixed'); //修复bug2 diff --git a/module/screen/test/model/buildcomponent.php b/module/screen/test/model/buildcomponent.php index 1a5a54a1bc..13bdce3dfd 100755 --- a/module/screen/test/model/buildcomponent.php +++ b/module/screen/test/model/buildcomponent.php @@ -3,6 +3,7 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/screen.class.php'; +zdTable('screen')->gen(0); zdTable('product')->gen(2); zdTable('story')->config('story')->gen(20); zdTable('action')->gen(20); @@ -58,4 +59,4 @@ if($component3) $screen->buildComponentTest($component3); r($component3->styles && $component->status && $component->request) && p('') && e('1'); //非列表的组件判断是否给予了默认的属性。 if($component4) $screen->buildComponentTest($component4); -r($component3->styles && $component->status && $component->request) && p('') && e('1'); //列表的组件判断是否给予了默认的属性。 \ No newline at end of file +r($component3->styles && $component->status && $component->request) && p('') && e('1'); //列表的组件判断是否给予了默认的属性。 diff --git a/module/screen/test/model/genchartdata.php b/module/screen/test/model/genchartdata.php index 84c4e2cb51..4c9c41ef44 100755 --- a/module/screen/test/model/genchartdata.php +++ b/module/screen/test/model/genchartdata.php @@ -24,6 +24,8 @@ cid=1 include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/screen.class.php'; +zdTable('screen')->gen(0); + $screenTest = new screenTest(); $screenIDList = array(1, 5, 8); $screenList = array(); @@ -45,4 +47,4 @@ r($editCanvasConfig) && p('width,height') && e('1300, 3267'); // 测试id为1的 r($componentList) && p('0:id;43:id') && e('5scfjzqsbzo000;1j55da3c41vk00'); list($schmea, $filter) = $screenTest->genChartDataTest($screenList[5], $yearList[1], 0, $deptList[1], $accountList[1]); -r($filter) && p('year,dept,account') && e('2022,1,admin'); //测试传入的过滤参数是否正常赋值。 \ No newline at end of file +r($filter) && p('year,dept,account') && e('2022,1,admin'); //测试传入的过滤参数是否正常赋值。 diff --git a/module/screen/test/model/gencomponentdata.php b/module/screen/test/model/gencomponentdata.php index 3a3242235b..f1ddc0b2e1 100755 --- a/module/screen/test/model/gencomponentdata.php +++ b/module/screen/test/model/gencomponentdata.php @@ -14,6 +14,8 @@ cid=1 */ +zdTable('screen')->gen(0); + global $tester; $screen = new screenTest(); @@ -54,4 +56,4 @@ $chart2->sql = ''; $chart2->filters = '[{"field":"type","type":"int"}]'; $screen->genComponentDataTest($chartList[1], $componentList[1], $typeList[1], array()); -r($chart2_->sql !== $chart2->sql) && p('') && e(1); //判断图表的sql字段是否被修改 \ No newline at end of file +r($chart2_->sql !== $chart2->sql) && p('') && e(1); //判断图表的sql字段是否被修改 diff --git a/module/screen/test/model/getbyid.php b/module/screen/test/model/getbyid.php index d1ef0154e5..780ebc072d 100755 --- a/module/screen/test/model/getbyid.php +++ b/module/screen/test/model/getbyid.php @@ -20,6 +20,8 @@ cid=1 */ +zdTable('screen')->gen(0); + $screen = new screenTest(); $screenIDList = array(0, 1, 2, 3, 4, 5, 6, 7, 8); @@ -83,4 +85,4 @@ foreach($result->chartData->componentList as $component) } } -r($chart2 && $chart2->chartConfig->dataset == $chart2->option->dataset) && p('') && e(1); //测试screenID为6的情况 \ No newline at end of file +r($chart2 && $chart2->chartConfig->dataset == $chart2->option->dataset) && p('') && e(1); //测试screenID为6的情况 diff --git a/module/screen/test/model/getchartfilters.php b/module/screen/test/model/getchartfilters.php index 4e7fe89e1a..a93df3655a 100755 --- a/module/screen/test/model/getchartfilters.php +++ b/module/screen/test/model/getchartfilters.php @@ -18,6 +18,8 @@ cid=1 */ +zdTable('screen')->gen(0); + $screen = new screenTest(); $chart = new stdclass(); @@ -88,4 +90,4 @@ $result = $screen->getChartFiltersTest($chart3); r($result[0]['default']) && p('0,1') && e('1672502400000,1672588800000'); //当from不存在,type为date并且default存在的时候,生成default应该为default的值,检查是否生成了正确的default值。 $result = $screen->getChartFiltersTest($chart5); -r($result) && p('0:default') && e('1672502400000'); //当from不存在,type为date并且default存在的时候,生成default应该为default的值,检查是否生成了正确的default值。 \ No newline at end of file +r($result) && p('0:default') && e('1672502400000'); //当from不存在,type为date并且default存在的时候,生成default应该为default的值,检查是否生成了正确的default值。 diff --git a/module/screen/test/model/getchartoption.php b/module/screen/test/model/getchartoption.php index 5353f696c7..879e2b696b 100755 --- a/module/screen/test/model/getchartoption.php +++ b/module/screen/test/model/getchartoption.php @@ -29,6 +29,8 @@ cid=1 */ +zdTable('screen')->gen(0); + $screen = new screenTest(); function getComponetAndChart($screen, $filters = array()) @@ -124,4 +126,4 @@ r(is_null($component12) && is_null($chart12)) && p('') && e(1); list($component13, $chart13) = getComponetAndChart($screen, $filter12); $screen->getChartOptionTest($chart13, $component13); -r($component13->option->dataset === '0') && p('') && e(1); //测试type为card的图表是否显示正确,生成的指标项和数据项是否正确。 \ No newline at end of file +r($component13->option->dataset === '0') && p('') && e(1); //测试type为card的图表是否显示正确,生成的指标项和数据项是否正确。 diff --git a/module/screen/test/model/getlatestchart.php b/module/screen/test/model/getlatestchart.php index bcae46553c..ad27bd9293 100755 --- a/module/screen/test/model/getlatestchart.php +++ b/module/screen/test/model/getlatestchart.php @@ -14,6 +14,8 @@ cid=1 */ +zdTable('screen')->gen(0); + $screen = new screenTest(); $components = $screen->getAllComponent(array('key' => 'Select')); @@ -35,4 +37,4 @@ foreach($components as $component) } $component2_ = clone($component2); $screen->getLatestChartTest($component2); -r($component2 && $component2 == $component2_) && p('') && e(1); //当component的sourceID不存在时,不会修改component \ No newline at end of file +r($component2 && $component2 == $component2_) && p('') && e(1); //当component的sourceID不存在时,不会修改component diff --git a/module/screen/test/model/gettablechartoption.php b/module/screen/test/model/gettablechartoption.php index 00171e6999..941176d9fd 100755 --- a/module/screen/test/model/gettablechartoption.php +++ b/module/screen/test/model/gettablechartoption.php @@ -19,6 +19,8 @@ cid=1 */ +zdTable('screen')->gen(0); + $screen = new screenTest(); function getComponetAndChart($screen, $filters = array()) @@ -42,4 +44,4 @@ list($component9, $chart9) = getComponetAndChart($screen, $filter9); $screen->getChartOptionTest($chart9, $component9); $option = $component9->option; r(isset($option->header[0]) && count($option->header[0]) == 10) && p('') && e(1); //测试type为table的图表是否显示正确,生成的header指标项数量是否正确。 -r(isset($option->dataset[0]) && count($option->dataset[0]) == 10) && p('') && e(1); //测试type为table的图表是否显示正确,生成的dataset数据项数量是否正确。 \ No newline at end of file +r(isset($option->dataset[0]) && count($option->dataset[0]) == 10) && p('') && e(1); //测试type为table的图表是否显示正确,生成的dataset数据项数量是否正确。 diff --git a/module/screen/test/model/initcomponent.php b/module/screen/test/model/initcomponent.php index 0b5d25bbda..75059b6c41 100755 --- a/module/screen/test/model/initcomponent.php +++ b/module/screen/test/model/initcomponent.php @@ -19,6 +19,8 @@ cid=1 */ +zdTable('screen')->gen(0); + $screen = new screenTest(); $component1 = new stdclass(); @@ -56,4 +58,4 @@ $screen->initComponentTest($chartList[1], $typeList[0], $componentList[1]); r(isset($componentList[1]->option)) && p('') && e(1); //当图表为自定义图表时, 判断是否正确生成了option对象。 r(isset($componentList[1]->option->dataset)) && p('') && e(1); //当图表为自定义图表时,判断是否正确生成了option->dataset对象。 r($componentList[1]->chartConfig->title) && p('') && e('test chart'); //当图表为自定义图表时,组件的设置名称为图表的名称。 -r($componentList[1]->chartConfig->sourceID) && p('') && e(1); //当图表为自定义图表时,组件的设置id为图表的id。 \ No newline at end of file +r($componentList[1]->chartConfig->sourceID) && p('') && e(1); //当图表为自定义图表时,组件的设置id为图表的id。 diff --git a/module/upgrade/test/model/createproject.php b/module/upgrade/test/model/createproject.php index 2247475569..4bf959e555 100644 --- a/module/upgrade/test/model/createproject.php +++ b/module/upgrade/test/model/createproject.php @@ -27,8 +27,8 @@ zdTable('user')->gen(5); zdTable('action')->gen(0); $project = zdTable('project'); -$project->begin->range('2023-11-01')->type('timestamp')->format('YYYY-MM-DD'); -$project->end->range('2023-12-31')->type('timestamp')->format('YYYY-MM-DD'); +$project->begin->range('20231101 000000:0')->type('timestamp')->format('YYYY-MM-DD'); +$project->end->range('20231231 000000:0')->type('timestamp')->format('YYYY-MM-DD'); $project->gen(2); su('admin'); @@ -62,9 +62,9 @@ $emptyName->PM = 'user1'; $programID = array(1, 2); -r($upgrade->createProjectTest($programID[0], $project1)) && p() && e('project:3,项目1,2059-12-31,open; program:2023-12-01,2024-03-12; actionCount:2'); // 测试创建 project1 到项目集 1 +r($upgrade->createProjectTest($programID[0], $project1)) && p() && e('project:3,项目1,2059-12-31,open; program:2023-11-01,2023-12-31; actionCount:2'); // 测试创建 project1 到项目集 1 r($upgrade->createProjectTest($programID[0], $project2)) && p() && e('project:4,项目2,2024-12-31,open; program:2021-12-01,2024-12-31; actionCount:1'); // 测试创建 project2 到项目集 1 -r($upgrade->createProjectTest($programID[1], $project1)) && p() && e('project:5,项目1,2059-12-31,open; program:2023-12-01,2024-03-12; actionCount:2'); // 测试创建 project1 到项目集 2 +r($upgrade->createProjectTest($programID[1], $project1)) && p() && e('project:5,项目1,2059-12-31,open; program:2023-11-01,2023-12-31; actionCount:2'); // 测试创建 project1 到项目集 2 r($upgrade->createProjectTest($programID[1], $project2)) && p() && e('project:6,项目2,2024-12-31,open; program:2021-12-01,2024-12-31; actionCount:1'); // 测试创建 project2 到项目集 2 r($upgrade->createProjectTest($programID[0], $emptyName)) && p('name:0') && e('『项目名称』不能为空。'); // 测试创建 项目名称空 的项目到项目集 1 r($upgrade->createProjectTest($programID[1], $project1)) && p('name:0') && e('『项目名称』已经有『项目1』这条记录了。如果您确定该记录已删除,请到后台-系统设置-回收站还原。'); // 测试重复创建 project1 到项目集 2