diff --git a/app/controller/Task.php b/app/controller/Task.php index da2fe55..8058c4f 100644 --- a/app/controller/Task.php +++ b/app/controller/Task.php @@ -108,6 +108,13 @@ class Task extends BaseController public function save() { $params = $this->request->param(); + $cache_name = md5($params); + if (Cache::get($cache_name)) { + $this->json_data['code'] = 0; + $this->json_data['msg'] = '表单已提交,请勿重复操作'; + return json($this->json_data); + } + Cache::set($cache_name, 1, 60); $type = $this->request->param('task_type', '0'); $original_filename = $this->request->param('original_filename'); $filename = $this->request->param('filename'); diff --git a/app/view/task/index.html b/app/view/task/index.html index dee8cea..8eb7157 100644 --- a/app/view/task/index.html +++ b/app/view/task/index.html @@ -391,9 +391,9 @@ function task_add() { var task_type = $('[name="task_type"]:checked').val(); - if (task_type == 5 || task_type == 2) { - var name = task_type == 5 ? $('#original_filename').val() : $('#queue-name').val(); - var type = task_type == 5 ? 'update' : 'export'; + if (task_type == 5 || task_type == 2 || task_type == 1) { + var name = task_type == 2 ? $('#queue-name').val() : $('#original_filename').val(); + var type = task_type == 2 ? 'export' : 'update'; $.get('{:url("task/checkIsExistName")}?name=' + name + '&type=' + type, function (ret) { if (ret.code == 1) { layer.confirm(ret.msg, function (index) { @@ -403,17 +403,25 @@ }else if (ret.code == 0) { layer.alert(ret.msg); }else if (ret.code == 2) { - submitForm(); + layer.confirm('确认并继续', function (index) { + layer.close(index); + submitForm(); + }); } }); }else { - submitForm(); + layer.confirm('确认并继续', function (index) { + layer.close(index); + submitForm(); + }); } } function submitForm(){ $.post('{:url("task/save")}', $('#task-model-add').find('.active :input').serialize(), function (ret) { if(ret.code == 0){ + $('#original_filename').val(''); + $('#filename').val(''); layer.alert(ret.msg); }else { layer.msg(ret['msg'],function(){