feat(recycle): add customer recycle amount for create order
This commit is contained in:
@@ -54,6 +54,14 @@
|
|||||||
<t-tag :content="recycleUnitName || '单位'" />
|
<t-tag :content="recycleUnitName || '单位'" />
|
||||||
</div>
|
</div>
|
||||||
</t-form-item>
|
</t-form-item>
|
||||||
|
<t-form-item
|
||||||
|
v-if="customerId && recycleItemId"
|
||||||
|
label="客户回收物数量"
|
||||||
|
label-width="9rem"
|
||||||
|
content-align="right"
|
||||||
|
>
|
||||||
|
<span :class="customerRecycleClass" v-text="customerRecycleText" />
|
||||||
|
</t-form-item>
|
||||||
<t-form-item v-if="selectedRule" label="兑换份数" required-mark content-align="right">
|
<t-form-item v-if="selectedRule" label="兑换份数" required-mark content-align="right">
|
||||||
<t-stepper v-model="multiple" size="large" :min="1" :max="9999" :step="1" integer theme="outline" />
|
<t-stepper v-model="multiple" size="large" :min="1" :max="9999" :step="1" integer theme="outline" />
|
||||||
</t-form-item>
|
</t-form-item>
|
||||||
@@ -230,8 +238,13 @@ import { Message } from "@/utils/message";
|
|||||||
import { comparePackageQuantity, normalizePackageQuantity, toPackageBaseQuantity } from "@/utils/package";
|
import { comparePackageQuantity, normalizePackageQuantity, toPackageBaseQuantity } from "@/utils/package";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getProductPhotoURL, getProductQuantityStep, getProductSkuSnapshotText } from "@/utils/product";
|
import { getProductPhotoURL, getProductQuantityStep, getProductSkuSnapshotText } from "@/utils/product";
|
||||||
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements, type ProductStockPreviewItem } from "@/utils/productStock";
|
import {
|
||||||
import { getRecycleQuantityText, multiplyRecycleQuantity } from "@/utils/recycle";
|
buildProductStockPreview,
|
||||||
|
getProductStockShortageMessage,
|
||||||
|
mergeProductStockRequirements,
|
||||||
|
type ProductStockPreviewItem
|
||||||
|
} from "@/utils/productStock";
|
||||||
|
import { getRecycleAvailable, getRecycleQuantityText, multiplyRecycleQuantity } from "@/utils/recycle";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
import { uploadPhotoList } from "@/utils/photo";
|
||||||
|
|
||||||
defineOptions({ name: "RecycleExchangeCreate" });
|
defineOptions({ name: "RecycleExchangeCreate" });
|
||||||
@@ -373,6 +386,36 @@ const recycleItemList = ref<RecycleItem[]>([]);
|
|||||||
const recycleItemId = ref("");
|
const recycleItemId = ref("");
|
||||||
const selectedRecycleItem = ref<RecycleItem>();
|
const selectedRecycleItem = ref<RecycleItem>();
|
||||||
const recycleQuantityText = ref("");
|
const recycleQuantityText = ref("");
|
||||||
|
const customerRecycleText = ref("正在加载");
|
||||||
|
const customerRecycleAvailable = ref<string>();
|
||||||
|
const customerRecycleClass = computed(() => {
|
||||||
|
const required = normalizePackageQuantity(recycleQuantityText.value || "0");
|
||||||
|
if (customerRecycleAvailable.value === undefined || required === undefined) return "";
|
||||||
|
return comparePackageQuantity(customerRecycleAvailable.value, required) < 0 ? "insufficient" : "sufficient";
|
||||||
|
});
|
||||||
|
|
||||||
|
watch([customerId, recycleItemId], async ([customer, item], _previous, onCleanup) => {
|
||||||
|
let active = true;
|
||||||
|
onCleanup(() => { active = false; });
|
||||||
|
customerRecycleAvailable.value = undefined;
|
||||||
|
if (!customer || !item) return;
|
||||||
|
if (!userStore.hasPermissions(permissionCodes.recycleAccount.read)) {
|
||||||
|
customerRecycleText.value = "无权限查看";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
customerRecycleText.value = "正在加载";
|
||||||
|
try {
|
||||||
|
const accounts = await RecycleAPI.accountList(customer);
|
||||||
|
if (!active) return;
|
||||||
|
const account = accounts.find(value => value.recycleItemId === item);
|
||||||
|
customerRecycleAvailable.value = getRecycleAvailable(account).toFixed(3);
|
||||||
|
customerRecycleText.value = `可用 ${getRecycleQuantityText(customerRecycleAvailable.value, recycleUnitName.value)}`;
|
||||||
|
} catch (error) {
|
||||||
|
if (!active) return;
|
||||||
|
customerRecycleText.value = "加载失败";
|
||||||
|
Message.error(getErrorMessage(error, "客户回收物数量加载失败"));
|
||||||
|
}
|
||||||
|
}, { immediate: true });
|
||||||
|
|
||||||
async function loadRecycleItems(): Promise<void> {
|
async function loadRecycleItems(): Promise<void> {
|
||||||
itemLoading.value = true;
|
itemLoading.value = true;
|
||||||
@@ -782,6 +825,13 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.recycle-exchange-create {
|
.recycle-exchange-create {
|
||||||
|
.sufficient {
|
||||||
|
color: var(--td-success-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.insufficient {
|
||||||
|
color: var(--td-warning-color);
|
||||||
|
}
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<bottom-popup
|
<bottom-popup
|
||||||
v-model="visible"
|
v-model="visible"
|
||||||
:title="props.title"
|
:title="props.title"
|
||||||
height="60vh"
|
height="70vh"
|
||||||
right-button-text=""
|
right-button-text=""
|
||||||
:z-index="12100"
|
:z-index="12100"
|
||||||
:overlay-props="{ zIndex: 12099 }"
|
:overlay-props="{ zIndex: 12099 }"
|
||||||
|
|||||||
Reference in New Issue
Block a user