Commit 896fdc0c authored by yinxiaoling's avatar yinxiaoling

任务数据编辑

parent af921c1f
......@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Models\StrategyTask;
use Illuminate\Foundation\Validation\ValidatesRequests;
use App\Http\Controllers\Tool;
use Illuminate\Support\Facades\Validator;
class StrategyTaskController extends Controller
{
......@@ -43,9 +44,9 @@ class StrategyTaskController extends Controller
});
if(empty($pageSize)){
$strategyInfo = $strategyInfo->get()->toArray();
$strategyInfo = $strategyInfo->orderBy('call_date','desc')->get()->toArray();
}else{
$strategyInfo = $strategyInfo->paginate($pageSize)->toArray();
$strategyInfo = $strategyInfo->orderBy('call_date','desc')->paginate($pageSize)->toArray();
}
$listInfo = [];
......@@ -57,19 +58,35 @@ class StrategyTaskController extends Controller
}
public function show($strategy_sn){
}
public function update(Request $request, $strategy_sn)
public function update(Request $request, $id)
{
try {
return $this->successWithInfo('更新成功');
} catch (\Exception $e) {
return $this->errorWithInfo($e->getMessageBag());
$phone = $request->phone;
$name = $request->name;
$callTime = $request->call_time;
$validator = Validator::make($request->all(), [
'phone' => 'required', //验证手机号格式?
'user_sn' => 'required',
'call_time' => 'required',
'name'=>'max:20'
]);
if ($validator->fails()) {
return $this->errorWithInfo('表单验证失败', 401);
}
$taskInfo = StrategyTask::find($id);
if ($taskInfo->is_created == 1){
return $this->errorWithInfo('任务已经创建不能编辑', 401);
}
$taskInfo->phone = $phone;
$taskInfo->name = $name;
$taskInfo->call_time = $callTime;
$taskInfo->save();
return $this->successWithInfo('更新成功');
}
......
......@@ -10,4 +10,5 @@ class StrategyTask extends Model
protected $table = 'strategy_task';
public $timestamps = false;//此处设置false 表示表中可以不需要created_at updated_at
}
......@@ -68,7 +68,7 @@ class DatabaseSeeder extends Seeder
$table->uuid('strategy_sn')->comment('策略sn编号'); //sn编号
$table->char('name',50)->nullable()->comment('姓名');
$table->date('duty_date')->nullable()->comment('值班日期(年月日)');
$table->date('import_date')->nullable()->comment('导入日期(年-月-日 时:分:秒)');
$table->timestamp('import_date')->nullable()->comment('导入日期(年-月-日 时:分:秒)');
$table->unsignedBigInteger('phone')->comment('手机号');
$table->char('call_number',50)->comment('主叫号码');
$table->date('call_date')->comment('外呼时间(年月日)');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment