fix layout

This commit is contained in:
Timi
2026-10-28 14:21:26 +08:00
parent 5609d2484e
commit adc6e38328
83 changed files with 5587 additions and 5386 deletions
+320 -316
View File
@@ -1,329 +1,333 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<t-button
v-if="userStore.hasPermissions(permissionCodes.customerPackage.create)"
@click="submitRecord"
theme="primary"
variant="text"
size="small"
content="提交"
/>
</template>
</t-navbar>
<div v-can="permissionCodes.customerPackage.create" class="package-purchase">
<t-form class="form card" v-entrance-transition>
<t-form-item label="客户" required-mark>
<t-input
:model-value="customerDisplayText"
class="customer"
readonly
borderless
placeholder="选择或扫码客户"
@click="openSelectedCustomerList()"
>
<template #suffix-icon>
<div class="actions">
<t-button
theme="primary"
variant="outline"
size="extra-small"
@click.stop="selectorVisible = true"
>选择</t-button>
<t-button
theme="primary"
size="extra-small"
@click.stop="toggleScanner"
>
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
</t-button>
</div>
</template>
</t-input>
</t-form-item>
<div v-if="scannerVisible" class="code-scanner-wrapper">
<code-scanner
visible
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
<div class="page-layout navbar">
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<t-button
v-if="userStore.hasPermissions(permissionCodes.customerPackage.create)"
@click="submitRecord"
theme="primary"
variant="text"
size="small"
content="提交"
/>
</div>
<customer-profile-card
v-if="selectedCustomer"
class="customer-profile"
:customer="selectedCustomer"
v-entrance-transition
/>
<t-form-item
v-if="isCustomerPackageCreate"
label="套餐"
required-mark
content-align="right"
arrow
@click="configSelectorVisible = true"
>选择套餐</t-form-item>
<div v-if="config && !isSaleable" class="saleable-tip red">套餐当前不可购买,请检查套餐状态和有效期</div>
<t-form-item v-if="config" label-width="0">
<div class="config-summary">
<div class="header">
<div class="name text-bold clip-text" v-text="config.name || '未命名套餐'" />
<div class="price">
<span class="label gray">标准价:</span>
<span class="value red text-bold" v-text="formatPackageAmount(config.standardAmount)" />
</div>
</template>
</t-navbar>
<main class="page-content scroll column">
<div v-can="permissionCodes.customerPackage.create" class="package-purchase">
<t-form class="form card" v-entrance-transition>
<t-form-item label="客户" required-mark>
<t-input
:model-value="customerDisplayText"
class="customer"
readonly
borderless
placeholder="选择或扫码客户"
@click="openSelectedCustomerList()"
>
<template #suffix-icon>
<div class="actions">
<t-button
theme="primary"
variant="outline"
size="extra-small"
@click.stop="selectorVisible = true"
>选择</t-button>
<t-button
theme="primary"
size="extra-small"
@click.stop="toggleScanner"
>
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
</t-button>
</div>
</template>
</t-input>
</t-form-item>
<div v-if="scannerVisible" class="code-scanner-wrapper">
<code-scanner
visible
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<div class="description" v-text="config.description" />
</div>
</t-form-item>
<t-form-item v-if="canPriceOverride" label="成交价" label-width="6rem" required-mark>
<t-input
v-model.trim="saleAmountText"
type="number"
align="right"
borderless
placeholder="请输入成交价"
/>
</t-form-item>
<t-form-item v-if="config" class="detail" label-width="0">
<t-form class="items" label-width="0">
<span v-if="!canPriceOverride">当前账号无定制权限,仅可等值转换单位</span>
<customer-profile-card
v-if="selectedCustomer"
class="customer-profile"
:customer="selectedCustomer"
v-entrance-transition
/>
<t-form-item
v-for="(item, index) in packagePurchaseItemList"
:key="`${index}-${item.skuId}-${item.skuUnitId}-${item.gifted}`"
class="item"
>
<div class="content">
<div class="photo">
<t-image
v-if="getItemPhotoURL(item)"
:src="getItemPhotoURL(item)"
:alt="getItemName(item)"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="getItemName(item).slice(0, 1)"
/>
</div>
<div class="main">
<div class="title">
<div class="heading">
<div class="name-tags">
<strong v-text="getItemName(item)" />
<div v-if="hasItemSkuText(item)" class="sku-tags">
<product-sku-tags
:product-name="getItemName(item)"
:fallback="getItemSkuFallback(item)"
/>
</div>
<t-tag v-if="item.gifted" size="small" theme="success" content="赠" />
</div>
<t-button
v-if="canRemoveItem(item)"
class="remove"
size="extra-small"
theme="danger"
variant="text"
content="移除"
@click="removePurchaseItem(index)"
/>
</div>
</div>
<div class="input">
<div class="quantity">
<t-stepper
:model-value="getItemQuantity(item)"
class="stepper"
size="large"
:max="Number.MAX_SAFE_INTEGER"
:min="0"
:step="getQuantityStep(item)"
:integer="!getItemSku(item)?.allowDecimalQuantity"
:disabled="!canEditItem(item)"
theme="outline"
@update:model-value="updateItemQuantity(index, $event)"
/>
<t-button
class="unit"
size="extra-small"
variant="outline"
:content="getItemUnit(item)?.name || '选择单位'"
:disabled="!canEditItem(item)"
@click.stop="openItemUnitPicker(index)"
/>
</div>
<t-input
v-if="item.gifted"
class="gift-remark"
:model-value="item.remark || ''"
align="right"
borderless
placeholder="赠送说明(选填)"
@update:model-value="updateItemRemark(index, $event)"
/>
v-if="isCustomerPackageCreate"
label="套餐"
required-mark
content-align="right"
arrow
@click="configSelectorVisible = true"
>选择套餐</t-form-item>
<div v-if="config && !isSaleable" class="saleable-tip red">套餐当前不可购买,请检查套餐状态和有效期</div>
<t-form-item v-if="config" label-width="0">
<div class="config-summary">
<div class="header">
<div class="name text-bold clip-text" v-text="config.name || '未命名套餐'" />
<div class="price">
<span class="label gray">标准价:</span>
<span class="value red text-bold" v-text="formatPackageAmount(config.standardAmount)" />
</div>
</div>
<div class="description" v-text="config.description" />
</div>
</t-form-item>
<product-select-form-item
v-if="canGiftCreate"
:model-value="undefined"
label=""
placeholder="添加可售赠送产品"
@update:model-value="addGiftProduct"
/>
<center-tips v-if="!packagePurchaseItemList.length" :content="'当前套餐暂无权益明细'" />
</t-form>
</t-form-item>
<t-form-item label="购买时间" content-align="right">
<date-time-now-picker v-model="purchasedAtText" title="购买时间" :start="minimumDateTimeText" />
</t-form-item>
<t-form-item
v-if="canReceiveImmediately"
class="payment-item"
:class="{ disabled: receiveFullPayment }"
:label="receiveFullPayment ? '收款和核销金额' : '已部分收款和核销'"
label-width="9rem"
content-align="right"
>
<t-input
:model-value="receiveFullPayment ? formatPackageAmount(parsedSaleAmount || 0) : paymentAmountText"
type="number"
align="right"
borderless
:disabled="receiveFullPayment"
:placeholder="paymentAmountPlaceholder"
@update:model-value="paymentAmountText = String($event)"
/>
</t-form-item>
<t-form-item v-if="canReceiveImmediately" label="已全额收款和核销" content-align="right">
<t-switch
v-model="receiveFullPayment"
size="small"
:disabled="!canReceiveImmediately"
/>
</t-form-item>
<t-form-item v-if="canFulfillImmediately" label="已全部产品履约和核销" content-align="right">
<t-switch
v-model="fulfillAll"
size="small"
:disabled="!canFulfillImmediately || isStockChecking"
/>
</t-form-item>
<t-form-item v-if="canFulfillImmediately" label-width="0">
<div class="stock-tips">
<div class="tips red">全部履约会同步启用全额收款;请先准备充足的库存,任意一步失败都会下单失败。</div>
<product-stock-preview v-if="stockPreviewList.length" :items="stockPreviewList" />
</div>
</t-form-item>
<t-form-item v-if="(paymentVerified && parsedPaymentAmount) || (receiveFullPayment && parsedSaleAmount)" label-width="0">
<attachment-selector
v-model:items="paymentPhotoItems"
:upload="uploadPhotoList"
title="收款凭证照片(必要)"
/>
</t-form-item>
<t-form-item v-if="fulfillAll" label-width="0">
<attachment-selector
v-model:items="fulfillmentPhotoItems"
:upload="uploadPhotoList"
title="履约凭证照片(必要)"
/>
</t-form-item>
<t-form-item label="购买备注">
<t-textarea
v-model.trim="note"
class="textarea"
:autosize="{ minRows: 3, maxRows: 5 }"
placeholder="购买说明"
/>
</t-form-item>
<t-form-item label-width="0">
<attachment-selector
v-model:items="photoItems"
:upload="uploadPhotoList"
title="订单照片"
/>
</t-form-item>
</t-form>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="selectorVisible"
selection-mode="single"
:enable-scan="false"
@change="handleCustomerChange"
/>
<bottom-popup
v-model="configSelectorVisible"
title="选择套餐"
height="70vh"
right-button-text=""
@left-button-click="configSelectorVisible = false"
>
<div class="config-selector fix-cell-title-clip empty-cell-title-margin">
<t-cell-group v-if="configList.length">
<t-cell
v-for="item in configList"
:key="item.id"
class="config-option"
arrow
@click="selectConfig(item)"
>
<template #title>
<div class="title">
<div class="clip-text" v-text="item.name || '未命名套餐'" />
<div class="price keep-text">
<span class="label gray">标准价:</span>
<span class="red" v-text="formatPackageAmount(item.standardAmount)" />
<t-form-item v-if="canPriceOverride" label="成交价" label-width="6rem" required-mark>
<t-input
v-model.trim="saleAmountText"
type="number"
align="right"
borderless
placeholder="请输入成交价"
/>
</t-form-item>
<t-form-item v-if="config" class="detail" label-width="0">
<t-form class="items" label-width="0">
<span v-if="!canPriceOverride">当前账号无定制权限,仅可等值转换单位</span>
<t-form-item
v-for="(item, index) in packagePurchaseItemList"
:key="`${index}-${item.skuId}-${item.skuUnitId}-${item.gifted}`"
class="item"
>
<div class="content">
<div class="photo">
<t-image
v-if="getItemPhotoURL(item)"
:src="getItemPhotoURL(item)"
:alt="getItemName(item)"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="getItemName(item).slice(0, 1)"
/>
</div>
<div class="main">
<div class="title">
<div class="heading">
<div class="name-tags">
<strong v-text="getItemName(item)" />
<div v-if="hasItemSkuText(item)" class="sku-tags">
<product-sku-tags
:product-name="getItemName(item)"
:fallback="getItemSkuFallback(item)"
/>
</div>
<t-tag v-if="item.gifted" size="small" theme="success" content="赠" />
</div>
<t-button
v-if="canRemoveItem(item)"
class="remove"
size="extra-small"
theme="danger"
variant="text"
content="移除"
@click="removePurchaseItem(index)"
/>
</div>
</div>
<div class="input">
<div class="quantity">
<t-stepper
:model-value="getItemQuantity(item)"
class="stepper"
size="large"
:max="Number.MAX_SAFE_INTEGER"
:min="0"
:step="getQuantityStep(item)"
:integer="!getItemSku(item)?.allowDecimalQuantity"
:disabled="!canEditItem(item)"
theme="outline"
@update:model-value="updateItemQuantity(index, $event)"
/>
<t-button
class="unit"
size="extra-small"
variant="outline"
:content="getItemUnit(item)?.name || '选择单位'"
:disabled="!canEditItem(item)"
@click.stop="openItemUnitPicker(index)"
/>
</div>
<t-input
v-if="item.gifted"
class="gift-remark"
:model-value="item.remark || ''"
align="right"
borderless
placeholder="赠送说明(选填)"
@update:model-value="updateItemRemark(index, $event)"
/>
</div>
</div>
</div>
</div>
</template>
<template #description>
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getConfigProductText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="'暂无可购买套餐'" />
</div>
</bottom-popup>
<t-popup v-model="unitPickerVisible" placement="bottom">
<t-picker v-model="unitPickerDraft" :columns="unitPickerOptions" title="调整权益单位" @cancel="unitPickerVisible = false" @confirm="confirmItemUnitPicker" />
</t-popup>
<t-popup v-model="selectedCustomerListVisible" placement="bottom">
<div class="selected-customer-popup bg-white">
<div class="popup-header">
<t-button variant="text" size="small" @click="selectedCustomerListVisible = false">关闭</t-button>
<h3>已选客户</h3>
<t-button theme="primary" variant="text" size="small" @click="openCustomerSelector">选择</t-button>
</div>
<customer-list
class="list"
:customer-list="selectedCustomerList"
removable
empty-text="暂未选择客户"
@remove="removeSelectedCustomer"
</t-form-item>
<product-select-form-item
v-if="canGiftCreate"
:model-value="undefined"
label=""
placeholder="添加可售赠送产品"
@update:model-value="addGiftProduct"
/>
<center-tips v-if="!packagePurchaseItemList.length" :content="'当前套餐暂无权益明细'" />
</t-form>
</t-form-item>
<t-form-item label="购买时间" content-align="right">
<date-time-now-picker v-model="purchasedAtText" title="购买时间" :start="minimumDateTimeText" />
</t-form-item>
<t-form-item
v-if="canReceiveImmediately"
class="payment-item"
:class="{ disabled: receiveFullPayment }"
:label="receiveFullPayment ? '收款和核销金额' : '已部分收款和核销'"
label-width="9rem"
content-align="right"
>
<t-input
:model-value="receiveFullPayment ? formatPackageAmount(parsedSaleAmount || 0) : paymentAmountText"
type="number"
align="right"
borderless
:disabled="receiveFullPayment"
:placeholder="paymentAmountPlaceholder"
@update:model-value="paymentAmountText = String($event)"
/>
</t-form-item>
<t-form-item v-if="canReceiveImmediately" label="已全额收款和核销" content-align="right">
<t-switch
v-model="receiveFullPayment"
size="small"
:disabled="!canReceiveImmediately"
/>
</t-form-item>
<t-form-item v-if="canFulfillImmediately" label="已全部产品履约和核销" content-align="right">
<t-switch
v-model="fulfillAll"
size="small"
:disabled="!canFulfillImmediately || isStockChecking"
/>
</t-form-item>
<t-form-item v-if="canFulfillImmediately" label-width="0">
<div class="stock-tips">
<div class="tips red">全部履约会同步启用全额收款;请先准备充足的库存,任意一步失败都会下单失败。</div>
<product-stock-preview v-if="stockPreviewList.length" :items="stockPreviewList" />
</div>
</t-form-item>
<t-form-item v-if="(paymentVerified && parsedPaymentAmount) || (receiveFullPayment && parsedSaleAmount)" label-width="0">
<attachment-selector
v-model:items="paymentPhotoItems"
:upload="uploadPhotoList"
title="收款凭证照片(必要)"
/>
</t-form-item>
<t-form-item v-if="fulfillAll" label-width="0">
<attachment-selector
v-model:items="fulfillmentPhotoItems"
:upload="uploadPhotoList"
title="履约凭证照片(必要)"
/>
</t-form-item>
<t-form-item label="购买备注">
<t-textarea
v-model.trim="note"
class="textarea"
:autosize="{ minRows: 3, maxRows: 5 }"
placeholder="购买说明"
/>
</t-form-item>
<t-form-item label-width="0">
<attachment-selector
v-model:items="photoItems"
:upload="uploadPhotoList"
title="订单照片"
/>
</t-form-item>
</t-form>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="selectorVisible"
selection-mode="single"
:enable-scan="false"
@change="handleCustomerChange"
/>
<bottom-popup
v-model="configSelectorVisible"
title="选择套餐"
height="70vh"
right-button-text=""
@left-button-click="configSelectorVisible = false"
>
<div class="config-selector fix-cell-title-clip empty-cell-title-margin">
<t-cell-group v-if="configList.length">
<t-cell
v-for="item in configList"
:key="item.id"
class="config-option"
arrow
@click="selectConfig(item)"
>
<template #title>
<div class="title">
<div class="clip-text" v-text="item.name || '未命名套餐'" />
<div class="price keep-text">
<span class="label gray">标准价:</span>
<span class="red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
</div>
</template>
<template #description>
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getConfigProductText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="'暂无可购买套餐'" />
</div>
</bottom-popup>
<t-popup v-model="unitPickerVisible" placement="bottom">
<t-picker v-model="unitPickerDraft" :columns="unitPickerOptions" title="调整权益单位" @cancel="unitPickerVisible = false" @confirm="confirmItemUnitPicker" />
</t-popup>
<t-popup v-model="selectedCustomerListVisible" placement="bottom">
<div class="selected-customer-popup bg-white">
<div class="popup-header">
<t-button variant="text" size="small" @click="selectedCustomerListVisible = false">关闭</t-button>
<h3>已选客户</h3>
<t-button theme="primary" variant="text" size="small" @click="openCustomerSelector">选择</t-button>
</div>
<customer-list
class="list"
:customer-list="selectedCustomerList"
removable
empty-text="暂未选择客户"
@remove="removeSelectedCustomer"
/>
</div>
</t-popup>
</div>
</t-popup>
</main>
</div>
</template>
@@ -966,7 +970,7 @@ watch(config, value => {
.package-purchase {
gap: 1rem;
display: flex;
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
padding: 0 0 1rem 0;
flex-direction: column;
.form {