update: 修复定价中保存图片问题
This commit is contained in:
parent
58e2cb435b
commit
b23ad4b28a
|
@ -44,24 +44,6 @@
|
|||
</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)"
|
||||
>
|
||||
<template #suffix>
|
||||
<text>
|
||||
{{ item.unit }}
|
||||
</text>
|
||||
</template>
|
||||
</u-input>
|
||||
<template #right v-if="item.type === 'select'">
|
||||
<u-icon name="arrow-right"></u-icon>
|
||||
</template>
|
||||
|
@ -86,7 +68,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { GoodsApi } from "@/services";
|
||||
import { countDots } from "@/utils";
|
||||
import { countDots, isTwoDecimalPlaces } from "@/utils";
|
||||
import valid from "@/utils/validate";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import _ from "underscore";
|
||||
|
@ -97,20 +79,18 @@ const handleClear = (item: any) => {
|
|||
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) {
|
||||
if (countDots(temp) > 1) {
|
||||
uni.showToast({
|
||||
title: "请输入正确的" + item.name,
|
||||
icon: "none",
|
||||
});
|
||||
} else if(countDots(temp) === 1 && (isTwoDecimalPlaces(temp))) {
|
||||
uni.showToast({
|
||||
title: item.name + "最多只能输入2位小数",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
model1.formData[item.key] = temp;
|
||||
}, 10);
|
||||
|
@ -185,21 +165,21 @@ const formAttrList = reactive<any>([
|
|||
{
|
||||
name: "最低价",
|
||||
key: "minPrice",
|
||||
type: "number",
|
||||
type: "input",
|
||||
required: false,
|
||||
unit: "",
|
||||
},
|
||||
{
|
||||
name: "最高价",
|
||||
key: "maxPrice",
|
||||
type: "number",
|
||||
type: "input",
|
||||
required: false,
|
||||
unit: "",
|
||||
},
|
||||
{
|
||||
name: "常用价格",
|
||||
key: "commonPrice",
|
||||
type: "number",
|
||||
type: "input",
|
||||
required: false,
|
||||
unit: "",
|
||||
},
|
||||
|
|
|
@ -68,7 +68,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
// #endif
|
||||
},
|
||||
timeout: 1800000,
|
||||
url: baseUrl + '/test/sh0001' + options.url, //仅为示例,非真实的接口地址
|
||||
url: options.url, //仅为示例,非真实的接口地址
|
||||
fileType: "image",
|
||||
// #ifdef H5
|
||||
files: (options as any).data.files,
|
||||
|
|
|
@ -269,7 +269,15 @@ export function formatMoney(
|
|||
export function countDots(str: any) {
|
||||
return (str.match(/\./g) || []).length;
|
||||
}
|
||||
|
||||
export function isTwoDecimalPlaces(num:any) {
|
||||
// 转换为字符串并移除可能的符号
|
||||
const str = num.toString().replace(/[-]+/g, '');
|
||||
// 分割整数部分和小数部分
|
||||
const parts = str.split('.');
|
||||
console.log(parts)
|
||||
// 如果小数点后有两位数字,返回true
|
||||
return parts.length === 2 && parts[1].length > 2;
|
||||
}
|
||||
export function validateRegex(regexValue: string, value: string) {
|
||||
const regex = new RegExp(regexValue);
|
||||
return regex.test(value);
|
||||
|
|
|
@ -27,7 +27,7 @@ const valid = {
|
|||
message: "请输入正确的数字",
|
||||
},
|
||||
valid_decimal2: {
|
||||
pattern: /^\d+(\.\d{1,2})?$/,
|
||||
pattern: /([1-9]+[\d]*(\.[0-9]{0,2})?)/,
|
||||
message: "请输入正确的数字",
|
||||
},
|
||||
valid_id_card: {
|
||||
|
|
Loading…
Reference in New Issue