ソースを参照

字段添加副标题

songxy 9 ヶ月 前
コミット
77b72d3f1c

+ 62 - 0
client/src/utils/formRequiredValidate.ts

@@ -0,0 +1,62 @@
+interface IRuleField {
+  name: string
+  message: string
+  required?: boolean
+}
+
+type RuleMapType = {
+  [key: string]: {
+    message: string
+    required?: boolean
+  }
+}
+export class FormRequiredValidate {
+  private static ruleMap: RuleMapType = {}
+
+  static validate(rules: any[]) {
+    this.ruleMap = {}
+    for (const item of rules) {
+      if (item['name']) {
+        this.ruleMap[item['name']] = {
+          message: item['message'] || `${item['name']}不能为空!`,
+          required: item['required'] ?? true
+        }
+      }
+    }
+    return (form: any, callback: (state: boolean, rule: IRuleField | null) => void) => {
+      let cRule: IRuleField | null = null
+      let state: boolean = true
+      for (let i: number = 0; i < rules.length; i++) {
+        const name = rules[i]['name']
+        console.log(name)
+        if (
+          Object.hasOwn(form, name) &&
+          this.ruleMap[name]['required'] &&
+          !this.isNotBlank(form[name])
+        ) {
+          cRule = {
+            name,
+            ...this.ruleMap[name]
+          }
+          state = false
+          break
+        }
+      }
+      callback && callback(state, cRule)
+    }
+  }
+
+  static isNotBlank(val: any): boolean {
+    if (val === null) return false
+    if (val === undefined) return false
+    if (typeof val === 'string') {
+      if (val.trim() === '') return false
+    } else if (val instanceof Array) {
+      if (val.length === 0) return false
+    } else if (val instanceof Object) {
+      const keys = Object.keys(val)
+      if (keys.length === 0) return false
+    }
+    return true
+  }
+}

+ 3 - 2
client/src/views/OaSystem/personnelManagement/ygdaPage/index.ts

@@ -237,7 +237,7 @@ export const formConfigList = [
       },
       {
         name: 'zzsj',
-        title: '转正时间',
+        title: '实际转正时间',
         type: 'time'
       },
       {
@@ -256,7 +256,8 @@ export const formConfigList = [
       },
       {
         name: 'sl',
-        title: '司龄'
+        title: '司龄',
+        append: '年'
       }
     ]
   },

+ 3 - 1
client/src/views/OaSystem/personnelManagement/ygdaPage/staffDetail.vue

@@ -321,7 +321,9 @@ const saveTechCertificateList = (data: any[]) => {
                         v-if="child?.type === undefined"
                         v-model="formData[child?.name]"
                         placeholder=""
-                      />
+                      >
+                        <template v-if="child?.append" #append>{{ child?.append }}</template>
+                      </el-input>
                       <div v-if="child?.type === 'button'" class="generate-num">
                         <el-input v-model="formData[child?.name]" placeholder="" :disabled="true" />
                         <ElButton