diff --git a/components.d.ts b/components.d.ts index ac71025..cd3fcc8 100644 --- a/components.d.ts +++ b/components.d.ts @@ -42,7 +42,6 @@ declare module 'vue' { ASubMenu: typeof import('ant-design-vue/es')['SubMenu'] ATable: typeof import('ant-design-vue/es')['Table'] ATag: typeof import('ant-design-vue/es')['Tag'] - ATextarea: typeof import('ant-design-vue/es')['Textarea'] AUpload: typeof import('ant-design-vue/es')['Upload'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/src/api/myAxios.ts b/src/api/myAxios.ts index 47c794c..1a8817f 100644 --- a/src/api/myAxios.ts +++ b/src/api/myAxios.ts @@ -9,7 +9,7 @@ const myAxios = axios.create({ //baseURL:'http://localhost:9091' // baseURL:'http://1.94.237.210:3457' //baseURL:'http://1.94.237.210:8088' - // baseURL:'http://27.30.77.229:9091/' + //baseURL:'http://27.30.77.229:9091/' baseURL:'http://27.30.77.229:9092/' }); diff --git a/src/view/project/addProject.vue b/src/view/project/addProject.vue index 6f9b44f..1138a28 100644 --- a/src/view/project/addProject.vue +++ b/src/view/project/addProject.vue @@ -94,9 +94,12 @@ v-model.number="formData.projectSettlementCycle" type="number" min="1" + max="10" class="input-field" required - placeholder="请输入结算周期" + placeholder="请输入结算周期(1-10)" + @input="limitSettlementCycle" + @keypress="filterNumericInput" > @@ -108,9 +111,12 @@ v-model.number="formData.maxPromoterCount" type="number" min="1" + max="999999" class="input-field" required - placeholder="请输入最大人数" + placeholder="请输入最大人数(1-999999)" + @input="limitPromoterCount" + @keypress="filterNumericInput" > @@ -351,8 +357,8 @@ const handleSubmit = async () => { // 重置表单 Object.assign(formData, { projectName: '', - projectSettlementCycle: 2, - maxPromoterCount: 200, + projectSettlementCycle: '', + maxPromoterCount: '', projectStatus: 'running', projectDescription: '', settlementDesc: '', @@ -391,7 +397,45 @@ const validateForm = (): boolean => { return value !== '' && value !== null && value !== undefined; }); }; +const filterNumericInput = (event: KeyboardEvent) => { + const key = event.key; + // 只允许数字输入 + if (!/^\d$/.test(key)) { + event.preventDefault(); + } +}; +const limitSettlementCycle = (event: Event) => { + const input = event.target as HTMLInputElement; + let value = parseInt(input.value); + + if (isNaN(value)) { + formData.projectSettlementCycle = 1; + return; + } + + // 限制在1-10之间 + if (value < 1) value = 1; + if (value > 10) value = 10; + + formData.projectSettlementCycle = value; +}; + +const limitPromoterCount = (event: Event) => { + const input = event.target as HTMLInputElement; + let value = parseInt(input.value); + + if (isNaN(value)) { + formData.maxPromoterCount = 1; + return; + } + + // 限制在1-999999之间 + if (value < 1) value = 1; + if (value > 999999) value = 999999; + + formData.maxPromoterCount = value; +}; diff --git a/src/view/project/projectDetail.vue b/src/view/project/projectDetail.vue index 8623c1c..e4e9d61 100644 --- a/src/view/project/projectDetail.vue +++ b/src/view/project/projectDetail.vue @@ -134,13 +134,7 @@ const previewImage = ref(''); const formRef = ref(); -// 添加数字输入校验方法 -const handleNumberInput = (e: KeyboardEvent) => { - const allowedKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab']; - if (!allowedKeys.includes(e.key)) { - e.preventDefault(); - } -}; + // 添加粘贴校验方法 const handlePaste = (e: ClipboardEvent) => { @@ -281,6 +275,53 @@ const triggerFileInput = () => { fileInput.value.click(); } }; + +const handleNumberInput = (e: KeyboardEvent) => { + const allowedKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab']; + + // 只允许数字和控制键 + if (!allowedKeys.includes(e.key)) { + e.preventDefault(); + } +}; + +// 添加范围限制方法 - 现在在输入时立即修正 +const limitSettlementCycle = (value: number) => { + if (!editData.value) return; + + // 确保是数字 + if (isNaN(value)) { + editData.value.projectSettlementCycle = 1; + return; + } + + // 限制在1-10之间 + if (value < 1) editData.value.projectSettlementCycle = 1; + if (value > 10) editData.value.projectSettlementCycle = 10; +}; + +const limitPromoterCount = (value: number) => { + if (!editData.value) return; + + // 确保是数字 + if (isNaN(value)) { + editData.value.maxPromoterCount = 1; + return; + } + + // 限制在1-999999之间 + if (value < 1) editData.value.maxPromoterCount = 1; + if (value > 999999) editData.value.maxPromoterCount = 999999; +}; + +// 添加输入时实时限制 - 立即修正值 +const handleSettlementInput = (value: number) => { + limitSettlementCycle(value); +}; + +const handlePromoterInput = (value: number) => { + limitPromoterCount(value); +};