feat: 商品编辑

This commit is contained in:
2026-04-28 11:43:12 +08:00
parent 5cfccabcd7
commit 1e4134f8b9
5 changed files with 78 additions and 55 deletions

View File

@@ -1737,7 +1737,7 @@ export default {
GetStarted: '开始体验',
},
SellerListEdit:{
saveDraft: "保存草稿",
saveDraft: "全部保存",
publish: "发布",
sketch: "线稿图",
mainProductImage: "产品主图",

View File

@@ -1788,7 +1788,7 @@ export default {
GetStarted: 'Get Started',
},
SellerListEdit:{
saveDraft:'Save Draft',
saveDraft:'Save All New',
publish:'Publish',
sketch:'Sketch',
mainProductImage:'Main Product Image',

View File

@@ -204,23 +204,23 @@
.cropper-box-canvas {
background-color: #ffffff;
img {
height: 100%;
}
// img {
// height: 100%;
// }
}
}
&.is-cover {
:deep(.vue-cropper) {
overflow: hidden;
}
:deep(.cropper-box-canvas) {
width: 31.1rem !important;
left: 50% !important;
transform: translateX(-50%) !important;
img {
display: none;
}
}
// :deep(.cropper-box-canvas) {
// width: 31.1rem !important;
// left: 50% !important;
// transform: translateX(-50%) !important;
// img {
// display: none;
// }
// }
}
}

View File

@@ -8,7 +8,7 @@
'radio-button',
{
'is-active': multiple
? selectedValues.includes(item.key)
? selectedValues.includes(normalizeValue(item.key))
: modelValue === item.key
}
]"
@@ -20,54 +20,73 @@
</template>
<script setup lang="ts">
import { computed } from "vue"
import { computed } from "vue"
interface Option {
name: string | number
value: string | number | boolean
key: string
optype: boolean
interface Option {
name: string | number
value: string | number | boolean
key: string
optype: boolean
}
const props = defineProps<{
modelValue:
| string
| number
| boolean
| Array<string | number | boolean | null | undefined>
| null
options: Option[] // 按钮选项数组
multiple?: boolean // 是否支持多选,默认为 false
}>()
const emit = defineEmits<{
(e: "update:modelValue", value: any): void
}>()
const multiple = props.multiple === true
const normalizeValue = (value: any) =>
typeof value === "string" ? value.toLocaleLowerCase() : value
const selectedValues = computed(() => {
if (!multiple) {
return typeof props.modelValue === "undefined" || props.modelValue === null
? []
: [props.modelValue]
}
const props = defineProps<{
modelValue: string | number | boolean | Array<string | number | boolean> | null
options: Option[] // 按钮选项数组
multiple?: boolean // 是否支持多选,默认为 false
}>()
return Array.isArray(props.modelValue)
? props.modelValue
.filter((value) => value !== null && typeof value !== "undefined")
.map(normalizeValue)
: []
})
const emit = defineEmits<{
(e: "update:modelValue", value: any): void
}>()
const selectOption = (value: any) => {
if (multiple) {
const selectedValue = normalizeValue(value)
const current = Array.isArray(props.modelValue)
? props.modelValue
.filter((item) => item !== null && typeof item !== "undefined")
.map(normalizeValue)
: []
const index = current.indexOf(selectedValue)
const multiple = props.multiple === true
const selectedValues = computed(() => {
if (!multiple) {
return typeof props.modelValue === "undefined" || props.modelValue === null
? []
: [props.modelValue]
if (index >= 0) {
current.splice(index, 1)
} else {
current.push(selectedValue)
}
return Array.isArray(props.modelValue) ? props.modelValue : []
})
const selectOption = (value: any) => {
if (multiple) {
const current = Array.isArray(props.modelValue) ? [...props.modelValue] : []
const index = current.indexOf(value)
if (index >= 0) {
current.splice(index, 1)
} else {
current.push(value.toLocaleLowerCase)
}
emit("update:modelValue", current)
return
}
if (props.modelValue !== value) {
emit("update:modelValue", value)
}
emit("update:modelValue", current.length ? current : null)
return
}
if (props.modelValue !== value) {
emit("update:modelValue", value)
}
}
</script>
<style lang="less" scoped>

View File

@@ -280,7 +280,7 @@
price: string
desc: string
gender: string
category: string[]
category: string[] | null
prodImageList: Array<{
url: string
selected?: boolean
@@ -491,6 +491,10 @@
fetchUpdateListing(paramsList)
}
const handleClickMenu = async (status: StatusType) => {
if (status === "draft" && !selectList.value[currentIndex.value].cover) {
message.error("请先完成封面制作")
return
}
if (status === "publish" && !validatePublishRequired()) return
await handleSaveForm(status)