update: 更新收货补单 出货补单对接

This commit is contained in:
admin 2024-03-26 15:30:25 +08:00
parent 30faf31b8a
commit 270ca68aae
2 changed files with 281 additions and 74 deletions

View File

@ -7,9 +7,10 @@
ref="form" ref="form"
:labelWidth="80" :labelWidth="80"
:labelStyle="{ padding: '0rpx 10rpx' }" :labelStyle="{ padding: '0rpx 10rpx' }"
:errorType="'border-bottom'"
> >
<u-form-item <u-form-item
:prop="`order[${item.key}]`" :prop="`order.${item.key}`"
:label="item.name" :label="item.name"
:required="item.required" :required="item.required"
v-for="(item, index) in formAttrList" v-for="(item, index) in formAttrList"
@ -30,10 +31,11 @@
:clearable="true" :clearable="true"
:customStyle="{}" :customStyle="{}"
border="none" border="none"
:disabled="item.disabled"
> >
<template #suffix> <template #suffix>
<text v-if="item.key === 'subtractNum'"> <text v-if="item.key === 'subtractNum'">
{{ model1.order.buttonType === 1 ? item.unit : "%" }} {{ model1.order.buttonType === 0 ? item.unit : "%" }}
</text> </text>
<text v-else> <text v-else>
{{ item.unit }} {{ item.unit }}
@ -44,13 +46,14 @@
@delete="deletePic" --> @delete="deletePic" -->
<uni-file-picker <uni-file-picker
v-if="item.type === 'upload'" v-if="item.type === 'upload'"
v-model="model1.order.fileList" v-model="model1.order.fileLists"
limit="10" limit="9"
title="最多可上传10张图片" title="最多可上传9张图片"
:auto-upload="false" :auto-upload="false"
fileMediatype="image" fileMediatype="image"
mode="grid" mode="grid"
ref="filesRef" ref="filesRef"
@delete="handleDelete"
></uni-file-picker> ></uni-file-picker>
<u-radio-group <u-radio-group
@ -58,9 +61,9 @@
v-model="(model1.order as any)[item.key]" v-model="(model1.order as any)[item.key]"
placement="row" placement="row"
> >
<u-radio activeColor="#00DCEE" label="按固定重量" :name="1"></u-radio> <u-radio activeColor="#00DCEE" label="按固定重量" :name="0"></u-radio>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<u-radio activeColor="#00DCEE" label="按百分比" :name="2"></u-radio> <u-radio activeColor="#00DCEE" label="按百分比" :name="1"></u-radio>
</u-radio-group> </u-radio-group>
<template #right v-if="item.type === 'select'"> <template #right v-if="item.type === 'select'">
<u-icon name="arrow-right"></u-icon> <u-icon name="arrow-right"></u-icon>
@ -97,6 +100,7 @@ import {
ProfileApi, ProfileApi,
ReceiveApi, ReceiveApi,
ReceiveProductApi, ReceiveProductApi,
SupplierApi,
} from "@/services"; } from "@/services";
import { formatDate } from "@/utils"; import { formatDate } from "@/utils";
import { DeviceType, ImagesType, OrderType } from "@/utils/enum"; import { DeviceType, ImagesType, OrderType } from "@/utils/enum";
@ -105,22 +109,58 @@ import _ from "underscore";
const model1 = reactive<any>({ const model1 = reactive<any>({
order: { order: {
buttonType: 0, buttonType: 0,
fileList: [], fileLists: [],
splTime: "", splTime: "",
subtractType: 1, subtractType: 1,
}, },
}); });
const rules = ref({ const rules = reactive({
"userInfo.userName": { "order.repairTime": {
type: "string", type: "string",
required: true, required: true,
message: "请输入手机号", message: "请选择补单时间",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
"userInfo.password": { "order.deviceName": {
type: "string", type: "string",
required: true, required: true,
message: "请输入密码", message: "请选择站点磅秤",
trigger: ["blur", "change"],
},
"order.userName": {
type: "string",
required: true,
message: "请选择供应商",
trigger: ["blur", "change"],
},
"order.productName": {
type: "string",
required: true,
message: "请选择收货产品",
trigger: ["blur", "change"],
},
"order.grossWeight": {
type: "string",
required: true,
message: "请输入毛重",
trigger: ["blur", "change"],
},
"order.tare": {
type: "string",
required: true,
message: "请输入皮重",
trigger: ["blur", "change"],
},
"order.price": {
type: "string",
required: true,
message: "请输入单价",
trigger: ["blur", "change"],
},
"order.balanceTotalPrice": {
type: "string",
required: true,
message: "请输入货款金额",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
}); });
@ -227,6 +267,7 @@ const formAttrList = reactive<any>([
key: "netWeight", key: "netWeight",
type: "input", type: "input",
unit: "KG", unit: "KG",
disabled: true
}, },
{ {
name: "单价", name: "单价",
@ -240,9 +281,10 @@ const formAttrList = reactive<any>([
key: "totalPrice", key: "totalPrice",
type: "input", type: "input",
unit: "元", unit: "元",
disabled: true
}, },
{ {
name: "款金额", name: "款金额",
key: "balanceTotalPrice", key: "balanceTotalPrice",
type: "input", type: "input",
required: true, required: true,
@ -259,24 +301,73 @@ const formAttrList = reactive<any>([
type: "upload", type: "upload",
}, },
]); ]);
//
watch(
[
() => model1.order.grossWeight,
() => model1.order.tare,
() => model1.order.price,
() => model1.order.subtractNum,
() => model1.order.buttonType,
],
([grossWeightNew, tareNew]) => {
/**
* 过磅净重 毛重-皮重
结算重量 过磅净重-扣杂
预估总价 结算单价*结算重量
实际收入实际结算金额-运费-杂费
*/
model1.order.netWeight = (grossWeightNew || 0) - (tareNew || 0);
if (model1.order.buttonType === 0) {
if (model1.order.subtractNum) {
model1.order.netWeight =
model1.order.netWeight - model1.order.subtractNum;
}
} else if (model1.order.buttonType === 1) {
if (model1.order.subtractNum) {
model1.order.netWeight =
model1.order.netWeight * ((100 - model1.order.subtractNum) / 100);
}
}
model1.order.totalPrice =
(model1.order.price || 0) * (model1.order.netWeight || 0);
}
);
const handleDelete = (e: any) => {
console.log(model1.order.fileLists);
if (e.tempFile.fileID) {
PictureApi.deleteById({ id: e.tempFile.fileID }).then((res) => {
if (res.code === 200) {
uni.showToast({ title: "已删除" });
}
});
}
};
const filesRef = ref(); const filesRef = ref();
const handleUpload = () => { const handleUpload = () => {
// console.log(event.tempFilePaths) // console.log(event.tempFilePaths)
const list = filesRef.value[0].filesList; return filesRef.value[0].filesList.map((item: any, index: number) => {
return list.map((item: any) => { if (item.fileID) {
return;
}
return new Promise((resolve) => { return new Promise((resolve) => {
PictureApi.upload({ PictureApi.upload({
files: item, files: item,
path: item.path, path: item.path,
}).then((res) => { })
.then((res) => {
if (res.code === 200) { if (res.code === 200) {
resolve({ resolve({
...(res.data as any), ...(res.data as any),
businessId: (model1.order as any).id, businessId: model1.order.id,
imagesType: ImagesType.NORMARL, // imagesType: ImagesType.NORMARL, //
orderType: OrderType.Receive, // orderType: OrderType.Receive, //
}); });
} }
})
.catch((e) => {
return;
}); });
}); });
}); });
@ -296,10 +387,9 @@ const handleSelect = (key: string, v: any) => {
} }
}; };
// //
ProfileApi.getUserList({ userType: 2 }).then((res) => { SupplierApi.getSupplierUserList({}).then((res) => {
if (res.code === 200) { if (res.code === 200) {
contrlModalParams.user.list = res.data; contrlModalParams.user.list = res.data;
console.log(contrlModalParams.user.list);
} }
}); });
// //
@ -330,16 +420,42 @@ const upload = () => {
if (res.length > 0) { if (res.length > 0) {
PictureApi.addListAnnex({ annexPos: res }).then((res1) => { PictureApi.addListAnnex({ annexPos: res }).then((res1) => {
if (res1.code === 200) { if (res1.code === 200) {
uni.showToast({ console.log("*** 资源文件更新成功");
title: "图片资源上传成功",
icon: "success",
});
} }
}); });
} }
}); });
}; };
/**
* 校验
*/
const form = ref();
const check = () => {
return new Promise((resolve) => {
form.value
.validate()
.then((res: boolean) => {
resolve(res);
})
.catch((errors: any) => {
resolve(false);
uni.showToast({
icon: "none",
title: errors[0].message || "校验失败",
});
});
});
};
const save = () => { const save = () => {
check().then((res) => {
if (res) {
startSave();
}
});
};
const startSave = () => {
if (model1.order.buttonType === 0) { if (model1.order.buttonType === 0) {
model1.order.buckleMiscellaneous = model1.order.subtractNum; model1.order.buckleMiscellaneous = model1.order.subtractNum;
} else if (model1.order.buttonType === 1) { } else if (model1.order.buttonType === 1) {
@ -349,8 +465,8 @@ const save = () => {
if (res.code === 200) { if (res.code === 200) {
model1.order.id = res.data; model1.order.id = res.data;
upload(); upload();
uni.navigateTo({ uni.redirectTo({
url: "/pages/index/index", // url: "/pagesHome/index", //
}); });
} }
}); });

View File

@ -7,9 +7,10 @@
ref="form" ref="form"
:labelWidth="80" :labelWidth="80"
:labelStyle="{ padding: '0rpx 10rpx' }" :labelStyle="{ padding: '0rpx 10rpx' }"
:errorType="'border-bottom'"
> >
<u-form-item <u-form-item
:prop="`order[${item.key}]`" :prop="`order.${item.key}`"
:label="item.name" :label="item.name"
:required="item.required" :required="item.required"
v-for="(item, index) in formAttrList" v-for="(item, index) in formAttrList"
@ -30,6 +31,7 @@
:clearable="true" :clearable="true"
:customStyle="{}" :customStyle="{}"
border="none" border="none"
:disabled="item.disabled"
> >
<template #suffix> <template #suffix>
<text v-if="item.key === 'subtractNum'"> <text v-if="item.key === 'subtractNum'">
@ -44,13 +46,14 @@
@delete="deletePic" --> @delete="deletePic" -->
<uni-file-picker <uni-file-picker
v-if="item.type === 'upload'" v-if="item.type === 'upload'"
v-model="model1.order.fileList" v-model="model1.order.fileLists"
limit="10" limit="9"
title="最多可上传10张图片" title="最多可上传9张图片"
:auto-upload="false" :auto-upload="false"
fileMediatype="image" fileMediatype="image"
mode="grid" mode="grid"
ref="filesRef" ref="filesRef"
@delete="handleDelete"
></uni-file-picker> ></uni-file-picker>
<u-radio-group <u-radio-group
@ -58,9 +61,9 @@
v-model="(model1.order as any)[item.key]" v-model="(model1.order as any)[item.key]"
placement="row" placement="row"
> >
<u-radio activeColor="#00DCEE" label="按固定重量" :name="1"></u-radio> <u-radio activeColor="#00DCEE" label="送货" :name="0"></u-radio>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<u-radio activeColor="#00DCEE" label="按百分比" :name="2"></u-radio> <u-radio activeColor="#00DCEE" label="自提" :name="1"></u-radio>
</u-radio-group> </u-radio-group>
<template #right v-if="item.type === 'select'"> <template #right v-if="item.type === 'select'">
<u-icon name="arrow-right"></u-icon> <u-icon name="arrow-right"></u-icon>
@ -92,6 +95,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { import {
CustomerApi,
DeviceApi, DeviceApi,
GoodsApi, GoodsApi,
PictureApi, PictureApi,
@ -106,23 +110,53 @@ import _ from "underscore";
const model1 = reactive<any>({ const model1 = reactive<any>({
order: { order: {
buttonType: 0, deliveryMethod: 0,
fileList: [], fileLists: [],
splTime: "", splTime: "",
subtractType: 1, subtractType: 1,
}, },
}); });
const rules = ref({ const rules = reactive({
"userInfo.userName": { "order.repairTime": {
type: "string", type: "string",
required: true, required: true,
message: "请输入手机号", message: "请选择补单时间",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
"userInfo.password": { "order.deviceName": {
type: "string", type: "string",
required: true, required: true,
message: "请输入密码", message: "请选择过磅设备",
trigger: ["blur", "change"],
},
"order.userName": {
type: "string",
required: true,
message: "请选择客户",
trigger: ["blur", "change"],
},
"order.productName": {
type: "string",
required: true,
message: "请选择出货产品",
trigger: ["blur", "change"],
},
"order.number": {
type: "string",
required: true,
message: "请输入数量",
trigger: ["blur", "change"],
},
"order.grossWeight": {
type: "string",
required: true,
message: "请输入毛重",
trigger: ["blur", "change"],
},
"order.tare": {
type: "string",
required: true,
message: "请输入皮重",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
}); });
@ -178,7 +212,7 @@ const formAttrList = reactive<any>([
unit: "", unit: "",
fn: () => { fn: () => {
contrlModalParams.user.isShow = true; contrlModalParams.user.isShow = true;
contrlModalParams.user.title = "供应商"; contrlModalParams.user.title = "客户";
}, },
}, },
{ {
@ -219,6 +253,7 @@ const formAttrList = reactive<any>([
key: "netWeight", key: "netWeight",
type: "input", type: "input",
required: true, required: true,
disabled: true,
unit: "KG", unit: "KG",
}, },
{ {
@ -280,28 +315,62 @@ const formAttrList = reactive<any>([
type: "upload", type: "upload",
}, },
]); ]);
//
watch(
[
() => model1.order.grossWeight,
() => model1.order.tare,
],
([grossWeightNew, tareNew]) => {
/**
* 过磅净重 毛重-皮重
结算重量 过磅净重-扣杂
预估总价 结算单价*结算重量
实际收入实际结算金额-运费-杂费
*/
model1.order.netWeight = (grossWeightNew || 0) - (tareNew || 0);
}
);
const filesRef = ref(); const filesRef = ref();
const handleUpload = () => { const handleUpload = () => {
// console.log(event.tempFilePaths) // console.log(event.tempFilePaths)
const list = filesRef.value[0].filesList; return filesRef.value[0].filesList.map((item: any, index: number) => {
return list.map((item: any) => { if (item.fileID) {
return;
}
return new Promise((resolve) => { return new Promise((resolve) => {
PictureApi.upload({ PictureApi.upload({
files: item, files: item,
path: item.path, path: item.path,
}).then((res) => { })
.then((res) => {
if (res.code === 200) { if (res.code === 200) {
resolve({ resolve({
...(res.data as any), ...(res.data as any),
businessId: (model1.order as any).id, businessId: model1.order.id,
imagesType: ImagesType.NORMARL, // imagesType: ImagesType.NORMARL, //
orderType: OrderType.Receive, // orderType: OrderType.Shipment, //
}); });
} }
})
.catch((e) => {
return;
}); });
}); });
}); });
}; };
const handleDelete = (e: any) => {
console.log(model1.order.fileLists);
if (e.tempFile.fileID) {
PictureApi.deleteById({ id: e.tempFile.fileID }).then((res) => {
if (res.code === 200) {
uni.showToast({ title: "已删除" });
}
});
}
};
const handleSelect = (key: string, v: any) => { const handleSelect = (key: string, v: any) => {
contrlModalParams[key].isShow = false; contrlModalParams[key].isShow = false;
if (key === "user") { if (key === "user") {
@ -316,11 +385,10 @@ const handleSelect = (key: string, v: any) => {
model1.order.deviceId = v.id; model1.order.deviceId = v.id;
} }
}; };
// //
ProfileApi.getUserList({ userType: 3 }).then((res) => { CustomerApi.getCustomUserList({}).then((res) => {
if (res.code === 200) { if (res.code === 200) {
contrlModalParams.user.list = res.data; contrlModalParams.user.list = res.data;
console.log(contrlModalParams.user.list);
} }
}); });
// //
@ -351,27 +419,50 @@ const upload = () => {
if (res.length > 0) { if (res.length > 0) {
PictureApi.addListAnnex({ annexPos: res }).then((res1) => { PictureApi.addListAnnex({ annexPos: res }).then((res1) => {
if (res1.code === 200) { if (res1.code === 200) {
uni.showToast({ console.log("*** 资源文件更新成功");
title: "图片资源上传成功",
icon: "success",
});
} }
}); });
} }
}); });
}; };
/**
* 校验
*/
const form = ref();
const check = () => {
return new Promise((resolve) => {
form.value
.validate()
.then((res: boolean) => {
resolve(res);
})
.catch((errors: any) => {
debugger
resolve(false);
uni.showToast({
icon: "none",
title: errors[0].message || "校验失败",
});
});
});
};
const save = () => { const save = () => {
if (model1.order.buttonType === 0) { check().then((res) => {
model1.order.buckleMiscellaneous = model1.order.subtractNum; if (res) {
} else if (model1.order.buttonType === 1) { startSave();
model1.order.points = model1.order.subtractNum;
} }
});
};
const startSave = () => {
ShipmentApi.addOrderOut(model1.order).then((res) => { ShipmentApi.addOrderOut(model1.order).then((res) => {
if (res.code === 200) { if (res.code === 200) {
model1.order.id = res.data; model1.order.id = res.data;
upload(); upload();
uni.navigateTo({ uni.redirectTo({
url: "/pages/index/index", // url: "/pagesHome/index", //
}); });
} }
}); });