123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class AssetItems extends Validate{
- protected $rule = [
- 'title|名称' => 'require',
- 'price|原值' => 'require|egt:0',
- 'company_id' => 'require|gt:0',
- 'cate_id' => 'require|gt:0',
- 'class_id' => 'require|gt:0',
- 'unit_id' => 'require|gt:0',
- 'add_id' => 'require|gt:0',
- 'buy_time' => 'require|date',
- 'nums' => 'require|gt:0',
- 'sn' => 'checkSn'
- ];
- protected $message = [
- 'price.require' => '请填写物品单价',
- 'price.egt' => '单价不能小于0',
- 'nums.require' => '请输入数量',
- 'nums.gt' => '数量必须大于0',
- 'cate_id.require' => '请选择物品分类',
- 'cate_id.gt' => '请选择物品分类',
- 'unit_id.require' => '请选择物品单位',
- 'unit_id.gt' => '请选择物品单位',
- 'buy_time.require' => '请选择购买日期',
- 'buy_time.date' => '购买日期格式不正确',
- 'company_id.require' => '请选择所属公司',
- 'company_id.gt' => '请选择所属公司',
- 'class_id.require' => '请选择类别',
- 'class_id.gt' => '请选择类别',
- 'add_id.require' => '请选择增加方式',
- 'add_id.gt' => '请选择增加方式',
- ];
- protected $scene = [
- ];
- protected function checkSn($value,$rule,$data=[])
- {
- if($data['id'] > 0){
- $info = Db::name('asset_items')->where('sn',$value)->where('id','<>',$data['id'])->where('del',0)->where('org_id',$data['org_id'])->find();
- if($info){
- return '该编号已被占用';
- }
- }
- return true;
- }
- }
|