diff --git a/src/components/PackagePhotoField.vue b/src/components/PackagePhotoField.vue
deleted file mode 100644
index d0b37f5..0000000
--- a/src/components/PackagePhotoField.vue
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/PhotoScroller.vue b/src/components/PhotoScroller.vue
index b453ecc..0737c8f 100644
--- a/src/components/PhotoScroller.vue
+++ b/src/components/PhotoScroller.vue
@@ -44,8 +44,8 @@
theme="primary"
variant="dashed"
class="add"
- :loading="loading"
- :disabled="loading"
+ :loading="isBusy"
+ :disabled="isBusy"
@click="handleAddAction(addActionList[0])"
>
@@ -60,8 +60,8 @@
class="add"
theme="primary"
variant="dashed"
- :loading="loading"
- :disabled="loading"
+ :loading="isBusy"
+ :disabled="isBusy"
>
@@ -73,7 +73,7 @@
variant="text"
:theme="action.theme"
class="add-action"
- :disabled="loading"
+ :disabled="isBusy"
@click="handleAddAction(action)"
>
@@ -86,6 +86,15 @@
+
Promise;
showViewerActions?: boolean;
showAdd?: boolean;
showRemove?: boolean;
@@ -217,12 +227,15 @@ const photoViewerItems = ref([]);
const photoViewerIndex = ref(0);
const photoActionVisible = ref(false);
const isSubmitting = ref(false);
+const isUploading = ref(false);
const addPopoverVisible = ref(false);
+const fileInput = ref();
const addActionList = computed(() => props.addActions.length ? props.addActions : [{
emit: "add",
text: props.addText,
theme: "default"
}]);
+const isBusy = computed(() => props.loading || isSubmitting.value || isUploading.value);
const displayPhotoList = computed(() => {
if (props.photoItems?.length) {
return props.photoItems.map(normalizePhotoItem);
@@ -250,9 +263,37 @@ function handleAddAction(action?: AddAction): void {
return;
}
addPopoverVisible.value = false;
+ if (action.emit === "add" && props.upload) {
+ fileInput.value?.click();
+ return;
+ }
emit(action.emit);
}
+async function handleFileChange(event: Event): Promise {
+ const input = event.target as HTMLInputElement;
+ const fileList = Array.from(input.files || []);
+ if (!fileList.length || !props.upload) {
+ return;
+ }
+
+ isUploading.value = true;
+ try {
+ const uploadedPhotoItems = await props.upload(fileList);
+ if (!uploadedPhotoItems.length) {
+ return;
+ }
+ const nextPhotoItems = [...displayPhotoList.value, ...uploadedPhotoItems];
+ emit("update:photoItems", nextPhotoItems);
+ emit("update:modelValue", nextPhotoItems.map(item => item.url));
+ } catch {
+ Message.error("照片上传失败");
+ } finally {
+ isUploading.value = false;
+ input.value = "";
+ }
+}
+
async function removePhoto(index: number): Promise {
if (index < 0 || displayPhotoList.value.length <= index) {
return;
@@ -341,6 +382,10 @@ function normalizePhotoItem(item: PhotoItem): PhotoItem {
width: 100%;
display: grid;
+ .file-input {
+ display: none;
+ }
+
.photo-shell {
display: grid;
gap: .75rem;
diff --git a/src/pages/fulfillment/OrderFulfillmentCreate.vue b/src/pages/fulfillment/OrderFulfillmentCreate.vue
index 3c19dc8..9d1bc40 100644
--- a/src/pages/fulfillment/OrderFulfillmentCreate.vue
+++ b/src/pages/fulfillment/OrderFulfillmentCreate.vue
@@ -17,7 +17,15 @@
-
+
@@ -45,7 +53,7 @@
import PackageAPI from "@/api/PackageAPI";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import FulfillmentAPI from "@/api/FulfillmentAPI";
-import PackagePhotoField from "@/components/PackagePhotoField.vue";
+import PhotoScroller from "@/components/PhotoScroller.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { CustomerPackageItem, GaoCustomerPackage } from "@/types/Package";
import type { OrderFulfillmentItemRequest } from "@/types/Fulfillment";
@@ -56,6 +64,7 @@ import { createPackageRequestNo, formatPackageAmount, getPackageQuantityText, no
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
+import { uploadPhotoList } from "@/utils/photo";
type SourceItem = SalesOrderItem | CustomerPackageItem;
defineOptions({ name: "OrderFulfillmentCreate" });
@@ -72,6 +81,7 @@ const remark = ref("");
const requestNo = ref("");
const isSaving = ref(false);
const photoItems = ref([]);
+const photoUrlList = computed(() => photoItems.value.map(item => item.url));
const orderPickerVisible = ref(false);
const orderLoading = ref(false);
const orderOptions = ref([]);
diff --git a/src/pages/fulfillment/OrderFulfillmentDetail.vue b/src/pages/fulfillment/OrderFulfillmentDetail.vue
index 4d94f0d..49fa56e 100644
--- a/src/pages/fulfillment/OrderFulfillmentDetail.vue
+++ b/src/pages/fulfillment/OrderFulfillmentDetail.vue
@@ -52,7 +52,14 @@
-
+
@@ -62,7 +69,7 @@ import { BottomPopup } from "timi-tdesign-mobile";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import FulfillmentAPI from "@/api/FulfillmentAPI";
-import PackagePhotoField from "@/components/PackagePhotoField.vue";
+import PhotoScroller from "@/components/PhotoScroller.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { OrderFulfillment } from "@/types/Fulfillment";
import type { PhotoItem } from "@/types/Photo";
@@ -72,6 +79,7 @@ import { getErrorMessage } from "@/utils/error";
import { getFulfillmentStatusText, getFulfillmentTypeText, getStatusTheme } from "@/utils/salesOrder";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
+import { uploadPhotoList } from "@/utils/photo";
type ReasonAction = "reject" | "cancel";
defineOptions({ name: "OrderFulfillmentDetail" });
@@ -90,6 +98,7 @@ const revokeReason = ref("");
const returnedToStore = ref(true);
const revokeRequestNo = ref("");
const photoItems = ref([]);
+const photoUrlList = computed(() => photoItems.value.map(item => item.url));
const isWaitingStock = computed(() => fulfillment.value?.status === "WAITING_STOCK");
const isPending = computed(() => fulfillment.value?.status === "PENDING");
const isVerified = computed(() => fulfillment.value?.status === "VERIFIED");
diff --git a/src/pages/package/FundRecordRevoke.vue b/src/pages/package/FundRecordRevoke.vue
index 58410cb..8b7c586 100644
--- a/src/pages/package/FundRecordRevoke.vue
+++ b/src/pages/package/FundRecordRevoke.vue
@@ -11,7 +11,16 @@
-
+
@@ -22,7 +31,7 @@
diff --git a/src/pages/salesOrder/SalesOrderRefund.vue b/src/pages/salesOrder/SalesOrderRefund.vue
index 4fd1fac..6e9317a 100644
--- a/src/pages/salesOrder/SalesOrderRefund.vue
+++ b/src/pages/salesOrder/SalesOrderRefund.vue
@@ -10,7 +10,16 @@
-
+
@@ -20,7 +29,7 @@