Merge remote-tracking branch 'origin/main'

# Conflicts:
#	.env
#	.env.development
#	.env.production
#	src/api/shop/shopGoods/index.ts
#	src/views/shop/shopGoods/components/search.vue
#	src/views/shop/shopGoods/index.vue
This commit is contained in:
2026-06-16 13:06:00 +08:00
17 changed files with 2183 additions and 724 deletions

View File

@@ -25,11 +25,11 @@
</template>
<span>导入</span>
</a-button>
<a-button type="dashed" class="ele-btn-icon" @click="openCollect">
<a-button type="dashed" class="ele-btn-icon" @click="openImageImport">
<template #icon>
<LinkOutlined />
<UploadOutlined />
</template>
<span>采集</span>
<span>导入图片</span>
</a-button>
<a-button type="dashed" class="ele-btn-icon" @click="handleExport">
导出xls
@@ -70,10 +70,10 @@
</template>
<script lang="ts" setup>
import { PlusOutlined, DeleteOutlined, UploadOutlined, LinkOutlined } from '@ant-design/icons-vue';
import { PlusOutlined, DeleteOutlined, UploadOutlined } from '@ant-design/icons-vue';
import { ref, watch } from 'vue';
import { getCount } from '@/api/shop/shopGoods';
import type { GoodsCount, ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
import type { GoodsCount, ShopGoodsParam } from '@/api/shop/shopGoods/model';
import useSearch from '@/utils/use-search';
import { getMerchantId } from '@/utils/merchant';
import { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model';
@@ -81,7 +81,7 @@
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: ShopGoods[];
selection?: [];
merchantId?: number;
navigationList?: ShopGoodsCategory[];
}>(),
@@ -111,7 +111,7 @@
(e: 'remove'): void;
(e: 'batchMove'): void;
(e: 'import'): void;
(e: 'collect'): void;
(e: 'imageImport'): void;
(e: 'export'): void;
}>();
@@ -130,9 +130,8 @@
emit('import');
};
// 打开链接采集
const openCollect = () => {
emit('collect');
const openImageImport = () => {
emit('imageImport');
};
// 导出
@@ -140,7 +139,7 @@
emit('export');
};
const handleSearch = (e: any) => {
const handleSearch = (e) => {
const text = e.target.value;
resetFields();
if (text === '出售中') {

View File

@@ -1,5 +1,5 @@
<template>
<a-page-header :title="String(getPageTitle())" @back="goBack">
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<template #extra>
<Extra />
</template>
@@ -23,7 +23,7 @@
@remove="removeBatch"
@batchMove="openMove"
@import="openImport"
@collect="openCollect"
@imageImport="openImageImport"
@export="handleExport"
/>
</template>
@@ -87,10 +87,8 @@
@done="reload"
/>
<!-- 链接采集弹窗 -->
<ShopGoodsCollect
v-model:visible="showCollect"
:navigationList="navigationList"
<ShopGoodsImageImport
v-model:visible="showImageImport"
@done="reload"
/>
</a-page-header>
@@ -98,7 +96,6 @@
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { useRouter } from 'vue-router';
import { message, Modal } from 'ant-design-vue';
import {
ExclamationCircleOutlined,
@@ -116,7 +113,7 @@
import ShopGoodsEdit from './components/shopGoodsEdit.vue';
import Extra from '@/views/shop/shopGoods/components/extra.vue';
import ShopGoodsImport from './components/shop-goods-import.vue';
import ShopGoodsCollect from './components/shop-goods-collect.vue';
import ShopGoodsImageImport from './components/shop-goods-image-import.vue';
import { listShopGoods, pageShopGoods, removeShopGoods, removeBatchShopGoods, updateShopGoods } from '@/api/shop/shopGoods';
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
import { getPageTitle } from '@/utils/common';
@@ -127,7 +124,6 @@
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const router = useRouter();
// 表格选中数据
const selection = ref<ShopGoods[]>([]);
@@ -139,17 +135,13 @@
const showEdit = ref(false);
// 是否显示导入弹窗
const showImport = ref(false);
// 是否显示链接采集弹窗
const showCollect = ref(false);
// 是否显示图片导入弹窗
const showImageImport = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
const goBack = () => {
router.go(-1);
};
// 表格数据源
const datasource: DatasourceFunction = ({
page,
@@ -276,9 +268,9 @@
showImport.value = true;
};
// 打开链接采集
const openCollect = () => {
showCollect.value = true;
/* 打开图片导入弹窗 */
const openImageImport = () => {
showImageImport.value = true;
};
/* 导出商品列表 */
@@ -324,7 +316,7 @@
});
const sheetName = `商品列表${dayjs(new Date()).format('YYYYMMDD')}`;
const workbook: { SheetNames: string[]; Sheets: Record<string, any> } = {
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};

View File

@@ -57,6 +57,22 @@
</div>
</a-upload>
</a-form-item>
<a-form-item label="广告图" name="adImage">
<a-upload
:before-upload="handleAdImageUpload"
:show-upload-list="false"
accept="image/*"
>
<a-button v-if="!form.adImage">
<template #icon><UploadOutlined /></template>
上传广告图
</a-button>
<div v-else class="flex items-center gap-2">
<img :src="form.adImage" style="width: 120px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid #d9d9d9;" />
<a-button type="text" danger size="small" @click.stop="form.adImage = undefined">删除</a-button>
</div>
</a-upload>
</a-form-item>
<a-form-item label="排序号" name="sortNumber">
<a-input-number
:min="0"
@@ -124,6 +140,7 @@
title: undefined,
type: 0,
image: undefined,
adImage: undefined,
parentId: undefined,
path: undefined,
component: undefined,
@@ -235,6 +252,23 @@
return false; // 阻止默认上传
};
const handleAdImageUpload = async (file: File) => {
const isImage = file.type?.startsWith('image/');
if (!isImage) {
message.error('只能上传图片文件');
return false;
}
try {
const res = await uploadFile(file);
if (res?.path) {
form.adImage = res.path;
}
} catch (e: any) {
message.error(e.message || '上传失败');
}
return false;
};
watch(
() => props.visible,
(visible) => {
@@ -250,6 +284,7 @@
title: undefined,
type: 0,
image: undefined,
adImage: undefined,
parentId: undefined,
sortNumber: 100,
comments: undefined,

View File

@@ -33,6 +33,14 @@
{{ record.type === 0 ? '商城分类' : '外卖分类' }}
</a-tag>
</template>
<template v-if="column.key === 'adImage'">
<img
v-if="record.adImage"
:src="record.adImage"
style="width: 72px; height: 40px; object-fit: cover; border-radius: 4px;"
/>
<span v-else>-</span>
</template>
<template v-if="column.key === 'parentId'">
{{ getParentName(record.parentId) }}
</template>
@@ -164,6 +172,13 @@
align: 'center',
width: 100
},
{
title: '广告图',
dataIndex: 'adImage',
key: 'adImage',
align: 'center',
width: 110
},
{
title: '上级分类',
dataIndex: 'parentId',

View File

@@ -51,6 +51,22 @@
v-model:value="form.mchId"
/>
</a-form-item>
<template v-if="form.wechatType === 1">
<a-form-item label="子商户APPID" name="subAppId">
<a-input
allow-clear
placeholder="请输入子商户APPID"
v-model:value="form.subAppId"
/>
</a-form-item>
<a-form-item label="子商户号" name="subMchId">
<a-input
allow-clear
placeholder="请输入子商户号"
v-model:value="form.subMchId"
/>
</a-form-item>
</template>
<a-form-item label="设置APIv3密钥" name="apiKey">
<a-input-password
allow-clear
@@ -176,6 +192,8 @@
wechatType: 0,
appId: '',
mchId: '',
subAppId: '',
subMchId: '',
apiKey: '',
pubKey: '',
pubKeyId: '',
@@ -221,6 +239,34 @@
trigger: 'blur'
}
],
subAppId: [
{
required: true,
type: 'string',
message: '请填写子商户APPID',
trigger: 'blur',
validator: async (_rule, value: string) => {
if (form.code === '1' && form.wechatType === 1 && !value) {
return Promise.reject('请填写子商户APPID');
}
return Promise.resolve();
}
}
],
subMchId: [
{
required: true,
type: 'string',
message: '请填写子商户号',
trigger: 'blur',
validator: async (_rule, value: string) => {
if (form.code === '1' && form.wechatType === 1 && !value) {
return Promise.reject('请填写子商户号');
}
return Promise.resolve();
}
}
],
wechatType: [
{
required: true,
@@ -268,14 +314,6 @@
message: '请填写支付通知地址',
trigger: 'blur'
}
],
merchantSerialNumber: [
{
required: true,
type: 'string',
message: '请填写商户证书序列号',
trigger: 'blur'
}
]
});
@@ -325,6 +363,10 @@
const formData = {
...form
};
if (!(formData.code === '1' && formData.wechatType === 1)) {
formData.subAppId = '';
formData.subMchId = '';
}
console.log(form);
const saveOrUpdate = isUpdate.value ? updatePayment : addPayment;
saveOrUpdate(formData)