|
@@ -186,14 +186,108 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
show: false,
|
|
show: false,
|
|
|
},
|
|
},
|
|
|
form: {
|
|
form: {
|
|
|
- component: { placeholder: '请填写密码' },
|
|
|
|
|
|
|
+ component: {
|
|
|
|
|
+ placeholder: '请填写密码',
|
|
|
|
|
+ type: 'password',
|
|
|
|
|
+ showPassword: true
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
addForm:{
|
|
addForm:{
|
|
|
- component:{placeholder: '请填写密码'} ,
|
|
|
|
|
- rules: [{ required: true, message: '请填写密码' }],},
|
|
|
|
|
|
|
+ component:{
|
|
|
|
|
+ placeholder: '请填写密码',
|
|
|
|
|
+ type: 'password',
|
|
|
|
|
+ showPassword: true
|
|
|
|
|
+ } ,
|
|
|
|
|
+ rules: [
|
|
|
|
|
+ { required: true, message: '请填写密码' },
|
|
|
|
|
+ {
|
|
|
|
|
+ validator: (rule: any, value: string, callback: Function) => {
|
|
|
|
|
+ // 新增时密码必填,如果为空则报错
|
|
|
|
|
+ if (!value || value.trim() === '') {
|
|
|
|
|
+ callback(new Error('请填写密码'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 密码格式校验
|
|
|
|
|
+ const minLength = 8;
|
|
|
|
|
+ const hasLetter = /[a-zA-Z]/.test(value);
|
|
|
|
|
+ const hasNumber = /\d/.test(value);
|
|
|
|
|
+ const hasSpecialChar = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(value);
|
|
|
|
|
+
|
|
|
|
|
+ if (value.length < minLength) {
|
|
|
|
|
+ callback(new Error('密码长度不能少于8位'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasLetter) {
|
|
|
|
|
+ callback(new Error('密码必须包含字母'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasNumber) {
|
|
|
|
|
+ callback(new Error('密码必须包含数字'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasSpecialChar) {
|
|
|
|
|
+ callback(new Error('密码必须包含特殊符号'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ callback();
|
|
|
|
|
+ },
|
|
|
|
|
+ trigger: 'blur'
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ },
|
|
|
editForm:{
|
|
editForm:{
|
|
|
show:true,
|
|
show:true,
|
|
|
|
|
+ component: {
|
|
|
|
|
+ placeholder: '留空则不修改密码',
|
|
|
|
|
+ type: 'password',
|
|
|
|
|
+ showPassword: true
|
|
|
|
|
+ },
|
|
|
|
|
+ rules: [
|
|
|
|
|
+ {
|
|
|
|
|
+ validator: (rule: any, value: string, callback: Function) => {
|
|
|
|
|
+ // 如果密码为空,则通过验证(非必填)
|
|
|
|
|
+ if (!value || value.trim() === '') {
|
|
|
|
|
+ callback();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果填写了密码,则进行格式校验
|
|
|
|
|
+ const minLength = 8;
|
|
|
|
|
+ const hasLetter = /[a-zA-Z]/.test(value);
|
|
|
|
|
+ const hasNumber = /\d/.test(value);
|
|
|
|
|
+ const hasSpecialChar = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(value);
|
|
|
|
|
+
|
|
|
|
|
+ if (value.length < minLength) {
|
|
|
|
|
+ callback(new Error('密码长度不能少于8位'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasLetter) {
|
|
|
|
|
+ callback(new Error('密码必须包含字母'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasNumber) {
|
|
|
|
|
+ callback(new Error('密码必须包含数字'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasSpecialChar) {
|
|
|
|
|
+ callback(new Error('密码必须包含特殊符号'));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ callback();
|
|
|
|
|
+ },
|
|
|
|
|
+ trigger: 'blur'
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
},
|
|
},
|
|
|
viewForm:{
|
|
viewForm:{
|
|
|
show:false,
|
|
show:false,
|