fix(Design): 修复上传组件最小数量大于最大数量的问题

- 将 van-field 组件的 type 从 "number" 改为 "digit",以限制输入为非负整数
- 添加 minMax 函数,在输入最小数量时同步更新最大数量
- 在最小数量输入框失焦时调用 minMax 函数,并触发保存选项事件
This commit is contained in:
陈昱达
2025-03-21 17:59:15 +08:00
parent 5fd7efd61c
commit 03f79ee66a
6 changed files with 68 additions and 53 deletions

View File

@@ -1,5 +1,4 @@
import axios from 'axios';
import { showToast } from 'vant';
// import router from '@/router/index';
// import { A_COMMON_CLEAR_TOKEN } from '@/stores/constance/constance.common.js';
@@ -56,45 +55,39 @@ service.interceptors.response.use(
return Promise.resolve(response);
}
// return Promise.reject(/* new Error(response.message || 'Error') */);
},
(error) => {
// for debug
// if (error.response.status === 401) {
// const query = router.currentRoute.value.query;
// //关闭已弹出的所有弹框,防止弹框重叠
// // Modal.destroyAll();
// store.dispatch(A_COMMON_CLEAR_TOKEN);
// window.parent.postMessage(
// {
// code: '301',
// params: {}
// },
// '*'
// );
// store.commit('common/M_COMMON_SET_TOKEN_UNAUTHORIZED', false);
// } else if (error.response.status === 403) {
// router.push({
// path: '/error/403'
// });
// } else if (error.response.status === 404) {
// router.push({
// path: '/error/404'
// });
// } else if (error.response.status === 500) {
// router.push({
// path: '/error/500'
// });
// } else {
// // message.error(error.response.data?.message || '服务器错误');
// }
if (error.response.data?.message) {
showToast({
message: error.response.data?.message
});
}
return Promise.reject(error.response);
}
// (error) => {
// // for debug
// if (error.response.status === 401) {
// const query = router.currentRoute.value.query;
// //关闭已弹出的所有弹框,防止弹框重叠
// // Modal.destroyAll();
// store.dispatch(A_COMMON_CLEAR_TOKEN);
// window.parent.postMessage(
// {
// code: '301',
// params: {}
// },
// '*'
// );
// store.commit('common/M_COMMON_SET_TOKEN_UNAUTHORIZED', false);
// } else if (error.response.status === 403) {
// router.push({
// path: '/error/403'
// });
// } else if (error.response.status === 404) {
// router.push({
// path: '/error/404'
// });
// } else if (error.response.status === 500) {
// router.push({
// path: '/error/500'
// });
// } else {
// // message.error(error.response.data?.message || '服务器错误');
// }
// return Promise.reject(error.response);
// }
);
export default service;

View File

@@ -271,15 +271,15 @@ const debouncedSaveQueItem = debounce((logics, newVal) => {
};
});
// 保存全部 更新title
saveQueItem(questionInfo.value.logics, questionCopy);
// saveQueItem(questionInfo.value.logics, questionCopy);
}
}, 1000);
// 在 watch 回调中调用这个已经防抖过的函数
watch(
() => questionInfo.value.questions,
(newVal) => {
debouncedSaveQueItem(questionInfo.value.logics, newVal);
() => {
// debouncedSaveQueItem(questionInfo.value.logics, newVal);
},
{ deep: true }
);

View File

@@ -3,13 +3,13 @@
<van-field
v-model="actionQuestion.config.min_select"
label="最少"
type="number"
type="digit"
:border="false"
label-align="left"
input-align="right"
class="action-field"
placeholder="不限"
@blur="emit('saveOption')"
@blur="minMax"
@update:model-value="
(value) => {
actionQuestion.config.min_select = value;
@@ -26,7 +26,7 @@
<van-field
v-model="actionQuestion.config.max_select"
label="最多"
type="number"
type="digit"
:border="false"
placeholder="不限"
input-align="right"
@@ -63,6 +63,13 @@ const actionQuestion = computed({
emit('update:modelValue', newValue);
}
});
// 最小大于最大 同步到最大
const minMax = (e) => {
if (Number(e.target.value) > Number(actionQuestion.value.config.max_select)) {
actionQuestion.value.config.min_select = actionQuestion.value.config.max_select;
}
emit('saveOption');
};
</script>
<style scoped lang="scss">
.action-field {

View File

@@ -3,13 +3,13 @@
<van-field
v-model="actionQuestion.config.min_number"
label="最少"
type="number"
type="digit"
:border="false"
label-align="left"
input-align="right"
class="action-field"
placeholder="不限"
@blur="emit('saveOption')"
@blur="minMax"
@update:model-value="
(value) => {
actionQuestion.config.min_number = value;
@@ -23,7 +23,7 @@
<van-field
v-model="actionQuestion.config.max_number"
label="最多"
type="number"
type="digit"
:border="false"
placeholder="不限"
input-align="right"
@@ -119,6 +119,13 @@ const actionQuestion = computed({
}
});
// 最小大于最大 同步到最大
const minMax = (e) => {
if (Number(e.target.value) > Number(actionQuestion.value.config.max_number)) {
actionQuestion.value.config.min_number = actionQuestion.value.config.max_number;
}
emit('saveOption');
};
const fileTypeList = ref([]);
const fileType = ref([]);
actionQuestion.value.config.file_type.split(',').map((item) => {

View File

@@ -86,13 +86,13 @@
<van-field
v-model="actionQuestion.config.min_select"
label="最少"
type="number"
type="digit"
:border="false"
label-align="left"
input-align="right"
class="action-field"
placeholder="不限"
@blur="emit('saveOption')"
@blur="minMax"
@update:model-value="
(value) => {
actionQuestion.config.min_select = value;
@@ -106,7 +106,7 @@
<van-field
v-model="actionQuestion.config.max_select"
label="最多"
type="number"
type="digit"
:border="false"
placeholder="不限"
input-align="right"
@@ -145,6 +145,14 @@ const actionQuestion = computed({
emit('update:modelValue', newValue);
}
});
// 最小大于最大 同步到最大
const minMax = (e) => {
if (Number(e.target.value) > Number(actionQuestion.value.config.max_select)) {
actionQuestion.value.config.min_select = actionQuestion.value.config.max_select;
}
emit('saveOption');
};
</script>
<style scoped lang="scss">
.action-field {

View File

@@ -41,7 +41,7 @@
<div class="flex align-center van-cell">
<contenteditable
v-model="it.option"
className="contenteditable-input"
:className="active ? 'contenteditable-input' : ''"
:active="active"
>
<template #right-icon>
@@ -79,7 +79,7 @@
<div class="flex align-center van-cell">
<contenteditable
v-model="it.option"
className="contenteditable-input"
:className="active ? 'contenteditable-input' : ''"
:active="active"
>
<template #right-icon>