Commit 1e4d46d4caaf7dc554398aa06b517aed115c7334
Merge branch 'ft-dev' into 'main'
fix:DEFECT-387视频管理编辑回显问题和加了一些验证 See merge request huang/yun-teng-iot-front!212
Showing
3 changed files
with
45 additions
and
12 deletions
| ... | ... | @@ -54,7 +54,10 @@ export const emailRule: Rule[] = [ |
| 54 | 54 | ]; |
| 55 | 55 | |
| 56 | 56 | // 中文正则 |
| 57 | -export const ChineseRegexp = /[\u4E00-\u9FA5]/g; | |
| 57 | +export const ChineseRegexp = /[\u4E00-\u9FA5]/; | |
| 58 | + | |
| 59 | +//字母或者数字正则 | |
| 60 | +export const allowLetterAndNumberRegExp = /^[A-Za-z0-9]+$/; | |
| 58 | 61 | |
| 59 | 62 | // 电子邮箱正则 |
| 60 | 63 | export const EmailRegexp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/; |
| ... | ... | @@ -62,6 +65,36 @@ export const EmailRegexp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a |
| 62 | 65 | // 手机号正则 |
| 63 | 66 | export const PhoneRegexp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; |
| 64 | 67 | |
| 68 | +/** | |
| 69 | + * 视频管理 | |
| 70 | + */ | |
| 71 | +export const CameraMaxLength: Rule[] = [ | |
| 72 | + { | |
| 73 | + required: true, | |
| 74 | + validator: (_, value: string) => { | |
| 75 | + if (String(value).length > 50) { | |
| 76 | + return Promise.reject('视频标题长度不超过200字'); | |
| 77 | + } | |
| 78 | + return Promise.resolve(); | |
| 79 | + }, | |
| 80 | + validateTrigger: 'blur', | |
| 81 | + }, | |
| 82 | +]; | |
| 83 | + | |
| 84 | +export const CameraVideoUrl: Rule[] = [ | |
| 85 | + { | |
| 86 | + required: true, | |
| 87 | + validator: (_, value: string) => { | |
| 88 | + const ChineseRegexp = /[\u4E00-\u9FA5]/; | |
| 89 | + if (ChineseRegexp.test(value)) { | |
| 90 | + return Promise.reject('视频流不能是中文'); | |
| 91 | + } | |
| 92 | + return Promise.resolve(); | |
| 93 | + }, | |
| 94 | + validateTrigger: 'blur', | |
| 95 | + }, | |
| 96 | +]; | |
| 97 | + | |
| 65 | 98 | //站内通知 |
| 66 | 99 | export const NotificationTitleMaxLength: Rule[] = [ |
| 67 | 100 | { | ... | ... |
| ... | ... | @@ -57,14 +57,9 @@ |
| 57 | 57 | setDrawerProps({ confirmLoading: false }); |
| 58 | 58 | isUpdate.value = !!data?.isUpdate; |
| 59 | 59 | if (unref(isUpdate)) { |
| 60 | - if (data.record.organizationDTO) { | |
| 61 | - await setFieldsValue(data.record); | |
| 62 | - } else { | |
| 63 | - editId.value = data.record.id; | |
| 64 | - tenantLogo.value = data.record?.avatar; | |
| 65 | - Reflect.deleteProperty(data.record, 'organizationId'); | |
| 66 | - await setFieldsValue(data.record); | |
| 67 | - } | |
| 60 | + editId.value = data.record.id; | |
| 61 | + tenantLogo.value = data.record?.avatar; | |
| 62 | + await setFieldsValue(data.record); | |
| 68 | 63 | } else { |
| 69 | 64 | tenantLogo.value = ''; |
| 70 | 65 | editId.value = ''; | ... | ... |
| 1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 2 | 2 | import { getOrganizationList } from '/@/api/system/system'; |
| 3 | 3 | import { copyTransFun } from '/@/utils/fnUtils'; |
| 4 | +import type { FormSchema as QFormSchema } from '/@/components/Form/index'; | |
| 5 | + | |
| 6 | +import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules'; | |
| 4 | 7 | |
| 5 | 8 | // 表格列数据 |
| 6 | 9 | export const columns: BasicColumn[] = [ |
| ... | ... | @@ -57,7 +60,7 @@ export const searchFormSchema: FormSchema[] = [ |
| 57 | 60 | ]; |
| 58 | 61 | |
| 59 | 62 | // 弹框配置项 |
| 60 | -export const formSchema: FormSchema[] = [ | |
| 63 | +export const formSchema: QFormSchema[] = [ | |
| 61 | 64 | { |
| 62 | 65 | field: 'avatar', |
| 63 | 66 | label: '视频封面', |
| ... | ... | @@ -73,6 +76,7 @@ export const formSchema: FormSchema[] = [ |
| 73 | 76 | placeholder: '请输入视频名字', |
| 74 | 77 | maxLength: 30, |
| 75 | 78 | }, |
| 79 | + rules: CameraMaxLength, | |
| 76 | 80 | }, |
| 77 | 81 | { |
| 78 | 82 | field: 'organizationId', |
| ... | ... | @@ -91,7 +95,6 @@ export const formSchema: FormSchema[] = [ |
| 91 | 95 | field: 'brand', |
| 92 | 96 | label: '视频厂家', |
| 93 | 97 | component: 'Input', |
| 94 | - required: true, | |
| 95 | 98 | componentProps: { |
| 96 | 99 | placeholder: '请输入视频厂家', |
| 97 | 100 | }, |
| ... | ... | @@ -99,8 +102,9 @@ export const formSchema: FormSchema[] = [ |
| 99 | 102 | { |
| 100 | 103 | field: 'sn', |
| 101 | 104 | label: '摄像头编号', |
| 102 | - component: 'Input', | |
| 103 | 105 | required: true, |
| 106 | + component: 'Input', | |
| 107 | + rules: CameraVideoUrl, | |
| 104 | 108 | componentProps: { |
| 105 | 109 | placeholder: '请输入摄像头编号', |
| 106 | 110 | }, |
| ... | ... | @@ -114,5 +118,6 @@ export const formSchema: FormSchema[] = [ |
| 114 | 118 | placeholder: '请输入视频流', |
| 115 | 119 | maxLength: 255, |
| 116 | 120 | }, |
| 121 | + rules: CameraVideoUrl, | |
| 117 | 122 | }, |
| 118 | 123 | ]; | ... | ... |