|
@@ -30,9 +30,39 @@ class WaterMaterialScience extends AuthController
|
|
|
/**
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function index()
|
|
|
+ public function roof()
|
|
|
{
|
|
|
+ $this->assign('role', 'roof');
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function side_plate()
|
|
|
+ {
|
|
|
+ $this->assign('role', 'side_plate');
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function lacing()
|
|
|
+ {
|
|
|
+ $this->assign('role', 'lacing');
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
|
|
|
+ public function floor()
|
|
|
+ {
|
|
|
+ $this->assign('role', 'floor');
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function column()
|
|
|
+ {
|
|
|
+ $this->assign('role', 'column');
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fula()
|
|
|
+ {
|
|
|
+ $this->assign('role', 'fula');
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
@@ -42,7 +72,8 @@ class WaterMaterialScience extends AuthController
|
|
|
$where = Util::getMore([
|
|
|
['page', 1],
|
|
|
['limit', 20],
|
|
|
- ['name', '']
|
|
|
+ ['name', ''],
|
|
|
+ ['role', '']
|
|
|
]);
|
|
|
|
|
|
return Json::successlayui(model::list($where));
|
|
@@ -57,8 +88,21 @@ class WaterMaterialScience extends AuthController
|
|
|
{
|
|
|
$f = [];
|
|
|
$f[] = Form::input('name', '名称')->col(12);
|
|
|
- $f[] = Form::input('weight', '重量');
|
|
|
- if ($id) $f[] = Form::hidden('id', $id);
|
|
|
+ $f[] = Form::select('type', '选择分类', '')->options([
|
|
|
+ ['value' => 0, 'label' => '请选择分类'],
|
|
|
+ ['value' => 1, 'label' => '顶板'],
|
|
|
+ ['value' => 2, 'label' => '侧板'],
|
|
|
+ ['value' => 3, 'label' => '拉筋'],
|
|
|
+ ['value' => 4, 'label' => '底板'],
|
|
|
+ ])->filterable(true);
|
|
|
+ $f[] = Form::select('th_id', '选择厚度', '')->options(
|
|
|
+ array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
|
|
|
+ )->filterable(true);
|
|
|
+ $f[] = Form::input('weight', '重量(kg)');
|
|
|
+ $f[] = Form::input('unit_price', '单价');
|
|
|
+ $f[] = Form::input('company', '单位');
|
|
|
+ $f[] = Form::input('long', '长');
|
|
|
+ $f[] = Form::input('wide', '宽');
|
|
|
$form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
@@ -71,15 +115,33 @@ class WaterMaterialScience extends AuthController
|
|
|
$model = new model;
|
|
|
$data = Util::postMore([
|
|
|
'name',
|
|
|
- 'thickness',
|
|
|
+ 'type',
|
|
|
+ 'th_id',
|
|
|
+ 'weight',
|
|
|
+ 'unit_price',
|
|
|
+ 'company',
|
|
|
+ 'long',
|
|
|
+ 'wide',
|
|
|
]);
|
|
|
$validate = Validate::rule('name', 'require')->rule([
|
|
|
'name' => 'require',
|
|
|
- 'thickness' => 'require',
|
|
|
+ 'type' => 'require',
|
|
|
+ 'th_id' => 'require',
|
|
|
+ 'weight' => 'require',
|
|
|
+ 'unit_price' => 'require',
|
|
|
+ 'company' => 'require',
|
|
|
+ 'long' => 'require',
|
|
|
+ 'wide' => 'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'name.require' => '名称不能为空',
|
|
|
- 'thickness.require' => '厚度不能为空',
|
|
|
+ 'type.require' => '请选择分类',
|
|
|
+ 'th_id.require' => '请选择厚度',
|
|
|
+ 'weight.require' => '请填写重量',
|
|
|
+ 'unit_price.require' => '请填写单价',
|
|
|
+ 'company.require' => '请填写单位',
|
|
|
+ 'long.require' => '请填写长度',
|
|
|
+ 'wide.require' => '请填写宽度',
|
|
|
]);
|
|
|
if (!$validate->check($data)) {
|
|
|
return Json::fail($validate->getError());
|
|
@@ -99,8 +161,24 @@ class WaterMaterialScience extends AuthController
|
|
|
{
|
|
|
$data = model::find($id);
|
|
|
$f = [];
|
|
|
- $f[] = Form::input('name', '名称',$data->getData('name'))->col(12);
|
|
|
- $f[] = Form::input('thickness', '额度', $data->getData('thickness'));
|
|
|
+ $f[] = Form::input('name', '名称', $data['name'])->col(12);
|
|
|
+ $f[] = Form::select('type', '选择分类', (string)$data['type'])->options([
|
|
|
+ ['value' => 0, 'label' => '请选择分类'],
|
|
|
+ ['value' => 1, 'label' => '顶板'],
|
|
|
+ ['value' => 2, 'label' => '侧板'],
|
|
|
+ ['value' => 3, 'label' => '拉筋'],
|
|
|
+ ['value' => 4, 'label' => '底板'],
|
|
|
+ ['value' => 5, 'label' => '立柱'],
|
|
|
+ ['value' => 6, 'label' => '辅拉'],
|
|
|
+ ])->filterable(true);
|
|
|
+ $f[] = Form::select('th_id', '选择厚度', (string)$data['th_id'])->options(
|
|
|
+ array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
|
|
|
+ )->filterable(true);
|
|
|
+ $f[] = Form::input('weight', '重量(kg)', $data['weight']);
|
|
|
+ $f[] = Form::input('unit_price', '单价', $data['unit_price']);
|
|
|
+ $f[] = Form::input('company', '单位', $data['company']);
|
|
|
+ $f[] = Form::input('long', '长', $data['long']);
|
|
|
+ $f[] = Form::input('wide', '宽', $data['wide']);
|
|
|
$f[] = Form::hidden('id', $id);
|
|
|
$form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
|
|
|
$this->assign(compact('form'));
|
|
@@ -119,21 +197,36 @@ class WaterMaterialScience extends AuthController
|
|
|
{
|
|
|
$model = new model;
|
|
|
$data = Util::postMore([
|
|
|
- 'id',
|
|
|
'name',
|
|
|
- 'thickness',
|
|
|
+ 'type',
|
|
|
+ 'th_id',
|
|
|
+ 'weight',
|
|
|
+ 'unit_price',
|
|
|
+ 'company',
|
|
|
+ 'long',
|
|
|
+ 'wide',
|
|
|
+ 'id',
|
|
|
]);
|
|
|
$validate = Validate::rule('name', 'require')->rule([
|
|
|
'name' => 'require',
|
|
|
- 'thickness' => 'require',
|
|
|
+ 'type' => 'require',
|
|
|
+ 'th_id' => 'require',
|
|
|
+ 'weight' => 'require',
|
|
|
+ 'unit_price' => 'require',
|
|
|
+ 'company' => 'require',
|
|
|
+ 'long' => 'require',
|
|
|
+ 'wide' => 'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'name.require' => '名称不能为空',
|
|
|
- 'thickness.require' => '额度不能为空',
|
|
|
+ 'type.require' => '请选择分类',
|
|
|
+ 'th_id.require' => '请选择厚度',
|
|
|
+ 'weight.require' => '请填写重量',
|
|
|
+ 'unit_price.require' => '请填写单价',
|
|
|
+ 'company.require' => '请填写单位',
|
|
|
+ 'long.require' => '请填写长度',
|
|
|
+ 'wide.require' => '请填写宽度',
|
|
|
]);
|
|
|
- if (!$validate->check($data)) {
|
|
|
- return Json::fail($validate->getError());
|
|
|
- }
|
|
|
$details = $model->find($data['id']);
|
|
|
$details['name'] = $data['name'];
|
|
|
$details['thickness'] = $data['thickness'];
|
|
@@ -142,60 +235,6 @@ class WaterMaterialScience extends AuthController
|
|
|
return Json::fail('修改失败');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 显示创建资源表单页.
|
|
|
- *
|
|
|
- * @return \think\Response
|
|
|
- */
|
|
|
- public function next($id = 0)
|
|
|
- {
|
|
|
- $f = [];
|
|
|
- $f[] = Form::dateTime('add_time', '开启时间');
|
|
|
- $f[] = Form::dateTime('end_time', '结束时间');
|
|
|
- $f[] = Form::hidden('id', $id);
|
|
|
- $form = Form::make_post_form('添加', $f, Url::buildUrl('next_save'));
|
|
|
- $this->assign(compact('form'));
|
|
|
- return $this->fetch('public/form-builder');
|
|
|
- }
|
|
|
-
|
|
|
- public function next_save()
|
|
|
- {
|
|
|
- $model = new model;
|
|
|
- $data = Util::postMore([
|
|
|
- 'id',
|
|
|
- 'add_time',
|
|
|
- 'end_time',
|
|
|
- ]);
|
|
|
- $validate = Validate::rule([
|
|
|
- 'add_time' => 'require',
|
|
|
- 'end_time' => 'require',
|
|
|
- ]);
|
|
|
- $validate->message([
|
|
|
- 'add_time.require' => '请选择开启时间',
|
|
|
- 'end_time.require' => '请选择结束时间',
|
|
|
- ]);
|
|
|
- if (!$validate->check($data)) {
|
|
|
- return Json::fail($validate->getError());
|
|
|
- }
|
|
|
- $details = $model->find($data['id']);
|
|
|
- if ($details['status'] == 1) return Json::fail('未结束不能进行下一场');
|
|
|
- if ($details['suc'] == 2) return Json::fail('已众筹失败无法就行下一场');
|
|
|
- if (strtotime($data['end_time']) < strtotime($data['add_time'])) return Json::fail('结束时间不能小于开启时间');
|
|
|
- $details['stage'] += 1;
|
|
|
- $details['status'] = 1;
|
|
|
- $details['number'] = 0;//重置额度
|
|
|
- $details['money'] = intval($details['money'] * 1.3);//提搞额度130%
|
|
|
- $details['suc'] = 0;
|
|
|
- $details['add_time'] = strtotime($data['add_time']);
|
|
|
- $details['end_time'] = strtotime($data['end_time']);
|
|
|
- $res = $details->save();
|
|
|
- if ($res) return Json::successful('成功');
|
|
|
- return Json::fail('失败');
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 删除
|