Showing
2 changed files
with
32 additions
and
4 deletions
@@ -119,7 +119,35 @@ export const CameraVideoUrl: Rule[] = [ | @@ -119,7 +119,35 @@ export const CameraVideoUrl: Rule[] = [ | ||
119 | validator: (_, value: string) => { | 119 | validator: (_, value: string) => { |
120 | const ChineseRegexp = /[\u4E00-\u9FA5]/; | 120 | const ChineseRegexp = /[\u4E00-\u9FA5]/; |
121 | if (ChineseRegexp.test(value)) { | 121 | if (ChineseRegexp.test(value)) { |
122 | - return Promise.reject('视频流不能是中文'); | 122 | + return Promise.reject('输入内容不能是中文'); |
123 | + } | ||
124 | + return Promise.resolve(); | ||
125 | + }, | ||
126 | + validateTrigger: 'blur', | ||
127 | + }, | ||
128 | +]; | ||
129 | + | ||
130 | +export const CameraVideoStreamUrl: Rule[] = [ | ||
131 | + { | ||
132 | + required: true, | ||
133 | + validator: (_, value: string) => { | ||
134 | + const ChineseRegexp = | ||
135 | + /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4|m3u8))$/i; | ||
136 | + if (!ChineseRegexp.test(value)) { | ||
137 | + return Promise.reject('请输入正确格式的视频地址'); | ||
138 | + } | ||
139 | + return Promise.resolve(); | ||
140 | + }, | ||
141 | + validateTrigger: 'blur', | ||
142 | + }, | ||
143 | +]; | ||
144 | +export const CameraNumberUrl: Rule[] = [ | ||
145 | + { | ||
146 | + required: true, | ||
147 | + validator: (_, value: string) => { | ||
148 | + const ChineseRegexp = /^[A-Za-z0-9]+$/; | ||
149 | + if (!ChineseRegexp.test(value)) { | ||
150 | + return Promise.reject('请输入正确格式的视频编号'); | ||
123 | } | 151 | } |
124 | return Promise.resolve(); | 152 | return Promise.resolve(); |
125 | }, | 153 | }, |
@@ -3,7 +3,7 @@ import { getOrganizationList } from '/@/api/system/system'; | @@ -3,7 +3,7 @@ import { getOrganizationList } from '/@/api/system/system'; | ||
3 | import { copyTransFun } from '/@/utils/fnUtils'; | 3 | import { copyTransFun } from '/@/utils/fnUtils'; |
4 | import type { FormSchema as QFormSchema } from '/@/components/Form/index'; | 4 | import type { FormSchema as QFormSchema } from '/@/components/Form/index'; |
5 | 5 | ||
6 | -import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules'; | 6 | +import { CameraMaxLength, CameraVideoStreamUrl, CameraNumberUrl } from '/@/utils/rules'; |
7 | 7 | ||
8 | // 表格列数据 | 8 | // 表格列数据 |
9 | export const columns: BasicColumn[] = [ | 9 | export const columns: BasicColumn[] = [ |
@@ -104,7 +104,7 @@ export const formSchema: QFormSchema[] = [ | @@ -104,7 +104,7 @@ export const formSchema: QFormSchema[] = [ | ||
104 | label: '摄像头编号', | 104 | label: '摄像头编号', |
105 | required: true, | 105 | required: true, |
106 | component: 'Input', | 106 | component: 'Input', |
107 | - rules: CameraVideoUrl, | 107 | + rules: CameraNumberUrl, |
108 | componentProps: { | 108 | componentProps: { |
109 | placeholder: '请输入摄像头编号', | 109 | placeholder: '请输入摄像头编号', |
110 | }, | 110 | }, |
@@ -118,6 +118,6 @@ export const formSchema: QFormSchema[] = [ | @@ -118,6 +118,6 @@ export const formSchema: QFormSchema[] = [ | ||
118 | placeholder: '请输入视频流', | 118 | placeholder: '请输入视频流', |
119 | maxLength: 255, | 119 | maxLength: 255, |
120 | }, | 120 | }, |
121 | - rules: CameraVideoUrl, | 121 | + rules: CameraVideoStreamUrl, |
122 | }, | 122 | }, |
123 | ]; | 123 | ]; |