This commit is contained in:
weiwei committed 2025-10-28 10:55:00 +08:00
commit 9691f91a62
12 files changed
+194 -447

No files matched your search

@@ -0,0 +1,73 @@
// 进销存报表相关类型定义
// 查询参数接口
export interface InventoryInOutQueryParams {
current?: number // 当前页码
size?: number // 每页记录数
startDate?: string // 开始日期 (yyyy-MM-dd)
endDate?: string // 结束日期 (yyyy-MM-dd)
startTime?: string // 开始时间 (yyyy-MM-dd HH:mm:ss)
endTime?: string // 结束时间 (yyyy-MM-dd HH:mm:ss)
productName?: string // 商品名称
productCode?: string // 商品编码
categoryId?: number // 分类ID
warehouseId?: string // 仓库ID
onlyChanged?: boolean // 是否仅显示有发生额的商品
topLimit?: number // 限制返回记录数
}
// 进销存报表数据项接口
export interface InventoryInOutItem {
productId: number // 商品ID
productCode: string // 商品编码
productName: string // 商品名称
categoryId: number // 分类ID
categoryName: string // 分类名称
unit: string // 基础单位
openingQty: number // 期初库存数量
inQty: number // 入库数量
outQty: number // 出库数量
closingQty: number // 期末库存数量
inAmount: number // 入库金额
outAmount: number // 出库金额
}
// 分页响应接口
export interface InventoryInOutPageResponse {
records: InventoryInOutItem[] // 数据列表
total: number // 总记录数
size: number // 每页记录数
current: number // 当前页码
pages: number // 总页数
}
// 汇总统计接口
export interface InventoryInOutSummary {
totalProducts: number // 统计商品总数
changedProducts: number // 有发生额的商品数量
totalOpeningQty: number // 总期初库存数量
totalInQty: number // 总入库数量
totalOutQty: number // 总出库数量
totalClosingQty: number // 总期末库存数量
totalInAmount: number // 总入库金额
totalOutAmount: number // 总出库金额
turnoverRate: number // 库存周转率
avgPrice: number // 平均单价
}
// API响应接口
export interface ApiResponse<T = any> {
code: number // 状态码
msg: string // 消息描述
data: T // 具体数据
}
// 分页查询响应
export type InventoryInOutPageApiResponse = ApiResponse<InventoryInOutPageResponse>
// 列表查询响应
export type InventoryInOutListApiResponse = ApiResponse<InventoryInOutItem[]>
// 汇总统计响应
export type InventoryInOutSummaryApiResponse = ApiResponse<InventoryInOutSummary>
+3 -1
View File
@@ -1,6 +1,6 @@
<template>
<el-select style="width: 100%" v-model="state.selectId" :placeholder="props.placeholder" clearable
@visible-change="(e: boolean) => e && getDictOptions()">
:multiple="props.multiple" @visible-change="(e: boolean) => e && getDictOptions()">
<el-option v-for="v in filterDictList" :key="v.code" :label="v.label" :value="v.value" />
</el-select>
</template>
@@ -16,9 +16,11 @@ export type Props = {
dictCode: string
placeholder?: string
hideIds?: string | Array<string>
multiple?: boolean
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "请选择",
multiple: false,
})
const state = reactive<any>({
+7 -50
View File
@@ -7,7 +7,6 @@ interface JsonpOptions {
timeout?: number
callbackName?: string
callbackParam?: string
debug?: boolean
}
/**
@@ -18,17 +17,11 @@ interface JsonpOptions {
*/
export function jsonp(url: string, options: JsonpOptions = {}): Promise<any> {
const {
timeout = 15000,
timeout = 10000,
callbackName = `jsonp_callback_${Date.now()}_${Math.random().toString(36).substr(2)}`,
callbackParam = "callback",
debug = false
} = options
if (debug) {
console.log('[JSONP] 发起请求:', url)
console.log('[JSONP] 回调函数名:', callbackName)
}
return new Promise((resolve, reject) => {
// 创建 script 标签
const script = document.createElement("script")
@@ -36,11 +29,7 @@ export function jsonp(url: string, options: JsonpOptions = {}): Promise<any> {
// 设置超时
const timer = setTimeout(() => {
cleanup()
const error = new Error(`JSONP request timeout after ${timeout}ms`)
if (debug) {
console.error('[JSONP] 请求超时:', error)
}
reject(error)
reject(new Error("JSONP request timeout"))
}, timeout)
// 清理函数
@@ -56,34 +45,22 @@ export function jsonp(url: string, options: JsonpOptions = {}): Promise<any> {
// 设置全局回调函数
;(window as any)[callbackName] = (data: any) => {
if (debug) {
console.log('[JSONP] 收到响应:', data)
}
cleanup()
resolve(data)
}
// 处理错误
script.onerror = (event) => {
script.onerror = () => {
cleanup()
const error = new Error("JSONP request failed to load script")
if (debug) {
console.error('[JSONP] 脚本加载失败:', event)
}
reject(error)
reject(new Error("JSONP request failed"))
}
// 构建请求 URL
const separator = url.includes("?") ? "&" : "?"
const requestUrl = `${url}${separator}${callbackParam}=${callbackName}`
if (debug) {
console.log('[JSONP] 完整请求URL:', requestUrl)
}
// 发起请求
script.src = requestUrl
script.async = true
document.head.appendChild(script)
})
}
@@ -93,11 +70,9 @@ export function jsonp(url: string, options: JsonpOptions = {}): Promise<any> {
*/
export class TencentMapAPI {
private apiKey: string
private debug: boolean
constructor(apiKey: string, debug: boolean = false) {
constructor(apiKey: string) {
this.apiKey = apiKey
this.debug = debug
}
/**
@@ -109,17 +84,8 @@ export class TencentMapAPI {
async reverseGeocode(lat: number, lng: number): Promise<any> {
const url = `https://apis.map.qq.com/ws/geocoder/v1/?location=${lat},${lng}&key=${this.apiKey}&get_poi=1&output=jsonp`
if (this.debug) {
console.log('[TencentMapAPI] 逆地址解析请求:', { lat, lng })
}
try {
const data = await jsonp(url, { debug: this.debug })
if (this.debug) {
console.log('[TencentMapAPI] 逆地址解析响应:', data)
}
const data = await jsonp(url)
return data
} catch (error) {
console.error("逆地址解析失败:", error)
@@ -138,17 +104,8 @@ export class TencentMapAPI {
keyword,
)}&page_size=10&page_index=1&key=${this.apiKey}&output=jsonp`
if (this.debug) {
console.log('[TencentMapAPI] 地址搜索请求:', { keyword, boundary })
}
try {
const data = await jsonp(url, { debug: this.debug })
if (this.debug) {
console.log('[TencentMapAPI] 地址搜索响应:', data)
}
const data = await jsonp(url)
return data
} catch (error) {
console.error("地址搜索失败:", error)
+12 -4
View File
@@ -261,9 +261,13 @@ export function downBlobFile(url: any, query: any, fileName: string) {
method: "get",
responseType: "blob",
params: query,
}).then((response) => {
handleBlobFile(response, fileName)
})
.then((response) => {
handleBlobFile(response, fileName)
})
.catch((error) => {
useMessage().error(error.msg || "下载失败")
})
}
export function postDownBlobFile(url: any, data: any, fileName: string) {
@@ -278,9 +282,13 @@ export function postDownBlobFile(url: any, data: any, fileName: string) {
descs: data?.descs ?? [],
},
data,
}).then((response) => {
handleBlobFile(response, fileName)
})
.then((response) => {
handleBlobFile(response, fileName)
})
.catch((error) => {
useMessage().error(error.msg || "下载失败")
})
}
/**
+4
View File
@@ -30,6 +30,10 @@
<el-form-item style="width: 250px" label="用餐时间段" prop="hourType">
<dict-select v-model="state.queryForm.hourType" dict-code="daily_menu" />
</el-form-item>
<el-form-item style="width: 300px" label="支付方式" prop="orderPayTypeCodes">
<dict-select v-model="state.queryForm.orderPayTypeCodes" dict-code="hard_pay_type"
multiple />
</el-form-item>
<el-form-item style="width: 300px" label="订单状态" prop="orderStatus">
<dict-select v-model="state.queryForm.orderStatus" dict-code="hard_order_status" />
</el-form-item>
+8 -1
View File
@@ -87,7 +87,7 @@
</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120">
<el-table-column label="操作" align="center" width="250">
<template #default="{ row }">
<el-tooltip class="box-item" effect="dark" content="只有合作商家能结账" placement="top">
<el-button icon="Tickets" text :disabled="row.merchantType != 2" type="primary"
@@ -95,6 +95,9 @@
商户结账
</el-button>
</el-tooltip>
<el-button icon="Tickets" type="primary" text @click="exportMchExcel(row)">
导出商户流水
</el-button>
</template>
</el-table-column>
</el-table>
@@ -138,6 +141,10 @@ const doCheckout = (row: any) => {
push({ path: "/mch/mch-checkout/index", query: { mchId: row.merchantId } })
}
const exportMchExcel = (row: any) => {
postDownBlobFile("/hard/hard-total/export-mch-cs", { ...state.queryForm, merchantId: row.merchantId }, "商户流水.xlsx")
}
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["totalPayPrice", "totalPayCount", "totalRefundPrice", "totalRefundCount", "totalProfitPrice", "totalProfitCount"]
+22 -38
View File
@@ -1,16 +1,19 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form v-if="showSearch" ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-form v-if="showSearch" ref="queryRef" :inline="true" :model="state.queryForm"
@keyup.enter="getDataList">
<el-row>
<el-form-item style="width: 300px" label="商户" prop="merchantId">
<select-mch v-model="state.queryForm.merchantId" :apiParams="{ types: '2' }" />
</el-form-item>
<el-form-item style="width: 400px" label="结账时间" prop="checkoutTimeList">
<el-date-picker v-model="state.queryForm.checkoutTimeList" value-format="YYYY-MM-DD" type="daterange" />
<el-date-picker v-model="state.queryForm.checkoutTimeList" value-format="YYYY-MM-DD"
type="daterange" />
</el-form-item>
<el-form-item style="width: 400px" label="创建时间" prop="createTimeList">
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD" type="daterange" />
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD"
type="daterange" />
</el-form-item>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">
@@ -22,38 +25,22 @@
</el-form>
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'wallet_mchCheckout_add'">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
v-auth="'wallet_mchCheckout_add'">
新 增
</el-button>
<el-button
plain
:disabled="multiple"
icon="Delete"
type="primary"
v-auth="'wallet_mchCheckout_del'"
@click="handleDelete(selectObjs)"
>
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'wallet_mchCheckout_del'"
@click="handleDelete(selectObjs)">
删除
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
:export="'wallet_mchCheckout_export'"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
<!-- :export="'wallet_mchCheckout_export'" -->
<right-toolbar v-model:showSearch="showSearch" @exportExcel="exportExcel" class="ml10 mr20"
style="float: right" @queryTable="getDataList"></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
@sort-change="sortChangeHandle">
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="username" label="结账人" />
@@ -73,22 +60,19 @@
<el-table-column prop="remark" label="结账备注" width="250" />
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button
icon="edit-pen"
text
type="primary"
v-auth="'wallet_mchCheckout_edit'"
@click="formDialogRef.openDialog(scope.row.id)"
>
<el-button icon="edit-pen" text type="primary" v-auth="'wallet_mchCheckout_edit'"
@click="formDialogRef.openDialog(scope.row.id)">
编辑
</el-button>
<el-button icon="delete" text type="primary" v-auth="'wallet_mchCheckout_del'" @click="handleDelete([scope.row.id])">
<el-button icon="delete" text type="primary" v-auth="'wallet_mchCheckout_del'"
@click="handleDelete([scope.row.id])">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
+6 -1
View File
@@ -14,7 +14,12 @@ const loading = ref(false)
onMounted(async () => {
try {
openPlanUrl("http://localhost:5173/#/canteen")
// 是否生成环境
if (import.meta.env.VITE_ENV === "prod") {
openPlanUrl("https://stgl.pj.gov.cn/cockpit/#/canteen")
} else {
openPlanUrl("http://localhost:5173/#/canteen")
}
loading.value = true
router.back()
} catch (error: any) {
+31 -102
View File
@@ -30,20 +30,18 @@
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item label="计量单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入计量单位" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item label="定价方式" prop="priceType">
<el-radio-group v-model="form.priceType" @change="onPriceTypeChange">
<el-radio :label="1">多SKU模式</el-radio>
<el-radio :label="2">单价SPU模式</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<!-- <el-col :span="12" class="mb20">-->
<!-- <el-form-item label="计量单位" prop="unit">-->
<!-- <el-input v-model="form.unit" placeholder="请输入计量单位" />-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="8" class="mb20">
<el-form-item label="商品性质" prop="productNature">
<el-select v-model="form.productNature" placeholder="请选择商品性质">
<el-option :value="item.value" :label="item.label" v-for="(item, index) in supermarket_nature" :key="index" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item label="状态" prop="status">
@@ -54,23 +52,6 @@
</el-form-item>
</el-col>
<!-- 单价SPU模式的价格设置 -->
<template v-if="form.priceType === 2">
<el-col :span="12" class="mb20">
<el-form-item label="SPU售价" prop="spuPrice">
<el-input-number v-model="form.spuPrice" :precision="2" :min="0" placeholder="请输入SPU售价" style="width: 100%" />
<span class="price-tip">单位:元</span>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item label="划线价" prop="originalPrice">
<el-input-number v-model="form.originalPrice" :precision="2" :min="0" placeholder="请输入划线价" style="width: 100%" />
<span class="price-tip">单位:元</span>
</el-form-item>
</el-col>
</template>
<el-col :span="12" class="mb20">
<el-form-item label="开售时间" prop="saleStartTime">
<el-date-picker v-model="form.saleStartTime" type="datetime" placeholder="请选择开售时间" style="width: 100%" />
@@ -104,13 +85,13 @@
</el-tab-pane>
<!-- SKU信息 -->
<el-tab-pane label="SKU信息" name="sku" v-if="form.priceType === 1">
<el-tab-pane label="SKU信息" name="sku">
<div class="sku-header">
<el-button type="primary" @click="addSku" :disabled="loading">
<el-icon><Plus /></el-icon>
添加SKU
</el-button>
<span class="sku-tip">多SKU模式:支持不同规格的商品(如不同颜色、尺寸、配置等)</span>
<span class="sku-tip">单个商品添加一条SKU,多规格商品添加多条SKU(如不同颜色、尺寸等)</span>
</div>
<div class="sku-table-container">
@@ -240,6 +221,7 @@ import { tree as fetchCategoryTree } from "/@/api/supermarket/mallCategory"
const emit = defineEmits(["refresh"])
// 定义变量内容
const { supermarket_nature } = useDict("supermarket_nature")
const dataFormRef = ref()
const visible = ref(false)
const loading = ref(false)
@@ -269,10 +251,7 @@ const form = reactive({
title: "",
coverImage: "",
carouselImages: "",
priceType: 1, // 默认多SKU模式
spuPrice: 0,
originalPrice: 0,
unit: "",
productNature: "",
status: "0", // 默认上架
saleStartTime: "",
saleEndTime: "",
@@ -294,19 +273,6 @@ const dataRules = ref({
categoryId: [{ required: true, message: "商品分类不能为空", trigger: "change" }],
title: [{ required: true, message: "商品标题不能为空", trigger: "blur" }],
coverImage: [{ required: true, message: "主图不能为空", trigger: "blur" }],
priceType: [{ required: true, message: "定价方式不能为空", trigger: "change" }],
spuPrice: [
{
validator: (rule: any, value: any, callback: any) => {
if (form.priceType === 2 && (!value || value <= 0)) {
callback(new Error("单价SPU模式下,SPU售价不能为空且必须大于0"))
} else {
callback()
}
},
trigger: "blur",
},
],
status: [{ required: true, message: "状态不能为空", trigger: "change" }],
})
@@ -343,19 +309,6 @@ const removeSku = (index: number) => {
}
}
// 定价方式改变
const onPriceTypeChange = (value: number) => {
if (value === 1) {
// 多SKU模式:确保至少有一个SKU
if (form.skuList.length === 0) {
addSku()
}
} else {
// 单价SPU模式:清空SKU列表
form.skuList = []
}
}
// SKU字段验证
const validateSkuField = (index: number, field: string) => {
const sku = form.skuList[index]
@@ -384,10 +337,7 @@ const openDialog = (id: string) => {
title: "",
coverImage: "",
carouselImages: "",
priceType: 1,
spuPrice: 0,
originalPrice: 0,
unit: "",
productNature: "",
status: "0",
saleStartTime: "",
saleEndTime: "",
@@ -411,23 +361,21 @@ const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => {})
if (!valid) return false
// 多SKU模式下的额外验证
if (form.priceType === 1) {
if (!form.skuList || form.skuList.length === 0) {
useMessage().error("多SKU模式下至少需要添加一个SKU")
// SKU验证
if (!form.skuList || form.skuList.length === 0) {
useMessage().error("至少需要添加一个SKU")
activeTab.value = "sku"
return false
}
// 验证SKU数据
for (let i = 0; i < form.skuList.length; i++) {
const sku = form.skuList[i]
if (!sku.skuCode || !sku.skuName || !sku.price || sku.stock === undefined) {
useMessage().error(`第${i + 1}个SKU信息不完整,请检查必填项`)
activeTab.value = "sku"
return false
}
// 验证SKU数据
for (let i = 0; i < form.skuList.length; i++) {
const sku = form.skuList[i]
if (!sku.skuCode || !sku.skuName || !sku.price || sku.stock === undefined) {
useMessage().error(`第${i + 1}个SKU信息不完整,请检查必填项`)
activeTab.value = "sku"
return false
}
}
}
try {
@@ -451,18 +399,7 @@ const onSubmit = async () => {
submitData.saleEndTime = date.toISOString().slice(0, 19).replace("T", " ")
}
// 如果是单价SPU模式,清空SKU列表
if (form.priceType === 2) {
submitData.skuList = []
}
// 价格转换:元转分
if (submitData.spuPrice) {
submitData.spuPrice = Math.round(submitData.spuPrice * 100)
}
if (submitData.originalPrice) {
submitData.originalPrice = Math.round(submitData.originalPrice * 100)
}
if (submitData.skuList && submitData.skuList.length > 0) {
submitData.skuList = submitData.skuList.map((sku: any) => ({
...sku,
@@ -495,12 +432,6 @@ const getmallProductData = async (id: string) => {
}
// 价格转换:分转元
if (form.spuPrice) {
form.spuPrice = form.spuPrice / 100
}
if (form.originalPrice) {
form.originalPrice = form.originalPrice / 100
}
if (form.skuList && form.skuList.length > 0) {
form.skuList = form.skuList.map((sku: any) => ({
...sku,
@@ -513,11 +444,9 @@ const getmallProductData = async (id: string) => {
form.categoryId = findCategoryPath(categoryOptions.value, res.data.categoryId) as any
}
// 如果没有SKU数据,根据定价方式初始化
// 如果没有SKU数据,默认添加一个
if (!form.skuList || form.skuList.length === 0) {
if (form.priceType === 1) {
addSku()
}
addSku()
}
} finally {
loading.value = false
+27 -41
View File
@@ -58,7 +58,7 @@
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="title" label="商品标题" width="200" show-overflow-tooltip />
<el-table-column prop="title" label="商品标题" show-overflow-tooltip />
<el-table-column prop="merchantId" label="商户" width="150" show-overflow-tooltip>
<template #default="scope">
@@ -72,52 +72,37 @@
</template>
</el-table-column>
<el-table-column prop="priceType" label="定价方式" width="120" align="center">
<template #default="scope">
<el-tag :type="scope.row.priceType === 1 ? 'primary' : 'success'">
{{ scope.row.priceType === 1 ? "多SKU" : "单价SPU" }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="价格信息" width="200">
<template #default="scope">
<div v-if="scope.row.priceType === 1">
<div v-if="scope.row.skuList && scope.row.skuList.length > 0">
<div class="price-range">
<span class="min-price">¥{{ getMinPrice(scope.row.skuList) }}</span>
<span v-if="getMinPrice(scope.row.skuList) !== getMaxPrice(scope.row.skuList)">
- ¥{{ getMaxPrice(scope.row.skuList) }}</span
>
</div>
<div class="sku-count">{{ scope.row.skuList.length }}个SKU</div>
<div v-if="scope.row.skuList && scope.row.skuList.length > 0">
<div class="price-range">
<span class="min-price">¥{{ getMinPrice(scope.row.skuList) }}</span>
<span v-if="getMinPrice(scope.row.skuList) !== getMaxPrice(scope.row.skuList)">
- ¥{{ getMaxPrice(scope.row.skuList) }}</span
>
</div>
<div v-else class="no-sku">暂无SKU</div>
</div>
<div v-else>
<div class="spu-price">¥{{ ((scope.row.spuPrice || 0) / 100).toFixed(2) }}</div>
<div v-if="scope.row.originalPrice" class="original-price">¥{{ ((scope.row.originalPrice || 0) / 100).toFixed(2) }}</div>
<div class="sku-count">{{ scope.row.skuList.length }}个SKU</div>
</div>
<div v-else class="no-sku">暂无SKU</div>
</template>
</el-table-column>
<el-table-column label="库存信息" width="120">
<template #default="scope">
<div v-if="scope.row.priceType === 1">
<div v-if="scope.row.skuList && scope.row.skuList.length > 0">
<div class="total-stock">{{ getTotalStock(scope.row.skuList) }}</div>
<div class="sku-count">{{ scope.row.skuList.length }}个SKU</div>
</div>
<div v-else class="no-stock">0</div>
</div>
<div v-else>
<div class="spu-stock">{{ scope.row.totalStock || 0 }}</div>
<div v-if="scope.row.skuList && scope.row.skuList.length > 0">
<div class="total-stock">{{ getTotalStock(scope.row.skuList) }}</div>
<div class="sku-count">{{ scope.row.skuList.length }}个SKU</div>
</div>
<div v-else class="no-stock">0</div>
</template>
</el-table-column>
<el-table-column prop="unit" label="单位" width="80" align="center" />
<el-table-column prop="productNature" label="商品性质" show-overflow-tooltip width="150">
<template #default="scope">
<dict-tag :options="supermarket_nature" :value="scope.row.productNature" />
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100" align="center">
<template #default="scope">
<el-tag :type="scope.row.status === '0' ? 'success' : 'danger'">
@@ -130,10 +115,10 @@
<el-table-column prop="saleEndTime" label="停售时间" width="160" show-overflow-tooltip />
<el-table-column label="SKU详情" width="120" align="center">
<!-- <el-table-column label="SKU详情" width="120" align="center">
<template #default="scope">
<el-button
v-if="scope.row.priceType === 1 && scope.row.skuList && scope.row.skuList.length > 0"
v-if="scope.row.skuList && scope.row.skuList.length > 0"
type="primary"
size="small"
@click="showSkuDetail(scope.row)"
@@ -142,7 +127,7 @@
</el-button>
<span v-else class="no-sku-detail">-</span>
</template>
</el-table-column>
</el-table-column>-->
<el-table-column label="操作" width="180" fixed="right">
<template #default="scope">
@@ -167,7 +152,7 @@
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
<!-- SKU详情弹窗 -->
<el-dialog v-model="skuDetailVisible" title="SKU详情" width="80%" :close-on-click-modal="false">
<!-- <el-dialog v-model="skuDetailVisible" title="SKU详情" width="80%" :close-on-click-modal="false">
<div v-if="currentProduct">
<div class="product-info">
<h3>{{ currentProduct.title }}</h3>
@@ -201,7 +186,7 @@
<el-button @click="skuDetailVisible = false">关闭</el-button>
</span>
</template>
</el-dialog>
</el-dialog>-->
</div>
</template>
@@ -211,7 +196,8 @@ import { fetchList, delObjs } from "/@/api/supermarket/mallProduct"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { tree as fetchCategoryTree } from "/@/api/supermarket/mallCategory"
import { select } from "/@/api/wallet/mch-manage"
import {useDict} from "/@/hooks/dict";
const { supermarket_nature } = useDict("supermarket_nature")
// 引入组件
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
@@ -72,7 +72,7 @@
</span>
</template>
</el-table-column>
<el-table-column prop="salesPrice" label="销售单价(元)" show-overflow-tooltip min-width="120" align="right" />
<el-table-column prop="salesPrice" label="销售平均单价(元)" show-overflow-tooltip min-width="120" align="right" />
<el-table-column prop="salesCount" label="销售笔数" show-overflow-tooltip min-width="100" align="right" />
</el-table-column>
-208
View File
@@ -1,208 +0,0 @@
<template>
<div class="test-jsonp-page">
<h2>JSONP 跨域测试页面</h2>
<div class="test-section">
<h3>1. 逆地址解析测试</h3>
<el-button @click="testReverseGeocode" type="primary">
测试逆地址解析 (北京天安门)
</el-button>
<div v-if="reverseResult" class="result">
<p><strong>结果:</strong> {{ reverseResult }}</p>
</div>
</div>
<div class="test-section">
<h3>2. 地址搜索测试</h3>
<el-input
v-model="searchKeyword"
placeholder="输入搜索关键词"
style="width: 300px; margin-right: 10px;"
/>
<el-button @click="testSearch" type="primary">搜索</el-button>
<div v-if="searchResults.length > 0" class="result">
<p><strong>搜索结果:</strong></p>
<ul>
<li v-for="(item, index) in searchResults" :key="index">
{{ item.title }} - {{ item.address }}
</li>
</ul>
</div>
</div>
<div class="test-section">
<h3>3. 地图选择器组件测试</h3>
<map-select
ref="mapSelectRef"
v-model="selectedLocation"
placeholder="点击选择位置"
style="width: 400px;"
/>
<div v-if="selectedLocation" class="result">
<p><strong>选中位置:</strong></p>
<p>地址: {{ selectedLocation.address }}</p>
<p>坐标: {{ selectedLocation.coordinates }}</p>
</div>
</div>
<div class="logs">
<h3>日志信息</h3>
<div class="log-content">
<div v-for="(log, index) in logs" :key="index" class="log-item">
{{ log }}
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ElButton, ElInput, ElMessage } from 'element-plus'
import { TencentMapAPI } from '../utils/jsonp'
import MapSelect from '../components/map/map-select.vue'
// 创建腾讯地图API实例 (启用调试模式)
const mapAPI = new TencentMapAPI('CGABZ-3MH66-6VGST-MEMS3-K6U3V-DGBKA', true)
// 定义类型
interface LocationData {
address: string
coordinates: string
location: {
lat: number
lng: number
}
}
// 响应式数据
const reverseResult = ref('')
const searchKeyword = ref('北京大学')
const searchResults = ref<any[]>([])
const selectedLocation = ref<LocationData | null>(null)
const logs = ref<string[]>([])
// 添加日志
const addLog = (message: string) => {
const timestamp = new Date().toLocaleTimeString()
logs.value.unshift(`[${timestamp}] ${message}`)
if (logs.value.length > 10) {
logs.value.pop()
}
}
// 测试逆地址解析
const testReverseGeocode = async () => {
addLog('开始测试逆地址解析...')
try {
// 北京天安门坐标
const data = await mapAPI.reverseGeocode(39.908823, 116.397470)
if (data.status === 0) {
reverseResult.value = data.result.address
addLog(`逆地址解析成功: ${data.result.address}`)
ElMessage.success('逆地址解析成功')
} else {
addLog(`逆地址解析失败: ${data.message}`)
ElMessage.error('逆地址解析失败')
}
} catch (error) {
addLog(`逆地址解析错误: ${error}`)
ElMessage.error('逆地址解析错误')
console.error('逆地址解析错误:', error)
}
}
// 测试地址搜索
const testSearch = async () => {
if (!searchKeyword.value.trim()) {
ElMessage.warning('请输入搜索关键词')
return
}
addLog(`开始搜索: ${searchKeyword.value}`)
try {
const data = await mapAPI.searchLocation(searchKeyword.value)
if (data.status === 0) {
searchResults.value = data.data.map((item: any) => ({
title: item.title,
address: item.address,
location: item.location
}))
addLog(`搜索成功,找到 ${searchResults.value.length} 个结果`)
ElMessage.success(`搜索成功,找到 ${searchResults.value.length} 个结果`)
} else {
addLog(`搜索失败: ${data.message}`)
ElMessage.error('搜索失败')
}
} catch (error) {
addLog(`搜索错误: ${error}`)
ElMessage.error('搜索错误')
console.error('搜索错误:', error)
}
}
</script>
<style scoped>
.test-jsonp-page {
padding: 20px;
max-width: 800px;
margin: 0 auto;
}
.test-section {
margin-bottom: 30px;
padding: 20px;
border: 1px solid #e4e7ed;
border-radius: 8px;
background-color: #fafafa;
}
.test-section h3 {
margin-top: 0;
color: #409eff;
}
.result {
margin-top: 15px;
padding: 10px;
background-color: #f0f9ff;
border: 1px solid #b3d8ff;
border-radius: 4px;
}
.result ul {
margin: 5px 0;
padding-left: 20px;
}
.logs {
margin-top: 30px;
padding: 20px;
border: 1px solid #e4e7ed;
border-radius: 8px;
background-color: #f8f9fa;
}
.logs h3 {
margin-top: 0;
color: #67c23a;
}
.log-content {
max-height: 200px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 12px;
}
.log-item {
padding: 2px 0;
border-bottom: 1px solid #eee;
}
.log-item:last-child {
border-bottom: none;
}
</style>