增加清除电话

master
zhaocheng 2 years ago
parent 8962d636d0
commit e85be75bc6
  1. 26
      app/controller/Index.php
  2. 21
      app/view/index/index.html

@ -258,6 +258,32 @@ class Index extends BaseController
return json($this->json_data);
}
/**
* 批量删除
* @return Json
* @throws \Exception
*/
public function phoneReset()
{
//
$params = array_filter($this->request->param());
$params_1 = $params;
unset($params_1['car_phone_empty'], $params['data_check'], $params['car_frame_check']);
if (empty($params_1)) {
$this->json_data['code'] = 0;
$this->json_data['msg'] = '搜索条件不能为空';
return json($this->json_data);
}
$map = $this->getQueryCondition($params);
if($this->model->where($map)->update(['car_phone' => ''])){
$this->json_data['msg'] = '请求成功';
}else {
$this->json_data['code'] = 0;
$this->json_data['msg'] = '请求失败';
}
return json($this->json_data);
}
/**
* @param $id
* @return Json

@ -36,6 +36,7 @@
<button type="button" class="layui-btn layui-btn-sm" id="search-btn">搜索</button>
<a href="{:url('index/index')}" class="layui-btn layui-btn-sm" id="reset-btn">重置条件</a>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" style="display: none;" id="deletes-btn">批量删除</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" style="display: none;" id="reset-car-phone">清空电话</button>
</div>
</h2>
<div class="layui-colla-content layui-form">
@ -348,10 +349,13 @@
delete param_a['car_phone_empty'];
delete param_a['car_frame_check'];
delete param_a['data_check'];
if (Object.values(param_a).filter(data => data).length > 0)
if (Object.values(param_a).filter(data => data).length > 0) {
$('#deletes-btn').css('display', 'inline-block')
else
$('#reset-car-phone').css('display', 'inline-block')
} else {
$('#deletes-btn').css('display', 'none')
$('#reset-car-phone').css('display', 'none')
}
});
$('#deletes-btn').on('click', function () {
layer.confirm('真的删除行么', function(index){
@ -366,6 +370,19 @@
});
});
});
$('#reset-car-phone').on('click', function () {
layer.confirm('确认执行删除车主电话并继续', function(index){
layer.close(index);
index = layer.load();
//向服务端发送删除指令
$.post('{:url("/index/phoneReset/")}', $('.layui-colla-content').find(':input').serialize(), function (ret) {
layer.close(index);
layer.msg(ret.msg, function () {
layui.table.reload('carInfo');
});
});
});
});
});
function task_create(type,id = 0){

Loading…
Cancel
Save