Merge branch 'modular' of https://get.feep.ir/khaneghi_abshodeh/khaneghi_admin into modular
B
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
:show-upload-list="false"
|
||||
:action="uploadURL"
|
||||
:headers="fileHeader"
|
||||
:before-upload="beforeUpload"
|
||||
:custom-request="customRequest"
|
||||
@change="onChange"
|
||||
>
|
||||
<div class="banner-image-upload__empty">
|
||||
@@ -18,7 +20,7 @@
|
||||
<template v-else>
|
||||
<BaseIcon icon="vuesax-linear:gallery-add" size="40" class="banner-image-upload__icon" />
|
||||
<span class="banner-image-upload__cta">افزودن تصویر بنر</span>
|
||||
<span class="banner-image-upload__hint">کلیک کنید — تصویر افقی با نسبت ۱۶:۹</span>
|
||||
<span class="banner-image-upload__hint">حداکثر ۱ مگابایت — تبدیل خودکار به WebP — نسبت ۱۶:۹</span>
|
||||
</template>
|
||||
</div>
|
||||
</a-upload>
|
||||
@@ -32,6 +34,8 @@
|
||||
:show-upload-list="false"
|
||||
:action="uploadURL"
|
||||
:headers="fileHeader"
|
||||
:before-upload="beforeUpload"
|
||||
:custom-request="customRequest"
|
||||
@change="onChange"
|
||||
>
|
||||
<button type="button" class="banner-image-upload__btn banner-image-upload__btn--primary">
|
||||
@@ -56,6 +60,11 @@ import { message } from 'ant-design-vue'
|
||||
import { uploadURL } from '@root/config'
|
||||
import { getToken } from '@/utils'
|
||||
import { normalizeUploadFileResponse } from '@/utils/file'
|
||||
import {
|
||||
createImageBeforeUpload,
|
||||
createImageCustomRequest
|
||||
} from '@/utils/prepareImageForUpload'
|
||||
import type { UploadProps } from 'ant-design-vue'
|
||||
|
||||
defineProps<{
|
||||
imageUrl?: string | null
|
||||
@@ -72,27 +81,35 @@ const fileHeader = computed(() => ({
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
}))
|
||||
|
||||
function onChange({ file }: { file: { status?: string; response?: unknown } }) {
|
||||
if (file.status === 'uploading') {
|
||||
const beforeUpload: UploadProps['beforeUpload'] = createImageBeforeUpload((msg) =>
|
||||
message.error(msg)
|
||||
)
|
||||
|
||||
const customRequest: UploadProps['customRequest'] = createImageCustomRequest({
|
||||
action: () => uploadURL,
|
||||
getHeaders: () => fileHeader.value,
|
||||
messageError: (msg) => message.error(msg),
|
||||
onStarted: () => {
|
||||
loading.value = true
|
||||
return
|
||||
}
|
||||
|
||||
if (file.status === 'error') {
|
||||
},
|
||||
onUploaded: (body) => {
|
||||
loading.value = false
|
||||
message.error('خطا در آپلود تصویر')
|
||||
return
|
||||
}
|
||||
|
||||
if (file.status === 'done') {
|
||||
loading.value = false
|
||||
const fileResource = normalizeUploadFileResponse(file.response)
|
||||
const fileResource = normalizeUploadFileResponse(body)
|
||||
if (!fileResource?.full_src) {
|
||||
message.error('خطا در ساخت آدرس تصویر')
|
||||
return
|
||||
}
|
||||
emit('upload', fileResource.full_src)
|
||||
message.success('تصویر با موفقیت آپلود شد')
|
||||
},
|
||||
onFailed: () => {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
function onChange({ file }: { file: { status?: string } }) {
|
||||
if (file.status === 'uploading') {
|
||||
loading.value = true
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -733,8 +733,12 @@ const weightFieldLabel = computed(() => {
|
||||
return weightFieldLabelForUnit(tradeWeightUnit.value)
|
||||
})
|
||||
|
||||
// واحد حداقل تحویل فیزیکی: محصول وزنی → گرم/کیلوگرم، محصول تعدادی → عدد
|
||||
// واحد حداقل تحویل فیزیکی: تعدادی → عدد، مقداری/وزنی → گرم/کیلوگرم
|
||||
const physicalDeliveryUnit = computed(() => {
|
||||
if (!isQuantityTrade.value && !isMeltedGroup.value) {
|
||||
return 'عدد'
|
||||
}
|
||||
|
||||
const productUnit = props.form.unit?.trim()
|
||||
if (productUnit === 'کیلوگرم' || productUnit === 'گرم') {
|
||||
return productUnit
|
||||
|
||||
Reference in New Issue
Block a user