diff --git a/module/programplan/js/edit.ui.js b/module/programplan/js/edit.ui.js index 70980cf1dc..c437dcbe93 100644 --- a/module/programplan/js/edit.ui.js +++ b/module/programplan/js/edit.ui.js @@ -8,12 +8,22 @@ function changeParentStage(event) { const stageID = parseInt($(event.target).val()); - if(stageID == 0) $('#acl').attr('disabled', false); - $('#acl').attr('disabled', true); + $('#acl').attr('disabled', stageID != 0); - $.get($.createLink('programplan', 'ajaxGetAttribute', 'stageID=' + stageID + '&attribute=' + plan.attribute), function(attribute) + $.get($.createLink('programplan', 'ajaxGetStageAttr', 'stageID=' + stageID), function(attribute) { - $('#attributeType').html(attribute); + var isPicker = $('#attributeType').find('.picker-box').length > 0; + if((attribute.length == 0 || attribute == 'mix') && !isPicker) + { + $('#attributeType').empty().append('
'); + $('#attribute').picker({name: 'attribute', items: stageTypeItems, defaultValue: attribute}); + } + if(isPicker && attribute != 'mix' && attribute.length > 0) + { + $('#attributeType').find('[name=attribute]').zui('picker').destroy(); + $('#attributeType').find('.picker-box').remove(); + $('#attributeType').append('' + stageTypeList[attribute] + ''); + } }); } @@ -23,31 +33,43 @@ function changeParentStage(event) * * @return void */ -function editStage() +window.editStage = function() { - if(plan.parent != $('#parent').val() && $('#parent').val() != 0) + var result = true; + var currentParent = $('[name=parent]').val(); + if(plan.parent != currentParent && currentParent != 0) { - var result = true; - - $.get($.createLink('programplan', 'ajaxGetStageAttr', 'stageID=' + $('#parent').val()), function(attribute) + result = false; + $.get($.createLink('programplan', 'ajaxGetStageAttr', 'stageID=' + currentParent), function(attribute) { - if(attribute != 'mix' && plan.attribute != attribute) - { - result = confirm(changeAttrLang.replace('%s', stageTypeList[attribute])); - } + if(attribute != 'mix' && plan.attribute != attribute) zui.Modal.confirm(changeAttrLang.replace('%s', stageTypeList[attribute])).then((res) => + { + if(res) + { + var $form = $('#editForm'); + var formUrl = $form.attr('action'); + var formData = new FormData($form[0]); + $.ajaxSubmit({url: formUrl, data: formData}); + } + }); }); - - if(!result) return; } - var currentAttribute = $('#attribute').val(); - var currentParent = $('#parent').val(); + var currentAttribute = $('[name=attribute]').val(); var hasChangedAttribute = (currentAttribute && currentAttribute != 'mix' && plan.attribute != currentAttribute); - var hasChangedParent = ((isTopStage && $('#parent').val() != 0) || (!isTopStage && plan.parent != $('#parent').val())); + var hasChangedParent = ((isTopStage && currentParent != 0) || (!isTopStage && plan.parent != currentParent)); if(hasChangedAttribute && !hasChangedParent && !isLeafStage) { - var result = confirm(changeAttrLang.replace('%s', stageTypeList[currentAttribute])); - - if(!result) return; + zui.Modal.confirm(changeAttrLang.replace('%s', stageTypeList[currentAttribute])).then((res) => + { + if(res) + { + var $form = $('#editForm'); + var formUrl = $form.attr('action'); + var formData = new FormData($form[0]); + $.ajaxSubmit({url: formUrl, data: formData}); + } + }); } + return result; } diff --git a/module/programplan/tao.php b/module/programplan/tao.php index 8e2e2cb786..c5a5b1c4d6 100644 --- a/module/programplan/tao.php +++ b/module/programplan/tao.php @@ -153,7 +153,7 @@ class programplanTao extends programplanModel return false; } - if($projectID) $this->loadModel('execution')->checkBeginAndEndDate($projectID, $plan->begin, $plan->end); + if($projectID) $this->loadModel('execution')->checkBeginAndEndDate($projectID, $plan->begin, $plan->end, $plan->parent); if(dao::isError()) return false; $setCode = isset($this->config->setCode) && $this->config->setCode == 1; diff --git a/module/programplan/ui/edit.html.php b/module/programplan/ui/edit.html.php index 1b80e19789..9bb24a6695 100644 --- a/module/programplan/ui/edit.html.php +++ b/module/programplan/ui/edit.html.php @@ -11,9 +11,12 @@ declare(strict_types=1); */ namespace zin; -$typeList = $project->model == 'ipd' ? $lang->stage->ipdTypeList : $lang->stage->typeList; +$typeList = $project->model == 'ipd' ? $lang->stage->ipdTypeList : $lang->stage->typeList; +$typeItems = array(); +foreach($typeList as $key => $value) $typeItems[] = array('text' => $value, 'value' => $key); jsVar('plan', $plan); jsVar('stageTypeList', $typeList); +jsVar('stageTypeItems', $typeItems); jsVar('changeAttrLang', $lang->programplan->confirmChangeAttr); jsVar('isTopStage', $isTopStage); jsVar('isLeafStage', $isLeafStage); @@ -27,6 +30,8 @@ modalHeader formPanel ( + set::id('editForm'), + set::ajax(array('beforeSubmit' => jsRaw("editStage"))), set::submitBtnText($lang->save), formGroup ( @@ -49,8 +54,7 @@ formPanel set::required(true), input(set::name('name'), set::value($plan->name)) ), - isset($config->setCode) && $config->setCode == 1 ? - formGroup + isset($config->setCode) && $config->setCode == 1 ? formGroup ( set::label($lang->execution->code), set::width('1/2'), @@ -91,33 +95,24 @@ formPanel ( setID('attributeType'), setClass('flex self-center w-full'), - $enableOptionalAttr ? - select(set(array( - 'id' => 'attribute', - 'name' => 'attribute', - 'items' => $typeList, - 'value' => $plan->attribute, - 'required' => true - ))) : zget($typeList, $plan->attribute) + $enableOptionalAttr ? picker + ( + set::id('attribute'), + set::name('attribute'), + set::items($typeList), + set::value($plan->attribute), + set::required(true) + ) : zget($typeList, $plan->attribute), ) ), formGroup ( - btn(set(array( - 'icon' => 'help', - 'data-toggle' => 'tooltip', - 'data-placement' => 'right', - 'href' => 'helpTip', - 'class' => 'ghost h-8 tooltip-btn' - ))), - div + setClass('items-center'), + icon ( - $lang->execution->typeTip, - setClass('w-1/3'), - set(array( - 'id' => 'helpTip', - 'class' => 'tooltip darker' - )) + 'help', + toggle::tooltip(array('title' => $lang->execution->typeTip, 'placement' => 'right')), + setClass('ghost ml-1') ) ) ), @@ -148,7 +143,7 @@ formPanel ( set::label($lang->project->acl), set::width('1/2'), - select + picker ( set::name('acl'), set::items($lang->execution->aclList), @@ -157,12 +152,12 @@ formPanel set::required(true) ) ), - $plan->setMilestone ? - formGroup + $plan->setMilestone ? formGroup ( set::label($lang->programplan->milestone), set::width('1/2'), - radioList( + radioList + ( set::name('milestone'), set::items($lang->programplan->milestoneList), set::value($plan->milestone), @@ -174,13 +169,14 @@ formPanel ( set::label($lang->programplan->output), set::width('1/2'), - select(set(array( - 'name' => 'output[]', - 'items' => $documentList, - 'value' => $plan->output, - 'multiple' => true, - 'required' => true - ))) + picker + ( + set::name('output[]'), + set::items($documentList), + set::value($plan->output), + set::multiple(true), + set::required(true) + ) ) : null );