'require|checkData', 'name' => 'require|unique:' . MarketingCustom::class, 'important_level' => 'require|checkImportantLevel', 'dept_id' => 'require|checkDept', 'category' => 'require|checkCategory', 'email' => 'email', 'province' => 'checkProvince', 'city' => 'checkCity', 'website' => 'url', 'create_user' => 'require', 'create_time' => 'require|dateFormat:Y-m-d H:i:s', 'annex' => 'checkAnnex', 'detail' => 'checkDetail' ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'name' => '客户名称', 'sub_name' => '客户简称', 'code' => '客户编号', 'important_level' => '重要等级', 'dept_id' => '负责部门', 'category' => '客户分类', 'remark' => '备注', 'invoice_company' => '开票单位', 'taxpayer_identification_number' => '纳税人识别号', 'opening_bank' => '开户银行', 'invoice_contact' => '开票联系人', 'invoice_company_address' => '开票单位注册地址', 'invoice_company_telephone' => '开票单位电话', 'opening_bank_account' => '开户账号', 'email' => '电子邮箱', 'province' => '省份', 'city' => '城市', 'post_code' => '邮编', 'telephone' => '电话', 'fax' => '传真', 'website' => '网址', 'address' => '地址', 'create_user' => '录入人', 'create_time' => '录入日期', ]; /** * @notes 添加场景 * @return MarketingCustomValidate * @author likeadmin * @date 2024/04/01 14:26 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return MarketingCustomValidate * @author likeadmin * @date 2024/04/01 14:26 */ public function sceneEdit() { } /** * @notes 删除场景 * @return MarketingCustomValidate * @author likeadmin * @date 2024/04/01 14:26 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return MarketingCustomValidate * @author likeadmin * @date 2024/04/01 14:26 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = MarketingCustom::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '数据不存在' : true; } public function checkImportantLevel($value): bool|string { $dict = DictData::where('type_value', 'custom_important_level')->column('value'); return !in_array($value, $dict) ? '重要等级数据值无效' : true; } public function checkDept($value): bool|string { $data = Dept::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '部门信息不存在' : true; } public function checkCategory($value): bool|string { $dict = DictData::where('type_value', 'custom_category')->column('value'); return !in_array($value, $dict) ? '客户分类数据值无效' : true; } public function checkProvince($value): bool|string { if (empty($value)) return true; $data = GeoProvince::where('province_code', $value)->findOrEmpty(); return $data->isEmpty() ? '省份信息不存在' : true; } public function checkCity($value): bool|string { if (empty($value)) return true; $data = GeoCity::where('city_code', $value)->findOrEmpty(); return $data->isEmpty() ? '城市信息不存在' : true; } public function checkDetail($value): bool|string { if (!isset($value) || $value == '') return true; if (!is_array($value)) return '联系人数据格式错误'; foreach ($value as $k => $v) { if (isset($v['id']) && !empty($v['id'])) { $data = MarketingCustomContacts::where('id', $v['id'])->findOrEmpty(); if ($data->isEmpty()) { return '第' . ($k + 1) . '行联系人信息不存在'; } } if (empty($v['name'])) { return '联系人列表第' . ($k + 1) . '行姓名为空'; } if (!empty($v['gender'])) { if (!in_array($v['gender'], [0, 1])) return '联系人列表第' . ($k + 1) . '行性别数据错误'; } } return true; } }