表单提交后清空上传文件表单

提交增加确认
导入增加文件名检测
提交增加重复检测,60秒
master
zhaocheng 2 years ago
parent c82e4a8df1
commit 541d17e062
  1. 7
      app/controller/Task.php
  2. 18
      app/view/task/index.html

@ -108,6 +108,13 @@ class Task extends BaseController
public function save() public function save()
{ {
$params = $this->request->param(); $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'); $type = $this->request->param('task_type', '0');
$original_filename = $this->request->param('original_filename'); $original_filename = $this->request->param('original_filename');
$filename = $this->request->param('filename'); $filename = $this->request->param('filename');

@ -391,9 +391,9 @@
function task_add() { function task_add() {
var task_type = $('[name="task_type"]:checked').val(); var task_type = $('[name="task_type"]:checked').val();
if (task_type == 5 || task_type == 2) { if (task_type == 5 || task_type == 2 || task_type == 1) {
var name = task_type == 5 ? $('#original_filename').val() : $('#queue-name').val(); var name = task_type == 2 ? $('#queue-name').val() : $('#original_filename').val();
var type = task_type == 5 ? 'update' : 'export'; var type = task_type == 2 ? 'export' : 'update';
$.get('{:url("task/checkIsExistName")}?name=' + name + '&type=' + type, function (ret) { $.get('{:url("task/checkIsExistName")}?name=' + name + '&type=' + type, function (ret) {
if (ret.code == 1) { if (ret.code == 1) {
layer.confirm(ret.msg, function (index) { layer.confirm(ret.msg, function (index) {
@ -403,17 +403,25 @@
}else if (ret.code == 0) { }else if (ret.code == 0) {
layer.alert(ret.msg); layer.alert(ret.msg);
}else if (ret.code == 2) { }else if (ret.code == 2) {
submitForm(); layer.confirm('确认并继续', function (index) {
layer.close(index);
submitForm();
});
} }
}); });
}else { }else {
submitForm(); layer.confirm('确认并继续', function (index) {
layer.close(index);
submitForm();
});
} }
} }
function submitForm(){ function submitForm(){
$.post('{:url("task/save")}', $('#task-model-add').find('.active :input').serialize(), function (ret) { $.post('{:url("task/save")}', $('#task-model-add').find('.active :input').serialize(), function (ret) {
if(ret.code == 0){ if(ret.code == 0){
$('#original_filename').val('');
$('#filename').val('');
layer.alert(ret.msg); layer.alert(ret.msg);
}else { }else {
layer.msg(ret['msg'],function(){ layer.msg(ret['msg'],function(){

Loading…
Cancel
Save