zhanglinxin 1 year ago
parent
commit
1f256c6cad

+ 6 - 6
application/common/constant/CommonConstant.php

@@ -21,24 +21,24 @@ class CommonConstant
     const MODULE_10 = 10;
     const MODULE_11 = 11;
 
-    const MODULE_1_MODEL = \app\common\model\ApproveEvection::class;
+    const MODULE_1_MODEL = \app\common\model\ApproveApply::class;
     const MODULE_2_MODEL = \app\common\model\ApproveOffer::class;
     const MODULE_3_MODEL = \app\common\model\ApproveStock::class;
-    const MODULE_4_MODEL = \app\common\model\ApproveEvection::class;
+    const MODULE_4_MODEL = \app\common\model\ApproveUse::class;
     const MODULE_5_MODEL = \app\common\model\ApproveEvection::class;
-    const MODULE_6_MODEL = \app\common\model\ApproveEvection::class;
+    const MODULE_6_MODEL = \app\common\model\ApproveLeave::class;
     const MODULE_7_MODEL = \app\common\model\ApproveCar::class;
     const MODULE_8_MODEL = \app\common\model\ApproveMaintain::class;
     const MODULE_9_MODEL = \app\common\model\ApproveContract::class;
     const MODULE_10_MODEL = \app\common\model\ApproveFile::class;
     const MODULE_11_MODEL = \app\common\model\ApproveSchool::class;
 
-    const MODULE_1_VALIDATE = \app\common\validate\ApproveEvection::class;
+    const MODULE_1_VALIDATE = \app\common\validate\ApproveApply::class;
     const MODULE_2_VALIDATE = \app\common\validate\ApproveOffer::class;
     const MODULE_3_VALIDATE = \app\common\validate\ApproveStock::class;
-    const MODULE_4_VALIDATE = \app\common\validate\ApproveEvection::class;
+    const MODULE_4_VALIDATE = \app\common\validate\ApproveUse::class;
     const MODULE_5_VALIDATE = \app\common\validate\ApproveEvection::class;
-    const MODULE_6_VALIDATE = \app\common\validate\ApproveEvection::class;
+    const MODULE_6_VALIDATE = \app\common\validate\ApproveLeave::class;
     const MODULE_7_VALIDATE = \app\common\validate\ApproveCar::class;
     const MODULE_8_VALIDATE = \app\common\validate\ApproveMaintain::class;
     const MODULE_9_VALIDATE = \app\common\validate\ApproveContract::class;

+ 34 - 0
application/common/model/ApproveApply.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 申购信息模型
+ */
+class ApproveApply extends Model
+{
+    // 表名
+    protected $name = 'approve_apply';
+
+    // 追加属性
+    protected $append = [
+        'document_text',
+        'images_text',
+    ];
+
+
+    public function getDocumentTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
+        return $value ? explode(',', $value) : [];
+    }
+
+    public function getImagesTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['images']) ? $data['images'] : '');
+        return $value ? explode(',', $value) : [];
+    }
+
+}

+ 34 - 0
application/common/model/ApproveLeave.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 请假信息模型
+ */
+class ApproveLeave extends Model
+{
+    // 表名
+    protected $name = 'approve_leave';
+
+    // 追加属性
+    protected $append = [
+        'document_text',
+        'images_text',
+    ];
+
+
+    public function getDocumentTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
+        return $value ? explode(',', $value) : [];
+    }
+
+    public function getImagesTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['images']) ? $data['images'] : '');
+        return $value ? explode(',', $value) : [];
+    }
+
+}

+ 34 - 0
application/common/model/ApproveUse.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 领用信息模型
+ */
+class ApproveUse extends Model
+{
+    // 表名
+    protected $name = 'approve_use';
+
+    // 追加属性
+    protected $append = [
+        'document_text',
+        'images_text',
+    ];
+
+
+    public function getDocumentTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
+        return $value ? explode(',', $value) : [];
+    }
+
+    public function getImagesTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['images']) ? $data['images'] : '');
+        return $value ? explode(',', $value) : [];
+    }
+
+}

+ 80 - 0
application/common/validate/ApproveApply.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace app\common\validate;
+
+use think\Validate;
+
+/**
+ * 申购信息验证
+ */
+class ApproveApply extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+        'reason' => 'require',
+        'start_time' => 'require|check_start_time',
+        'end_time' => 'require|check_end_time',
+        'type' => 'require|in:1,2',
+        'is_who' => 'requireIf:type,1',
+        'remark' => 'requireIf:is_who,1',
+        'approve_user' => 'require',
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'create' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark', 'approve_user'],
+        'update' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark', 'approve_user'],
+        'edit' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark'],
+    ];
+
+    /**
+     * 构造函数
+     * @access public
+     * @param array $rules 验证规则
+     * @param array $message 验证提示信息
+     * @param array $field 验证字段描述信息
+     */
+    public function __construct(array $rules = [], $message = [], $field = [])
+    {
+        $this->field = [
+            'reason' => '事由',
+            'start_time' => '出差开始时间',
+            'end_time' => '出差结束时间',
+            'type' => '出差类型',
+            'is_who' => '是否跨关内关外',
+            'remark' => '备注',
+            'approve_user' => '审批人',
+        ];
+        $this->message = array_merge($this->message, [
+            'start_time.check_start_time' => '出差开始时间必须大于当前时间',
+            'end_time.check_end_time' => '出差结束时间必须大于开始时间',
+            'type.in' => '请选择出差类型',
+        ]);
+        parent::__construct($rules, $message, $field);
+    }
+
+    protected function check_start_time($value, $rule, $data)
+    {
+        if ($value <= date('Y-m-d H:i')) {
+            return false;
+        }
+        return true;
+    }
+
+    protected function check_end_time($value, $rule, $data)
+    {
+        if ($data['start_time'] >= $value) {
+            return false;
+        }
+        return true;
+    }
+
+}

+ 80 - 0
application/common/validate/ApproveLeave.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace app\common\validate;
+
+use think\Validate;
+
+/**
+ * 请假信息验证
+ */
+class ApproveLeave extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+        'reason' => 'require',
+        'start_time' => 'require|check_start_time',
+        'end_time' => 'require|check_end_time',
+        'type' => 'require|in:1,2',
+        'is_who' => 'requireIf:type,1',
+        'remark' => 'requireIf:is_who,1',
+        'approve_user' => 'require',
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'create' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark', 'approve_user'],
+        'update' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark', 'approve_user'],
+        'edit' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark'],
+    ];
+
+    /**
+     * 构造函数
+     * @access public
+     * @param array $rules 验证规则
+     * @param array $message 验证提示信息
+     * @param array $field 验证字段描述信息
+     */
+    public function __construct(array $rules = [], $message = [], $field = [])
+    {
+        $this->field = [
+            'reason' => '事由',
+            'start_time' => '出差开始时间',
+            'end_time' => '出差结束时间',
+            'type' => '出差类型',
+            'is_who' => '是否跨关内关外',
+            'remark' => '备注',
+            'approve_user' => '审批人',
+        ];
+        $this->message = array_merge($this->message, [
+            'start_time.check_start_time' => '出差开始时间必须大于当前时间',
+            'end_time.check_end_time' => '出差结束时间必须大于开始时间',
+            'type.in' => '请选择出差类型',
+        ]);
+        parent::__construct($rules, $message, $field);
+    }
+
+    protected function check_start_time($value, $rule, $data)
+    {
+        if ($value <= date('Y-m-d H:i')) {
+            return false;
+        }
+        return true;
+    }
+
+    protected function check_end_time($value, $rule, $data)
+    {
+        if ($data['start_time'] >= $value) {
+            return false;
+        }
+        return true;
+    }
+
+}

+ 80 - 0
application/common/validate/ApproveUse.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace app\common\validate;
+
+use think\Validate;
+
+/**
+ * 领用信息验证
+ */
+class ApproveUse extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+        'reason' => 'require',
+        'start_time' => 'require|check_start_time',
+        'end_time' => 'require|check_end_time',
+        'type' => 'require|in:1,2',
+        'is_who' => 'requireIf:type,1',
+        'remark' => 'requireIf:is_who,1',
+        'approve_user' => 'require',
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'create' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark', 'approve_user'],
+        'update' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark', 'approve_user'],
+        'edit' => ['reason', 'start_time', 'end_time', 'type', 'is_who', 'remark'],
+    ];
+
+    /**
+     * 构造函数
+     * @access public
+     * @param array $rules 验证规则
+     * @param array $message 验证提示信息
+     * @param array $field 验证字段描述信息
+     */
+    public function __construct(array $rules = [], $message = [], $field = [])
+    {
+        $this->field = [
+            'reason' => '事由',
+            'start_time' => '出差开始时间',
+            'end_time' => '出差结束时间',
+            'type' => '出差类型',
+            'is_who' => '是否跨关内关外',
+            'remark' => '备注',
+            'approve_user' => '审批人',
+        ];
+        $this->message = array_merge($this->message, [
+            'start_time.check_start_time' => '出差开始时间必须大于当前时间',
+            'end_time.check_end_time' => '出差结束时间必须大于开始时间',
+            'type.in' => '请选择出差类型',
+        ]);
+        parent::__construct($rules, $message, $field);
+    }
+
+    protected function check_start_time($value, $rule, $data)
+    {
+        if ($value <= date('Y-m-d H:i')) {
+            return false;
+        }
+        return true;
+    }
+
+    protected function check_end_time($value, $rule, $data)
+    {
+        if ($data['start_time'] >= $value) {
+            return false;
+        }
+        return true;
+    }
+
+}