|
|
@@ -115,7 +115,7 @@ const { router, getQueryStringToNumber } = useNavigation()
|
|
|
const wrstandardid = getQueryStringToNumber('wrstandardid')
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
|
|
|
-const { loading, details, chartData, getWrstandardDetails } = useWrstandardDetails(wrstandardid)
|
|
|
+const { loading, details, customDeposits, chartData, getWrstandardDetails } = useWrstandardDetails(wrstandardid)
|
|
|
const { formData, formSubmit } = usePurchaseOrderDesting()
|
|
|
|
|
|
// 当前选中的交割日期
|
|
|
@@ -129,28 +129,37 @@ const goodsImages = computed(() => {
|
|
|
return pictureurls.split(',').map((path) => getImageUrl(path))
|
|
|
})
|
|
|
|
|
|
-// 预售申请列表
|
|
|
+// 定金比例列表,商品定金比例和个性化定金比例进行合并
|
|
|
const presaleApplyDeposits = computed(() => {
|
|
|
const deposits = details.value.presaleapplydeposits ?? []
|
|
|
- const presaleApplyId = selectedDate.value?.presaleapplyid
|
|
|
+ const { presaleapplyid, remainqty = 0 } = selectedDate.value ?? {}
|
|
|
|
|
|
- return deposits.filter((e) => e.presaleapplyid === presaleApplyId).map(({ depositid, depositrate }) => ({
|
|
|
- label: parsePercent(depositrate),
|
|
|
- value: depositid
|
|
|
+ const result = deposits.filter((e) => e.presaleapplyid === presaleapplyid).map((e) => ({
|
|
|
+ id: e.depositid,
|
|
|
+ label: parsePercent(e.depositrate),
|
|
|
+ value: e.depositrate,
|
|
|
+ qty: remainqty,
|
|
|
+ type: 1, // 定金类型
|
|
|
}))
|
|
|
+
|
|
|
+ customDeposits.value.forEach((e) => {
|
|
|
+ result.push({
|
|
|
+ id: '0',
|
|
|
+ label: parsePercent(e.depositrate),
|
|
|
+ value: e.depositrate,
|
|
|
+ qty: e.qty,
|
|
|
+ type: 2, // 定金类型
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ return result.sort((a, b) => b.value - a.value)
|
|
|
})
|
|
|
|
|
|
// 计算定金
|
|
|
const deposit = computed(() => {
|
|
|
- const { Qty = 0, DepositID } = formData.value
|
|
|
- const { presaleapplydeposits } = details.value
|
|
|
+ const { Qty = 0, DepositRate = 0 } = formData.value
|
|
|
const { unitprice = 0 } = selectedDate.value ?? {}
|
|
|
- const apply = presaleapplydeposits?.find((e) => e.depositid === DepositID?.toString()) // 选中的支付方式
|
|
|
-
|
|
|
- if (apply) {
|
|
|
- return (unitprice * apply.depositrate * Qty).toFixed(2)
|
|
|
- }
|
|
|
- return '0.00'
|
|
|
+ return (unitprice * DepositRate * Qty).toFixed(2)
|
|
|
})
|
|
|
|
|
|
// 是否显示收货信息
|
|
|
@@ -199,12 +208,15 @@ const formRules: { [key in keyof Proto.SpotPresaleDestingOrderReq | 'addressInfo
|
|
|
message: '请输入采购数量',
|
|
|
validator: (val) => {
|
|
|
if (val) {
|
|
|
- const qty = Number(val)
|
|
|
- const { remainqty = 0 } = selectedDate.value ?? {}
|
|
|
- if (qty > 0 && qty <= remainqty) {
|
|
|
- return true
|
|
|
+ const deposit = presaleApplyDeposits.value.find((e) => e.value === formData.value.DepositRate)
|
|
|
+ if (deposit) {
|
|
|
+ const qty = Number(val)
|
|
|
+ if (qty > 0 && qty <= deposit.qty) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return '采购数量不能大于 ' + deposit.qty
|
|
|
}
|
|
|
- return '采购数量不正确'
|
|
|
+ return true
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
@@ -227,9 +239,15 @@ const onMonthChange = (value: string) => {
|
|
|
}
|
|
|
|
|
|
// 切换支付方式
|
|
|
-const onDepositChange = (value: string) => {
|
|
|
- formData.value.DepositID = Long.fromString(value)
|
|
|
+const onDepositChange = (value: number, index: number) => {
|
|
|
+ const item = presaleApplyDeposits.value[index]
|
|
|
+ formData.value.DepositID = Long.fromString(item.id)
|
|
|
+ formData.value.DepositType = item.type
|
|
|
+ formData.value.DepositRate = item.value
|
|
|
formRef.value?.validate('DepositID')
|
|
|
+ if (formData.value.Qty) {
|
|
|
+ formRef.value?.validate('Qty')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 更新表单数据
|