From db4328a225d626dfaf63ea8678c3215d84964c46 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Thu, 12 Nov 2020 13:23:39 +0800 Subject: [PATCH] * Finish task#8334. --- module/workestimation/config.php | 2 +- module/workestimation/js/index.js | 2 -- module/workestimation/model.php | 23 +++++++---------------- module/workestimation/view/index.html.php | 6 ++++-- 4 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 module/workestimation/js/index.js diff --git a/module/workestimation/config.php b/module/workestimation/config.php index 2309bdcb91..c011e1ef40 100644 --- a/module/workestimation/config.php +++ b/module/workestimation/config.php @@ -1,4 +1,4 @@ workestimation = new stdclass; $config->workestimation->index = new stdclass; -$config->workestimation->index->requiredFields = 'scale,productivity,scale,duration,unitLaborCost,totalLaborCost'; +$config->workestimation->index->requiredFields = 'scale,productivity,duration,unitLaborCost,totalLaborCost'; diff --git a/module/workestimation/js/index.js b/module/workestimation/js/index.js deleted file mode 100644 index 91a9de00b7..0000000000 --- a/module/workestimation/js/index.js +++ /dev/null @@ -1,2 +0,0 @@ -$('#scale+span').css('padding', '5px 27px'); -$('#duration+span').css('padding', '5px 33px') diff --git a/module/workestimation/model.php b/module/workestimation/model.php index 0c42095aa4..0da0ee4bdd 100644 --- a/module/workestimation/model.php +++ b/module/workestimation/model.php @@ -46,25 +46,16 @@ class workestimationModel extends model */ public function save($program) { - $budget = $this->getBudget($program); $postBudget = fixer::input('post')->get(); $postBudget->PRJ = $program; - if(empty($budget)) - { - $this->dao->insert(TABLE_WORKESTIMATION) - ->batchcheck($this->config->workestimation->index->requiredFields, 'notempty') - ->data($postBudget) - ->exec(); - } - else - { - $postBudget->id = $budget->id; - $this->dao->replace(TABLE_WORKESTIMATION) - ->batchcheck($this->config->workestimation->index->requiredFields, 'notempty') - ->data($postBudget) - ->exec(); - } + $budget = $this->getBudget($program); + if(!empty($budget)) $postBudget->id = $budget->id; + + $this->dao->replace(TABLE_WORKESTIMATION)->data($postBudget) + ->batchCheck($this->config->workestimation->index->requiredFields, 'notempty') + ->exec(); + return !dao::isError(); } } diff --git a/module/workestimation/view/index.html.php b/module/workestimation/view/index.html.php index 28c4afc650..5654d5ee4b 100644 --- a/module/workestimation/view/index.html.php +++ b/module/workestimation/view/index.html.php @@ -100,13 +100,15 @@ $(function() $(':input').keyup(function() { - duration = parseFloat($('#scale').val()) * parseFloat($('#productivity').val()); + duration = parseFloat($('#scale').val()) * parseFloat($('#productivity').val()).toFixed(2); + duration = duration.toFixed(2); if(!isNaN(duration)) $('#duration').val(duration); if(isNaN(duration)) $('#duration').val(''); totalLaborCost = parseFloat($('#unitLaborCost').val()) * parseFloat($('#duration').val()); + totalLaborCost = totalLaborCost.toFixed(2); if(!isNaN(totalLaborCost)) $('#totalLaborCost').val(totalLaborCost); - if(isNaN(totalLaborCost)) $('#totalLaborCost').val(''); + if(isNaN(totalLaborCost)) $('#totalLaborCost').val(''); }); $('#scale').change(); });