Browse Source

非法字符验证
回填多值

yangfan 4 months ago
parent
commit
0cc96ec789
2 changed files with 36 additions and 1 deletions
  1. 18 0
      src/views/basic/dynamicModel/list/index.vue
  2. 18 1
      src/views/form/webDesign/Form.vue

+ 18 - 0
src/views/basic/dynamicModel/list/index.vue

@@ -2042,6 +2042,24 @@ export default {
                 const find = column.params.compoentConfig.options.find((v) => v.id === cellValue)
                 cellValue = find ? find.fullName : cellValue
               }
+              if (column.params.jnpfKey === 'checkbox') {
+                if (['static', 'dictionary'].includes(data.params.dataType)) {
+                  try {
+                    // 转成数组
+                    cellValue = JSON.parse(cellValue)
+                    cellValue = cellValue.map((v) => {
+                      const find = column.params.compoentConfig.options.find((o) => o.id == v)
+                      return find && find.fullName ? find.fullName : cellValue
+                    })
+                    cellValue = cellValue.toString()
+                  } catch (e) {
+                    return cellValue
+                  }
+                  // const find = column.params.compoentConfig.options.find((v) => v.id == cellValue)
+                  // cellValue = find && find.fullName ? find.fullName : cellValue
+                }
+                console.log(column.params.compoentConfig)
+              }
               if (cellValue == 'null' || cellValue == 'undefined') {
                 return ''
               } else {

+ 18 - 1
src/views/form/webDesign/Form.vue

@@ -210,7 +210,24 @@ export default {
   data() {
     return {
       dataRule: {
-        fullName: [{ required: true, message: '功能名称不能为空', trigger: 'blur' }],
+        fullName: [
+          { required: true, message: '功能名称不能为空', trigger: 'blur' },
+          // 是否有非法字符
+          {
+            validator: (rule, value, callback) => {
+              // 定义非法字符的正则表达式,例如这里假设非法字符为除了字母和空格之外的字符
+              const illegalCharsPattern = /[^a-zA-Z\u4e00-\u9fa5\s]/
+              if (illegalCharsPattern.test(value)) {
+                // 如果有非法字符,通过回调函数提供错误消息
+                callback(new Error('功能名称包含非法字符'))
+              } else {
+                // 如果没有非法字符,验证通过
+                callback()
+              }
+            },
+            trigger: 'blur'
+          }
+        ],
         enCode: [
           { required: true, message: '功能编码不能为空', trigger: 'blur' },
           { validator: this.formValidate('enCode'), trigger: 'blur' }