fix layout
This commit is contained in:
+207
-203
@@ -1,216 +1,220 @@
|
||||
<template>
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
:title="routeNavBarTitle"
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
>
|
||||
<template #right>
|
||||
<t-button
|
||||
v-if="userStore.hasPermissions(savePermissionCode)"
|
||||
@click="save"
|
||||
theme="primary"
|
||||
variant="text"
|
||||
size="small"
|
||||
content="保存"
|
||||
/>
|
||||
</template>
|
||||
</t-navbar>
|
||||
<div v-can="savePermissionCode" class="product-edit">
|
||||
<t-form class="form card" label-width="6rem" v-entrance-transition>
|
||||
<t-form-item label="产品编码" required-mark help="使用英语、拼音或唯一数字">
|
||||
<t-input v-model="form.code" borderless maxlength="64" placeholder="门店内唯一编码" />
|
||||
</t-form-item>
|
||||
<t-form-item label="产品名称" required-mark>
|
||||
<t-input v-model="form.name" borderless maxlength="128" placeholder="请输入产品名称" />
|
||||
</t-form-item>
|
||||
<t-form-item label="产品类型" arrow content-align="right" @click="openTypePicker">
|
||||
<span class="picker-text" v-text="getProductTypeText(form.productType)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="产品分类" arrow content-align="right" @click="openCategoryPicker">
|
||||
<span class="picker-text" v-text="selectedCategoryName" />
|
||||
</t-form-item>
|
||||
<t-form-item label="库存管理" content-align="right">
|
||||
<t-switch v-model="form.stockEnabled" size="small" :disabled="form.productType === 'SERVICE'" />
|
||||
</t-form-item>
|
||||
<t-form-item label="状态" arrow content-align="right" @click="openStatusPicker">
|
||||
<span class="picker-text" v-text="getProductStatusText(form.status)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="备注">
|
||||
<t-textarea v-model="form.remark" borderless maxlength="255" autosize placeholder="可填写产品说明" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<attachment-selector
|
||||
v-model:items="attachmentItemList"
|
||||
title="产品公共图片及附件"
|
||||
:busy="isAttachmentUploading"
|
||||
@select="handleAttachmentSelected($event.files, $event.source)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="纯色封面" label-width="8rem" content-align="right">
|
||||
<div class="page-layout navbar">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
:title="routeNavBarTitle"
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
>
|
||||
<template #right>
|
||||
<t-button
|
||||
size="extra-small"
|
||||
variant="outline"
|
||||
class="color-trigger"
|
||||
:disabled="isAttachmentUploading"
|
||||
@click="openCoverColorPicker"
|
||||
>
|
||||
<div class="content">
|
||||
<span
|
||||
class="swatch"
|
||||
:class="{ 'no-color': !solidColorCoverColor }"
|
||||
:style="{ background: solidColorCoverColor || undefined }"
|
||||
/>
|
||||
<span v-text="solidColorCoverColor || '选择颜色'" />
|
||||
</div>
|
||||
</t-button>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
|
||||
<card-container title="产品规格" description="无多规格产品无需配置规格;有规格时每条 SKU 明细必须覆盖全部规格项" v-entrance-transition>
|
||||
<div class="spec-list">
|
||||
<t-form v-for="(spec, specIndex) in form.specList" :key="spec.clientKey" class="form spec">
|
||||
<t-form-item label="名称" label-width="2.5rem">
|
||||
<t-input
|
||||
class="name"
|
||||
v-model="spec.name"
|
||||
borderless
|
||||
maxlength="32"
|
||||
placeholder="如 颜色、尺寸"
|
||||
v-if="userStore.hasPermissions(savePermissionCode)"
|
||||
@click="save"
|
||||
theme="primary"
|
||||
variant="text"
|
||||
size="small"
|
||||
content="保存"
|
||||
/>
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main class="page-content scroll column">
|
||||
<div v-can="savePermissionCode" class="product-edit">
|
||||
<t-form class="form card" label-width="6rem" v-entrance-transition>
|
||||
<t-form-item label="产品编码" required-mark help="使用英语、拼音或唯一数字">
|
||||
<t-input v-model="form.code" borderless maxlength="64" placeholder="门店内唯一编码" />
|
||||
</t-form-item>
|
||||
<t-form-item label="产品名称" required-mark>
|
||||
<t-input v-model="form.name" borderless maxlength="128" placeholder="请输入产品名称" />
|
||||
</t-form-item>
|
||||
<t-form-item label="产品类型" arrow content-align="right" @click="openTypePicker">
|
||||
<span class="picker-text" v-text="getProductTypeText(form.productType)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="产品分类" arrow content-align="right" @click="openCategoryPicker">
|
||||
<span class="picker-text" v-text="selectedCategoryName" />
|
||||
</t-form-item>
|
||||
<t-form-item label="库存管理" content-align="right">
|
||||
<t-switch v-model="form.stockEnabled" size="small" :disabled="form.productType === 'SERVICE'" />
|
||||
</t-form-item>
|
||||
<t-form-item label="状态" arrow content-align="right" @click="openStatusPicker">
|
||||
<span class="picker-text" v-text="getProductStatusText(form.status)" />
|
||||
</t-form-item>
|
||||
<t-form-item label="备注">
|
||||
<t-textarea v-model="form.remark" borderless maxlength="255" autosize placeholder="可填写产品说明" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<attachment-selector
|
||||
v-model:items="attachmentItemList"
|
||||
title="产品公共图片及附件"
|
||||
:busy="isAttachmentUploading"
|
||||
@select="handleAttachmentSelected($event.files, $event.source)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="纯色封面" label-width="8rem" content-align="right">
|
||||
<t-button
|
||||
v-if="!spec.id"
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
content="删除"
|
||||
@click="removeSpec(specIndex)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="getNamedSpecValues(spec).length" label-width="0">
|
||||
<div class="tags">
|
||||
<t-tag
|
||||
v-for="value in getNamedSpecValues(spec)"
|
||||
:key="value.clientKey"
|
||||
class="tag"
|
||||
variant="light-outline"
|
||||
closable
|
||||
@close="removeSpecValue(spec, spec.valueList.indexOf(value))"
|
||||
>
|
||||
<t-input v-model.trim="value.name" class="value-name" borderless maxlength="32" />
|
||||
</t-tag>
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="规格值" label-width="3.5rem">
|
||||
<t-input
|
||||
v-model.trim="specValueDraftMap[spec.clientKey]"
|
||||
borderless
|
||||
maxlength="32"
|
||||
placeholder="输入规格值"
|
||||
variant="outline"
|
||||
class="color-trigger"
|
||||
:disabled="isAttachmentUploading"
|
||||
@click="openCoverColorPicker"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
<t-button
|
||||
size="extra-small"
|
||||
theme="light"
|
||||
content="添加"
|
||||
@click="addSpecValue(spec)"
|
||||
<div class="content">
|
||||
<span
|
||||
class="swatch"
|
||||
:class="{ 'no-color': !solidColorCoverColor }"
|
||||
:style="{ background: solidColorCoverColor || undefined }"
|
||||
/>
|
||||
</template>
|
||||
</t-input>
|
||||
<span v-text="solidColorCoverColor || '选择颜色'" />
|
||||
</div>
|
||||
</t-button>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<t-button
|
||||
class="add"
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="dashed"
|
||||
content="添加规格项"
|
||||
@click="addSpec"
|
||||
|
||||
<card-container title="产品规格" description="无多规格产品无需配置规格;有规格时每条 SKU 明细必须覆盖全部规格项" v-entrance-transition>
|
||||
<div class="spec-list">
|
||||
<t-form v-for="(spec, specIndex) in form.specList" :key="spec.clientKey" class="form spec">
|
||||
<t-form-item label="名称" label-width="2.5rem">
|
||||
<t-input
|
||||
class="name"
|
||||
v-model="spec.name"
|
||||
borderless
|
||||
maxlength="32"
|
||||
placeholder="如 颜色、尺寸"
|
||||
/>
|
||||
<t-button
|
||||
v-if="!spec.id"
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
content="删除"
|
||||
@click="removeSpec(specIndex)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="getNamedSpecValues(spec).length" label-width="0">
|
||||
<div class="tags">
|
||||
<t-tag
|
||||
v-for="value in getNamedSpecValues(spec)"
|
||||
:key="value.clientKey"
|
||||
class="tag"
|
||||
variant="light-outline"
|
||||
closable
|
||||
@close="removeSpecValue(spec, spec.valueList.indexOf(value))"
|
||||
>
|
||||
<t-input v-model.trim="value.name" class="value-name" borderless maxlength="32" />
|
||||
</t-tag>
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="规格值" label-width="3.5rem">
|
||||
<t-input
|
||||
v-model.trim="specValueDraftMap[spec.clientKey]"
|
||||
borderless
|
||||
maxlength="32"
|
||||
placeholder="输入规格值"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
<t-button
|
||||
size="extra-small"
|
||||
theme="light"
|
||||
content="添加"
|
||||
@click="addSpecValue(spec)"
|
||||
/>
|
||||
</template>
|
||||
</t-input>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<t-button
|
||||
class="add"
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="dashed"
|
||||
content="添加规格项"
|
||||
@click="addSpec"
|
||||
/>
|
||||
</div>
|
||||
</card-container>
|
||||
<card-container
|
||||
class="sku-wrap"
|
||||
title="SKU 明细"
|
||||
description="每条 SKU 明细都是独立的销售、库存和履约单元;生成后可移除不需要的组合,点列表项配置具体内容"
|
||||
v-entrance-transition
|
||||
>
|
||||
<div class="content-wrap">
|
||||
<t-cell-group theme="card">
|
||||
<t-cell title="销售单位">
|
||||
<template #note>
|
||||
<t-button
|
||||
variant="outline"
|
||||
size="extra-small"
|
||||
content="统一配置销售单位"
|
||||
:disabled="!form.skuList.length"
|
||||
@click="openBatchUnitEditor"
|
||||
/>
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="生成 SKU">
|
||||
<template #note>
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="extra-small"
|
||||
:content="generateSkuButtonText"
|
||||
:disabled="!canGenerateSku"
|
||||
@click="regenerateSkuList"
|
||||
/>
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="当前 SKU" :note="`${form.skuList.length} 个`" />
|
||||
</t-cell-group>
|
||||
<t-cell-group v-if="form.skuList.length" theme="card" class="sku-list fix-last-cell-line">
|
||||
<product-sku-editor
|
||||
v-for="(sku, skuIndex) in form.skuList"
|
||||
:key="sku.clientKey"
|
||||
:product-type="form.productType"
|
||||
v-model:sku="form.skuList[skuIndex]"
|
||||
:sku-index="skuIndex"
|
||||
:spec-list="form.specList"
|
||||
@configure-units="openUnitEditor(sku)"
|
||||
@remove="removeSku(skuIndex)"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<div v-else class="load-state" v-text="form.specList.length ? '请先添加规格值,再生成 SKU 组合' : '正在准备默认 SKU'" />
|
||||
</div>
|
||||
</card-container>
|
||||
<t-popup v-model="typePickerVisible" placement="bottom">
|
||||
<t-picker v-model="typeDraft" :columns="productTypeOptions" title="产品类型" @cancel="typePickerVisible = false" @confirm="confirmType" />
|
||||
</t-popup>
|
||||
<t-popup v-model="categoryPickerVisible" placement="bottom">
|
||||
<t-picker v-model="categoryDraft" :columns="categoryOptions" title="产品分类" @cancel="categoryPickerVisible = false" @confirm="confirmCategory" />
|
||||
</t-popup>
|
||||
<t-popup v-model="statusPickerVisible" placement="bottom">
|
||||
<t-picker v-model="statusDraft" :columns="statusOptions" title="产品状态" @cancel="statusPickerVisible = false" @confirm="confirmStatus" />
|
||||
</t-popup>
|
||||
<product-sku-unit-editor
|
||||
v-model="unitEditorVisible"
|
||||
:product-type="form.productType"
|
||||
v-model:sku="editingSku"
|
||||
:spec-list="form.specList"
|
||||
@close="closeUnitEditor"
|
||||
/>
|
||||
<product-sku-unit-batch-editor
|
||||
v-model="batchUnitEditorVisible"
|
||||
v-model:unit-list="batchUnitList"
|
||||
v-model:base-unit-migration-ratio-text="batchBaseUnitMigrationRatioText"
|
||||
:product-type="form.productType"
|
||||
:sku-count="form.skuList.length"
|
||||
@apply="applyBatchUnitTemplate"
|
||||
@close="closeBatchUnitEditor"
|
||||
/>
|
||||
<bottom-popup
|
||||
v-model="coverColorPickerVisible"
|
||||
title="颜色选择"
|
||||
:right-button-text="isAttachmentUploading ? '上传中' : '确定'"
|
||||
@left-button-click="cancelCoverColorPicker"
|
||||
@right-button-click="confirmCoverColorPicker"
|
||||
>
|
||||
<t-color-picker v-if="coverColorPickerVisible" v-model="coverColorDraft" format="HEX" type="multiple" :swatch-colors="colorSwatchList" @palette-bar-change="updateCoverColorDraftFromPalette" />
|
||||
</bottom-popup>
|
||||
</div>
|
||||
</card-container>
|
||||
<card-container
|
||||
class="sku-wrap"
|
||||
title="SKU 明细"
|
||||
description="每条 SKU 明细都是独立的销售、库存和履约单元;生成后可移除不需要的组合,点列表项配置具体内容"
|
||||
v-entrance-transition
|
||||
>
|
||||
<div class="content-wrap">
|
||||
<t-cell-group theme="card">
|
||||
<t-cell title="销售单位">
|
||||
<template #note>
|
||||
<t-button
|
||||
variant="outline"
|
||||
size="extra-small"
|
||||
content="统一配置销售单位"
|
||||
:disabled="!form.skuList.length"
|
||||
@click="openBatchUnitEditor"
|
||||
/>
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="生成 SKU">
|
||||
<template #note>
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="extra-small"
|
||||
:content="generateSkuButtonText"
|
||||
:disabled="!canGenerateSku"
|
||||
@click="regenerateSkuList"
|
||||
/>
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="当前 SKU" :note="`${form.skuList.length} 个`" />
|
||||
</t-cell-group>
|
||||
<t-cell-group v-if="form.skuList.length" theme="card" class="sku-list fix-last-cell-line">
|
||||
<product-sku-editor
|
||||
v-for="(sku, skuIndex) in form.skuList"
|
||||
:key="sku.clientKey"
|
||||
:product-type="form.productType"
|
||||
v-model:sku="form.skuList[skuIndex]"
|
||||
:sku-index="skuIndex"
|
||||
:spec-list="form.specList"
|
||||
@configure-units="openUnitEditor(sku)"
|
||||
@remove="removeSku(skuIndex)"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<div v-else class="load-state" v-text="form.specList.length ? '请先添加规格值,再生成 SKU 组合' : '正在准备默认 SKU'" />
|
||||
</div>
|
||||
</card-container>
|
||||
<t-popup v-model="typePickerVisible" placement="bottom">
|
||||
<t-picker v-model="typeDraft" :columns="productTypeOptions" title="产品类型" @cancel="typePickerVisible = false" @confirm="confirmType" />
|
||||
</t-popup>
|
||||
<t-popup v-model="categoryPickerVisible" placement="bottom">
|
||||
<t-picker v-model="categoryDraft" :columns="categoryOptions" title="产品分类" @cancel="categoryPickerVisible = false" @confirm="confirmCategory" />
|
||||
</t-popup>
|
||||
<t-popup v-model="statusPickerVisible" placement="bottom">
|
||||
<t-picker v-model="statusDraft" :columns="statusOptions" title="产品状态" @cancel="statusPickerVisible = false" @confirm="confirmStatus" />
|
||||
</t-popup>
|
||||
<product-sku-unit-editor
|
||||
v-model="unitEditorVisible"
|
||||
:product-type="form.productType"
|
||||
v-model:sku="editingSku"
|
||||
:spec-list="form.specList"
|
||||
@close="closeUnitEditor"
|
||||
/>
|
||||
<product-sku-unit-batch-editor
|
||||
v-model="batchUnitEditorVisible"
|
||||
v-model:unit-list="batchUnitList"
|
||||
v-model:base-unit-migration-ratio-text="batchBaseUnitMigrationRatioText"
|
||||
:product-type="form.productType"
|
||||
:sku-count="form.skuList.length"
|
||||
@apply="applyBatchUnitTemplate"
|
||||
@close="closeBatchUnitEditor"
|
||||
/>
|
||||
<bottom-popup
|
||||
v-model="coverColorPickerVisible"
|
||||
title="颜色选择"
|
||||
:right-button-text="isAttachmentUploading ? '上传中' : '确定'"
|
||||
@left-button-click="cancelCoverColorPicker"
|
||||
@right-button-click="confirmCoverColorPicker"
|
||||
>
|
||||
<t-color-picker v-if="coverColorPickerVisible" v-model="coverColorDraft" format="HEX" type="multiple" :swatch-colors="colorSwatchList" @palette-bar-change="updateCoverColorDraftFromPalette" />
|
||||
</bottom-popup>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1131,7 +1135,7 @@ onMounted(async () => {
|
||||
.product-edit {
|
||||
gap: 1rem;
|
||||
display: flex;
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 1rem;
|
||||
padding: 0 0 1rem;
|
||||
flex-direction: column;
|
||||
|
||||
.form {
|
||||
|
||||
Reference in New Issue
Block a user