From 541d17e062d7bc566ff0ce49ce439aa9a61ad5d0 Mon Sep 17 00:00:00 2001 From: zhaocheng <578322713@qq.com> Date: Wed, 31 Aug 2022 15:32:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=8F=90=E4=BA=A4=E5=90=8E?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=20=E6=8F=90=E4=BA=A4=E5=A2=9E=E5=8A=A0=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=20=E5=AF=BC=E5=85=A5=E5=A2=9E=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E6=A3=80=E6=B5=8B=20=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=A4=8D=E6=A3=80=E6=B5=8B=EF=BC=8C?= =?UTF-8?q?60=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Task.php | 7 +++++++ app/view/task/index.html | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) 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(){