fix(Design): 修复上传组件最小数量大于最大数量的问题
- 将 van-field 组件的 type 从 "number" 改为 "digit",以限制输入为非负整数 - 添加 minMax 函数,在输入最小数量时同步更新最大数量 - 在最小数量输入框失焦时调用 minMax 函数,并触发保存选项事件
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { showToast } from 'vant';
|
|
||||||
|
|
||||||
// import router from '@/router/index';
|
// import router from '@/router/index';
|
||||||
// import { A_COMMON_CLEAR_TOKEN } from '@/stores/constance/constance.common.js';
|
// 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.resolve(response);
|
||||||
}
|
}
|
||||||
// return Promise.reject(/* new Error(response.message || 'Error') */);
|
// 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;
|
export default service;
|
||||||
|
|||||||
@@ -271,15 +271,15 @@ const debouncedSaveQueItem = debounce((logics, newVal) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
// 保存全部 更新title
|
// 保存全部 更新title
|
||||||
saveQueItem(questionInfo.value.logics, questionCopy);
|
// saveQueItem(questionInfo.value.logics, questionCopy);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
// 在 watch 回调中调用这个已经防抖过的函数
|
// 在 watch 回调中调用这个已经防抖过的函数
|
||||||
watch(
|
watch(
|
||||||
() => questionInfo.value.questions,
|
() => questionInfo.value.questions,
|
||||||
(newVal) => {
|
() => {
|
||||||
debouncedSaveQueItem(questionInfo.value.logics, newVal);
|
// debouncedSaveQueItem(questionInfo.value.logics, newVal);
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
<van-field
|
<van-field
|
||||||
v-model="actionQuestion.config.min_select"
|
v-model="actionQuestion.config.min_select"
|
||||||
label="最少"
|
label="最少"
|
||||||
type="number"
|
type="digit"
|
||||||
:border="false"
|
:border="false"
|
||||||
label-align="left"
|
label-align="left"
|
||||||
input-align="right"
|
input-align="right"
|
||||||
class="action-field"
|
class="action-field"
|
||||||
placeholder="不限"
|
placeholder="不限"
|
||||||
@blur="emit('saveOption')"
|
@blur="minMax"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(value) => {
|
(value) => {
|
||||||
actionQuestion.config.min_select = value;
|
actionQuestion.config.min_select = value;
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<van-field
|
<van-field
|
||||||
v-model="actionQuestion.config.max_select"
|
v-model="actionQuestion.config.max_select"
|
||||||
label="最多"
|
label="最多"
|
||||||
type="number"
|
type="digit"
|
||||||
:border="false"
|
:border="false"
|
||||||
placeholder="不限"
|
placeholder="不限"
|
||||||
input-align="right"
|
input-align="right"
|
||||||
@@ -63,6 +63,13 @@ const actionQuestion = computed({
|
|||||||
emit('update:modelValue', newValue);
|
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>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.action-field {
|
.action-field {
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
<van-field
|
<van-field
|
||||||
v-model="actionQuestion.config.min_number"
|
v-model="actionQuestion.config.min_number"
|
||||||
label="最少"
|
label="最少"
|
||||||
type="number"
|
type="digit"
|
||||||
:border="false"
|
:border="false"
|
||||||
label-align="left"
|
label-align="left"
|
||||||
input-align="right"
|
input-align="right"
|
||||||
class="action-field"
|
class="action-field"
|
||||||
placeholder="不限"
|
placeholder="不限"
|
||||||
@blur="emit('saveOption')"
|
@blur="minMax"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(value) => {
|
(value) => {
|
||||||
actionQuestion.config.min_number = value;
|
actionQuestion.config.min_number = value;
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<van-field
|
<van-field
|
||||||
v-model="actionQuestion.config.max_number"
|
v-model="actionQuestion.config.max_number"
|
||||||
label="最多"
|
label="最多"
|
||||||
type="number"
|
type="digit"
|
||||||
:border="false"
|
:border="false"
|
||||||
placeholder="不限"
|
placeholder="不限"
|
||||||
input-align="right"
|
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 fileTypeList = ref([]);
|
||||||
const fileType = ref([]);
|
const fileType = ref([]);
|
||||||
actionQuestion.value.config.file_type.split(',').map((item) => {
|
actionQuestion.value.config.file_type.split(',').map((item) => {
|
||||||
|
|||||||
@@ -86,13 +86,13 @@
|
|||||||
<van-field
|
<van-field
|
||||||
v-model="actionQuestion.config.min_select"
|
v-model="actionQuestion.config.min_select"
|
||||||
label="最少"
|
label="最少"
|
||||||
type="number"
|
type="digit"
|
||||||
:border="false"
|
:border="false"
|
||||||
label-align="left"
|
label-align="left"
|
||||||
input-align="right"
|
input-align="right"
|
||||||
class="action-field"
|
class="action-field"
|
||||||
placeholder="不限"
|
placeholder="不限"
|
||||||
@blur="emit('saveOption')"
|
@blur="minMax"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(value) => {
|
(value) => {
|
||||||
actionQuestion.config.min_select = value;
|
actionQuestion.config.min_select = value;
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
<van-field
|
<van-field
|
||||||
v-model="actionQuestion.config.max_select"
|
v-model="actionQuestion.config.max_select"
|
||||||
label="最多"
|
label="最多"
|
||||||
type="number"
|
type="digit"
|
||||||
:border="false"
|
:border="false"
|
||||||
placeholder="不限"
|
placeholder="不限"
|
||||||
input-align="right"
|
input-align="right"
|
||||||
@@ -145,6 +145,14 @@ const actionQuestion = computed({
|
|||||||
emit('update:modelValue', newValue);
|
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>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.action-field {
|
.action-field {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<div class="flex align-center van-cell">
|
<div class="flex align-center van-cell">
|
||||||
<contenteditable
|
<contenteditable
|
||||||
v-model="it.option"
|
v-model="it.option"
|
||||||
className="contenteditable-input"
|
:className="active ? 'contenteditable-input' : ''"
|
||||||
:active="active"
|
:active="active"
|
||||||
>
|
>
|
||||||
<template #right-icon>
|
<template #right-icon>
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<div class="flex align-center van-cell">
|
<div class="flex align-center van-cell">
|
||||||
<contenteditable
|
<contenteditable
|
||||||
v-model="it.option"
|
v-model="it.option"
|
||||||
className="contenteditable-input"
|
:className="active ? 'contenteditable-input' : ''"
|
||||||
:active="active"
|
:active="active"
|
||||||
>
|
>
|
||||||
<template #right-icon>
|
<template #right-icon>
|
||||||
|
|||||||
Reference in New Issue
Block a user