|
@@ -18,6 +18,7 @@ use app\admin\model\system\{
|
|
|
SystemAttachment as SystemAttachmentModel, SystemAttachmentCategory as Category
|
|
|
};
|
|
|
use think\facade\Route as Url;
|
|
|
+use think\facade\Validate;
|
|
|
|
|
|
/**
|
|
|
* 竞拍管理
|
|
@@ -56,17 +57,42 @@ class Auction extends AuthController
|
|
|
*/
|
|
|
public function create($id = 0)
|
|
|
{
|
|
|
- $data = [];
|
|
|
- $model = new AuctionGu();
|
|
|
- $auction = $model->select();
|
|
|
- if ($id > 0) $data = \app\admin\model\auction\Auction::find($id)->toArray();
|
|
|
-
|
|
|
- $this->assign(['id' => $id, 'dataList' => $data, 'auction' => $auction]);
|
|
|
- return $this->fetch();
|
|
|
+ $f = [];
|
|
|
+ $f[] = Form::input('nickname', '场次名称')->col(12);
|
|
|
+ $f[] = Form::input('anticipate', '预约价格')->col(12);
|
|
|
+ $f[] = Form::frameImageOne('image', '场次主图片(305*305px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('image')->width('100%')->height('500px');
|
|
|
+ $f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]])->col(12);
|
|
|
+ $f[] = Form::select('auction_gu_id', '绑定场馆')->setOptions(function () {
|
|
|
+ $model = new AuctionGu();
|
|
|
+ $list = $model->select();
|
|
|
+ $menus = [];
|
|
|
+ foreach ($list as $menu) {
|
|
|
+ $menus[] = ['value' => $menu['id'], 'label' => $menu['name']];
|
|
|
+ }
|
|
|
+ return $menus;
|
|
|
+ })->filterable(1)->col(12);
|
|
|
+ $f[] = Form::dateTimes('add_time', '预约开始时间');
|
|
|
+ $f[] = Form::dateTimes('end_time', '预约结束时间');
|
|
|
+ $f[] = Form::dateTimes('radd_time', '预约结束时间');
|
|
|
+ $f[] = Form::dateTimes('rend_time', '预约结束时间');
|
|
|
+ $f[] = Form::input('sort', '排序', '0');
|
|
|
+ $f[] = Form::textarea('info', '介绍')->col(12);
|
|
|
+
|
|
|
+ $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
|
|
|
+ $this->assign(compact('form'));
|
|
|
+ return $this->fetch('public/form-builder');
|
|
|
+
|
|
|
+// $data = [];
|
|
|
+// $model = new AuctionGu();
|
|
|
+// $auction = $model->select();
|
|
|
+// if ($id > 0) $data = \app\admin\model\auction\Auction::find($id)->toArray();
|
|
|
+//
|
|
|
+// $this->assign(['id' => $id, 'dataList' => $data, 'auction' => $auction]);
|
|
|
+// return $this->fetch();
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function save($id)
|
|
|
+ public function save()
|
|
|
{
|
|
|
$mode = new \app\admin\model\auction\Auction();
|
|
|
$data = Util::postMore([
|
|
@@ -74,30 +100,45 @@ class Auction extends AuthController
|
|
|
'image',
|
|
|
'status',
|
|
|
'sort',
|
|
|
- 'time',
|
|
|
- 'rtime',
|
|
|
+ 'add_time',
|
|
|
+ 'end_time',
|
|
|
+ 'radd_time',
|
|
|
+ 'rend_time',
|
|
|
'info',
|
|
|
'anticipate',
|
|
|
'auction_gu_id'
|
|
|
]);
|
|
|
-
|
|
|
-
|
|
|
- $time = explode('-', $data['time']);
|
|
|
-
|
|
|
- $data['add_time'] = trim($time[0]);
|
|
|
- $data['end_time'] = trim($time[1]);
|
|
|
- $rtime = explode('-', $data['rtime']);
|
|
|
- $data['radd_time'] = trim($rtime[0]);
|
|
|
- $data['rend_time'] = trim($rtime[1]);
|
|
|
-
|
|
|
- if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('预约时间选择错误');
|
|
|
- if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('进场时间选择错误');
|
|
|
-
|
|
|
+ $validate = Validate::rule('nickname', 'require')->rule([
|
|
|
+ 'nickname' => 'require',
|
|
|
+ 'image' => 'require',
|
|
|
+ 'status' => 'require',
|
|
|
+ 'anticipate' => 'require',
|
|
|
+ 'add_time' => 'require',
|
|
|
+ 'end_time' => 'require',
|
|
|
+ 'radd_time' => 'require',
|
|
|
+ 'rend_time' => 'require',
|
|
|
+ 'auction_gu_id' => 'require',
|
|
|
+ ]);
|
|
|
+ $validate->message([
|
|
|
+ 'nickname.require' => '名称不能为空',
|
|
|
+ 'image.require' => '图片不能为空',
|
|
|
+ 'status.require' => '状态不能为空',
|
|
|
+ 'anticipate.require' => '请填写预约价格',
|
|
|
+ 'add_time.require' => '请选择预约开始时间价格',
|
|
|
+ 'end_time.require' => '请选择预约结束时间价格',
|
|
|
+ 'radd_time.require' => '请选择进场时间',
|
|
|
+ 'rend_time.require' => '请选择结束时间',
|
|
|
+ 'auction_gu_id.require' => '请选择绑定场馆',
|
|
|
+ ]);
|
|
|
+ if (!$validate->check($data)) {
|
|
|
+ return Json::fail($validate->getError());
|
|
|
+ dump($validate->getError());
|
|
|
+ }
|
|
|
$res = $mode->save($data);
|
|
|
if ($res){
|
|
|
return Json::success('添加成功!');
|
|
|
}else{
|
|
|
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
|
+ return Json::fail('添加失败');
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -139,13 +180,31 @@ class Auction extends AuthController
|
|
|
public function edit($id)
|
|
|
{
|
|
|
if (!$id) Json::fail('数据不存在');
|
|
|
- $data = [];
|
|
|
- $model = new AuctionGu();
|
|
|
- $auction = $model->select();
|
|
|
- if ($id > 0) $data = \app\admin\model\auction\Auction::find($id)->toArray();
|
|
|
-
|
|
|
- $this->assign(['id' => $id, 'dataList' => $data, 'auction' => $auction]);
|
|
|
- return $this->fetch();
|
|
|
+ $data = \app\admin\model\auction\Auction::find($id);
|
|
|
+ $f = [];
|
|
|
+ $f[] = Form::input('nickname', '场次名称', $data->getData('nickname'))->col(12);
|
|
|
+ $f[] = Form::input('anticipate', '预约价格', $data->getData('anticipate'))->col(12);
|
|
|
+ $f[] = Form::frameImageOne('image', '场次主图片(305*305px)',Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $data->getData('image'))->icon('image')->width('100%')->height('500px');
|
|
|
+ $f[] = Form::radio('status', '状态', $data->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]])->col(12);
|
|
|
+ $f[] = Form::select('auction_gu_id', '绑定场馆', (string)$data->getData('auction_gu_id'))->setOptions(function () {
|
|
|
+ $model = new AuctionGu();
|
|
|
+ $list = $model->select();
|
|
|
+ $menus = [];
|
|
|
+ foreach ($list as $menu) {
|
|
|
+ $menus[] = ['value' => $menu['id'], 'label' => $menu['name']];
|
|
|
+ }
|
|
|
+ return $menus;
|
|
|
+ })->filterable(1)->col(12);
|
|
|
+ $f[] = Form::dateTimes('add_time', '预约开始时间', $data->getData('add_time'));
|
|
|
+ $f[] = Form::dateTimes('end_time', '预约结束时间', $data->getData('end_time'));
|
|
|
+ $f[] = Form::dateTimes('radd_time', '预约结束时间', $data->getData('radd_time'));
|
|
|
+ $f[] = Form::dateTimes('rend_time', '预约结束时间', $data->getData('rend_time'));
|
|
|
+ $f[] = Form::input('sort', '排序', '0', $data->getData('sort'));
|
|
|
+ $f[] = Form::textarea('info', '介绍', $data->getData('info'))->col(12);
|
|
|
+
|
|
|
+ $form = Form::make_post_form('修改', $f, Url::buildUrl('update', compact('id')));
|
|
|
+ $this->assign(compact('form'));
|
|
|
+ return $this->fetch('public/form-builder');
|
|
|
}
|
|
|
|
|
|
|
|
@@ -165,22 +224,42 @@ class Auction extends AuthController
|
|
|
'id',
|
|
|
'nickname',
|
|
|
'image',
|
|
|
- 'time',
|
|
|
- 'rtime',
|
|
|
+ 'status',
|
|
|
'sort',
|
|
|
+ 'add_time',
|
|
|
+ 'end_time',
|
|
|
+ 'radd_time',
|
|
|
+ 'rend_time',
|
|
|
'info',
|
|
|
'anticipate',
|
|
|
'auction_gu_id'
|
|
|
]);
|
|
|
- $time = explode('-', $data['time']);
|
|
|
- $data['add_time'] = trim($time[0]);
|
|
|
- $data['end_time'] = trim($time[1]);
|
|
|
- $rtime = explode('-', $data['rtime']);
|
|
|
- $data['radd_time'] = trim($rtime[0]);
|
|
|
- $data['rend_time'] = trim($rtime[1]);
|
|
|
-
|
|
|
- if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('预约时间选择错误');
|
|
|
- if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('进场时间选择错误');
|
|
|
+ $validate = Validate::rule('nickname', 'require')->rule([
|
|
|
+ 'nickname' => 'require',
|
|
|
+ 'image' => 'require',
|
|
|
+ 'status' => 'require',
|
|
|
+ 'anticipate' => 'require',
|
|
|
+ 'add_time' => 'require',
|
|
|
+ 'end_time' => 'require',
|
|
|
+ 'radd_time' => 'require',
|
|
|
+ 'rend_time' => 'require',
|
|
|
+ 'auction_gu_id' => 'require',
|
|
|
+ ]);
|
|
|
+ $validate->message([
|
|
|
+ 'nickname.require' => '名称不能为空',
|
|
|
+ 'image.require' => '图片不能为空',
|
|
|
+ 'status.require' => '状态不能为空',
|
|
|
+ 'anticipate.require' => '请填写预约价格',
|
|
|
+ 'add_time.require' => '请选择预约开始时间价格',
|
|
|
+ 'end_time.require' => '请选择预约结束时间价格',
|
|
|
+ 'radd_time.require' => '请选择进场时间',
|
|
|
+ 'rend_time.require' => '请选择结束时间',
|
|
|
+ 'auction_gu_id.require' => '请选择绑定场馆',
|
|
|
+ ]);
|
|
|
+ if (!$validate->check($data)) {
|
|
|
+ return Json::fail($validate->getError());
|
|
|
+ dump($validate->getError());
|
|
|
+ }
|
|
|
|
|
|
$res = \app\admin\model\auction\Auction::update($data);
|
|
|
if ($res){
|