Преглед изворни кода

去除假数据,修改接口

付晓文。 пре 1 месец
родитељ
комит
8ba862cc6d

+ 1 - 1
pages/merchantDish/dish/form.vue

@@ -189,7 +189,7 @@
 </template>
 
 <script>
-import { buildSpecCombos } from '../mock.js';
+import { buildSpecCombos } from '../utils.js';
 import configService from '@/common/service/config.service';
 import merchantDishApi, {
 	belongingToKey,

+ 1 - 1
pages/merchantDish/dish/list.vue

@@ -190,7 +190,7 @@ export default {
 		initParams() {
 			const params = {
 				merchantId: getMerchantId(),
-				statusType: STATUS_KEY_TO_TYPE[this.filterStatus] != null ? STATUS_KEY_TO_TYPE[this.filterStatus] : 0
+				statusType: STATUS_KEY_TO_TYPE[this.filterStatus] != null ? STATUS_KEY_TO_TYPE[this.filterStatus] : ''
 			};
 			if (this.keyword) params.name = this.keyword;
 			if (this.filterType) params.productBelonging = belongingToApi(this.filterType);

+ 0 - 150
pages/merchantDish/mock.js

@@ -1,150 +0,0 @@
-/** 商户菜品模块:跨页共享的假数据与工具 */
-
-let dishIdSeed = 100;
-
-export function createMockDishes() {
-	return [
-		{
-			id: 1,
-			name: '宫保鸡丁套餐',
-			desc: '宫保鸡丁、米饭、时蔬、例汤',
-			image: '/static/logo.png',
-			belong: 'group',
-			isCombo: true,
-			category: 'seasonal',
-			productType: 'lunch',
-			price: 26.9,
-			originPrice: 32,
-			stock: 50,
-			sales: 1255,
-			status: 'selling',
-			unformedOrders: 8,
-			formedOrders: 10,
-			pendingPayOrders: 0
-		},
-		{
-			id: 2,
-			name: '番茄牛腩单品',
-			desc: '精选牛腩配番茄',
-			image: '/static/logo.png',
-			belong: 'store',
-			isCombo: false,
-			category: 'home',
-			productType: 'single',
-			price: 29.9,
-			originPrice: 36,
-			stock: 0,
-			sales: 860,
-			status: 'soldout',
-			unformedOrders: 0,
-			formedOrders: 0,
-			pendingPayOrders: 2
-		},
-		{
-			id: 3,
-			name: '清炒时蔬',
-			desc: '时令青菜',
-			image: '/static/logo.png',
-			belong: 'store',
-			isCombo: false,
-			category: 'home',
-			productType: 'single',
-			price: 12.9,
-			originPrice: 15,
-			stock: 100,
-			sales: 320,
-			status: 'pending',
-			unformedOrders: 0,
-			formedOrders: 0,
-			pendingPayOrders: 0
-		},
-		{
-			id: 4,
-			name: '企业商务简餐',
-			desc: '两荤一素一汤',
-			image: '/static/logo.png',
-			belong: 'group',
-			isCombo: true,
-			category: 'seasonal',
-			productType: 'lunch',
-			price: 18.8,
-			originPrice: 22,
-			stock: 200,
-			sales: 0,
-			status: 'reviewing',
-			unformedOrders: 0,
-			formedOrders: 0,
-			pendingPayOrders: 0
-		},
-		{
-			id: 5,
-			name: '麻辣香锅',
-			desc: '自选食材',
-			image: '/static/logo.png',
-			belong: 'store',
-			isCombo: false,
-			category: 'home',
-			productType: 'dinner',
-			price: 39.9,
-			originPrice: 48,
-			stock: 30,
-			sales: 12,
-			status: 'rejected',
-			unformedOrders: 0,
-			formedOrders: 0,
-			pendingPayOrders: 0
-		},
-		{
-			id: 6,
-			name: '早餐豆浆油条',
-			desc: '热豆浆+油条',
-			image: '/static/logo.png',
-			belong: 'group',
-			isCombo: false,
-			category: 'staple',
-			productType: 'breakfast',
-			price: 8.5,
-			originPrice: 10,
-			stock: 80,
-			sales: 540,
-			status: 'selling',
-			unformedOrders: 0,
-			formedOrders: 3,
-			pendingPayOrders: 0
-		}
-	];
-}
-
-export function nextDishId() {
-	return ++dishIdSeed;
-}
-
-/** 笛卡尔积生成规格组合 */
-export function buildSpecCombos(specs) {
-	const groups = (specs || [])
-		.map((s) => ({
-			name: s.name,
-			values: (s.values || []).filter((v) => v.selected)
-		}))
-		.filter((g) => g.values.length);
-	if (!groups.length) return [];
-	return groups.reduce(
-		(acc, g) => {
-			const next = [];
-			acc.forEach((prev) => {
-				g.values.forEach((v) => {
-					next.push({
-						label: prev.label ? `${prev.label} | ${v.name}` : v.name,
-						keys: [...(prev.keys || []), v.id],
-						price: '',
-						originPrice: '',
-						stock: '',
-						costPrice: ''
-					});
-				});
-			});
-			return next;
-		},
-		[{ label: '', keys: [] }]
-	);
-}

+ 29 - 0
pages/merchantDish/utils.js

@@ -0,0 +1,29 @@
+/** 笛卡尔积生成规格组合 */
+export function buildSpecCombos(specs) {
+	const groups = (specs || [])
+		.map((s) => ({
+			name: s.name,
+			values: (s.values || []).filter((v) => v.selected)
+		}))
+		.filter((g) => g.values.length);
+	if (!groups.length) return [];
+	return groups.reduce(
+		(acc, g) => {
+			const next = [];
+			acc.forEach((prev) => {
+				g.values.forEach((v) => {
+					next.push({
+						label: prev.label ? `${prev.label} | ${v.name}` : v.name,
+						keys: [...(prev.keys || []), v.id],
+						price: '',
+						originPrice: '',
+						stock: '',
+						costPrice: ''
+					});
+				});
+			});
+			return next;
+		},
+		[{ label: '', keys: [] }]
+	);
+}