Commit 1e4d46d4caaf7dc554398aa06b517aed115c7334

Authored by xp.Huang
2 parents a0643bc4 94504f55

Merge branch 'ft-dev' into 'main'

fix:DEFECT-387视频管理编辑回显问题和加了一些验证

See merge request huang/yun-teng-iot-front!212
@@ -54,7 +54,10 @@ export const emailRule: Rule[] = [ @@ -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 export const EmailRegexp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/; 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,6 +65,36 @@ export const EmailRegexp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a
62 // 手机号正则 65 // 手机号正则
63 export const PhoneRegexp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; 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 export const NotificationTitleMaxLength: Rule[] = [ 99 export const NotificationTitleMaxLength: Rule[] = [
67 { 100 {
@@ -57,14 +57,9 @@ @@ -57,14 +57,9 @@
57 setDrawerProps({ confirmLoading: false }); 57 setDrawerProps({ confirmLoading: false });
58 isUpdate.value = !!data?.isUpdate; 58 isUpdate.value = !!data?.isUpdate;
59 if (unref(isUpdate)) { 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 } else { 63 } else {
69 tenantLogo.value = ''; 64 tenantLogo.value = '';
70 editId.value = ''; 65 editId.value = '';
1 import { BasicColumn, FormSchema } from '/@/components/Table'; 1 import { BasicColumn, FormSchema } from '/@/components/Table';
2 import { getOrganizationList } from '/@/api/system/system'; 2 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';
  5 +
  6 +import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules';
4 7
5 // 表格列数据 8 // 表格列数据
6 export const columns: BasicColumn[] = [ 9 export const columns: BasicColumn[] = [
@@ -57,7 +60,7 @@ export const searchFormSchema: FormSchema[] = [ @@ -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 field: 'avatar', 65 field: 'avatar',
63 label: '视频封面', 66 label: '视频封面',
@@ -73,6 +76,7 @@ export const formSchema: FormSchema[] = [ @@ -73,6 +76,7 @@ export const formSchema: FormSchema[] = [
73 placeholder: '请输入视频名字', 76 placeholder: '请输入视频名字',
74 maxLength: 30, 77 maxLength: 30,
75 }, 78 },
  79 + rules: CameraMaxLength,
76 }, 80 },
77 { 81 {
78 field: 'organizationId', 82 field: 'organizationId',
@@ -91,7 +95,6 @@ export const formSchema: FormSchema[] = [ @@ -91,7 +95,6 @@ export const formSchema: FormSchema[] = [
91 field: 'brand', 95 field: 'brand',
92 label: '视频厂家', 96 label: '视频厂家',
93 component: 'Input', 97 component: 'Input',
94 - required: true,  
95 componentProps: { 98 componentProps: {
96 placeholder: '请输入视频厂家', 99 placeholder: '请输入视频厂家',
97 }, 100 },
@@ -99,8 +102,9 @@ export const formSchema: FormSchema[] = [ @@ -99,8 +102,9 @@ export const formSchema: FormSchema[] = [
99 { 102 {
100 field: 'sn', 103 field: 'sn',
101 label: '摄像头编号', 104 label: '摄像头编号',
102 - component: 'Input',  
103 required: true, 105 required: true,
  106 + component: 'Input',
  107 + rules: CameraVideoUrl,
104 componentProps: { 108 componentProps: {
105 placeholder: '请输入摄像头编号', 109 placeholder: '请输入摄像头编号',
106 }, 110 },
@@ -114,5 +118,6 @@ export const formSchema: FormSchema[] = [ @@ -114,5 +118,6 @@ export const formSchema: FormSchema[] = [
114 placeholder: '请输入视频流', 118 placeholder: '请输入视频流',
115 maxLength: 255, 119 maxLength: 255,
116 }, 120 },
  121 + rules: CameraVideoUrl,
117 }, 122 },
118 ]; 123 ];