瀏覽代碼

限制只能输入整型

lifanagju_citu 9 月之前
父節點
當前提交
fbe2c3e5fb

+ 24 - 1
src/components/FormUI/TextInput/index.vue

@@ -44,12 +44,35 @@ const emit = defineEmits(['update:modelValue', 'change', 'appendClick', 'appendI
 const item = props.item
 const value = ref(props.modelValue)
 const searchDebouncedTime = item?.searchDebouncedTime === 0 ? ref(0) : ref(500)
+if (item.type === 'number' && item.integer) searchDebouncedTime.value = 0
+
+const valueDeal = (val) => {
+  let dealData
+  if (item.type === 'number') {
+    // if (item.max && val > item.max) {
+    //   dealData = (item.max - 0)
+    //   Snackbar.warning(`最大可输入${item.max}`)
+    // }
+    // if (item.min && val < item.min) {
+    //   dealData = (item.min - 0)
+    //   Snackbar.warning(`最小可输入${item.max}`)
+    // }
+    if (item.integer) { // 为true时只能输入整型
+      dealData = val.replace(/\D/g,'') - 0
+    }
+  }
+  return dealData
+}
 
 watch(() => props.modelValue, (newVal) => {
-  value.value = newVal
+  const dealData = valueDeal(newVal)
+  value.value = dealData
 })
+
 const modelValueUpDate = (val) => {
   value.value = val
+  console.log('1', value.value)
+  console.log('modelValueUpDate val', val)
   emit('update:modelValue', value.value)
   debouncedCallbackUpDate(value.value) // emit('change', value.value)
 }

+ 2 - 0
src/views/recruit/enterprise/positionManagement/components/baseInfo.vue

@@ -134,6 +134,7 @@ const items = ref({
       value: null,
       label: '请填写众聘赏金',
       suffix: '元',
+      integer: true,
       hide: true,
       show: true,
       disabled: false,
@@ -286,6 +287,7 @@ const getQuery = async () => {
     // obj.hirePoint = 0
     obj.hirePrice = 0
   }
+  obj.hirePrice = (obj.hirePrice - 0)*100 // 后端需要
   query = Object.assign(query, obj)
   return query
 }