update: 去掉最大值和最小值校验

This commit is contained in:
admin 2024-07-20 10:27:42 +08:00
parent 37e2c5a641
commit 58e2cb435b
8 changed files with 56 additions and 147 deletions

View File

@ -2,12 +2,12 @@
<up-row customStyle="flex-wrap: wrap" :gutter="8">
<up-col span="6" v-for="(item, index) in list" :key="index">
<view class="grid-item">
<up-image
<image
:src="item.url || `${url}/static/110/error.jpg`"
:mode="'widthFix'"
:width="'100%'"
@click="showImage(index)"
></up-image>
></image>
</view>
</up-col>
</up-row>

View File

@ -210,16 +210,6 @@ const handleInput = (e: any, item: any) => {
});
}
if (item.key === "maxPrice" || item.key === "minPrice") {
if (state.minPrice && state.maxPrice && state.minPrice > state.maxPrice) {
uni.showToast({
title: `最大值应小于最小值`,
icon: "none",
});
return;
}
}
setTimeout(() => {
(state as any)[item.key] = temp;
}, 10);
@ -424,13 +414,6 @@ const resetState = () => {
};
const getFilter = () => {
if (state.minPrice && state.maxPrice && state.minPrice > state.maxPrice) {
uni.showToast({
title: `最大值应小于最小值`,
icon: "none",
});
return;
}
emit("handleOk", {
...state,
repairFlag: currentSpl.value,

View File

@ -32,7 +32,27 @@
:customStyle="{}"
border="none"
:disabled="item.type === 'select'"
:disabledColor="['收货分类'].indexOf(item.name) > -1?'#ffffff':'#f5f7fa'"
:disabledColor="
['收货分类'].indexOf(item.name) > -1 ? '#ffffff' : '#f5f7fa'
"
@change="(e:any) => {handleInput(e, item)}"
@clear="handleClear(item)"
>
<template #suffix>
<text>
{{ item.unit }}
</text>
</template>
</u-input>
<u-input
v-if="item.type === 'number'"
v-model="(model1.formData as any)[item.key]"
:placeholder="`请输入${
item.name
}`"
clearable
:customStyle="{}"
border="none"
@change="(e:any) => {handleInput(e, item)}"
@clear="handleClear(item)"
>
@ -70,44 +90,26 @@ import { countDots } from "@/utils";
import valid from "@/utils/validate";
import { onLoad } from "@dcloudio/uni-app";
import _ from "underscore";
const handleClear = (item:any) => {
(model1.formData as any)[item.key] = '';
}
const handleClear = (item: any) => {
(model1.formData as any)[item.key] = "";
};
//
const handleInput = (e: any, item: any) => {
if (["minPrice", "maxPrice", "commonPrice"].indexOf(item.key) > -1) {
const temp = e?.replace(valid.valid_decimal.pattern, "");
if (!valid.valid_decimal2.pattern.test(temp)) {
uni.showToast({
title: "请输入正确的" + item.name + ", 且最多保留2位小数",
icon: "none",
});
return;
}
if (countDots(temp).length > 1) {
uni.showToast({
title: "请输入正确的" + item.name,
icon: "none",
});
}
const minPrice = parseFloat(model1.formData.minPrice)
const maxPrice = parseFloat(model1.formData.maxPrice)
if (item.key === "maxPrice") {
if (minPrice > maxPrice) {
uni.showToast({
title: `${item.name}应小于${model1.formData.maxPrice}`,
icon: "none",
});
return;
}
}
if (item.key === "commonPrice") {
if (minPrice > -1 && maxPrice > -1) {
if (
!(temp >= minPrice &&
temp <= maxPrice)
) {
uni.showToast({
title: `${item.name}应在${model1.formData.minPrice}-${model1.formData.maxPrice}之间`,
icon: "none",
});
return;
}
}
}
setTimeout(() => {
model1.formData[item.key] = temp;
@ -151,24 +153,6 @@ const rules = ref({
// message: "",
// trigger: ["blur", "change"],
// },
"formData.minPrice": {
type: "number",
required: true,
message: "最低价为空或输入错误",
trigger: ["blur", "change"],
},
"formData.maxPrice": {
type: "number",
required: true,
message: "最高价为空或输入错误",
trigger: ["blur", "change"],
},
"formData.commonPrice": {
type: "number",
required: true,
message: "常用价格为空或输入错误",
trigger: ["blur", "change"],
},
});
const contrlModalParams = reactive<any>({
reCategory: {
@ -198,32 +182,25 @@ const formAttrList = reactive<any>([
contrlModalParams.reCategory.title = "收货分类";
},
},
// {
// name: "",
// key: "substationName",
// type: "input",
// required: true,
// unit: "",
// },
{
name: "最低价",
key: "minPrice",
type: "input",
required: true,
type: "number",
required: false,
unit: "",
},
{
name: "最高价",
key: "maxPrice",
type: "input",
required: true,
type: "number",
required: false,
unit: "",
},
{
name: "常用价格",
key: "commonPrice",
type: "input",
required: true,
type: "number",
required: false,
unit: "",
},
]);
@ -255,27 +232,7 @@ const check = () => {
};
const save = () => {
const minPrice = parseFloat(model1.formData.minPrice)
const maxPrice = parseFloat(model1.formData.maxPrice)
if (minPrice > maxPrice) {
uni.showToast({
title: `最低价应小于${model1.formData.maxPrice}`,
icon: "none",
});
return;
}
if (minPrice > -1 &&maxPrice > -1) {
const temp = model1.formData.commonPrice;
if (!(temp >= minPrice && temp <= maxPrice)) {
uni.showToast({
title: `常用价格应在${model1.formData.minPrice}-${model1.formData.maxPrice}之间`,
icon: "none",
});
return;
}
}
check().then((res) => {
if (res) {
startSave();
@ -286,13 +243,13 @@ const startSave = () => {
if (model1.formData.id) {
GoodsApi.EditReceiveProduct(model1.formData).then((res) => {
if (res.code === 200) {
uni.navigateBack()
uni.navigateBack();
}
});
} else {
GoodsApi.addReProducts(model1.formData).then((res) => {
if (res.code === 200) {
uni.navigateBack()
uni.navigateBack();
}
});
}
@ -324,7 +281,7 @@ onLoad((option) => {
//
uni.setNavigationBarTitle({
title: title || '新增收货产品',
title: title || "新增收货产品",
});
});
</script>
@ -350,7 +307,7 @@ onLoad((option) => {
border-radius: 13rpx 13rpx 0rpx 0rpx;
padding: 25rpx 50rpx;
position: fixed;
width: calc(100vw - 100rpx);
width: calc(100vw - 100rpx);
bottom: 0rpx;
z-index: 999;
::v-deep button {

View File

@ -28,7 +28,6 @@
<view>
<view>
<view>{{ item.reProductsName }}</view>
<view>{{ item.minPrice }} ~ {{ item.maxPrice }} </view>
</view>
<view class="op-box">
<view class="btn" @click="edit(item)"> 编辑 </view>

View File

@ -183,17 +183,6 @@ const handleInput = (e: any, item: any) => {
icon: "none",
});
}
if (item.key === "price") {
if (model1.order.minPrice && model1.order.maxPrice) {
if (temp < model1.order.minPrice || temp > model1.order.maxPrice) {
uni.showToast({
title: `${item.name}应在${model1.order.minPrice}-${model1.order.maxPrice}之间`,
icon: "none",
});
return;
}
}
}
if (item.key === "tare") {
if (

View File

@ -1,5 +1,5 @@
<template>
<view class="c-card">
<view class="c-card app-container">
<u-form
labelPosition="left"
:model="model1"
@ -111,7 +111,7 @@
</view>
<view class="btn-box">
<u-button text="暂不定价" @click="handleBack()"></u-button>
<u-button type="primary" text="保存" @click="save()"></u-button>
<u-button type="primary" :text="model1.order.scaleStatus === 0 ? '定价' : '保存'" @click="save()"></u-button>
</view>
<!-- 收货产品弹框 -->
@ -188,17 +188,6 @@ const handleInput = (e: any, item: any) => {
icon: "none",
});
}
if (item.key === "price") {
if (model1.order.minPrice && model1.order.maxPrice) {
if (temp < model1.order.minPrice || temp > model1.order.maxPrice) {
uni.showToast({
title: `${item.name}应在${model1.order.minPrice}-${model1.order.maxPrice}之间`,
icon: "none",
});
return;
}
}
}
setTimeout(() => {
model1.order[item.key] = temp;
@ -674,18 +663,6 @@ const save = () => {
return;
}
if (model1.order.minPrice && model1.order.maxPrice) {
if (
parseFloat(model1.order.price + "") < parseFloat(model1.order.minPrice) ||
parseFloat(model1.order.price + "") > parseFloat(model1.order.maxPrice)
) {
uni.showToast({
title: `单价应在${model1.order.minPrice}-${model1.order.maxPrice}之间`,
icon: "none",
});
return;
}
}
if (
model1.order.grossWeight?.toString() &&
model1.order.grossWeight?.toString()[
@ -766,9 +743,7 @@ const updateOrder = () => {
});
} else {
// 0 1
uni.redirectTo({
url: "/pagesHome/index", //
});
uni.navigateBack()
}
}
});

View File

@ -111,6 +111,7 @@ import PageView from "@/components/PageView/index.vue";
import { onLoad } from "@dcloudio/uni-app";
import { DeviceType, ScaleStatus } from "@/utils/enum";
import _ from "underscore";
import { onShow } from "@dcloudio/uni-app";
const stateNew = reactive<any>({
keywoard: "",
@ -183,7 +184,7 @@ const pricingDetail = (id: number) => {
resetPageList();
getList();
} else {
uni.redirectTo({
uni.navigateTo({
url: "/pagesReceive/form/pricingForm?id=" + id, //
});
}
@ -227,9 +228,10 @@ const handleOk = () => {
});
};
onMounted(() => {
onShow(() => {
resetPageList();
getList();
});
})
onLoad((option) => {
//

View File

@ -26,6 +26,10 @@ const valid = {
pattern: /[^0-9.]/g,
message: "请输入正确的数字",
},
valid_decimal2: {
pattern: /^\d+(\.\d{1,2})?$/,
message: "请输入正确的数字",
},
valid_id_card: {
pattern:
/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,