Adjust user appraisal order flow
This commit is contained in:
@@ -103,6 +103,9 @@ class AppraisalController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$product = Db::name('appraisal_draft_products')->where('draft_id', $draftId)->find();
|
$product = Db::name('appraisal_draft_products')->where('draft_id', $draftId)->find();
|
||||||
|
if ($product) {
|
||||||
|
$product['brand_name'] = $this->resolveBrandName($product);
|
||||||
|
}
|
||||||
$extra = Db::name('appraisal_draft_extras')->where('draft_id', $draftId)->find();
|
$extra = Db::name('appraisal_draft_extras')->where('draft_id', $draftId)->find();
|
||||||
|
|
||||||
return api_success([
|
return api_success([
|
||||||
@@ -140,10 +143,16 @@ class AppraisalController
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($productInfo) {
|
if ($productInfo) {
|
||||||
|
$brandId = !empty($productInfo['brand_id']) ? (int)$productInfo['brand_id'] : null;
|
||||||
|
$brandName = $this->limitText(trim((string)($productInfo['brand_name'] ?? '')), 128);
|
||||||
|
if ($brandName === '' && $brandId) {
|
||||||
|
$brandName = $this->lookupName('catalog_brands', 'name', $brandId);
|
||||||
|
}
|
||||||
$payload = [
|
$payload = [
|
||||||
'draft_id' => $draftId,
|
'draft_id' => $draftId,
|
||||||
'category_id' => $productInfo['category_id'] ?? null,
|
'category_id' => $productInfo['category_id'] ?? null,
|
||||||
'brand_id' => $productInfo['brand_id'] ?? null,
|
'brand_id' => $brandId,
|
||||||
|
'brand_name' => $brandName,
|
||||||
'color' => $productInfo['color'] ?? '',
|
'color' => $productInfo['color'] ?? '',
|
||||||
'size_spec' => $productInfo['size_spec'] ?? '',
|
'size_spec' => $productInfo['size_spec'] ?? '',
|
||||||
'serial_no' => $productInfo['serial_no'] ?? '',
|
'serial_no' => $productInfo['serial_no'] ?? '',
|
||||||
@@ -305,7 +314,7 @@ class AppraisalController
|
|||||||
'product_summary' => [
|
'product_summary' => [
|
||||||
'product_name' => $this->resolveProductName($product),
|
'product_name' => $this->resolveProductName($product),
|
||||||
'category_name' => $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null),
|
'category_name' => $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null),
|
||||||
'brand_name' => $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null),
|
'brand_name' => $this->resolveBrandName($product),
|
||||||
'price' => $extra['purchase_price'] ?? 0,
|
'price' => $extra['purchase_price'] ?? 0,
|
||||||
],
|
],
|
||||||
'upload_summary' => [
|
'upload_summary' => [
|
||||||
@@ -398,8 +407,8 @@ class AppraisalController
|
|||||||
'order_id' => $orderId,
|
'order_id' => $orderId,
|
||||||
'category_id' => $product['category_id'] ?? null,
|
'category_id' => $product['category_id'] ?? null,
|
||||||
'category_name' => $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null),
|
'category_name' => $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null),
|
||||||
'brand_id' => $product['brand_id'] ?? null,
|
'brand_id' => !empty($product['brand_id']) ? (int)$product['brand_id'] : null,
|
||||||
'brand_name' => $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null),
|
'brand_name' => $this->resolveBrandName($product),
|
||||||
'color' => $product['color'] ?? '',
|
'color' => $product['color'] ?? '',
|
||||||
'size_spec' => $product['size_spec'] ?? '',
|
'size_spec' => $product['size_spec'] ?? '',
|
||||||
'serial_no' => $product['serial_no'] ?? '',
|
'serial_no' => $product['serial_no'] ?? '',
|
||||||
@@ -562,13 +571,27 @@ class AppraisalController
|
|||||||
return (string)Db::name($table)->where('id', $id)->value($field);
|
return (string)Db::name($table)->where('id', $id)->value($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function resolveBrandName(?array $product): string
|
||||||
|
{
|
||||||
|
if (!$product) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$brandName = trim((string)($product['brand_name'] ?? ''));
|
||||||
|
if ($brandName !== '') {
|
||||||
|
return $brandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null);
|
||||||
|
}
|
||||||
|
|
||||||
private function resolveProductName(?array $product): string
|
private function resolveProductName(?array $product): string
|
||||||
{
|
{
|
||||||
if (!$product) {
|
if (!$product) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$categoryName = $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null);
|
$categoryName = $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null);
|
||||||
$brandName = $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null);
|
$brandName = $this->resolveBrandName($product);
|
||||||
$fallbackName = trim($categoryName . ' ' . $brandName);
|
$fallbackName = trim($categoryName . ' ' . $brandName);
|
||||||
if ($fallbackName !== '') {
|
if ($fallbackName !== '') {
|
||||||
return $fallbackName;
|
return $fallbackName;
|
||||||
@@ -576,6 +599,14 @@ class AppraisalController
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function limitText(string $value, int $maxLength): string
|
||||||
|
{
|
||||||
|
if (function_exists('mb_substr')) {
|
||||||
|
return mb_substr($value, 0, $maxLength, 'UTF-8');
|
||||||
|
}
|
||||||
|
return substr($value, 0, $maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
private function serviceConfig(string $serviceProvider): array
|
private function serviceConfig(string $serviceProvider): array
|
||||||
{
|
{
|
||||||
$configs = [
|
$configs = [
|
||||||
|
|||||||
@@ -455,6 +455,7 @@ CREATE TABLE appraisal_draft_products (
|
|||||||
draft_id BIGINT UNSIGNED NOT NULL,
|
draft_id BIGINT UNSIGNED NOT NULL,
|
||||||
category_id BIGINT UNSIGNED NULL DEFAULT NULL,
|
category_id BIGINT UNSIGNED NULL DEFAULT NULL,
|
||||||
brand_id BIGINT UNSIGNED NULL DEFAULT NULL,
|
brand_id BIGINT UNSIGNED NULL DEFAULT NULL,
|
||||||
|
brand_name VARCHAR(128) NOT NULL DEFAULT '',
|
||||||
color VARCHAR(64) NOT NULL DEFAULT '',
|
color VARCHAR(64) NOT NULL DEFAULT '',
|
||||||
size_spec VARCHAR(64) NOT NULL DEFAULT '',
|
size_spec VARCHAR(64) NOT NULL DEFAULT '',
|
||||||
serial_no VARCHAR(128) NOT NULL DEFAULT '',
|
serial_no VARCHAR(128) NOT NULL DEFAULT '',
|
||||||
|
|||||||
48
server-api/tools/schema_upgrade_appraisal_brand_input.php
Normal file
48
server-api/tools/schema_upgrade_appraisal_brand_input.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
|
||||||
|
$dotenv->safeLoad();
|
||||||
|
|
||||||
|
$dsn = sprintf(
|
||||||
|
'mysql:host=%s;port=%s;dbname=%s;charset=%s',
|
||||||
|
$_ENV['DB_HOST'] ?? '127.0.0.1',
|
||||||
|
$_ENV['DB_PORT'] ?? '3306',
|
||||||
|
$_ENV['DB_DATABASE'] ?? '',
|
||||||
|
$_ENV['DB_CHARSET'] ?? 'utf8mb4'
|
||||||
|
);
|
||||||
|
|
||||||
|
$pdo = new PDO(
|
||||||
|
$dsn,
|
||||||
|
$_ENV['DB_USERNAME'] ?? '',
|
||||||
|
$_ENV['DB_PASSWORD'] ?? '',
|
||||||
|
[
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
function abiHasColumn(PDO $pdo, string $table, string $column): bool
|
||||||
|
{
|
||||||
|
$stmt = $pdo->prepare('SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = ?');
|
||||||
|
$stmt->execute([$table, $column]);
|
||||||
|
return (int)$stmt->fetchColumn() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!abiHasColumn($pdo, 'appraisal_draft_products', 'brand_name')) {
|
||||||
|
$pdo->exec("ALTER TABLE appraisal_draft_products ADD COLUMN brand_name VARCHAR(128) NOT NULL DEFAULT '' AFTER brand_id");
|
||||||
|
echo "ADD_COLUMN appraisal_draft_products.brand_name\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo->exec(<<<'SQL'
|
||||||
|
UPDATE appraisal_draft_products p
|
||||||
|
JOIN catalog_brands b ON b.id = p.brand_id
|
||||||
|
SET p.brand_name = b.name
|
||||||
|
WHERE p.brand_name = ''
|
||||||
|
AND p.brand_id IS NOT NULL
|
||||||
|
SQL);
|
||||||
|
|
||||||
|
echo "SCHEMA_UPGRADE_APPRAISAL_BRAND_INPUT_OK\n";
|
||||||
@@ -25,18 +25,6 @@
|
|||||||
"navigationBarTitleText": "选择商品信息"
|
"navigationBarTitleText": "选择商品信息"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/appraisal/extra",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "补充商品信息"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/appraisal/upload",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "上传鉴定资料"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/appraisal/confirm",
|
"path": "pages/appraisal/confirm",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ const store = useAppraisalStore();
|
|||||||
const preview = computed(() => store.preview);
|
const preview = computed(() => store.preview);
|
||||||
const loading = computed(() => !store.preview);
|
const loading = computed(() => !store.preview);
|
||||||
const submitting = computed(() => false);
|
const submitting = computed(() => false);
|
||||||
const purchasePriceText = computed(() => {
|
const productCategoryBrandText = computed(() => {
|
||||||
const price = Number(preview.value?.product_summary.price || 0);
|
const categoryName = preview.value?.product_summary.category_name || "";
|
||||||
return price > 0 ? `¥${price}` : "未填写";
|
const brandName = preview.value?.product_summary.brand_name || "未填写";
|
||||||
|
return categoryName ? `${categoryName} / ${brandName}` : "";
|
||||||
});
|
});
|
||||||
const addressSheetVisible = ref(false);
|
const addressSheetVisible = ref(false);
|
||||||
const addressesLoading = ref(false);
|
const addressesLoading = ref(false);
|
||||||
@@ -163,10 +164,11 @@ onShow(fetchAddresses);
|
|||||||
<template>
|
<template>
|
||||||
<view class="app-page app-page--tight">
|
<view class="app-page app-page--tight">
|
||||||
<FlowStepHeader
|
<FlowStepHeader
|
||||||
:step="6"
|
:step="3"
|
||||||
|
:total="3"
|
||||||
title="确认订单并支付"
|
title="确认订单并支付"
|
||||||
desc="提交前请再次确认服务、商品资料与寄回地址,提交后会生成正式鉴定单并进入履约流程。"
|
desc="提交前请再次确认服务、商品信息与寄回地址,提交后会生成正式鉴定单并进入履约流程。"
|
||||||
:chips="['确认商品信息', '确认资料', '提交后生成正式鉴定单']"
|
:chips="['确认服务', '确认商品', '提交后生成正式鉴定单']"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<view v-if="loading" class="notice-card">
|
<view v-if="loading" class="notice-card">
|
||||||
@@ -180,10 +182,6 @@ onShow(fetchAddresses);
|
|||||||
<text class="summary-card__label">鉴定服务</text>
|
<text class="summary-card__label">鉴定服务</text>
|
||||||
<text class="summary-card__value">{{ preview?.service_summary.service_provider_text || '中检鉴定' }}</text>
|
<text class="summary-card__value">{{ preview?.service_summary.service_provider_text || '中检鉴定' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-card__row">
|
|
||||||
<text class="summary-card__label">资料进度</text>
|
|
||||||
<text class="summary-card__value">{{ preview?.upload_summary.uploaded_count || 0 }} 项资料已完成</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="section summary-card">
|
<view class="section summary-card">
|
||||||
@@ -194,11 +192,7 @@ onShow(fetchAddresses);
|
|||||||
</view>
|
</view>
|
||||||
<view class="summary-card__row">
|
<view class="summary-card__row">
|
||||||
<text class="summary-card__label">品类 / 品牌</text>
|
<text class="summary-card__label">品类 / 品牌</text>
|
||||||
<text class="summary-card__value">{{ preview?.product_summary.category_name || '' }} / {{ preview?.product_summary.brand_name || '' }}</text>
|
<text class="summary-card__value">{{ productCategoryBrandText }}</text>
|
||||||
</view>
|
|
||||||
<view class="summary-card__row">
|
|
||||||
<text class="summary-card__label">购买价格</text>
|
|
||||||
<text class="summary-card__value">{{ purchasePriceText }}</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import { appraisalApi, type CatalogOption, type CategoryOption } from "../../api/appraisal";
|
import { appraisalApi, type CategoryOption } from "../../api/appraisal";
|
||||||
import FlowStepHeader from "../../components/FlowStepHeader.vue";
|
import FlowStepHeader from "../../components/FlowStepHeader.vue";
|
||||||
import { useAppraisalStore } from "../../stores/appraisal";
|
import { useAppraisalStore } from "../../stores/appraisal";
|
||||||
import { isMissingDraftError, rebuildDraftFromStore } from "../../utils/appraisal-flow";
|
import { isMissingDraftError, rebuildDraftFromStore } from "../../utils/appraisal-flow";
|
||||||
import { showErrorToast, showInfoToast, withLoading } from "../../utils/feedback";
|
import { showErrorToast, showInfoToast, withLoading } from "../../utils/feedback";
|
||||||
|
|
||||||
type PickerType = "category" | "brand";
|
type PickerType = "category";
|
||||||
type CategoryPickerItem = {
|
type CategoryPickerItem = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -18,22 +18,21 @@ type CategoryPickerItem = {
|
|||||||
const store = useAppraisalStore();
|
const store = useAppraisalStore();
|
||||||
|
|
||||||
const categories = ref<CategoryPickerItem[]>([]);
|
const categories = ref<CategoryPickerItem[]>([]);
|
||||||
const brands = ref<CatalogOption[]>([]);
|
|
||||||
const pageLoading = ref(false);
|
const pageLoading = ref(false);
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
const loadError = ref("");
|
const loadError = ref("");
|
||||||
const activePicker = ref<PickerType | "">("");
|
const activePicker = ref<PickerType | "">("");
|
||||||
const pickerKeyword = ref("");
|
const pickerKeyword = ref("");
|
||||||
|
|
||||||
const canContinue = computed(() => Boolean(store.product.categoryId && store.product.brandId));
|
const canContinue = computed(() => Boolean(store.product.categoryId));
|
||||||
|
const brandNameForSave = computed(() => store.product.brandName.trim());
|
||||||
|
|
||||||
const productSummary = computed(() => [
|
const productSummary = computed(() => [
|
||||||
store.product.categoryName || "未选品类",
|
store.product.categoryName || "未选品类",
|
||||||
store.product.brandName || "未选品牌",
|
brandNameForSave.value || "未填品牌",
|
||||||
].join(" / "));
|
].join(" / "));
|
||||||
|
|
||||||
const pickerMeta = computed(() => {
|
const pickerMeta = computed(() => {
|
||||||
if (activePicker.value === "category") {
|
|
||||||
return {
|
return {
|
||||||
title: "选择品类",
|
title: "选择品类",
|
||||||
desc: "品类将持续扩展,建议统一通过搜索选择器完成选择,后续更便于拓展更多鉴定业务。",
|
desc: "品类将持续扩展,建议统一通过搜索选择器完成选择,后续更便于拓展更多鉴定业务。",
|
||||||
@@ -42,27 +41,6 @@ const pickerMeta = computed(() => {
|
|||||||
emptyText: "暂无可用品类",
|
emptyText: "暂无可用品类",
|
||||||
searchPlaceholder: "搜索品类名称",
|
searchPlaceholder: "搜索品类名称",
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (activePicker.value === "brand") {
|
|
||||||
return {
|
|
||||||
title: "选择品牌",
|
|
||||||
desc: "支持搜索品牌名称,选择后即可进入下一步。",
|
|
||||||
options: brands.value,
|
|
||||||
label: (item: CatalogOption) => item.brand_name || "",
|
|
||||||
emptyText: "当前品类下暂无品牌数据",
|
|
||||||
searchPlaceholder: "搜索品牌名称",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
title: "选择品牌",
|
|
||||||
desc: "支持搜索品牌名称,选择后即可进入下一步。",
|
|
||||||
options: brands.value,
|
|
||||||
label: (item: CatalogOption) => item.brand_name || "",
|
|
||||||
emptyText: "当前品类下暂无品牌数据",
|
|
||||||
searchPlaceholder: "搜索品牌名称",
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredPickerOptions = computed(() => {
|
const filteredPickerOptions = computed(() => {
|
||||||
@@ -71,33 +49,14 @@ const filteredPickerOptions = computed(() => {
|
|||||||
return pickerMeta.value.options;
|
return pickerMeta.value.options;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = pickerMeta.value.options as Array<CatalogOption | CategoryPickerItem>;
|
const options = pickerMeta.value.options;
|
||||||
return options.filter((item) =>
|
return options.filter((item) =>
|
||||||
pickerMeta.value.label(item as never).toLowerCase().includes(keyword),
|
pickerMeta.value.label(item).toLowerCase().includes(keyword),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function pickerOptionKey(item: CatalogOption | CategoryPickerItem) {
|
function pickerOptionKey(item: CategoryPickerItem) {
|
||||||
if (activePicker.value === "category") {
|
return String(item.id);
|
||||||
return String((item as CategoryPickerItem).id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activePicker.value === "brand") {
|
|
||||||
return String((item as CatalogOption).brand_id || "");
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadBrands() {
|
|
||||||
if (!store.product.categoryId) {
|
|
||||||
brands.value = [];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const data = await appraisalApi.getBrands(store.product.categoryId);
|
|
||||||
brands.value = data.list;
|
|
||||||
if (!store.product.brandId && brands.value.length) {
|
|
||||||
selectBrand(brands.value[0], false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectCategory(item: CategoryPickerItem) {
|
function selectCategory(item: CategoryPickerItem) {
|
||||||
@@ -105,10 +64,7 @@ function selectCategory(item: CategoryPickerItem) {
|
|||||||
categoryId: item.id,
|
categoryId: item.id,
|
||||||
categoryName: item.name,
|
categoryName: item.name,
|
||||||
brandId: 0,
|
brandId: 0,
|
||||||
brandName: "",
|
|
||||||
});
|
});
|
||||||
brands.value = [];
|
|
||||||
loadBrands();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadCategories() {
|
async function loadCategories() {
|
||||||
@@ -121,16 +77,6 @@ async function loadCategories() {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectBrand(item: CatalogOption, closeSheet = true) {
|
|
||||||
store.setProduct({
|
|
||||||
brandId: item.brand_id || 0,
|
|
||||||
brandName: item.brand_name || "",
|
|
||||||
});
|
|
||||||
if (closeSheet) {
|
|
||||||
closePicker();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openPicker(type: PickerType) {
|
function openPicker(type: PickerType) {
|
||||||
activePicker.value = type;
|
activePicker.value = type;
|
||||||
pickerKeyword.value = "";
|
pickerKeyword.value = "";
|
||||||
@@ -141,52 +87,56 @@ function closePicker() {
|
|||||||
pickerKeyword.value = "";
|
pickerKeyword.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmPicker(item: CatalogOption) {
|
function confirmPicker(item: CategoryPickerItem) {
|
||||||
if (activePicker.value === "category") {
|
selectCategory(item);
|
||||||
selectCategory(item as unknown as CategoryPickerItem);
|
|
||||||
closePicker();
|
closePicker();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (activePicker.value === "brand") {
|
|
||||||
selectBrand(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPickerCurrent(item: CatalogOption | CategoryPickerItem) {
|
function isPickerCurrent(item: CategoryPickerItem) {
|
||||||
if (activePicker.value === "category") {
|
return Number(item.id) === Number(store.product.categoryId || 0);
|
||||||
return Number((item as CategoryPickerItem).id) === Number(store.product.categoryId || 0);
|
|
||||||
}
|
}
|
||||||
if (activePicker.value === "brand") {
|
|
||||||
return Number((item as CatalogOption).brand_id || 0) === Number(store.product.brandId || 0);
|
function setBrandName(event: unknown) {
|
||||||
}
|
const value = typeof event === "string"
|
||||||
return false;
|
? event
|
||||||
|
: (event as { detail?: { value?: string } })?.detail?.value || "";
|
||||||
|
store.setProduct({
|
||||||
|
brandId: 0,
|
||||||
|
brandName: value,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function goNext() {
|
async function goNext() {
|
||||||
if (submitting.value) return;
|
if (submitting.value) return;
|
||||||
if (!canContinue.value) {
|
if (!canContinue.value) {
|
||||||
showInfoToast("请先完成品类和品牌选择");
|
showInfoToast("请先选择品类");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store.setProduct({
|
||||||
|
brandId: 0,
|
||||||
|
brandName: brandNameForSave.value,
|
||||||
|
});
|
||||||
submitting.value = true;
|
submitting.value = true;
|
||||||
try {
|
try {
|
||||||
await withLoading("正在保存商品信息", async () => {
|
await withLoading("正在保存商品信息", async () => {
|
||||||
await appraisalApi.saveDraft({
|
await appraisalApi.saveDraft({
|
||||||
draft_id: store.draftId,
|
draft_id: store.draftId,
|
||||||
current_step: 2,
|
current_step: 3,
|
||||||
service_provider: store.serviceProvider,
|
service_provider: store.serviceProvider,
|
||||||
product_info: {
|
product_info: {
|
||||||
category_id: store.product.categoryId,
|
category_id: store.product.categoryId,
|
||||||
brand_id: store.product.brandId,
|
brand_id: 0,
|
||||||
|
brand_name: store.product.brandName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
loadError.value = "";
|
loadError.value = "";
|
||||||
store.setCurrentStep(2);
|
store.setCurrentStep(3);
|
||||||
uni.navigateTo({ url: "/pages/appraisal/extra" });
|
store.setPreview(null);
|
||||||
|
uni.navigateTo({ url: "/pages/appraisal/confirm" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadError.value = "商品信息保存失败,请确认字典接口是否正常。";
|
loadError.value = "商品信息保存失败,请稍后重试或联系管理员检查服务。";
|
||||||
showErrorToast(error, "商品信息保存失败");
|
showErrorToast(error, "商品信息保存失败");
|
||||||
} finally {
|
} finally {
|
||||||
submitting.value = false;
|
submitting.value = false;
|
||||||
@@ -226,7 +176,7 @@ onLoad(async () => {
|
|||||||
categoryId,
|
categoryId,
|
||||||
categoryName,
|
categoryName,
|
||||||
brandId: Number(draft.product_info.brand_id || 0),
|
brandId: Number(draft.product_info.brand_id || 0),
|
||||||
brandName: "",
|
brandName: draft.product_info.brand_name || "",
|
||||||
});
|
});
|
||||||
} else if (store.product.categoryId) {
|
} else if (store.product.categoryId) {
|
||||||
const currentCategory = categories.value.find((item) => item.id === store.product.categoryId);
|
const currentCategory = categories.value.find((item) => item.id === store.product.categoryId);
|
||||||
@@ -242,21 +192,11 @@ onLoad(async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await loadBrands();
|
|
||||||
|
|
||||||
if (store.product.brandId) {
|
|
||||||
const brand = brands.value.find((item) => item.brand_id === store.product.brandId);
|
|
||||||
if (brand?.brand_name) {
|
|
||||||
store.setProduct({ brandName: brand.brand_name });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadError.value = "";
|
loadError.value = "";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isMissingDraftError(error)) {
|
if (isMissingDraftError(error)) {
|
||||||
try {
|
try {
|
||||||
await rebuildDraftFromStore(store);
|
await rebuildDraftFromStore(store);
|
||||||
await loadBrands();
|
|
||||||
loadError.value = "";
|
loadError.value = "";
|
||||||
showInfoToast("草稿已自动恢复,可继续填写商品信息。");
|
showInfoToast("草稿已自动恢复,可继续填写商品信息。");
|
||||||
} catch (recoverError) {
|
} catch (recoverError) {
|
||||||
@@ -278,29 +218,30 @@ onLoad(async () => {
|
|||||||
<view class="app-page app-page--tight">
|
<view class="app-page app-page--tight">
|
||||||
<FlowStepHeader
|
<FlowStepHeader
|
||||||
:step="2"
|
:step="2"
|
||||||
|
:total="3"
|
||||||
title="选择商品信息"
|
title="选择商品信息"
|
||||||
desc="只需确认本次送检商品的品类和品牌,其他细节可在后续补充说明中填写。"
|
desc="只需确认本次送检商品的品类,品牌可按实际情况选填,其他细节可在后续补充说明中填写。"
|
||||||
:chips="['选择品类', '选择品牌']"
|
:chips="['选择品类', '品牌选填']"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<view class="section form-panel">
|
<view class="section form-panel">
|
||||||
<view class="form-panel__title">当前识别路径</view>
|
<view class="form-panel__title">当前识别路径</view>
|
||||||
<view class="form-panel__desc">当前步骤仅用于确定商品大类和品牌,便于匹配资料模板与服务流程。</view>
|
<view class="form-panel__desc">当前步骤用于确定商品大类,便于匹配资料模板与服务流程。</view>
|
||||||
<view class="selection-summary-card">
|
<view class="selection-summary-card">
|
||||||
<view class="selection-summary-card__title">{{ productSummary }}</view>
|
<view class="selection-summary-card__title">{{ productSummary }}</view>
|
||||||
<view class="selection-summary-card__desc">
|
<view class="selection-summary-card__desc">
|
||||||
{{ canContinue ? "已完成基础商品信息" : "请选择品类和品牌后继续" }}
|
{{ canContinue ? "已完成基础商品信息" : "请选择品类后继续" }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="section form-panel">
|
<view class="section form-panel">
|
||||||
<view class="form-panel__title">商品识别信息</view>
|
<view class="form-panel__title">商品识别信息</view>
|
||||||
<view class="form-panel__desc">品牌列表会随品类变化,支持搜索快速定位。</view>
|
<view class="form-panel__desc">品类来源于后台资料配置,品牌由用户按实际商品自行填写。</view>
|
||||||
|
|
||||||
<view v-if="pageLoading" class="notice-card">
|
<view v-if="pageLoading" class="notice-card">
|
||||||
<view class="notice-card__title">正在加载商品字典</view>
|
<view class="notice-card__title">正在加载商品字典</view>
|
||||||
<view class="notice-card__desc">品类和品牌数据加载完成后即可继续选择。</view>
|
<view class="notice-card__desc">品类数据加载完成后即可继续选择。</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="loadError" class="notice-card">
|
<view v-if="loadError" class="notice-card">
|
||||||
@@ -323,17 +264,17 @@ onLoad(async () => {
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="form-group">
|
<view class="form-group">
|
||||||
<view class="form-group__label">品牌</view>
|
<view class="form-group__label">品牌(选填)</view>
|
||||||
<view :class="['selector-card', store.product.brandId ? 'selector-card--selected' : '']" @click="openPicker('brand')">
|
<view class="field-box">
|
||||||
<view class="selector-card__main">
|
<input
|
||||||
<view class="selector-card__value">{{ store.product.brandName || "请选择品牌" }}</view>
|
:value="store.product.brandName"
|
||||||
<view class="selector-card__meta">当前品类下共 {{ brands.length }} 个品牌,支持搜索。</view>
|
class="field-input"
|
||||||
</view>
|
maxlength="128"
|
||||||
<view class="selector-card__side">
|
placeholder="请输入品牌名称,可不填"
|
||||||
<view v-if="store.product.brandId" class="selector-card__badge">已选品牌</view>
|
@input="setBrandName"
|
||||||
<view class="selector-card__action">选择</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view class="form-group__hint">不确定品牌时可留空,后续补充说明中仍可描述商品细节。</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -356,11 +297,11 @@ onLoad(async () => {
|
|||||||
<view
|
<view
|
||||||
v-for="item in filteredPickerOptions"
|
v-for="item in filteredPickerOptions"
|
||||||
:key="pickerOptionKey(item)"
|
:key="pickerOptionKey(item)"
|
||||||
:class="['picker-sheet__option', isPickerCurrent(item as CatalogOption) ? 'picker-sheet__option--selected' : '']"
|
:class="['picker-sheet__option', isPickerCurrent(item) ? 'picker-sheet__option--selected' : '']"
|
||||||
@click="confirmPicker(item as CatalogOption)"
|
@click="confirmPicker(item)"
|
||||||
>
|
>
|
||||||
<view class="picker-sheet__option-title">{{ pickerMeta.label(item as never) }}</view>
|
<view class="picker-sheet__option-title">{{ pickerMeta.label(item) }}</view>
|
||||||
<view class="picker-sheet__option-action">{{ isPickerCurrent(item as CatalogOption) ? '已选' : '选择' }}</view>
|
<view class="picker-sheet__option-action">{{ isPickerCurrent(item) ? '已选' : '选择' }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="filteredPickerOptions.length === 0" class="picker-sheet__empty">
|
<view v-if="filteredPickerOptions.length === 0" class="picker-sheet__empty">
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ function chooseProvider(code: keyof typeof providerMeta) {
|
|||||||
<view class="app-page app-page--tight">
|
<view class="app-page app-page--tight">
|
||||||
<FlowStepHeader
|
<FlowStepHeader
|
||||||
:step="1"
|
:step="1"
|
||||||
|
:total="3"
|
||||||
title="选择鉴定服务"
|
title="选择鉴定服务"
|
||||||
desc="对比安心验与中检两种服务方式,确认本次送检适合的出具机构和结果交付标准。"
|
desc="对比安心验与中检两种服务方式,确认本次送检适合的出具机构和结果交付标准。"
|
||||||
:chips="['服务流程一致', '机构与报告不同', '价格时效有差异']"
|
:chips="['服务流程一致', '机构与报告不同', '价格时效有差异']"
|
||||||
|
|||||||
@@ -12,14 +12,15 @@ export async function rebuildDraftFromStore(store: AppraisalStore) {
|
|||||||
const draft = await appraisalApi.createDraft(store.serviceProvider || "anxinyan");
|
const draft = await appraisalApi.createDraft(store.serviceProvider || "anxinyan");
|
||||||
store.setDraft(draft.draft_id);
|
store.setDraft(draft.draft_id);
|
||||||
|
|
||||||
if (store.product.categoryId && store.product.brandId) {
|
if (store.product.categoryId) {
|
||||||
await appraisalApi.saveDraft({
|
await appraisalApi.saveDraft({
|
||||||
draft_id: draft.draft_id,
|
draft_id: draft.draft_id,
|
||||||
current_step: 2,
|
current_step: 3,
|
||||||
service_provider: store.serviceProvider,
|
service_provider: store.serviceProvider,
|
||||||
product_info: {
|
product_info: {
|
||||||
category_id: store.product.categoryId,
|
category_id: store.product.categoryId,
|
||||||
brand_id: store.product.brandId,
|
brand_id: store.product.brandId || 0,
|
||||||
|
brand_name: store.product.brandName.trim(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user